libMesh::DifferentiableSystem Class Referenceabstract

#include <diff_system.h>

Inheritance diagram for libMesh::DifferentiableSystem:

Public Types

typedef DifferentiableSystem sys_type
 
typedef ImplicitSystem Parent
 
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

 DifferentiableSystem (EquationSystems &es, const std::string &name, const unsigned int number)
 
virtual ~DifferentiableSystem ()
 
virtual void clear () libmesh_override
 
virtual void reinit () libmesh_override
 
virtual void assemble () libmesh_override
 
virtual LinearSolver< Number > * get_linear_solver () const libmesh_override
 
virtual std::pair< unsigned int, Realget_linear_solve_parameters () const libmesh_override
 
virtual void release_linear_solver (LinearSolver< Number > *) const libmesh_override
 
virtual void assembly (bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) libmesh_override=0
 
virtual void solve () libmesh_override
 
virtual std::pair< unsigned int, Realadjoint_solve (const QoISet &qoi_indices=QoISet()) libmesh_override
 
virtual UniquePtr< DifferentiablePhysicsclone_physics () libmesh_override
 
virtual UniquePtr< DifferentiableQoIclone () libmesh_override
 
const DifferentiablePhysicsget_physics () const
 
DifferentiablePhysicsget_physics ()
 
void attach_physics (DifferentiablePhysics *physics_in)
 
void swap_physics (DifferentiablePhysics *&swap_physics)
 
const DifferentiableQoIget_qoi () const
 
DifferentiableQoIget_qoi ()
 
void attach_qoi (DifferentiableQoI *qoi_in)
 
void set_time_solver (UniquePtr< TimeSolver > _time_solver)
 
TimeSolverget_time_solver ()
 
const TimeSolverget_time_solver () const
 
virtual UniquePtr< DiffContextbuild_context ()
 
virtual void postprocess ()
 
virtual void element_postprocess (DiffContext &)
 
virtual void side_postprocess (DiffContext &)
 
unsigned int get_second_order_dot_var (unsigned int var) const
 
bool have_first_order_scalar_vars () const
 
bool have_second_order_scalar_vars () const
 
sys_typesystem ()
 
virtual void disable_cache () libmesh_override
 
virtual std::string system_type () const libmesh_override
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) libmesh_override
 
virtual std::pair< unsigned int, Realsensitivity_solve (const ParameterVector &parameters) libmesh_override
 
virtual std::pair< unsigned int, Realweighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights) libmesh_override
 
virtual std::pair< unsigned int, Realweighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) libmesh_override
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) libmesh_override
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) libmesh_override
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian) libmesh_override
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product) libmesh_override
 
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 libmesh_override
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet()) libmesh_override
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) libmesh_override
 
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 &parameters, 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=libmesh_nullptr) const
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=libmesh_nullptr) const
 
void project_solution (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters) const
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void project_vector (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, 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=libmesh_nullptr)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters)
 
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=libmesh_nullptr, 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 &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, 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 MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_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=libmesh_nullptr)
 
unsigned int add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
 
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=libmesh_nullptr)
 
const Variablevariable (unsigned int var) const
 
const VariableGroupvariable_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 FETypevariable_type (const unsigned int i) const
 
const FETypevariable_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, std::set< unsigned int > *skip_dimensions=libmesh_nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=libmesh_nullptr) 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
 
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
 
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
 
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
 
bool & hide_output ()
 
const Parallel::Communicatorcomm () 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)
 
virtual void time_evolving (unsigned int var, unsigned int order)
 
bool is_time_evolving (unsigned int var) const
 
virtual bool eulerian_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 bool damping_residual (bool request_jacobian, DiffContext &)
 
virtual bool side_damping_residual (bool request_jacobian, DiffContext &)
 
virtual bool nonlocal_damping_residual (bool request_jacobian, DiffContext &)
 
virtual void init_context (DiffContext &)
 
virtual void set_mesh_system (System *sys)
 
const Systemget_mesh_system () const
 
Systemget_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 &)
 
bool have_first_order_vars () const
 
const std::set< unsigned int > & get_first_order_vars () const
 
bool is_first_order_var (unsigned int var) const
 
bool have_second_order_vars () const
 
const std::set< unsigned int > & get_second_order_vars () const
 
bool is_second_order_var (unsigned int var) const
 
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 init_context (DiffContext &)
 
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

UniquePtr< TimeSolvertime_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
 
bool zero_out_matrix_and_rhs
 
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< Numberqoi
 
bool compute_internal_sides
 
bool assemble_qoi_sides
 
bool assemble_qoi_internal_sides
 
bool assemble_qoi_elements
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 

Protected Member Functions

virtual void init_data () libmesh_override
 
void add_second_order_dot_vars ()
 
void add_dot_var_dirichlet_bcs (unsigned int var_idx, unsigned int dot_var_idx)
 
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

DifferentiablePhysics_diff_physics
 
DifferentiableQoIdiff_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< unsigned int > _time_evolving
 
std::set< unsigned int > _first_order_vars
 
std::set< unsigned int > _second_order_vars
 
std::map< unsigned int, unsigned int > _second_order_dot_vars
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic< unsigned int > _n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Detailed Description

This class provides a specific system class. It aims to generalize any system, linear or nonlinear, which provides both a residual and a Jacobian.

This class is part of the new DifferentiableSystem framework, which is still experimental. Users of this framework should beware of bugs and future API changes.

Author
Roy H. Stogner
Date
2006

Definition at line 53 of file diff_system.h.

Member Typedef Documentation

typedef std::map<std::string, SparseMatrix<Number> *>::const_iterator libMesh::ImplicitSystem::const_matrices_iterator
inherited

Definition at line 283 of file implicit_system.h.

typedef std::map<std::string, NumericVector<Number> *>::const_iterator libMesh::System::const_vectors_iterator
inherited

Definition at line 749 of file system.h.

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information. The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

typedef std::map<std::string, SparseMatrix<Number> *>::iterator libMesh::ImplicitSystem::matrices_iterator
inherited

Matrix iterator typedefs.

Definition at line 282 of file implicit_system.h.

The type of the parent.

Definition at line 80 of file diff_system.h.

The type of system.

Definition at line 75 of file diff_system.h.

typedef std::map<std::string, NumericVector<Number> *>::iterator libMesh::System::vectors_iterator
inherited

Vector iterator typedefs.

Definition at line 748 of file system.h.

Constructor & Destructor Documentation

libMesh::DifferentiableSystem::DifferentiableSystem ( EquationSystems es,
const std::string &  name,
const unsigned int  number 
)

Constructor. Optionally initializes required data structures.

Definition at line 34 of file diff_system.C.

36  :
37  Parent (es, name_in, number_in),
38  time_solver (),
39  deltat(1.),
40  print_solution_norms(false),
41  print_solutions(false),
42  print_residual_norms(false),
43  print_residuals(false),
44  print_jacobian_norms(false),
45  print_jacobians(false),
49  _diff_physics(this),
50  diff_qoi(this)
51 {
52 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358
libMesh::DifferentiableSystem::~DifferentiableSystem ( )
virtual

Destructor.

Definition at line 56 of file diff_system.C.

References _diff_physics, and diff_qoi.

57 {
58  // If we had an attached Physics object, delete it.
59  if (this->_diff_physics != this)
60  delete this->_diff_physics;
61 
62  // If we had an attached QoI object, delete it.
63  if (this->diff_qoi != this)
64  delete this->diff_qoi;
65 }
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358

Member Function Documentation

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(), libMesh::Euler2Solver::element_residual(), libMesh::NewmarkSolver::element_residual(), and libMesh::DifferentiablePhysics::init_context().

void libMesh::System::activate ( )
inlineinherited

Activates the system. Only active systems are solved.

Definition at line 2052 of file system.h.

References libMesh::System::_active.

Referenced by libMesh::System::get_equation_systems().

2053 {
2054  _active = true;
2055 }
bool libMesh::System::active ( ) const
inlineinherited
Returns
true if the system is active, false otherwise. An active system will be solved.

Definition at line 2044 of file system.h.

References libMesh::System::_active.

Referenced by libMesh::System::get_equation_systems().

2045 {
2046  return _active;
2047 }
NumericVector< Number > & libMesh::System::add_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1035 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), and libMesh::System::project_solution_on_reinit().

1036 {
1037  std::ostringstream adjoint_rhs_name;
1038  adjoint_rhs_name << "adjoint_rhs" << i;
1039 
1040  return this->add_vector(adjoint_rhs_name.str(), false);
1041 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
NumericVector< Number > & libMesh::System::add_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 971 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), and libMesh::System::project_solution_on_reinit().

972 {
973  std::ostringstream adjoint_name;
974  adjoint_name << "adjoint_solution" << i;
975 
976  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
977  this->set_vector_as_adjoint(adjoint_name.str(), i);
978  return returnval;
979 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:899
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
void libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs ( unsigned int  var_idx,
unsigned int  dot_var_idx 
)
protected

Helper function to and Dirichlet boundary conditions to "dot" variable cousins of second order variables in the system. The function takes the second order variable index, it's corresponding "dot" variable index and then searches for DirchletBoundary objects for var_idx and then adds a DirichletBoundary object for dot_var_idx using the same boundary ids and functors for the var_idx DirichletBoundary.

Definition at line 228 of file diff_system.C.

References libMesh::DofMap::add_dirichlet_boundary(), libMesh::DirichletBoundary::b, libMesh::DirichletBoundary::f, libMesh::DirichletBoundary::f_fem, libMesh::DofMap::get_dirichlet_boundaries(), libMesh::System::get_dof_map(), libMesh::libmesh_assert(), and libMesh::DirichletBoundary::variables.

Referenced by add_second_order_dot_vars().

230 {
231  // We're assuming that there could be a lot more variables than
232  // boundary conditions, so we search each of the boundary conditions
233  // for this variable rather than looping over boundary conditions
234  // in a separate loop and searching through all the variables.
235  const DirichletBoundaries * all_dbcs =
237 
238  if (all_dbcs)
239  {
240  // We need to cache the DBCs to be added so that we add them
241  // after looping over the existing DBCs. Otherwise, we're polluting
242  // the thing we're looping over.
243  std::vector<DirichletBoundary*> new_dbcs;
244 
245  DirichletBoundaries::const_iterator dbc_it = all_dbcs->begin();
246  for ( ; dbc_it != all_dbcs->end(); ++dbc_it )
247  {
248  libmesh_assert(*dbc_it);
249  DirichletBoundary & dbc = *(*dbc_it);
250 
251  // Look for second order variable in the current
252  // DirichletBoundary object
253  std::vector<unsigned int>::const_iterator dbc_var_it =
254  std::find( dbc.variables.begin(), dbc.variables.end(), var_idx );
255 
256  // If we found it, then we also need to add it's corresponding
257  // "dot" variable to a DirichletBoundary
258  std::vector<unsigned int> vars_to_add;
259  if (dbc_var_it != dbc.variables.end())
260  vars_to_add.push_back(dot_var_idx);
261 
262  if (!vars_to_add.empty())
263  {
264  // We need to check if the boundary condition is time-dependent.
265  // Currently, we cannot automatically differentiate w.r.t. time
266  // so if the user supplies a time-dependent Dirichlet BC, then
267  // we can't automatically support the Dirichlet BC for the
268  // "velocity" boundary condition, so we error. Otherwise,
269  // the "velocity boundary condition will just be zero.
270  bool is_time_evolving_bc = false;
271  if (dbc.f)
272  is_time_evolving_bc = dbc.f->is_time_dependent();
273  else if (dbc.f_fem)
274  // We it's a FEMFunctionBase object, it will be implictly
275  // time-dependent since it is assumed to depend on the solution.
276  is_time_evolving_bc = true;
277  else
278  libmesh_error_msg("Could not find valid boundary function!");
279 
280  if (is_time_evolving_bc)
281  libmesh_error_msg("Cannot currently support time-dependent Dirichlet BC for dot variables!");
282 
283 
284  DirichletBoundary * new_dbc;
285 
286  if (dbc.f)
287  {
288  ZeroFunction<Number> zf;
289 
290  new_dbc = new DirichletBoundary(dbc.b, vars_to_add, zf);
291  }
292  else
293  libmesh_error();
294 
295  new_dbcs.push_back(new_dbc);
296  }
297  }
298 
299  // Now add the new DBCs for the "dot" vars to the DofMap
300  std::vector<DirichletBoundary*>::iterator new_dbc_it =
301  new_dbcs.begin();
302 
303  for ( ; new_dbc_it != new_dbcs.end(); ++new_dbc_it )
304  {
305  const DirichletBoundary & dbc = *(*new_dbc_it);
306  this->get_dof_map().add_dirichlet_boundary(dbc);
307  delete *new_dbc_it;
308  }
309 
310  } // if (all_dbcs)
311 }
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1124
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
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 209 of file implicit_system.C.

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().

Referenced by libMesh::ImplicitSystem::add_system_matrix(), libMesh::EigenTimeSolver::init(), and libMesh::NewmarkSystem::NewmarkSystem().

210 {
211  // only add matrices before initializing...
212  if (!_can_add_matrices)
213  libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
214  << "\n any more. You should have done this earlier.");
215 
216  // Return the matrix if it is already there.
217  if (this->have_matrix(mat_name))
218  return *(_matrices[mat_name]);
219 
220  // Otherwise build the matrix and return it.
221  SparseMatrix<Number> * buf = SparseMatrix<Number>::build(this->comm()).release();
222  _matrices.insert (std::make_pair (mat_name, buf));
223 
224  return *buf;
225 }
static UniquePtr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
std::map< std::string, SparseMatrix< Number > * > _matrices
bool have_matrix(const std::string &mat_name) const
const Parallel::Communicator & comm() const
void libMesh::DifferentiableSystem::add_second_order_dot_vars ( )
protected

Helper function to add "velocity" variables that are cousins to second order-in-time variables in the DifferentiableSystem. This function is only called if the TimeSolver is a FirstOrderUnsteadySolver.

Definition at line 198 of file diff_system.C.

References libMesh::DifferentiablePhysics::_second_order_dot_vars, libMesh::Variable::active_subdomains(), add_dot_var_dirichlet_bcs(), libMesh::System::add_variable(), libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::Variable::name(), libMesh::DifferentiablePhysics::time_evolving(), libMesh::Variable::type(), and libMesh::System::variable().

Referenced by init_data().

199 {
200  const std::set<unsigned int> & second_order_vars = this->get_second_order_vars();
201  if (!second_order_vars.empty())
202  {
203  for (std::set<unsigned int>::const_iterator var_it = second_order_vars.begin();
204  var_it != second_order_vars.end(); ++var_it)
205  {
206  const Variable & var = this->variable(*var_it);
207  std::string new_var_name = std::string("dot_")+var.name();
208 
209  unsigned int v_var_idx;
210 
211  if (var.active_subdomains().empty())
212  v_var_idx = this->add_variable( new_var_name, var.type() );
213  else
214  v_var_idx = this->add_variable( new_var_name, var.type(), &var.active_subdomains() );
215 
216  _second_order_dot_vars.insert( std::pair<unsigned int,unsigned int>(*var_it,v_var_idx) );
217 
218  // The new velocities are time evolving variables of first order
219  this->time_evolving( v_var_idx, 1 );
220 
221  // And if there are any boundary conditions set on the second order
222  // variable, we also need to set it on its velocity variable.
223  this->add_dot_var_dirichlet_bcs( *var_it, v_var_idx );
224  }
225  }
226 }
const std::set< unsigned int > & get_second_order_vars() const
Definition: diff_physics.h:527
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1095
void add_dot_var_dirichlet_bcs(unsigned int var_idx, unsigned int dot_var_idx)
Definition: diff_system.C:228
std::map< unsigned int, unsigned int > _second_order_dot_vars
Definition: diff_physics.h:568
const Variable & variable(unsigned int var) const
Definition: system.h:2112
virtual void time_evolving(unsigned int var)
Definition: diff_physics.h:247
NumericVector< Number > & libMesh::System::add_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1065 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives(), and libMesh::System::project_solution_on_reinit().

1066 {
1067  std::ostringstream sensitivity_rhs_name;
1068  sensitivity_rhs_name << "sensitivity_rhs" << i;
1069 
1070  return this->add_vector(sensitivity_rhs_name.str(), false);
1071 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
NumericVector< Number > & libMesh::System::add_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 920 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::ImplicitSystem::sensitivity_solve().

921 {
922  std::ostringstream sensitivity_name;
923  sensitivity_name << "sensitivity_solution" << i;
924 
925  return this->add_vector(sensitivity_name.str());
926 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = libmesh_nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

Returns
The index number for the new variable.

Definition at line 1095 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_nullptr, libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by add_second_order_dot_vars(), libMesh::System::add_variable(), libMesh::ErrorVector::plot_error(), and libMesh::System::project_solution_on_reinit().

1098 {
1099  libmesh_assert(!this->is_initialized());
1100 
1101  // Make sure the variable isn't there already
1102  // or if it is, that it's the type we want
1103  for (unsigned int v=0; v<this->n_vars(); v++)
1104  if (this->variable_name(v) == var)
1105  {
1106  if (this->variable_type(v) == type)
1107  return _variables[v].number();
1108 
1109  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1110  }
1111 
1112  // Optimize for VariableGroups here - if the user is adding multiple
1113  // variables of the same FEType and subdomain restriction, catch
1114  // that here and add them as members of the same VariableGroup.
1115  //
1116  // start by setting this flag to whatever the user has requested
1117  // and then consider the conditions which should negate it.
1118  bool should_be_in_vg = this->identify_variable_groups();
1119 
1120  // No variable groups, nothing to add to
1121  if (!this->n_variable_groups())
1122  should_be_in_vg = false;
1123 
1124  else
1125  {
1126  VariableGroup & vg(_variable_groups.back());
1127 
1128  // get a pointer to their subdomain restriction, if any.
1129  const std::set<subdomain_id_type> * const
1130  their_active_subdomains (vg.implicitly_active() ?
1131  libmesh_nullptr : &vg.active_subdomains());
1132 
1133  // Different types?
1134  if (vg.type() != type)
1135  should_be_in_vg = false;
1136 
1137  // they are restricted, we aren't?
1138  if (their_active_subdomains && !active_subdomains)
1139  should_be_in_vg = false;
1140 
1141  // they aren't restriced, we are?
1142  if (!their_active_subdomains && active_subdomains)
1143  should_be_in_vg = false;
1144 
1145  if (their_active_subdomains && active_subdomains)
1146  // restricted to different sets?
1147  if (*their_active_subdomains != *active_subdomains)
1148  should_be_in_vg = false;
1149 
1150  // OK, after all that, append the variable to the vg if none of the conditions
1151  // were violated
1152  if (should_be_in_vg)
1153  {
1154  const unsigned short curr_n_vars = cast_int<unsigned short>
1155  (this->n_vars());
1156 
1157  vg.append (var);
1158 
1159  _variables.push_back(vg(vg.n_variables()-1));
1160  _variable_numbers[var] = curr_n_vars;
1161  return curr_n_vars;
1162  }
1163  }
1164 
1165  // otherwise, fall back to adding a single variable group
1166  return this->add_variables (std::vector<std::string>(1, var),
1167  type,
1168  active_subdomains);
1169 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2132
const class libmesh_nullptr_t libmesh_nullptr
std::vector< Variable > _variables
Definition: system.h:1890
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2162
libmesh_assert(j)
unsigned int n_variable_groups() const
Definition: system.h:2092
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
bool is_initialized()
Definition: system.h:2068
bool identify_variable_groups() const
Definition: system.h:2180
unsigned int number() const
Definition: system.h:2004
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1185
unsigned int n_vars() const
Definition: system.h:2084
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 = libmesh_nullptr 
)
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 1173 of file system.C.

References libMesh::System::add_variable().

1177 {
1178  return this->add_variable(var,
1179  FEType(order, family),
1180  active_subdomains);
1181 }
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1095
unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = libmesh_nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

Returns
The index number for the new variable.

Definition at line 1185 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::is_initialized(), libMesh::libmesh_assert(), libmesh_nullptr, 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(), libMesh::System::add_variables(), and libMesh::System::project_solution_on_reinit().

1188 {
1189  libmesh_assert(!this->is_initialized());
1190 
1191  // Make sure the variable isn't there already
1192  // or if it is, that it's the type we want
1193  for (std::size_t ov=0; ov<vars.size(); ov++)
1194  for (unsigned int v=0; v<this->n_vars(); v++)
1195  if (this->variable_name(v) == vars[ov])
1196  {
1197  if (this->variable_type(v) == type)
1198  return _variables[v].number();
1199 
1200  libmesh_error_msg("ERROR: incompatible variable " << vars[ov] << " has already been added for this system!");
1201  }
1202 
1203  const unsigned short curr_n_vars = cast_int<unsigned short>
1204  (this->n_vars());
1205 
1206  const unsigned int next_first_component = this->n_components();
1207 
1208  // Add the variable group to the list
1209  _variable_groups.push_back((active_subdomains == libmesh_nullptr) ?
1210  VariableGroup(this, vars, curr_n_vars,
1211  next_first_component, type) :
1212  VariableGroup(this, vars, curr_n_vars,
1213  next_first_component, type, *active_subdomains));
1214 
1215  const VariableGroup & vg (_variable_groups.back());
1216 
1217  // Add each component of the group individually
1218  for (std::size_t v=0; v<vars.size(); v++)
1219  {
1220  _variables.push_back (vg(v));
1221  _variable_numbers[vars[v]] = cast_int<unsigned short>
1222  (curr_n_vars+v);
1223  }
1224 
1225  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1226 
1227  // BSK - Defer this now to System::init_data() so we can detect
1228  // VariableGroups 12/28/2012
1229  // // Add the variable group to the _dof_map
1230  // _dof_map->add_variable_group (vg);
1231 
1232  // Return the number of the new variable
1233  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1234 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2132
const class libmesh_nullptr_t libmesh_nullptr
std::vector< Variable > _variables
Definition: system.h:1890
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2162
libmesh_assert(j)
unsigned int n_components() const
Definition: system.h:2100
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
bool is_initialized()
Definition: system.h:2068
unsigned int number() const
Definition: system.h:2004
unsigned int n_vars() const
Definition: system.h:2084
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 = libmesh_nullptr 
)
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 1238 of file system.C.

References libMesh::System::add_variables().

1242 {
1243  return this->add_variables(vars,
1244  FEType(order, family),
1245  active_subdomains);
1246 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1185
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 676 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::NumericVector< T >::build(), 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::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::OptimizationSystem::init_data(), libMesh::ContinuationSystem::init_data(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

679 {
680  // Return the vector if it is already there.
681  if (this->have_vector(vec_name))
682  return *(_vectors[vec_name]);
683 
684  // Otherwise build the vector
685  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
686  _vectors.insert (std::make_pair (vec_name, buf));
687  _vector_projections.insert (std::make_pair (vec_name, projections));
688 
689  _vector_types.insert (std::make_pair (vec_name, type));
690 
691  // Vectors are primal by default
692  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
693 
694  // Initialize it if necessary
695  if (_is_initialized)
696  {
697  if (type == GHOSTED)
698  {
699 #ifdef LIBMESH_ENABLE_GHOSTED
700  buf->init (this->n_dofs(), this->n_local_dofs(),
701  _dof_map->get_send_list(), false,
702  GHOSTED);
703 #else
704  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
705 #endif
706  }
707  else
708  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
709  }
710 
711  return *buf;
712 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1931
bool _is_initialized
Definition: system.h:1950
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
bool have_vector(const std::string &vec_name) const
Definition: system.h:2204
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1926
dof_id_type n_local_dofs() const
Definition: system.C:180
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
const Parallel::Communicator & comm() const
std::map< std::string, bool > _vector_projections
Definition: system.h:1920
dof_id_type n_dofs() const
Definition: system.C:143
NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1003 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1004 {
1005  std::ostringstream adjoint_name;
1006  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1007 
1008  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1009  this->set_vector_as_adjoint(adjoint_name.str(), i);
1010  return returnval;
1011 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:899
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.

Definition at line 950 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

951 {
952  return this->add_vector("weighted_sensitivity_solution");
953 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
void libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
virtualinherited

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 693 of file implicit_system.C.

References std::abs(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::NumericVector< T >::dot(), libMesh::System::get_sensitivity_rhs(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), std::max(), libMesh::System::qoi, libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::ImplicitSystem::assembly().

696 {
697  ParameterVector & parameters =
698  const_cast<ParameterVector &>(parameters_in);
699 
700  const unsigned int Np = cast_int<unsigned int>
701  (parameters.size());
702  const unsigned int Nq = cast_int<unsigned int>
703  (qoi.size());
704 
705  // An introduction to the problem:
706  //
707  // Residual R(u(p),p) = 0
708  // partial R / partial u = J = system matrix
709  //
710  // This implies that:
711  // d/dp(R) = 0
712  // (partial R / partial p) +
713  // (partial R / partial u) * (partial u / partial p) = 0
714 
715  // We first do an adjoint solve:
716  // J^T * z = (partial q / partial u)
717  // if we havent already or dont have an initial condition for the adjoint
718  if (!this->is_adjoint_already_solved())
719  {
720  this->adjoint_solve(qoi_indices);
721  }
722 
723  this->assemble_residual_derivatives(parameters_in);
724 
725  // Get ready to fill in senstivities:
726  sensitivities.allocate_data(qoi_indices, *this, parameters);
727 
728  // We use the identities:
729  // dq/dp = (partial q / partial p) + (partial q / partial u) *
730  // (partial u / partial p)
731  // dq/dp = (partial q / partial p) + (J^T * z) *
732  // (partial u / partial p)
733  // dq/dp = (partial q / partial p) + z * J *
734  // (partial u / partial p)
735 
736  // Leading to our final formula:
737  // dq/dp = (partial q / partial p) - z * (partial R / partial p)
738 
739  // In the case of adjoints with heterogenous Dirichlet boundary
740  // function phi, where
741  // q := S(u) - R(u,phi)
742  // the final formula works out to:
743  // dq/dp = (partial S / partial p) - z * (partial R / partial p)
744  // Because we currently have no direct access to
745  // (partial S / partial p), we use the identity
746  // (partial S / partial p) = (partial q / partial p) +
747  // phi * (partial R / partial p)
748  // to derive an equivalent equation:
749  // dq/dp = (partial q / partial p) - (z-phi) * (partial R / partial p)
750 
751  // Since z-phi degrees of freedom are zero for constrained indices,
752  // we can use the same constrained -(partial R / partial p) that we
753  // use for forward sensitivity solves, taking into account the
754  // differing sign convention.
755  //
756  // Since that vector is constrained, its constrained indices are
757  // zero, so its product with phi is zero, so we can neglect the
758  // evaluation of phi terms.
759 
760  for (unsigned int j=0; j != Np; ++j)
761  {
762  // We currently get partial derivatives via central differencing
763 
764  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
765  // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
766 
767  Number old_parameter = *parameters[j];
768 
769  const Real delta_p =
770  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
771 
772  *parameters[j] = old_parameter - delta_p;
773  this->assemble_qoi(qoi_indices);
774  std::vector<Number> qoi_minus = this->qoi;
775 
776  NumericVector<Number> & neg_partialR_partialp = this->get_sensitivity_rhs(j);
777 
778  *parameters[j] = old_parameter + delta_p;
779  this->assemble_qoi(qoi_indices);
780  std::vector<Number> & qoi_plus = this->qoi;
781 
782  std::vector<Number> partialq_partialp(Nq, 0);
783  for (unsigned int i=0; i != Nq; ++i)
784  if (qoi_indices.has_index(i))
785  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
786 
787  // Don't leave the parameter changed
788  *parameters[j] = old_parameter;
789 
790  for (unsigned int i=0; i != Nq; ++i)
791  if (qoi_indices.has_index(i))
792  sensitivities[i][j] = partialq_partialp[i] +
793  neg_partialR_partialp.dot(this->get_adjoint_solution(i));
794  }
795 
796  // All parameters have been reset.
797  // Reset the original qoi.
798 
799  this->assemble_qoi(qoi_indices);
800 }
double abs(double a)
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) libmesh_override
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1075
static const Real TOLERANCE
long double max(long double a, double b)
std::vector< Number > qoi
Definition: system.h:1551
bool is_adjoint_already_solved() const
Definition: system.h:372
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) libmesh_override
virtual void assemble_residual_derivatives(const ParameterVector &parameters) libmesh_override
std::pair< unsigned int, Real > libMesh::DifferentiableSystem::adjoint_solve ( const QoISet qoi_indices = QoISet())
virtual

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 164 of file diff_system.C.

References libMesh::ImplicitSystem::adjoint_solve(), get_time_solver(), and libMesh::TimeSolver::set_is_adjoint().

165 {
166  // Get the time solver object associated with the system, and tell it that
167  // we are solving the adjoint problem
168  this->get_time_solver().set_is_adjoint(true);
169 
170  return this->ImplicitSystem::adjoint_solve(qoi_indices);
171 }
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) libmesh_override
void set_is_adjoint(bool _is_adjoint_value)
Definition: time_solver.h:239
TimeSolver & get_time_solver()
Definition: diff_system.h:402
void libMesh::DifferentiableSystem::assemble ( )
virtual

Prepares matrix and rhs for matrix assembly. Users should not reimplement this

Reimplemented from libMesh::ImplicitSystem.

Definition at line 145 of file diff_system.C.

References assembly().

146 {
147  this->assembly(true, true);
148 }
virtual void assembly(bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) libmesh_override=0
void libMesh::ExplicitSystem::assemble_qoi ( const QoISet qoi_indices = QoISet())
virtualinherited

Prepares qoi for quantity of interest assembly, then calls user qoi function. Can be overridden in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 89 of file explicit_system.C.

References libMesh::System::assemble_qoi(), libMesh::QoISet::has_index(), and libMesh::System::qoi.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ExplicitSystem::system().

90 {
91  // The user quantity of interest assembly gets to expect to
92  // accumulate on initially zero values
93  for (std::size_t i=0; i != qoi.size(); ++i)
94  if (qoi_indices.has_index(i))
95  qoi[i] = 0;
96 
97  Parent::assemble_qoi (qoi_indices);
98 }
std::vector< Number > qoi
Definition: system.h:1551
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Definition: system.C:485
void libMesh::ExplicitSystem::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtualinherited

Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative function. Can be overridden in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 102 of file explicit_system.C.

References libMesh::System::add_adjoint_rhs(), libMesh::System::assemble_qoi_derivative(), libMesh::QoISet::has_index(), libMesh::System::qoi, and libMesh::NumericVector< T >::zero().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::ExplicitSystem::system(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

105 {
106  // The user quantity of interest derivative assembly gets to expect
107  // to accumulate on initially zero vectors
108  for (std::size_t i=0; i != qoi.size(); ++i)
109  if (qoi_indices.has_index(i))
110  this->add_adjoint_rhs(i).zero();
111 
112  Parent::assemble_qoi_derivative (qoi_indices, include_liftfunc,
113  apply_constraints);
114 }
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:496
virtual void zero()=0
std::vector< Number > qoi
Definition: system.h:1551
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1035
void libMesh::ImplicitSystem::assemble_residual_derivatives ( const ParameterVector parameters)
virtualinherited

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 overridden in derived classes.

Reimplemented from libMesh::System.

Definition at line 650 of file implicit_system.C.

References std::abs(), libMesh::System::add_sensitivity_rhs(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), std::max(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::assembly(), and libMesh::ImplicitSystem::sensitivity_solve().

651 {
652  ParameterVector & parameters =
653  const_cast<ParameterVector &>(parameters_in);
654 
655  const unsigned int Np = cast_int<unsigned int>
656  (parameters.size());
657 
658  for (unsigned int p=0; p != Np; ++p)
659  {
660  NumericVector<Number> & sensitivity_rhs = this->add_sensitivity_rhs(p);
661 
662  // Approximate -(partial R / partial p) by
663  // (R(p-dp) - R(p+dp)) / (2*dp)
664 
665  Number old_parameter = *parameters[p];
666 
667  const Real delta_p =
668  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
669 
670  *parameters[p] -= delta_p;
671 
672  // this->assembly(true, false, true);
673  this->assembly(true, false, false);
674  this->rhs->close();
675  sensitivity_rhs = *this->rhs;
676 
677  *parameters[p] = old_parameter + delta_p;
678 
679  // this->assembly(true, false, true);
680  this->assembly(true, false, false);
681  this->rhs->close();
682 
683  sensitivity_rhs -= *this->rhs;
684  sensitivity_rhs /= (2*delta_p);
685  sensitivity_rhs.close();
686 
687  *parameters[p] = old_parameter;
688  }
689 }
double abs(double a)
NumericVector< Number > * rhs
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1065
static const Real TOLERANCE
long double max(long double a, double b)
virtual void assembly(bool, bool, bool=false, bool=false)
virtual void close()=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void libMesh::DifferentiableSystem::assembly ( bool  get_residual,
bool  get_jacobian,
bool  apply_heterogeneous_constraints = false,
bool  apply_no_constraints = false 
)
pure virtual

Assembles a residual in rhs and/or a jacobian in matrix, as requested.

Reimplemented from libMesh::ImplicitSystem.

Implemented in libMesh::FEMSystem.

Referenced by assemble(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::EigenTimeSolver::solve().

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 1801 of file system.C.

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1803 {
1804  libmesh_assert(fptr);
1805 
1807  {
1808  libmesh_here();
1809  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1810  << std::endl;
1811 
1813  }
1814 
1816 }
Assembly * _assemble_system_object
Definition: system.h:1820
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
OStreamProxy out(std::cout)
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 1820 of file system.C.

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1821 {
1823  {
1824  libmesh_here();
1825  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1826  << std::endl;
1827 
1829  }
1830 
1831  _assemble_system_object = &assemble_in;
1832 }
Assembly * _assemble_system_object
Definition: system.h:1820
const class libmesh_nullptr_t libmesh_nullptr
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 1836 of file system.C.

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1838 {
1839  libmesh_assert(fptr);
1840 
1842  {
1843  libmesh_here();
1844  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1845  << std::endl;
1846 
1848  }
1849 
1851 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
Constraint * _constrain_system_object
Definition: system.h:1831
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_object ( System::Constraint constrain)
inherited

Register a user object for imposing constraints.

Definition at line 1855 of file system.C.

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1856 {
1858  {
1859  libmesh_here();
1860  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1861  << std::endl;
1862 
1864  }
1865 
1866  _constrain_system_object = &constrain;
1867 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
Constraint * _constrain_system_object
Definition: system.h:1831
const class libmesh_nullptr_t libmesh_nullptr
OStreamProxy out(std::cout)
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 1766 of file system.C.

References libMesh::System::_init_system_function, libMesh::System::_init_system_object, libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1768 {
1769  libmesh_assert(fptr);
1770 
1772  {
1773  libmesh_here();
1774  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1775  << std::endl;
1776 
1778  }
1779 
1780  _init_system_function = fptr;
1781 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
Initialization * _init_system_object
Definition: system.h:1809
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
OStreamProxy out(std::cout)
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 1785 of file system.C.

References libMesh::System::_init_system_function, libMesh::System::_init_system_object, libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1786 {
1788  {
1789  libmesh_here();
1790  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1791  << std::endl;
1792 
1794  }
1795 
1796  _init_system_object = &init_in;
1797 }
const class libmesh_nullptr_t libmesh_nullptr
Initialization * _init_system_object
Definition: system.h:1809
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
OStreamProxy out(std::cout)
void libMesh::DifferentiableSystem::attach_physics ( DifferentiablePhysics physics_in)
inline

Attach external Physics object.

Definition at line 184 of file diff_system.h.

References _diff_physics, libMesh::DifferentiablePhysics::clone_physics(), libMesh::DifferentiablePhysics::init_physics(), and swap_physics().

185  { this->_diff_physics = (physics_in->clone_physics()).release();
186  this->_diff_physics->init_physics(*this);}
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358
virtual void init_physics(const System &sys)
void libMesh::DifferentiableSystem::attach_qoi ( DifferentiableQoI qoi_in)
inline

Attach external QoI object.

Definition at line 212 of file diff_system.h.

References libMesh::DifferentiableQoI::clone(), diff_qoi, libMesh::DifferentiableQoI::init_qoi(), and libMesh::System::qoi.

213  { this->diff_qoi = (qoi_in->clone()).release();
214  // User needs to resize qoi system qoi accordingly
215  this->diff_qoi->init_qoi( this->qoi );}
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
std::vector< Number > qoi
Definition: system.h:1551
virtual void init_qoi(std::vector< Number > &)
Definition: diff_qoi.h:67
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 1907 of file system.C.

References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1909 {
1910  libmesh_assert(fptr);
1911 
1913  {
1914  libmesh_here();
1915  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1916  << std::endl;
1917 
1919  }
1920 
1922 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
OStreamProxy out(std::cout)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1848
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 1926 of file system.C.

References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1927 {
1929  {
1930  libmesh_here();
1931  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1932  << std::endl;
1933 
1935  }
1936 
1937  _qoi_evaluate_derivative_object = &qoi_derivative;
1938 }
const class libmesh_nullptr_t libmesh_nullptr
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
OStreamProxy out(std::cout)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1848
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 1871 of file system.C.

References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libMesh::libmesh_assert(), libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1874 {
1875  libmesh_assert(fptr);
1876 
1878  {
1879  libmesh_here();
1880  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1881  << std::endl;
1882 
1884  }
1885 
1886  _qoi_evaluate_function = fptr;
1887 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
libmesh_assert(j)
QOI * _qoi_evaluate_object
Definition: system.h:1843
OStreamProxy out(std::cout)
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 1891 of file system.C.

References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libmesh_nullptr, and libMesh::out.

Referenced by libMesh::System::read_parallel_data().

1892 {
1894  {
1895  libmesh_here();
1896  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1897  << std::endl;
1898 
1900  }
1901 
1902  _qoi_evaluate_object = &qoi_in;
1903 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
QOI * _qoi_evaluate_object
Definition: system.h:1843
OStreamProxy out(std::cout)
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 = libmesh_nullptr 
)
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 999 of file system_projection.C.

References libMesh::System::boundary_project_vector().

Referenced by libMesh::System::project_vector(), and libMesh::System::system_type().

1003 {
1004  this->boundary_project_vector(b, variables, *solution, f, g);
1005 
1006  solution->localize(*current_local_solution);
1007 }
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=libmesh_nullptr, int is_adjoint=-1) const
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
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 &parameters, const std::string &sys_name, const std::string &unknown_name,
Gradient   gptrconst Point &p, const Parameters &parameters, 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.

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 = libmesh_nullptr,
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 1041 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::get_dof_map(), and libMesh::Threads::parallel_for().

Referenced by libMesh::System::boundary_project_solution(), and libMesh::System::system_type().

1047 {
1048  LOG_SCOPE ("boundary_project_vector()", "System");
1049 
1051  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1052  this->get_mesh().active_local_elements_end() ),
1053  BoundaryProjectSolution(b, variables, *this, f, g,
1054  this->get_equation_systems().parameters,
1055  new_vector)
1056  );
1057 
1058  // We don't do SCALAR dofs when just projecting the boundary, so
1059  // we're done here.
1060 
1061  new_vector.close();
1062 
1063 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1064  if (is_adjoint == -1)
1065  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1066  else if (is_adjoint >= 0)
1068  is_adjoint);
1069 #endif
1070 }
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=libmesh_nullptr, bool homogeneous=false) const
virtual void close()=0
const EquationSystems & get_equation_systems() const
Definition: system.h:712
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
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 &parameters, const std::string &sys_name, const std::string &unknown_name,
Gradient   gptrconst Point &p, const Parameters &parameters, 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.

UniquePtr< DiffContext > libMesh::DifferentiableSystem::build_context ( )
virtual

Builds a DiffContext object with enough information to do evaluations on each element.

For most problems, the default "Let FEMSystem build an * FEMContext" reimplementation is correct; users who subclass FEMContext will need to also reimplement this method to build it.

Reimplemented in libMesh::FEMSystem.

Definition at line 137 of file diff_system.C.

References deltat, and libMesh::DiffContext::set_deltat_pointer().

138 {
139  DiffContext * context = new DiffContext(*this);
140  context->set_deltat_pointer( &this->deltat );
141  return UniquePtr<DiffContext>(context);
142 }
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type,
std::set< unsigned int > *  skip_dimensions = libmesh_nullptr 
) const
inherited
Returns
A norm of variable var in the vector v, in the specified norm (e.g. L2, L_INF, H1)

Definition at line 1393 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(), libMesh::UnsteadySolver::du(), and libMesh::System::project_solution_on_reinit().

1397 {
1398  //short circuit to save time
1399  if (norm_type == DISCRETE_L1 ||
1400  norm_type == DISCRETE_L2 ||
1401  norm_type == DISCRETE_L_INF)
1402  return discrete_var_norm(v,var,norm_type);
1403 
1404  // Not a discrete norm
1405  std::vector<FEMNormType> norms(this->n_vars(), L2);
1406  std::vector<Real> weights(this->n_vars(), 0.0);
1407  norms[var] = norm_type;
1408  weights[var] = 1.0;
1409  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1410  return val;
1411 }
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=libmesh_nullptr) const
Definition: system.C:1393
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_vars() const
Definition: system.h:2084
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1374
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm,
std::set< unsigned int > *  skip_dimensions = libmesh_nullptr 
) const
inherited
Returns
A norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 1415 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_mesh, 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::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::Elem::dim(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::System::get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), 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::libmesh_assert(), libmesh_nullptr, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::QBase::n_points(), libMesh::System::n_vars(), libMesh::TypeVector< T >::norm(), libMesh::TypeTensor< T >::norm(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::TypeTensor< T >::norm_sq(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::NumericVector< T >::size(), 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().

1418 {
1419  // This function must be run on all processors at once
1420  parallel_object_only();
1421 
1422  LOG_SCOPE ("calculate_norm()", "System");
1423 
1424  // Zero the norm before summation
1425  Real v_norm = 0.;
1426 
1427  if (norm.is_discrete())
1428  {
1429  //Check to see if all weights are 1.0 and all types are equal
1430  FEMNormType norm_type0 = norm.type(0);
1431  unsigned int check_var = 0;
1432  for (; check_var != this->n_vars(); ++check_var)
1433  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1434  break;
1435 
1436  //All weights were 1.0 so just do the full vector discrete norm
1437  if (check_var == this->n_vars())
1438  {
1439  if (norm_type0 == DISCRETE_L1)
1440  return v.l1_norm();
1441  if (norm_type0 == DISCRETE_L2)
1442  return v.l2_norm();
1443  if (norm_type0 == DISCRETE_L_INF)
1444  return v.linfty_norm();
1445  else
1446  libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
1447  }
1448 
1449  for (unsigned int var=0; var != this->n_vars(); ++var)
1450  {
1451  // Skip any variables we don't need to integrate
1452  if (norm.weight(var) == 0.0)
1453  continue;
1454 
1455  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1456  }
1457 
1458  return v_norm;
1459  }
1460 
1461  // Localize the potentially parallel vector
1462  UniquePtr<NumericVector<Number> > local_v = NumericVector<Number>::build(this->comm());
1463  local_v->init(v.size(), true, SERIAL);
1464  v.localize (*local_v, _dof_map->get_send_list());
1465 
1466  // I'm not sure how best to mix Hilbert norms on some variables (for
1467  // which we'll want to square then sum then square root) with norms
1468  // like L_inf (for which we'll just want to take an absolute value
1469  // and then sum).
1470  bool using_hilbert_norm = true,
1471  using_nonhilbert_norm = true;
1472 
1473  // Loop over all variables
1474  for (unsigned int var=0; var != this->n_vars(); ++var)
1475  {
1476  // Skip any variables we don't need to integrate
1477  Real norm_weight_sq = norm.weight_sq(var);
1478  if (norm_weight_sq == 0.0)
1479  continue;
1480  Real norm_weight = norm.weight(var);
1481 
1482  // Check for unimplemented norms (rather than just returning 0).
1483  FEMNormType norm_type = norm.type(var);
1484  if ((norm_type==H1) ||
1485  (norm_type==H2) ||
1486  (norm_type==L2) ||
1487  (norm_type==H1_SEMINORM) ||
1488  (norm_type==H2_SEMINORM))
1489  {
1490  if (!using_hilbert_norm)
1491  libmesh_not_implemented();
1492  using_nonhilbert_norm = false;
1493  }
1494  else if ((norm_type==L1) ||
1495  (norm_type==L_INF) ||
1496  (norm_type==W1_INF_SEMINORM) ||
1497  (norm_type==W2_INF_SEMINORM))
1498  {
1499  if (!using_nonhilbert_norm)
1500  libmesh_not_implemented();
1501  using_hilbert_norm = false;
1502  }
1503  else
1504  libmesh_not_implemented();
1505 
1506  const FEType & fe_type = this->get_dof_map().variable_type(var);
1507 
1508  // Allow space for dims 0-3, even if we don't use them all
1509  std::vector<FEBase *> fe_ptrs(4,libmesh_nullptr);
1510  std::vector<QBase *> q_rules(4,libmesh_nullptr);
1511 
1512  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1513 
1514  // Prepare finite elements for each dimension present in the mesh
1515  for (std::set<unsigned char>::const_iterator d_it = elem_dims.begin();
1516  d_it != elem_dims.end(); ++d_it)
1517  {
1518  if (skip_dimensions && skip_dimensions->find(*d_it) != skip_dimensions->end())
1519  continue;
1520 
1521  q_rules[*d_it] =
1522  fe_type.default_quadrature_rule (*d_it).release();
1523 
1524  // Construct finite element object
1525 
1526  fe_ptrs[*d_it] = FEBase::build(*d_it, fe_type).release();
1527 
1528  // Attach quadrature rule to FE object
1529  fe_ptrs[*d_it]->attach_quadrature_rule (q_rules[*d_it]);
1530  }
1531 
1532  std::vector<dof_id_type> dof_indices;
1533 
1534  // Begin the loop over the elements
1535  MeshBase::const_element_iterator el =
1537  const MeshBase::const_element_iterator end_el =
1539 
1540  for ( ; el != end_el; ++el)
1541  {
1542  const Elem * elem = *el;
1543  const unsigned int dim = elem->dim();
1544 
1545  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1546  continue;
1547 
1548  FEBase * fe = fe_ptrs[dim];
1549  QBase * qrule = q_rules[dim];
1550  libmesh_assert(fe);
1551  libmesh_assert(qrule);
1552 
1553  const std::vector<Real> & JxW = fe->get_JxW();
1554  const std::vector<std::vector<Real> > * phi = libmesh_nullptr;
1555  if (norm_type == H1 ||
1556  norm_type == H2 ||
1557  norm_type == L2 ||
1558  norm_type == L1 ||
1559  norm_type == L_INF)
1560  phi = &(fe->get_phi());
1561 
1562  const std::vector<std::vector<RealGradient> > * dphi = libmesh_nullptr;
1563  if (norm_type == H1 ||
1564  norm_type == H2 ||
1565  norm_type == H1_SEMINORM ||
1566  norm_type == W1_INF_SEMINORM)
1567  dphi = &(fe->get_dphi());
1568 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1569  const std::vector<std::vector<RealTensor> > * d2phi = libmesh_nullptr;
1570  if (norm_type == H2 ||
1571  norm_type == H2_SEMINORM ||
1572  norm_type == W2_INF_SEMINORM)
1573  d2phi = &(fe->get_d2phi());
1574 #endif
1575 
1576  fe->reinit (elem);
1577 
1578  this->get_dof_map().dof_indices (elem, dof_indices, var);
1579 
1580  const unsigned int n_qp = qrule->n_points();
1581 
1582  const unsigned int n_sf = cast_int<unsigned int>
1583  (dof_indices.size());
1584 
1585  // Begin the loop over the Quadrature points.
1586  for (unsigned int qp=0; qp<n_qp; qp++)
1587  {
1588  if (norm_type == L1)
1589  {
1590  Number u_h = 0.;
1591  for (unsigned int i=0; i != n_sf; ++i)
1592  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1593  v_norm += norm_weight *
1594  JxW[qp] * std::abs(u_h);
1595  }
1596 
1597  if (norm_type == L_INF)
1598  {
1599  Number u_h = 0.;
1600  for (unsigned int i=0; i != n_sf; ++i)
1601  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1602  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
1603  }
1604 
1605  if (norm_type == H1 ||
1606  norm_type == H2 ||
1607  norm_type == L2)
1608  {
1609  Number u_h = 0.;
1610  for (unsigned int i=0; i != n_sf; ++i)
1611  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1612  v_norm += norm_weight_sq *
1613  JxW[qp] * TensorTools::norm_sq(u_h);
1614  }
1615 
1616  if (norm_type == H1 ||
1617  norm_type == H2 ||
1618  norm_type == H1_SEMINORM)
1619  {
1620  Gradient grad_u_h;
1621  for (unsigned int i=0; i != n_sf; ++i)
1622  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1623  v_norm += norm_weight_sq *
1624  JxW[qp] * grad_u_h.norm_sq();
1625  }
1626 
1627  if (norm_type == W1_INF_SEMINORM)
1628  {
1629  Gradient grad_u_h;
1630  for (unsigned int i=0; i != n_sf; ++i)
1631  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1632  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1633  }
1634 
1635 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1636  if (norm_type == H2 ||
1637  norm_type == H2_SEMINORM)
1638  {
1639  Tensor hess_u_h;
1640  for (unsigned int i=0; i != n_sf; ++i)
1641  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1642  v_norm += norm_weight_sq *
1643  JxW[qp] * hess_u_h.norm_sq();
1644  }
1645 
1646  if (norm_type == W2_INF_SEMINORM)
1647  {
1648  Tensor hess_u_h;
1649  for (unsigned int i=0; i != n_sf; ++i)
1650  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1651  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1652  }
1653 #endif
1654  }
1655  }
1656 
1657  // Need to delete the FE and quadrature objects to prevent a memory leak
1658  for (std::size_t i=0; i<fe_ptrs.size(); i++)
1659  if (fe_ptrs[i])
1660  delete fe_ptrs[i];
1661 
1662  for (std::size_t i=0; i<q_rules.size(); i++)
1663  if (q_rules[i])
1664  delete q_rules[i];
1665  }
1666 
1667  if (using_hilbert_norm)
1668  {
1669  this->comm().sum(v_norm);
1670  v_norm = std::sqrt(v_norm);
1671  }
1672  else
1673  {
1674  this->comm().max(v_norm);
1675  }
1676 
1677  return v_norm;
1678 }
double abs(double a)
virtual numeric_index_type size() const =0
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1676
void add_scaled(const TypeTensor< T2 > &, const T)
Definition: type_tensor.h:773
void add_scaled(const TypeVector< T2 > &, const T)
Definition: type_vector.h:620
virtual Real l2_norm() const =0
const class libmesh_nullptr_t libmesh_nullptr
virtual Real l1_norm() const =0
long double max(long double a, double b)
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
libmesh_assert(j)
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
virtual element_iterator active_local_elements_begin()=0
NumberVectorValue Gradient
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:196
FEGenericBase< Real > FEBase
virtual Real linfty_norm() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
NumberTensorValue Tensor
const Parallel::Communicator & comm() const
ParallelType type() const
unsigned int n_vars() const
Definition: system.h:2084
virtual element_iterator active_local_elements_end()=0
MeshBase & _mesh
Definition: system.h:1875
virtual void localize(std::vector< T > &v_local) const =0
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1374
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2005
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
void libMesh::DifferentiableSystem::clear ( )
virtual

Clear all the data structures associated with the system.

Reimplemented from libMesh::ImplicitSystem.

Reimplemented in libMesh::ContinuationSystem.

Definition at line 69 of file diff_system.C.

References _diff_physics, libMesh::DifferentiablePhysics::clear_physics(), libMesh::DifferentiableQoI::clear_qoi(), diff_qoi, and libMesh::System::use_fixed_solution.

Referenced by libMesh::ContinuationSystem::clear().

70 {
71  // If we had an attached Physics object, delete it.
72  if (this->_diff_physics != this)
73  {
74  delete this->_diff_physics;
75  this->_diff_physics = this;
76  }
77  // If we had no attached Physics object, clear our own Physics data
78  else
79  this->clear_physics();
80 
81  // If we had an attached QoI object, delete it.
82  if (this->diff_qoi != this)
83  {
84  delete this->diff_qoi;
85  this->diff_qoi = this;
86  }
87  // If we had no attached QoI object, clear our own QoI data
88  else
89  this->clear_qoi();
90 
91  use_fixed_solution = false;
92 }
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358
bool use_fixed_solution
Definition: system.h:1491
virtual void clear_qoi()
Definition: diff_qoi.h:73
virtual void libMesh::DifferentiablePhysics::clear_physics ( )
virtualinherited

Clear any data structures associated with the physics.

Referenced by clear(), and libMesh::DifferentiablePhysics::DifferentiablePhysics().

virtual void libMesh::DifferentiableQoI::clear_qoi ( )
inlinevirtualinherited

Clear all the data structures associated with the QoI.

Definition at line 73 of file diff_qoi.h.

Referenced by clear().

73 {}
virtual UniquePtr<DifferentiableQoI> libMesh::DifferentiableSystem::clone ( )
inlinevirtual

We don't allow systems to be attached to each other

Implements libMesh::DifferentiableQoI.

Definition at line 156 of file diff_system.h.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

157  {
158  libmesh_not_implemented();
159  // dummy
160  return UniquePtr<DifferentiableQoI>(this);
161  }
virtual UniquePtr<DifferentiablePhysics> libMesh::DifferentiableSystem::clone_physics ( )
inlinevirtual

We don't allow systems to be attached to each other

Implements libMesh::DifferentiablePhysics.

Definition at line 146 of file diff_system.h.

147  {
148  libmesh_not_implemented();
149  // dummy
150  return UniquePtr<DifferentiablePhysics>(this);
151  }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 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_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), 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::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), libMesh::DistributedMesh::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::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), 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::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), 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::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
bool libMesh::System::compare ( const System other_system,
const Real  threshold,
const bool  verbose 
) const
virtualinherited
Returns
true when the other system contains identical data, up to the given threshold. Outputs some diagnostic info when verbose is set.

Definition at line 526 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(), and libMesh::System::set_adjoint_already_solved().

529 {
530  // we do not care for matrices, but for vectors
532  libmesh_assert (other_system._is_initialized);
533 
534  if (verbose)
535  {
536  libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
537  libMesh::out << " comparing matrices not supported." << std::endl;
538  libMesh::out << " comparing names...";
539  }
540 
541  // compare the name: 0 means identical
542  const int name_result = _sys_name.compare(other_system.name());
543  if (verbose)
544  {
545  if (name_result == 0)
546  libMesh::out << " identical." << std::endl;
547  else
548  libMesh::out << " names not identical." << std::endl;
549  libMesh::out << " comparing solution vector...";
550  }
551 
552 
553  // compare the solution: -1 means identical
554  const int solu_result = solution->compare (*other_system.solution.get(),
555  threshold);
556 
557  if (verbose)
558  {
559  if (solu_result == -1)
560  libMesh::out << " identical up to threshold." << std::endl;
561  else
562  libMesh::out << " first difference occured at index = "
563  << solu_result << "." << std::endl;
564  }
565 
566 
567  // safety check, whether we handle at least the same number
568  // of vectors
569  std::vector<int> ov_result;
570 
571  if (this->n_vectors() != other_system.n_vectors())
572  {
573  if (verbose)
574  {
575  libMesh::out << " Fatal difference. This system handles "
576  << this->n_vectors() << " add'l vectors," << std::endl
577  << " while the other system handles "
578  << other_system.n_vectors()
579  << " add'l vectors." << std::endl
580  << " Aborting comparison." << std::endl;
581  }
582  return false;
583  }
584  else if (this->n_vectors() == 0)
585  {
586  // there are no additional vectors...
587  ov_result.clear ();
588  }
589  else
590  {
591  // compare other vectors
592  for (const_vectors_iterator pos = _vectors.begin();
593  pos != _vectors.end(); ++pos)
594  {
595  if (verbose)
596  libMesh::out << " comparing vector \""
597  << pos->first << "\" ...";
598 
599  // assume they have the same name
600  const NumericVector<Number> & other_system_vector =
601  other_system.get_vector(pos->first);
602 
603  ov_result.push_back(pos->second->compare (other_system_vector,
604  threshold));
605 
606  if (verbose)
607  {
608  if (ov_result[ov_result.size()-1] == -1)
609  libMesh::out << " identical up to threshold." << std::endl;
610  else
611  libMesh::out << " first difference occured at" << std::endl
612  << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
613  }
614 
615  }
616 
617  } // finished comparing additional vectors
618 
619 
620  bool overall_result;
621 
622  // sum up the results
623  if ((name_result==0) && (solu_result==-1))
624  {
625  if (ov_result.size()==0)
626  overall_result = true;
627  else
628  {
629  bool ov_identical;
630  unsigned int n = 0;
631  do
632  {
633  ov_identical = (ov_result[n]==-1);
634  n++;
635  }
636  while (ov_identical && n<ov_result.size());
637  overall_result = ov_identical;
638  }
639  }
640  else
641  overall_result = false;
642 
643  if (verbose)
644  {
645  libMesh::out << " finished comparisons, ";
646  if (overall_result)
647  libMesh::out << "found no differences." << std::endl << std::endl;
648  else
649  libMesh::out << "found differences." << std::endl << std::endl;
650  }
651 
652  return overall_result;
653 }
bool _is_initialized
Definition: system.h:1950
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
libmesh_assert(j)
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
const std::string _sys_name
Definition: system.h:1880
OStreamProxy out(std::cout)
unsigned int n_vectors() const
Definition: system.h:2212
Number libMesh::System::current_solution ( const dof_id_type  global_dof_number) const
inherited
Returns
The current solution for the specified global DOF.

Definition at line 187 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::ExactErrorEstimator::estimate_error(), 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().

188 {
189  // Check the sizes
190  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
191  libmesh_assert_less (global_dof_number, current_local_solution->size());
192 
193  return (*current_local_solution)(global_dof_number);
194 }
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
virtual bool libMesh::DifferentiablePhysics::damping_residual ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

Subtracts a damping vector contribution on elem from elem_residual. This method is not used in first-order-in-time problems. For second-order-in-time problems, this is the $ C(u,\ddot{u})\ddot{u} $ term. This method is only called for UnsteadySolver-based TimeSolvers.

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.

If the problem has no damping, the default "do-nothing" is correct. Otherwise, this must be reimplemented.

Definition at line 371 of file diff_physics.h.

Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), and libMesh::NewmarkSolver::element_residual().

372  {
373  return request_jacobian;
374  }
void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system. Only active systems are solved.

Definition at line 2060 of file system.h.

References libMesh::System::_active.

Referenced by libMesh::System::get_equation_systems().

2061 {
2062  _active = false;
2063 }
void libMesh::ImplicitSystem::disable_cache ( )
virtualinherited

Avoids use of any cached data that might affect any solve result. Should be overridden in derived systems.

Reimplemented from libMesh::System.

Definition at line 298 of file implicit_system.C.

References libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::get_linear_solver(), and libMesh::LinearSolver< T >::reuse_preconditioner().

298  {
299  this->assemble_before_solve = true;
300  this->get_linear_solver()->reuse_preconditioner(false);
301 }
virtual LinearSolver< Number > * get_linear_solver() const
virtual void reuse_preconditioner(bool)
bool assemble_before_solve
Definition: system.h:1475
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
virtual bool libMesh::DifferentiablePhysics::element_constraint ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 141 of file diff_physics.h.

Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::SteadySolver::element_residual(), libMesh::EigenTimeSolver::element_residual(), and libMesh::NewmarkSolver::element_residual().

142  {
143  return request_jacobian;
144  }
virtual void libMesh::DifferentiableSystem::element_postprocess ( DiffContext )
inlinevirtual

Does any work that needs to be done on elem in a postprocessing loop.

Definition at line 269 of file diff_system.h.

269 {}
virtual void libMesh::DifferentiableQoI::element_qoi ( DiffContext ,
const QoISet  
)
inlinevirtualinherited

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 106 of file diff_qoi.h.

108  {}
virtual void libMesh::DifferentiableQoI::element_qoi_derivative ( DiffContext ,
const QoISet  
)
inlinevirtualinherited

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 118 of file diff_qoi.h.

120  {}
virtual bool libMesh::DifferentiablePhysics::element_time_derivative ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 123 of file diff_physics.h.

Referenced by libMesh::SteadySolver::element_residual(), and libMesh::EigenTimeSolver::element_residual().

124  {
125  return request_jacobian;
126  }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::ReferenceCounter::n_objects().

102 {
103  _enable_print_counter = true;
104  return;
105 }
virtual bool libMesh::DifferentiablePhysics::eulerian_residual ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 291 of file diff_physics.h.

292  {
293  return request_jacobian;
294  }
void libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
virtualinherited

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 804 of file implicit_system.C.

References std::abs(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::ImplicitSystem::matrix, std::max(), libMesh::System::qoi, libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::ImplicitSystem::assembly().

807 {
808  ParameterVector & parameters =
809  const_cast<ParameterVector &>(parameters_in);
810 
811  const unsigned int Np = cast_int<unsigned int>
812  (parameters.size());
813  const unsigned int Nq = cast_int<unsigned int>
814  (qoi.size());
815 
816  // An introduction to the problem:
817  //
818  // Residual R(u(p),p) = 0
819  // partial R / partial u = J = system matrix
820  //
821  // This implies that:
822  // d/dp(R) = 0
823  // (partial R / partial p) +
824  // (partial R / partial u) * (partial u / partial p) = 0
825 
826  // We first solve for (partial u / partial p) for each parameter:
827  // J * (partial u / partial p) = - (partial R / partial p)
828 
829  this->sensitivity_solve(parameters);
830 
831  // Get ready to fill in senstivities:
832  sensitivities.allocate_data(qoi_indices, *this, parameters);
833 
834  // We use the identity:
835  // dq/dp = (partial q / partial p) + (partial q / partial u) *
836  // (partial u / partial p)
837 
838  // We get (partial q / partial u) from the user
839  this->assemble_qoi_derivative(qoi_indices,
840  /* include_liftfunc = */ true,
841  /* apply_constraints = */ false);
842 
843  // We don't need these to be closed() in this function, but libMesh
844  // standard practice is to have them closed() by the time the
845  // function exits
846  for (std::size_t i=0; i != this->qoi.size(); ++i)
847  if (qoi_indices.has_index(i))
848  this->get_adjoint_rhs(i).close();
849 
850  for (unsigned int j=0; j != Np; ++j)
851  {
852  // We currently get partial derivatives via central differencing
853 
854  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
855 
856  Number old_parameter = *parameters[j];
857 
858  const Real delta_p =
859  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
860 
861  *parameters[j] = old_parameter - delta_p;
862  this->assemble_qoi(qoi_indices);
863  std::vector<Number> qoi_minus = this->qoi;
864 
865  *parameters[j] = old_parameter + delta_p;
866  this->assemble_qoi(qoi_indices);
867  std::vector<Number> & qoi_plus = this->qoi;
868 
869  std::vector<Number> partialq_partialp(Nq, 0);
870  for (unsigned int i=0; i != Nq; ++i)
871  if (qoi_indices.has_index(i))
872  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
873 
874  // Don't leave the parameter changed
875  *parameters[j] = old_parameter;
876 
877  for (unsigned int i=0; i != Nq; ++i)
878  if (qoi_indices.has_index(i))
879  sensitivities[i][j] = partialq_partialp[i] +
880  this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
881  }
882 
883  // All parameters have been reset.
884  // We didn't cache the original rhs or matrix for memory reasons,
885  // but we can restore them to a state consistent solution -
886  // principle of least surprise.
887  this->assembly(true, true);
888  this->rhs->close();
889  this->matrix->close();
890  this->assemble_qoi(qoi_indices);
891 }
double abs(double a)
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:930
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters) libmesh_override
NumericVector< Number > * rhs
static const Real TOLERANCE
long double max(long double a, double b)
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) libmesh_override
virtual void assembly(bool, bool, bool=false, bool=false)
std::vector< Number > qoi
Definition: system.h:1551
virtual void close()=0
virtual void close()=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
virtual T dot(const NumericVector< T > &v) const =0
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) libmesh_override
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1045
NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. This what the user's QoI derivative code should assemble when setting up an adjoint problem

Definition at line 1045 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::System::project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1046 {
1047  std::ostringstream adjoint_rhs_name;
1048  adjoint_rhs_name << "adjoint_rhs" << i;
1049 
1050  return this->get_vector(adjoint_rhs_name.str());
1051 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.

Definition at line 1055 of file system.C.

References libMesh::System::get_vector().

1056 {
1057  std::ostringstream adjoint_rhs_name;
1058  adjoint_rhs_name << "adjoint_rhs" << i;
1059 
1060  return this->get_vector(adjoint_rhs_name.str());
1061 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 983 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(), libMesh::System::project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

984 {
985  std::ostringstream adjoint_name;
986  adjoint_name << "adjoint_solution" << i;
987 
988  return this->get_vector(adjoint_name.str());
989 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 993 of file system.C.

References libMesh::System::get_vector().

994 {
995  std::ostringstream adjoint_name;
996  adjoint_name << "adjoint_solution" << i;
997 
998  return this->get_vector(adjoint_name.str());
999 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 1272 of file system.C.

References libMesh::System::_variable_numbers, and libMesh::System::n_vars().

Referenced by libMesh::System::project_solution_on_reinit().

1273 {
1274  all_variable_numbers.resize(n_vars());
1275 
1276  // Make sure the variable exists
1277  std::map<std::string, unsigned short int>::const_iterator
1278  it = _variable_numbers.begin();
1279  std::map<std::string, unsigned short int>::const_iterator
1280  it_end = _variable_numbers.end();
1281 
1282  unsigned int count = 0;
1283  for ( ; it != it_end; ++it)
1284  {
1285  all_variable_numbers[count] = it->second;
1286  count++;
1287  }
1288 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
unsigned int n_vars() const
Definition: system.h:2084
const DofMap & libMesh::System::get_dof_map ( ) const
inlineinherited
Returns
A constant reference to this system's _dof_map.

Definition at line 2028 of file system.h.

References libMesh::System::_dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), add_dot_var_dirichlet_bcs(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::calculate_norm(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), 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::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::SecondOrderUnsteadySolver::old_solution_accel(), libMesh::SecondOrderUnsteadySolver::old_solution_rate(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::operator()(), libMesh::BuildProjectionList::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::re_update(), libMesh::SecondOrderUnsteadySolver::reinit(), 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::PetscDiffSolver::solve(), libMesh::PetscNonlinearSolver< T >::solve(), libMesh::System::system_type(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

2029 {
2030  return *_dof_map;
2031 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
A writable reference to this system's _dof_map.

Definition at line 2036 of file system.h.

References libMesh::System::_dof_map.

2037 {
2038  return *_dof_map;
2039 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
EquationSystems& libMesh::System::get_equation_systems ( )
inlineinherited
Returns
A reference to this system's parent EquationSystems object.

Definition at line 717 of file system.h.

References libMesh::System::_equation_systems, libMesh::System::activate(), libMesh::System::active(), libMesh::System::deactivate(), and libMesh::System::set_basic_system_only().

717 { return _equation_systems; }
EquationSystems & _equation_systems
Definition: system.h:1869
const std::set<unsigned int>& libMesh::DifferentiablePhysics::get_first_order_vars ( ) const
inlineinherited
Returns
The set of first order in time variable indices. May be empty.

Definition at line 514 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

Referenced by have_first_order_scalar_vars().

515  { return _first_order_vars; }
std::set< unsigned int > _first_order_vars
Definition: diff_physics.h:556
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

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().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
std::string libMesh::System::get_info ( ) const
inherited
Returns
A string containing information about the system.

Definition at line 1682 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().

Referenced by libMesh::System::read_parallel_data().

1683 {
1684  std::ostringstream oss;
1685 
1686 
1687  const std::string & sys_name = this->name();
1688 
1689  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1690  << " Type \"" << this->system_type() << "\"\n"
1691  << " Variables=";
1692 
1693  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1694  {
1695  const VariableGroup & vg_description (this->variable_group(vg));
1696 
1697  if (vg_description.n_variables() > 1) oss << "{ ";
1698  for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
1699  oss << "\"" << vg_description.name(vn) << "\" ";
1700  if (vg_description.n_variables() > 1) oss << "} ";
1701  }
1702 
1703  oss << '\n';
1704 
1705  oss << " Finite Element Types=";
1706 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1707  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1708  oss << "\""
1709  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1710  << "\" ";
1711 #else
1712  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1713  {
1714  oss << "\""
1715  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1716  << "\", \""
1717  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1718  << "\" ";
1719  }
1720 
1721  oss << '\n' << " Infinite Element Mapping=";
1722  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1723  oss << "\""
1724  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1725  << "\" ";
1726 #endif
1727 
1728  oss << '\n';
1729 
1730  oss << " Approximation Orders=";
1731  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1732  {
1733 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1734  oss << "\""
1735  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1736  << "\" ";
1737 #else
1738  oss << "\""
1739  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1740  << "\", \""
1741  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1742  << "\" ";
1743 #endif
1744  }
1745 
1746  oss << '\n';
1747 
1748  oss << " n_dofs()=" << this->n_dofs() << '\n';
1749  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1750 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1751  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1752  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1753 #endif
1754 
1755  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1756  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1757  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1758 
1759  oss << this->get_dof_map().get_info();
1760 
1761  return oss.str();
1762 }
FEFamily family
Definition: fe_type.h:203
dof_id_type n_constrained_dofs() const
Definition: system.C:150
const FEType & type() const
Definition: variable.h:119
std::string get_info() const
Definition: dof_map.C:2764
OrderWrapper radial_order
Definition: fe_type.h:236
OrderWrapper order
Definition: fe_type.h:197
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2122
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1636
const std::string & name() const
Definition: system.h:1996
unsigned int n_variable_groups() const
Definition: system.h:2092
const DofMap & get_dof_map() const
Definition: system.h:2028
InfMapType inf_map
Definition: fe_type.h:257
virtual unsigned int n_matrices() const
Definition: system.h:2218
FEFamily radial_family
Definition: fe_type.h:249
dof_id_type n_local_dofs() const
Definition: system.C:180
virtual std::string system_type() const
Definition: system.h:471
dof_id_type n_local_constrained_dofs() const
Definition: system.C:165
unsigned int number() const
Definition: system.h:2004
dof_id_type n_dofs() const
Definition: system.C:143
unsigned int n_vectors() const
Definition: system.h:2212
std::pair< unsigned int, Real > libMesh::DifferentiableSystem::get_linear_solve_parameters ( ) const
virtual
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 184 of file diff_system.C.

References libMesh::libmesh_assert(), and time_solver.

185 {
187  libmesh_assert_equal_to (&(time_solver->system()), this);
188  return std::make_pair(this->time_solver->diff_solver()->max_linear_iterations,
189  this->time_solver->diff_solver()->relative_residual_tolerance);
190 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
libmesh_assert(j)
LinearSolver< Number > * libMesh::DifferentiableSystem::get_linear_solver ( ) const
virtual
Returns
A pointer to a linear solver appropriate for use in adjoint and/or sensitivity solves

Reimplemented from libMesh::ImplicitSystem.

Definition at line 175 of file diff_system.C.

References libMesh::libmesh_assert(), and time_solver.

176 {
178  libmesh_assert_equal_to (&(time_solver->system()), this);
179  return this->time_solver->linear_solver().get();
180 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
libmesh_assert(j)
const SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix ( const std::string &  mat_name) const
inherited
Returns
A const reference to this system's additional matrix named 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 255 of file implicit_system.C.

References libMesh::ImplicitSystem::_matrices.

Referenced by libMesh::NewmarkSystem::compute_matrix(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().

256 {
257  // Make sure the matrix exists
258  const_matrices_iterator pos = _matrices.find (mat_name);
259 
260  if (pos == _matrices.end())
261  libmesh_error_msg("ERROR: matrix " << mat_name << " does not exist in this system!");
262 
263  return *(pos->second);
264 }
std::map< std::string, SparseMatrix< Number > * > _matrices
std::map< std::string, SparseMatrix< Number > * >::const_iterator const_matrices_iterator
SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix ( const std::string &  mat_name)
inherited
Returns
A writable reference to this system's additional matrix named 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 268 of file implicit_system.C.

References libMesh::ImplicitSystem::_matrices.

269 {
270  // Make sure the matrix exists
271  matrices_iterator pos = _matrices.find (mat_name);
272 
273  if (pos == _matrices.end())
274  libmesh_error_msg("ERROR: matrix " << mat_name << " does not exist in this system!");
275 
276  return *(pos->second);
277 }
std::map< std::string, SparseMatrix< Number > * > _matrices
std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator
const MeshBase & libMesh::System::get_mesh ( ) const
inlineinherited
Returns
A constant reference to this systems's _mesh.

Definition at line 2012 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::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), 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::BoundaryProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::System::system_type(), and libMesh::System::zero_variable().

2013 {
2014  return _mesh;
2015 }
MeshBase & _mesh
Definition: system.h:1875
MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
A reference to this systems's _mesh.

Definition at line 2020 of file system.h.

References libMesh::System::_mesh.

2021 {
2022  return _mesh;
2023 }
MeshBase & _mesh
Definition: system.h:1875
const System * libMesh::DifferentiablePhysics::get_mesh_system ( ) const
inlineinherited
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 621 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_sys.

Referenced by libMesh::FEMSystem::build_context(), and libMesh::DifferentiablePhysics::init_context().

622 {
623  return _mesh_sys;
624 }
System * libMesh::DifferentiablePhysics::get_mesh_system ( )
inlineinherited
Returns
A reference to the system with variables corresponding to mesh nodal coordinates, or NULL if the mesh is fixed.

Definition at line 627 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_sys.

628 {
629  return _mesh_sys;
630 }
unsigned int libMesh::DifferentiablePhysics::get_mesh_x_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh x coordinate. Useful for ALE calculations.

Definition at line 633 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_x_var.

Referenced by libMesh::FEMSystem::build_context(), and libMesh::DifferentiablePhysics::init_context().

634 {
635  return _mesh_x_var;
636 }
unsigned int libMesh::DifferentiablePhysics::get_mesh_y_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh y coordinate. Useful for ALE calculations.

Definition at line 639 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_y_var.

Referenced by libMesh::FEMSystem::build_context(), and libMesh::DifferentiablePhysics::init_context().

640 {
641  return _mesh_y_var;
642 }
unsigned int libMesh::DifferentiablePhysics::get_mesh_z_var ( ) const
inlineinherited
Returns
The variable number corresponding to the mesh z coordinate. Useful for ALE calculations.

Definition at line 645 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_z_var.

Referenced by libMesh::FEMSystem::build_context(), and libMesh::DifferentiablePhysics::init_context().

646 {
647  return _mesh_z_var;
648 }
DifferentiablePhysics* libMesh::DifferentiableSystem::get_physics ( )
inline
Returns
A reference to a DifferentiablePhysics object.
Note
If no external Physics object is attached, the default is this.

Definition at line 178 of file diff_system.h.

References _diff_physics.

179  { return this->_diff_physics; }
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358
const DifferentiableQoI* libMesh::DifferentiableSystem::get_qoi ( ) const
inline
Returns
A const reference to a DifferentiableQoI object.
Note
If no external QoI object is attached, the default is this.

Definition at line 198 of file diff_system.h.

References diff_qoi.

199  { return this->diff_qoi; }
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
DifferentiableQoI* libMesh::DifferentiableSystem::get_qoi ( )
inline
Returns
A reference to a DifferentiableQoI object.
Note
If no external QoI object is attached, the default is this.

Definition at line 206 of file diff_system.h.

References diff_qoi.

207  { return this->diff_qoi; }
DifferentiableQoI * diff_qoi
Definition: diff_system.h:365
unsigned int libMesh::DifferentiableSystem::get_second_order_dot_var ( unsigned int  var) const

For a given second order (in time) variable var, this method will return the index to the corresponding "dot" variable. For FirstOrderUnsteadySolver classes, the "dot" variable would automatically be added and the returned index will correspond to that variable. For SecondOrderUnsteadySolver classes, this method will return var as there this is no "dot" variable per se, but having this function allows one to use the interface to treat both FirstOrderUnsteadySolver and SecondOrderUnsteadySolver simultaneously.

Definition at line 313 of file diff_system.C.

References libMesh::DifferentiablePhysics::_second_order_dot_vars, libMesh::UnsteadySolver::time_order(), and time_solver.

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), and side_postprocess().

314 {
315  // For SteadySolver or SecondOrderUnsteadySolvers, we just give back var
316  unsigned int dot_var = var;
317 
318  if (!time_solver->is_steady())
319  {
320  const UnsteadySolver & unsteady_solver =
321  cast_ref<const UnsteadySolver &>(*(time_solver.get()));
322 
323  if (unsteady_solver.time_order() == 1)
324  dot_var = this->_second_order_dot_vars.find(var)->second;
325  }
326 
327  return dot_var;
328 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
std::map< unsigned int, unsigned int > _second_order_dot_vars
Definition: diff_physics.h:568
const std::set<unsigned int>& libMesh::DifferentiablePhysics::get_second_order_vars ( ) const
inlineinherited
Returns
The set of second order in time variable indices. May be empty.

Definition at line 527 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_second_order_vars.

Referenced by add_second_order_dot_vars(), libMesh::DiffContext::DiffContext(), libMesh::Euler2Solver::element_residual(), have_second_order_scalar_vars(), and libMesh::FEMContext::pre_fe_reinit().

528  { return _second_order_vars; }
std::set< unsigned int > _second_order_vars
Definition: diff_physics.h:561
NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. By default these vectors are built by the library, using finite differences, when assemble_residual_derivatives() is called.

When assembled, this vector should hold -(partial R / partial p_i)

Definition at line 1075 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::System::project_solution_on_reinit(), and libMesh::ImplicitSystem::sensitivity_solve().

1076 {
1077  std::ostringstream sensitivity_rhs_name;
1078  sensitivity_rhs_name << "sensitivity_rhs" << i;
1079 
1080  return this->get_vector(sensitivity_rhs_name.str());
1081 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.

Definition at line 1085 of file system.C.

References libMesh::System::get_vector().

1086 {
1087  std::ostringstream sensitivity_rhs_name;
1088  sensitivity_rhs_name << "sensitivity_rhs" << i;
1089 
1090  return this->get_vector(sensitivity_rhs_name.str());
1091 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 930 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::System::project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::sensitivity_solve().

931 {
932  std::ostringstream sensitivity_name;
933  sensitivity_name << "sensitivity_solution" << i;
934 
935  return this->get_vector(sensitivity_name.str());
936 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 940 of file system.C.

References libMesh::System::get_vector().

941 {
942  std::ostringstream sensitivity_name;
943  sensitivity_name << "sensitivity_solution" << i;
944 
945  return this->get_vector(sensitivity_name.str());
946 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
TimeSolver & libMesh::DifferentiableSystem::get_time_solver ( )
inline
Returns
A pointer to the time solver attached to the calling system

Definition at line 402 of file diff_system.h.

References libMesh::libmesh_assert(), and time_solver.

Referenced by adjoint_solve(), libMesh::FEMSystem::build_context(), libMesh::DiffContext::DiffContext(), libMesh::FEMSystem::postprocess(), libMesh::FEMContext::pre_fe_reinit(), set_time_solver(), and solve().

403 {
405  libmesh_assert_equal_to (&(time_solver->system()), this);
406  return *time_solver;
407 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
libmesh_assert(j)
const TimeSolver & libMesh::DifferentiableSystem::get_time_solver ( ) const
inline

Non-const version of the above

Definition at line 410 of file diff_system.h.

References libMesh::libmesh_assert(), and time_solver.

411 {
413  libmesh_assert_equal_to (&(time_solver->system()), this);
414  return *time_solver;
415 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
libmesh_assert(j)
const NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name) const
inherited
Returns
A const reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 788 of file system.C.

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::System::compare(), libMesh::NewmarkSolver::compute_initial_accel(), 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::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::System::project_solution_on_reinit(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::TaoOptimizationSolver< T >::solve(), libMesh::NloptOptimizationSolver< T >::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

789 {
790  // Make sure the vector exists
791  const_vectors_iterator pos = _vectors.find(vec_name);
792 
793  if (pos == _vectors.end())
794  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
795 
796  return *(pos->second);
797 }
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name)
inherited
Returns
A writable reference to this system's additional vector named 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.

802 {
803  // Make sure the vector exists
804  vectors_iterator pos = _vectors.find(vec_name);
805 
806  if (pos == _vectors.end())
807  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
808 
809  return *(pos->second);
810 }
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
const NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num) const
inherited
Returns
A const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 814 of file system.C.

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

815 {
818  unsigned int num = 0;
819  while ((num<vec_num) && (v!=v_end))
820  {
821  num++;
822  ++v;
823  }
824  libmesh_assert (v != v_end);
825  return *(v->second);
826 }
vectors_iterator vectors_end()
Definition: system.h:2236
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2224
libmesh_assert(j)
NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
A writable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 830 of file system.C.

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

831 {
833  vectors_iterator v_end = vectors_end();
834  unsigned int num = 0;
835  while ((num<vec_num) && (v!=v_end))
836  {
837  num++;
838  ++v;
839  }
840  libmesh_assert (v != v_end);
841  return *(v->second);
842 }
vectors_iterator vectors_end()
Definition: system.h:2236
vectors_iterator vectors_begin()
Definition: system.h:2224
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1015 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::System::project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1016 {
1017  std::ostringstream adjoint_name;
1018  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1019 
1020  return this->get_vector(adjoint_name.str());
1021 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1025 of file system.C.

References libMesh::System::get_vector().

1026 {
1027  std::ostringstream adjoint_name;
1028  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1029 
1030  return this->get_vector(adjoint_name.str());
1031 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 957 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::System::project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

958 {
959  return this->get_vector("weighted_sensitivity_solution");
960 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( ) const
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 964 of file system.C.

References libMesh::System::get_vector().

965 {
966  return this->get_vector("weighted_sensitivity_solution");
967 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
bool libMesh::System::has_variable ( const std::string &  var) const
inherited
Returns
true if a variable named var exists in this System

Definition at line 1250 of file system.C.

References libMesh::System::_variable_numbers.

Referenced by libMesh::GMVIO::copy_nodal_solution(), and libMesh::System::project_solution_on_reinit().

1251 {
1252  return _variable_numbers.count(var);
1253 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
bool libMesh::DifferentiableSystem::have_first_order_scalar_vars ( ) const

Check for any first order vars that are also belong to FEFamily::SCALAR

Definition at line 330 of file diff_system.C.

References libMesh::FEType::family, libMesh::DifferentiablePhysics::get_first_order_vars(), libMesh::DifferentiablePhysics::have_first_order_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by side_postprocess().

331 {
332  bool have_first_order_scalar_vars = false;
333 
334  if (this->have_first_order_vars())
335  {
336  for (std::set<unsigned int>::const_iterator var_it = this->get_first_order_vars().begin();
337  var_it != this->get_first_order_vars().end();
338  ++var_it)
339  {
340  if (this->variable(*var_it).type().family == SCALAR)
341  have_first_order_scalar_vars = true;
342  }
343  }
344 
346 }
FEFamily family
Definition: fe_type.h:203
const FEType & type() const
Definition: variable.h:119
const Variable & variable(unsigned int var) const
Definition: system.h:2112
bool have_first_order_scalar_vars() const
Definition: diff_system.C:330
const std::set< unsigned int > & get_first_order_vars() const
Definition: diff_physics.h:514
bool libMesh::DifferentiablePhysics::have_first_order_vars ( ) const
inlineinherited

Definition at line 508 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

Referenced by have_first_order_scalar_vars().

509  { return !_first_order_vars.empty(); }
std::set< unsigned int > _first_order_vars
Definition: diff_physics.h:556
bool libMesh::ImplicitSystem::have_matrix ( const std::string &  mat_name) const
inlineinherited
Returns
true if this System has a matrix associated with the given name, false otherwise.

Definition at line 394 of file implicit_system.h.

Referenced by libMesh::ImplicitSystem::add_matrix(), and libMesh::EigenTimeSolver::init().

395 {
396  return (_matrices.count(mat_name));
397 }
std::map< std::string, SparseMatrix< Number > * > _matrices
bool libMesh::DifferentiableSystem::have_second_order_scalar_vars ( ) const

Check for any second order vars that are also belong to FEFamily::SCALAR

Definition at line 348 of file diff_system.C.

References libMesh::FEType::family, libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::DifferentiablePhysics::have_second_order_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), and side_postprocess().

349 {
350  bool have_second_order_scalar_vars = false;
351 
352  if (this->have_second_order_vars())
353  {
354  for (std::set<unsigned int>::const_iterator var_it = this->get_second_order_vars().begin();
355  var_it != this->get_second_order_vars().end();
356  ++var_it)
357  {
358  if (this->variable(*var_it).type().family == SCALAR)
359  have_second_order_scalar_vars = true;
360  }
361  }
362 
364 }
FEFamily family
Definition: fe_type.h:203
const FEType & type() const
Definition: variable.h:119
const std::set< unsigned int > & get_second_order_vars() const
Definition: diff_physics.h:527
bool have_second_order_scalar_vars() const
Definition: diff_system.C:348
bool have_second_order_vars() const
Definition: diff_physics.h:521
const Variable & variable(unsigned int var) const
Definition: system.h:2112
bool libMesh::DifferentiablePhysics::have_second_order_vars ( ) const
inlineinherited
bool libMesh::System::have_vector ( const std::string &  vec_name) const
inlineinherited
Returns
true if this System has a vector associated with the given name, false otherwise.

Definition at line 2204 of file system.h.

References libMesh::System::_vectors.

Referenced by libMesh::System::add_vector(), libMesh::System::project_solution_on_reinit(), and libMesh::System::remove_vector().

2205 {
2206  return (_vectors.count(vec_name));
2207 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
bool& libMesh::System::hide_output ( )
inlineinherited
bool libMesh::System::identify_variable_groups ( ) const
inlineinherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2180 of file system.h.

References libMesh::System::_identify_variable_groups.

Referenced by libMesh::System::add_variable(), and libMesh::System::project_solution_on_reinit().

2181 {
2183 }
bool _identify_variable_groups
Definition: system.h:1956
void libMesh::System::identify_variable_groups ( const bool  ivg)
inlineinherited

Toggle automatic VariableGroup identification.

Definition at line 2188 of file system.h.

References libMesh::System::_identify_variable_groups.

2189 {
2191 }
bool _identify_variable_groups
Definition: system.h:1956
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 185 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 198 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 230 of file system.C.

References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_vars(), and libMesh::System::user_initialization().

Referenced by libMesh::System::system().

231 {
232  // Calling init() twice on the same system currently works evil
233  // magic, whether done directly or via EquationSystems::read()
234  libmesh_assert(!this->is_initialized());
235 
236  // First initialize any required data:
237  // either only the basic System data
238  if (_basic_system_only)
240  // or all the derived class' data too
241  else
242  this->init_data();
243 
244  // If no variables have been added to this system
245  // don't do anything
246  if (!this->n_vars())
247  return;
248 
249  // Then call the user-provided intialization function
250  this->user_initialization();
251 }
bool _basic_system_only
Definition: system.h:1944
virtual void init_data()
Definition: system.C:255
virtual void user_initialization()
Definition: system.C:1942
libmesh_assert(j)
bool is_initialized()
Definition: system.h:2068
unsigned int n_vars() const
Definition: system.h:2084
virtual void libMesh::DifferentiableQoI::init_context ( DiffContext )
inlinevirtualinherited

Prepares the result of a build_context() call for use.

Most FEMSystem-based problems will need to reimplement this in order to call FE::get_*() as their particular QoI requires.

Reimplemented in libMesh::FEMSystem.

Definition at line 151 of file diff_qoi.h.

References libMesh::DifferentiableQoI::clone(), libMesh::DifferentiableQoI::parallel_op(), and libMesh::DifferentiableQoI::thread_join().

151 {}
void libMesh::DifferentiableSystem::init_data ( )
protectedvirtual

Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

If the TimeSolver is a FirstOrderUnsteadySolver, we check for second order in time variables and then add them to the System as dot_<varname>. Then, during assembly, the TimeSolver will populate the elem_accel vectors with the dot_<varname> values so the user's element assembly function can still treat the variable as a second order in time variable.

Reimplemented from libMesh::ImplicitSystem.

Reimplemented in libMesh::ContinuationSystem, and libMesh::FEMSystem.

Definition at line 108 of file diff_system.C.

References _diff_physics, add_second_order_dot_vars(), libMesh::ImplicitSystem::init_data(), libMesh::DifferentiablePhysics::init_physics(), libMesh::libmesh_assert(), libMesh::UnsteadySolver::time_order(), and time_solver.

Referenced by libMesh::FEMSystem::init_data().

109 {
110  // If it isn't a separate initialized-upon-attachment object, do any
111  // initialization our physics needs.
112  if (this->_diff_physics == this)
113  this->init_physics(*this);
114 
115  // Do any initialization our solvers need
117  libmesh_assert_equal_to (&(time_solver->system()), this);
118 
119  // Now check for second order variables and add their velocities to the System.
120  if (!time_solver->is_steady())
121  {
122  const UnsteadySolver & unsteady_solver =
123  cast_ref<const UnsteadySolver &>(*(time_solver.get()));
124 
125  if (unsteady_solver.time_order() == 1)
127  }
128 
129  time_solver->init();
130 
131  // Next initialize ImplicitSystem data
133 
134  time_solver->init_data();
135 }
UniquePtr< TimeSolver > time_solver
Definition: diff_system.h:221
libmesh_assert(j)
DifferentiablePhysics * _diff_physics
Definition: diff_system.h:358
virtual void init_data() libmesh_override
virtual void init_physics(const System &sys)
void libMesh::ImplicitSystem::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Definition at line 106 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().

107 {
109 
110  // Check for quick return in case the system matrix
111  // (and by extension all the matrices) has already
112  // been initialized
113  if (matrix->initialized())
114  return;
115 
116  // Get a reference to the DofMap
117  DofMap & dof_map = this->get_dof_map();
118 
119  // no chance to add other matrices
120  _can_add_matrices = false;
121 
122  // Tell the matrices about the dof map, and vice versa
123  for (matrices_iterator pos = _matrices.begin();
124  pos != _matrices.end(); ++pos)
125  {
126  SparseMatrix<Number> & m = *(pos->second);
127  libmesh_assert (!m.initialized());
128 
129  // We want to allow repeated init() on systems, but we don't
130  // want to attach the same matrix to the DofMap twice
131  if (!dof_map.is_attached(m))
132  dof_map.attach_matrix (m);
133  }
134 
135  // Compute the sparsity pattern for the current
136  // mesh and DOF distribution. This also updates
137  // additional matrices, \p DofMap now knows them
138  dof_map.compute_sparsity (this->get_mesh());
139 
140  // Initialize matrices
141  for (matrices_iterator pos = _matrices.begin();
142  pos != _matrices.end(); ++pos)
143  pos->second->init ();
144 
145  // Set the additional matrices to 0.
146  for (matrices_iterator pos = _matrices.begin();
147  pos != _matrices.end(); ++pos)
148  pos->second->zero ();
149 }
std::map< std::string, SparseMatrix< Number > * > _matrices
libmesh_assert(j)
virtual bool initialized() const
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
SparseMatrix< Number > * matrix
std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator
virtual void libMesh::DifferentiablePhysics::init_physics ( const System sys)
virtualinherited

Initialize any data structures associated with the physics.

Referenced by attach_physics(), libMesh::DifferentiablePhysics::DifferentiablePhysics(), and init_data().

virtual void libMesh::DifferentiableQoI::init_qoi ( std::vector< Number > &  )
inlinevirtualinherited

Initialize system qoi. By default, does nothing in order to maintain backward compatibility for FEMSystem applications that control qoi.

Definition at line 67 of file diff_qoi.h.

Referenced by attach_qoi().

67 {}
bool libMesh::DifferentiablePhysics::is_first_order_var ( unsigned int  var) const
inlineinherited

Definition at line 517 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

518  { return _first_order_vars.find(var) != _first_order_vars.end(); }
std::set< unsigned int > _first_order_vars
Definition: diff_physics.h:556
bool libMesh::System::is_initialized ( )
inlineinherited
Returns
true iff this system has been initialized.

Definition at line 2068 of file system.h.

References libMesh::System::_is_initialized.

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::init(), and libMesh::System::system().

2069 {
2070  return _is_initialized;
2071 }
bool _is_initialized
Definition: system.h:1950
bool libMesh::DifferentiablePhysics::is_second_order_var ( unsigned int  var) const
inlineinherited
bool libMesh::DifferentiablePhysics::is_time_evolving ( unsigned int  var) const
inlineinherited
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 274 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_time_evolving, and libMesh::libmesh_assert().

Referenced by libMesh::FEMSystem::init_context().

275  {
276  libmesh_assert_less(var,_time_evolving.size());
277  libmesh_assert( _time_evolving[var] == 0 ||
278  _time_evolving[var] == 1 ||
279  _time_evolving[var] == 2 );
280  return _time_evolving[var];
281  }
libmesh_assert(j)
std::vector< unsigned int > _time_evolving
Definition: diff_physics.h:551
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 1291 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().

1293 {
1294  // Make sure the set is clear
1295  var_indices.clear();
1296 
1297  std::vector<dof_id_type> dof_indices;
1298 
1299  // Begin the loop over the elements
1300  MeshBase::const_element_iterator el =
1302  const MeshBase::const_element_iterator end_el =
1304 
1305  const dof_id_type
1306  first_local = this->get_dof_map().first_dof(),
1307  end_local = this->get_dof_map().end_dof();
1308 
1309  for ( ; el != end_el; ++el)
1310  {
1311  const Elem * elem = *el;
1312  this->get_dof_map().dof_indices (elem, dof_indices, var);
1313 
1314  for (std::size_t i=0; i<dof_indices.size(); i++)
1315  {
1316  dof_id_type dof = dof_indices[i];
1317 
1318  //If the dof is owned by the local processor
1319  if (first_local <= dof && dof < end_local)
1320  var_indices.insert(dof_indices[i]);
1321  }
1322  }
1323 }
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:535
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:575
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_local_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2005
virtual bool libMesh::DifferentiablePhysics::mass_residual ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

Subtracts a mass vector contribution on elem from elem_residual. For first-order-in-time problems, this is the $ M(u,\dot{u})\dot{u} $ term. For second-order-in-time problems, this is the $ M(u,\ddot{u})\ddot{u} $ term. This method is only called for UnsteadySolver-based TimeSolvers.

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 first-order-in-time 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 or second-order-in-time problems will need to reimplement this themselves.

Reimplemented in libMesh::FEMPhysics.

Definition at line 315 of file diff_physics.h.

Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::NewmarkSolver::element_residual(), and libMesh::EigenTimeSolver::element_residual().

316  {
317  return request_jacobian;
318  }
dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited
Returns
The number of active degrees of freedom for this System.

Definition at line 2196 of file system.h.

References libMesh::System::n_constrained_dofs(), and libMesh::System::n_dofs().

Referenced by libMesh::System::project_solution_on_reinit().

2197 {
2198  return this->n_dofs() - this->n_constrained_dofs();
2199 }
dof_id_type n_constrained_dofs() const
Definition: system.C:150
dof_id_type n_dofs() const
Definition: system.C:143
unsigned int libMesh::System::n_components ( ) const
inlineinherited
Returns
The total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables.

Definition at line 2100 of file system.h.

References libMesh::System::_variables, libMesh::Variable::first_scalar_number(), and libMesh::Variable::n_components().

Referenced by libMesh::System::add_variables(), libMesh::WrappedFunction< Output >::operator()(), and libMesh::System::project_solution_on_reinit().

2101 {
2102  if (_variables.empty())
2103  return 0;
2104 
2105  const Variable & last = _variables.back();
2106  return last.first_scalar_number() + last.n_components();
2107 }
std::vector< Variable > _variables
Definition: system.h:1890
dof_id_type libMesh::System::n_constrained_dofs ( ) const
inherited
Returns
The total number of constrained degrees of freedom in the system.

Definition at line 150 of file system.C.

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info(), libMesh::System::n_active_dofs(), and libMesh::System::project_solution_on_reinit().

151 {
152 #ifdef LIBMESH_ENABLE_CONSTRAINTS
153 
154  return _dof_map->n_constrained_dofs();
155 
156 #else
157 
158  return 0;
159 
160 #endif
161 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
inherited
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 165 of file system.C.

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info(), and libMesh::System::project_solution_on_reinit().

166 {
167 #ifdef LIBMESH_ENABLE_CONSTRAINTS
168 
169  return _dof_map->n_local_constrained_dofs();
170 
171 #else
172 
173  return 0;
174 
175 #endif
176 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
unsigned int libMesh::ImplicitSystem::n_matrices ( ) const
inlinevirtualinherited
Returns
The number of matrices handled by this system

Reimplemented from libMesh::System.

Definition at line 401 of file implicit_system.h.

References libMesh::ImplicitSystem::_matrices.

402 {
403  return cast_int<unsigned int>(_matrices.size());
404 }
std::map< std::string, SparseMatrix< Number > * > _matrices
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), 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::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:722
const Parallel::Communicator & _communicator
unsigned int libMesh::System::n_variable_groups ( ) const
inlineinherited
Returns
The number of VariableGroup variable groups in the system

Definition at line 2092 of file system.h.

References libMesh::System::_variable_groups.

Referenced by libMesh::System::add_variable(), libMesh::FEMSystem::assembly(), libMesh::System::get_info(), libMesh::System::init_data(), and libMesh::System::project_solution_on_reinit().

2093 {
2094  return cast_int<unsigned int>(_variable_groups.size());
2095 }
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
The number of variables in the system

Definition at line 2084 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_parallel_solution_vector(), libMesh::System::calculate_norm(), libMesh::WrappedFunction< Output >::component(), 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::OldSolutionValue< Output, point_output >::init_context(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WrappedFunction< Output >::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_solution_on_reinit(), libMesh::System::re_update(), libMesh::System::reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), and libMesh::System::zero_variable().

2085 {
2086  return cast_int<unsigned int>(_variables.size());
2087 }
std::vector< Variable > _variables
Definition: system.h:1890
unsigned int libMesh::System::n_vectors ( ) const
inlineinherited
Returns
The number of vectors (in addition to the solution) handled by this system This is the size of the _vectors map

Definition at line 2212 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::project_solution_on_reinit().

2213 {
2214  return cast_int<unsigned int>(_vectors.size());
2215 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
virtual bool libMesh::DifferentiablePhysics::nonlocal_constraint ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 226 of file diff_physics.h.

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::SteadySolver::nonlocal_residual(), libMesh::EigenTimeSolver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

227  {
228  return request_jacobian;
229  }
virtual bool libMesh::DifferentiablePhysics::nonlocal_damping_residual ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

Subtracts any nonlocal damping vector contributions (e.g. any first 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.

Definition at line 403 of file diff_physics.h.

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

404  {
405  return request_jacobian;
406  }
virtual bool libMesh::DifferentiablePhysics::nonlocal_mass_residual ( bool  request_jacobian,
DiffContext c 
)
virtualinherited

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(), libMesh::EigenTimeSolver::nonlocal_residual(), libMesh::NewmarkSolver::nonlocal_residual(), and libMesh::DifferentiablePhysics::side_mass_residual().

virtual bool libMesh::DifferentiablePhysics::nonlocal_time_derivative ( bool  request_jacobian,
DiffContext  
)
inlinevirtualinherited

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 208 of file diff_physics.h.

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::SteadySolver::nonlocal_residual(), libMesh::EigenTimeSolver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

209  {
210  return request_jacobian;
211  }
virtual void libMesh::DifferentiableQoI::parallel_op ( const Parallel::Communicator communicator,
std::vector< Number > &  sys_qoi,
std::vector< Number > &  local_qoi,
const QoISet qoi_indices 
)
virtualinherited

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(), and libMesh::DifferentiableQoI::init_context().

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 2129 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::MeshBase::is_serial(), 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::verify().

Referenced by libMesh::System::point_gradient().

2130 {
2131  // This function must be called on every processor; there's no
2132  // telling where in the partition p falls.
2133  parallel_object_only();
2134 
2135  // And every processor had better agree about which point we're
2136  // looking for
2137 #ifndef NDEBUG
2138  libmesh_assert(this->comm().verify(p(0)));
2139 #if LIBMESH_DIM > 1
2140  libmesh_assert(this->comm().verify(p(1)));
2141 #endif
2142 #if LIBMESH_DIM > 2
2143  libmesh_assert(this->comm().verify(p(2)));
2144 #endif
2145 #endif // NDEBUG
2146 
2147  // Get a reference to the mesh object associated with the system object that calls this function
2148  const MeshBase & mesh = this->get_mesh();
2149 
2150  // Use an existing PointLocator or create a new one
2151  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2152  PointLocatorBase & locator = *locator_ptr;
2153 
2154  if (!insist_on_success || !mesh.is_serial())
2155  locator.enable_out_of_mesh_mode();
2156 
2157  // Get a pointer to the element that contains P
2158  const Elem * e = locator(p);
2159 
2160  Gradient grad_u;
2161 
2162  if (e && this->get_dof_map().is_evaluable(*e, var))
2163  grad_u = point_gradient(var, p, *e);
2164 
2165  // If I have an element containing p, then let's let everyone know
2166  processor_id_type lowest_owner =
2167  (e && (e->processor_id() == this->processor_id())) ?
2168  this->processor_id() : this->n_processors();
2169  this->comm().min(lowest_owner);
2170 
2171  // Everybody should get their value from a processor that was able
2172  // to compute it.
2173  // If nobody admits owning the point, we may have a problem.
2174  if (lowest_owner != this->n_processors())
2175  this->comm().broadcast(grad_u, lowest_owner);
2176  else
2177  libmesh_assert(!insist_on_success);
2178 
2179  return grad_u;
2180 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
NumberVectorValue Gradient
void broadcast(T &data, const unsigned int root_id=0) const
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2129
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
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 2183 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(), and libMesh::libmesh_assert().

2184 {
2185  // Ensuring that the given point is really in the element is an
2186  // expensive assert, but as long as debugging is turned on we might
2187  // as well try to catch a particularly nasty potential error
2188  libmesh_assert (e.contains_point(p));
2189 
2190  // Get the dof map to get the proper indices for our computation
2191  const DofMap & dof_map = this->get_dof_map();
2192 
2193  // Make sure we can evaluate on this element.
2194  libmesh_assert (dof_map.is_evaluable(e, var));
2195 
2196  // Need dof_indices for phi[i][j]
2197  std::vector<dof_id_type> dof_indices;
2198 
2199  // Fill in the dof_indices for our element
2200  dof_map.dof_indices (&e, dof_indices, var);
2201 
2202  // Get the no of dofs assciated with this point
2203  const unsigned int num_dofs = cast_int<unsigned int>
2204  (dof_indices.size());
2205 
2206  FEType fe_type = dof_map.variable_type(var);
2207 
2208  // Build a FE again so we can calculate u(p)
2209  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2210 
2211  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2212  // Build a vector of point co-ordinates to send to reinit
2213  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2214 
2215  // Get the values of the shape function derivatives
2216  const std::vector<std::vector<RealGradient> > & dphi = fe->get_dphi();
2217 
2218  // Reinitialize the element and compute the shape function values at coor
2219  fe->reinit (&e, &coor);
2220 
2221  // Get ready to accumulate a gradient
2222  Gradient grad_u;
2223 
2224  for (unsigned int l=0; l<num_dofs; l++)
2225  {
2226  grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
2227  }
2228 
2229  return grad_u;
2230 }
void add_scaled(const TypeVector< T2 > &, const T)
Definition: type_vector.h:620
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
NumberVectorValue Gradient
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:187
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) const
inherited

Calls the version of point_gradient() which takes a reference. This function exists only to prevent people from calling the version of point_gradient() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2234 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::point_gradient().

2235 {
2236  libmesh_assert(e);
2237  return this->point_gradient(var, p, *e);
2238 }
libmesh_assert(j)
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2129
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 2244 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::MeshBase::is_serial(), 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::verify().

Referenced by libMesh::System::point_hessian().

2245 {
2246  // This function must be called on every processor; there's no
2247  // telling where in the partition p falls.
2248  parallel_object_only();
2249 
2250  // And every processor had better agree about which point we're
2251  // looking for
2252 #ifndef NDEBUG
2253  libmesh_assert(this->comm().verify(p(0)));
2254 #if LIBMESH_DIM > 1
2255  libmesh_assert(this->comm().verify(p(1)));
2256 #endif
2257 #if LIBMESH_DIM > 2
2258  libmesh_assert(this->comm().verify(p(2)));
2259 #endif
2260 #endif // NDEBUG
2261 
2262  // Get a reference to the mesh object associated with the system object that calls this function
2263  const MeshBase & mesh = this->get_mesh();
2264 
2265  // Use an existing PointLocator or create a new one
2266  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2267  PointLocatorBase & locator = *locator_ptr;
2268 
2269  if (!insist_on_success || !mesh.is_serial())
2270  locator.enable_out_of_mesh_mode();
2271 
2272  // Get a pointer to the element that contains P
2273  const Elem * e = locator(p);
2274 
2275  Tensor hess_u;
2276 
2277  if (e && this->get_dof_map().is_evaluable(*e, var))
2278  hess_u = point_hessian(var, p, *e);
2279 
2280  // If I have an element containing p, then let's let everyone know
2281  processor_id_type lowest_owner =
2282  (e && (e->processor_id() == this->processor_id())) ?
2283  this->processor_id() : this->n_processors();
2284  this->comm().min(lowest_owner);
2285 
2286  // Everybody should get their value from a processor that was able
2287  // to compute it.
2288  // If nobody admits owning the point, we may have a problem.
2289  if (lowest_owner != this->n_processors())
2290  this->comm().broadcast(hess_u, lowest_owner);
2291  else
2292  libmesh_assert(!insist_on_success);
2293 
2294  return hess_u;
2295 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2244
void broadcast(T &data, const unsigned int root_id=0) const
bool verify(const T &r, const Communicator &comm=Communicator_World)
NumberTensorValue Tensor
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
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 2297 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(), and libMesh::libmesh_assert().

2298 {
2299  // Ensuring that the given point is really in the element is an
2300  // expensive assert, but as long as debugging is turned on we might
2301  // as well try to catch a particularly nasty potential error
2302  libmesh_assert (e.contains_point(p));
2303 
2304  // Get the dof map to get the proper indices for our computation
2305  const DofMap & dof_map = this->get_dof_map();
2306 
2307  // Make sure we can evaluate on this element.
2308  libmesh_assert (dof_map.is_evaluable(e, var));
2309 
2310  // Need dof_indices for phi[i][j]
2311  std::vector<dof_id_type> dof_indices;
2312 
2313  // Fill in the dof_indices for our element
2314  dof_map.dof_indices (&e, dof_indices, var);
2315 
2316  // Get the no of dofs assciated with this point
2317  const unsigned int num_dofs = cast_int<unsigned int>
2318  (dof_indices.size());
2319 
2320  FEType fe_type = dof_map.variable_type(var);
2321 
2322  // Build a FE again so we can calculate u(p)
2323  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2324 
2325  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2326  // Build a vector of point co-ordinates to send to reinit
2327  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2328 
2329  // Get the values of the shape function derivatives
2330  const std::vector<std::vector<RealTensor> > & d2phi = fe->get_d2phi();
2331 
2332  // Reinitialize the element and compute the shape function values at coor
2333  fe->reinit (&e, &coor);
2334