libMesh::System Class Reference
#include <system.h>

Classes | |
| class | Assembly |
| class | Constraint |
| class | Initialization |
| class | QOI |
| class | QOIDerivative |
Public Types | |
| typedef System | sys_type |
| 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 | |
| System (EquationSystems &es, const std::string &name, const unsigned int number) | |
| virtual | ~System () |
| sys_type & | system () |
| virtual void | clear () |
| void | init () |
| virtual void | reinit () |
| virtual void | update () |
| virtual void | assemble () |
| virtual void | assemble_qoi (const QoISet &qoi_indices=QoISet()) |
| virtual void | assemble_qoi_derivative (const QoISet &qoi_indices=QoISet()) |
| virtual void | assemble_residual_derivatives (const ParameterVector ¶meters) |
| virtual void | restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) |
| virtual void | solve () |
| virtual std::pair< unsigned int, Real > | sensitivity_solve (const ParameterVector ¶meters) |
| virtual std::pair< unsigned int, Real > | weighted_sensitivity_solve (const ParameterVector ¶meters, const ParameterVector &weights) |
| virtual std::pair< unsigned int, Real > | adjoint_solve (const QoISet &qoi_indices=QoISet()) |
| virtual std::pair< unsigned int, Real > | weighted_sensitivity_adjoint_solve (const ParameterVector ¶meters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) |
| bool | is_adjoint_already_solved () const |
| void | set_adjoint_already_solved (bool setting) |
| virtual void | qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual void | adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual void | forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual void | qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &hessian) |
| virtual void | qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector ¶meters, const ParameterVector &vector, SensitivityData &product) |
| virtual bool | compare (const System &other_system, const Real threshold, const bool verbose) const |
| const std::string & | name () const |
| virtual std::string | system_type () const |
| void | project_solution (FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const |
| void | project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const |
| void | project_solution (Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters) const |
| void | project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const |
| void | project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const |
| void | project_vector (Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters, NumericVector< Number > &new_vector) const |
| void | boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) |
| void | boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters) |
| void | boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const |
| void | boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters, NumericVector< Number > &new_vector) 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 unsigned int dest_proc) const |
| const MeshBase & | get_mesh () const |
| MeshBase & | get_mesh () |
| const DofMap & | get_dof_map () const |
| DofMap & | get_dof_map () |
| const EquationSystems & | get_equation_systems () const |
| EquationSystems & | get_equation_systems () |
| bool | active () const |
| void | activate () |
| void | deactivate () |
| void | set_basic_system_only () |
| vectors_iterator | vectors_begin () |
| const_vectors_iterator | vectors_begin () const |
| vectors_iterator | vectors_end () |
| const_vectors_iterator | vectors_end () const |
| NumericVector< Number > & | add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL) |
| void | remove_vector (const std::string &vec_name) |
| bool & | project_solution_on_reinit (void) |
| bool | have_vector (const std::string &vec_name) const |
| const NumericVector< Number > * | request_vector (const std::string &vec_name) const |
| NumericVector< Number > * | request_vector (const std::string &vec_name) |
| const NumericVector< Number > * | request_vector (const unsigned int vec_num) const |
| NumericVector< Number > * | request_vector (const unsigned int vec_num) |
| const NumericVector< Number > & | get_vector (const std::string &vec_name) const |
| NumericVector< Number > & | get_vector (const std::string &vec_name) |
| const NumericVector< Number > & | get_vector (const unsigned int vec_num) const |
| NumericVector< Number > & | get_vector (const unsigned int vec_num) |
| const std::string & | vector_name (const unsigned int vec_num) const |
| const std::string & | vector_name (const NumericVector< Number > &vec_reference) const |
| void | set_vector_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 |
| virtual unsigned int | n_matrices () const |
| unsigned int | n_vars () const |
| unsigned int | n_variable_groups () const |
| unsigned int | n_components () const |
| dof_id_type | n_dofs () const |
| dof_id_type | n_active_dofs () const |
| dof_id_type | n_constrained_dofs () const |
| dof_id_type | n_local_constrained_dofs () const |
| dof_id_type | n_local_dofs () const |
| unsigned int | add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| const Variable & | variable (unsigned int var) const |
| const VariableGroup & | variable_group (unsigned int vg) const |
| bool | has_variable (const std::string &var) const |
| const std::string & | variable_name (const unsigned int i) const |
| unsigned short int | variable_number (const std::string &var) const |
| void | get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const |
| unsigned int | variable_scalar_number (const std::string &var, unsigned int component) const |
| unsigned int | variable_scalar_number (unsigned int var_num, unsigned int component) const |
| const FEType & | variable_type (const unsigned int i) const |
| const FEType & | variable_type (const std::string &var) const |
| bool | identify_variable_groups () const |
| void | identify_variable_groups (const bool) |
| Real | calculate_norm (const NumericVector< Number > &v, unsigned int var=0, FEMNormType norm_type=L2) const |
| Real | calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm) const |
| void | read_header (Xdr &io, const std::string &version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false) |
| void | read_legacy_data (Xdr &io, const bool read_additional_data=true) |
| void | read_serialized_data (Xdr &io, const bool read_additional_data=true) |
| dof_id_type | read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const |
| 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 |
| dof_id_type | 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)) |
| 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) |
| virtual void | re_update () |
| virtual void | restrict_vectors () |
| virtual void | prolong_vectors () |
| virtual void | disable_cache () |
| Number | current_solution (const dof_id_type global_dof_number) const |
| Number | point_value (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Number | point_value (unsigned int var, const Point &p, const Elem &e) const |
| Gradient | point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Gradient | point_gradient (unsigned int var, const Point &p, const Elem &e) const |
| Tensor | point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Tensor | point_hessian (unsigned int var, const Point &p, const Elem &e) const |
| void | local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const |
| void | zero_variable (NumericVector< Number > &v, unsigned int var_num) const |
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 | |
| bool | assemble_before_solve |
| bool | use_fixed_solution |
| int | extra_quadrature_order |
| AutoPtr< NumericVector< Number > > | solution |
| AutoPtr< NumericVector< Number > > | current_local_solution |
| Real | time |
| std::vector< Number > | qoi |
Protected Types | |
| typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Protected Member Functions | |
| virtual void | init_data () |
| void | project_vector (NumericVector< Number > &) const |
| void | project_vector (const NumericVector< Number > &, NumericVector< Number > &) const |
| void | increment_constructor_count (const std::string &name) |
| void | increment_destructor_count (const std::string &name) |
Static Protected Attributes | |
| static Counts | _counts |
| static Threads::atomic < unsigned int > | _n_objects |
| static Threads::spin_mutex | _mutex |
| static bool | _enable_print_counter = true |
Private Member Functions | |
| System (const System &) | |
| System & | operator= (const System &) |
| Real | discrete_var_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const |
| template<typename iterator_type > | |
| dof_id_type | read_serialized_blocked_dof_objects (const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const |
| unsigned int | read_SCALAR_dofs (const unsigned int var, Xdr &io, NumericVector< Number > &vec) const |
| numeric_index_type | read_serialized_vector (Xdr &io, NumericVector< Number > &vec) |
| template<typename iterator_type > | |
| dof_id_type | write_serialized_blocked_dof_objects (const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const |
| unsigned int | write_SCALAR_dofs (const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const |
| dof_id_type | write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const |
Private Attributes | |
| void(* | _init_system_function )(EquationSystems &es, const std::string &name) |
| Initialization * | _init_system_object |
| void(* | _assemble_system_function )(EquationSystems &es, const std::string &name) |
| Assembly * | _assemble_system_object |
| void(* | _constrain_system_function )(EquationSystems &es, const std::string &name) |
| Constraint * | _constrain_system_object |
| void(* | _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) |
| QOI * | _qoi_evaluate_object |
| void(* | _qoi_evaluate_derivative_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) |
| QOIDerivative * | _qoi_evaluate_derivative_object |
| AutoPtr< DofMap > | _dof_map |
| EquationSystems & | _equation_systems |
| MeshBase & | _mesh |
| const std::string | _sys_name |
| const unsigned int | _sys_number |
| std::vector< Variable > | _variables |
| std::vector< VariableGroup > | _variable_groups |
| std::map< std::string, unsigned short int > | _variable_numbers |
| bool | _active |
| std::map< std::string, NumericVector< Number > * > | _vectors |
| std::map< std::string, bool > | _vector_projections |
| std::map< std::string, ParallelType > | _vector_types |
| bool | _solution_projection |
| bool | _basic_system_only |
| bool | _can_add_vectors |
| bool | _identify_variable_groups |
| bool | _additional_data_written |
| std::vector< unsigned int > | _written_var_indices |
| bool | adjoint_already_solved |
Detailed Description
This is the base class for classes which contain information related to any physical process that might be simulated. Such information may range from the actual solution values to algorithmic flags that may be used to control the numerical methods employed. In general, use an EqnSystems<T_sys> object to handle one or more of the children of this class. Note that templating EqnSystems relaxes the use of virtual members.
Definition at line 78 of file system.h.
Member Typedef Documentation
| typedef std::map<std::string, NumericVector<Number>* >::const_iterator libMesh::System::const_vectors_iterator |
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 113 of file reference_counter.h.
| typedef System libMesh::System::sys_type |
The type of system.
Reimplemented in libMesh::CondensedEigenSystem, libMesh::ContinuationSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::FEMSystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, libMesh::RBConstruction, libMesh::RBEIMConstruction, libMesh::RBSCMConstruction, libMesh::TransientRBConstruction, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, and libMesh::TransientSystem< RBConstruction >.
| typedef std::map<std::string, NumericVector<Number>* >::iterator libMesh::System::vectors_iterator |
Constructor & Destructor Documentation
| libMesh::System::System | ( | EquationSystems & | es, | |
| const std::string & | name, | |||
| const unsigned int | number | |||
| ) |
Constructor. Optionally initializes required data structures.
Definition at line 55 of file system.C.
00057 : 00058 00059 assemble_before_solve (true), 00060 use_fixed_solution (false), 00061 extra_quadrature_order (0), 00062 solution (NumericVector<Number>::build()), 00063 current_local_solution (NumericVector<Number>::build()), 00064 time (0.), 00065 qoi (0), 00066 _init_system_function (NULL), 00067 _init_system_object (NULL), 00068 _assemble_system_function (NULL), 00069 _assemble_system_object (NULL), 00070 _constrain_system_function (NULL), 00071 _constrain_system_object (NULL), 00072 _qoi_evaluate_function (NULL), 00073 _qoi_evaluate_object (NULL), 00074 _qoi_evaluate_derivative_function (NULL), 00075 _qoi_evaluate_derivative_object (NULL), 00076 _dof_map (new DofMap(number_in)), 00077 _equation_systems (es), 00078 _mesh (es.get_mesh()), 00079 _sys_name (name_in), 00080 _sys_number (number_in), 00081 _active (true), 00082 _solution_projection (true), 00083 _basic_system_only (false), 00084 _can_add_vectors (true), 00085 _identify_variable_groups (true), 00086 _additional_data_written (false) 00087 { 00088 }
| libMesh::System::~System | ( | ) | [virtual] |
Destructor.
Definition at line 110 of file system.C.
References _assemble_system_function, _assemble_system_object, _constrain_system_function, _constrain_system_object, _init_system_function, _init_system_object, _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, _qoi_evaluate_function, _qoi_evaluate_object, clear(), and libMesh::closed().
00111 { 00112 // Null-out the function pointers. Since this 00113 // class is getting destructed it is pointless, 00114 // but a good habit. 00115 _init_system_function = 00116 _assemble_system_function = 00117 _constrain_system_function = NULL; 00118 00119 _qoi_evaluate_function = 00120 _qoi_evaluate_derivative_function = NULL; 00121 00122 // NULL-out user-provided objects. 00123 _init_system_object = NULL; 00124 _assemble_system_object = NULL; 00125 _constrain_system_object = NULL; 00126 _qoi_evaluate_object = NULL; 00127 _qoi_evaluate_derivative_object = NULL; 00128 00129 // Clear data 00130 this->clear (); 00131 00132 libmesh_assert (!libMesh::closed()); 00133 }
| libMesh::System::System | ( | const System & | other | ) | [private] |
This isn't a copyable object, so let's make sure nobody tries.
We won't even bother implementing this; we'll just make sure that the compiler doesn't implement a default.
Definition at line 93 of file system.C.
00093 : 00094 ReferenceCountedObject<System>(), 00095 _equation_systems(other._equation_systems), 00096 _mesh(other._mesh), 00097 _sys_number(other._sys_number) 00098 { 00099 libmesh_error(); 00100 }
Member Function Documentation
| void libMesh::System::activate | ( | ) | [inline] |
| bool libMesh::System::active | ( | ) | const [inline] |
| NumericVector< Number > & libMesh::System::add_adjoint_rhs | ( | unsigned int | i = 0 |
) |
- 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 1016 of file system.C.
References add_vector().
Referenced by libMesh::FEMSystem::assemble_qoi_derivative(), and libMesh::ExplicitSystem::assemble_qoi_derivative().
01017 { 01018 std::ostringstream adjoint_rhs_name; 01019 adjoint_rhs_name << "adjoint_rhs" << i; 01020 01021 return this->add_vector(adjoint_rhs_name.str(), false); 01022 }
| NumericVector< Number > & libMesh::System::add_adjoint_solution | ( | unsigned int | i = 0 |
) |
- 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 956 of file system.C.
References add_vector().
Referenced by libMesh::ImplicitSystem::adjoint_solve().
00957 { 00958 std::ostringstream adjoint_name; 00959 adjoint_name << "adjoint_solution" << i; 00960 00961 return this->add_vector(adjoint_name.str()); 00962 }
| NumericVector< Number > & libMesh::System::add_sensitivity_rhs | ( | unsigned int | i = 0 |
) |
- 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 1046 of file system.C.
References add_vector().
Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives().
01047 { 01048 std::ostringstream sensitivity_rhs_name; 01049 sensitivity_rhs_name << "sensitivity_rhs" << i; 01050 01051 return this->add_vector(sensitivity_rhs_name.str(), false); 01052 }
| NumericVector< Number > & libMesh::System::add_sensitivity_solution | ( | unsigned int | i = 0 |
) |
- 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 905 of file system.C.
References add_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
00906 { 00907 std::ostringstream sensitivity_name; 00908 sensitivity_name << "sensitivity_solution" << i; 00909 00910 return this->add_vector(sensitivity_name.str()); 00911 }
| unsigned int libMesh::System::add_variable | ( | const std::string & | var, | |
| const Order | order = FIRST, |
|||
| const FEFamily | family = LAGRANGE, |
|||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL | |||
| ) |
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 1155 of file system.C.
References add_variable().
01159 { 01160 return this->add_variable(var, 01161 FEType(order, family), 01162 active_subdomains); 01163 }
| unsigned int libMesh::System::add_variable | ( | const std::string & | var, | |
| const FEType & | type, | |||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL | |||
| ) |
Adds the variable var to the list of variables for this system. Returns the index number for the new variable.
Definition at line 1076 of file system.C.
References _variable_groups, _variable_numbers, _variables, add_variables(), libMesh::err, identify_variable_groups(), n_variable_groups(), n_vars(), number(), variable_name(), and variable_type().
Referenced by add_variable(), libMesh::ErrorVector::plot_error(), and read_header().
01079 { 01080 // Make sure the variable isn't there already 01081 // or if it is, that it's the type we want 01082 for (unsigned int v=0; v<this->n_vars(); v++) 01083 if (this->variable_name(v) == var) 01084 { 01085 if (this->variable_type(v) == type) 01086 return _variables[v].number(); 01087 01088 libMesh::err << "ERROR: incompatible variable " 01089 << var 01090 << " has already been added for this system!" 01091 << std::endl; 01092 libmesh_error(); 01093 } 01094 01095 // Optimize for VariableGroups here - if the user is adding multiple 01096 // variables of the same FEType and subdomain restriction, catch 01097 // that here and add them as members of the same VariableGroup. 01098 // 01099 // start by setting this flag to whatever the user has requested 01100 // and then consider the conditions which should negate it. 01101 bool should_be_in_vg = this->identify_variable_groups(); 01102 01103 // No variable groups, nothing to add to 01104 if (!this->n_variable_groups()) 01105 should_be_in_vg = false; 01106 01107 else 01108 { 01109 VariableGroup &vg(_variable_groups.back()); 01110 01111 // get a pointer to their subdomain restriction, if any. 01112 const std::set<subdomain_id_type> * const 01113 their_active_subdomains (vg.implicitly_active() ? 01114 NULL : &vg.active_subdomains()); 01115 01116 // Different types? 01117 if (vg.type() != type) 01118 should_be_in_vg = false; 01119 01120 // they are restricted, we aren't? 01121 if (their_active_subdomains && !active_subdomains) 01122 should_be_in_vg = false; 01123 01124 // they aren't restriced, we are? 01125 if (!their_active_subdomains && active_subdomains) 01126 should_be_in_vg = false; 01127 01128 if (their_active_subdomains && active_subdomains) 01129 // restricted to different sets? 01130 if (*their_active_subdomains != *active_subdomains) 01131 should_be_in_vg = false; 01132 01133 // OK, after all that, append the variable to the vg if none of the conditions 01134 // were violated 01135 if (should_be_in_vg) 01136 { 01137 const unsigned int curr_n_vars = this->n_vars(); 01138 01139 vg.append (var); 01140 01141 _variables.push_back(vg(vg.n_variables()-1)); 01142 _variable_numbers[var] = curr_n_vars; 01143 return curr_n_vars; 01144 } 01145 } 01146 01147 // otherwise, fall back to adding a single variable group 01148 return this->add_variables (std::vector<std::string>(1, var), 01149 type, 01150 active_subdomains); 01151 }
| unsigned int libMesh::System::add_variables | ( | const std::vector< std::string > & | vars, | |
| const Order | order = FIRST, |
|||
| const FEFamily | family = LAGRANGE, |
|||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL | |||
| ) |
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 1220 of file system.C.
References add_variables().
01224 { 01225 return this->add_variables(vars, 01226 FEType(order, family), 01227 active_subdomains); 01228 }
| unsigned int libMesh::System::add_variables | ( | const std::vector< std::string > & | vars, | |
| const FEType & | type, | |||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL | |||
| ) |
Adds the variable var to the list of variables for this system. Returns the index number for the new variable.
Definition at line 1167 of file system.C.
References _variable_groups, _variable_numbers, _variables, libMesh::err, n_components(), n_vars(), number(), variable_name(), and variable_type().
Referenced by add_variable(), and add_variables().
01170 { 01171 // Make sure the variable isn't there already 01172 // or if it is, that it's the type we want 01173 for (unsigned int ov=0; ov<vars.size(); ov++) 01174 for (unsigned int v=0; v<this->n_vars(); v++) 01175 if (this->variable_name(v) == vars[ov]) 01176 { 01177 if (this->variable_type(v) == type) 01178 return _variables[v].number(); 01179 01180 libMesh::err << "ERROR: incompatible variable " 01181 << vars[ov] 01182 << " has already been added for this system!" 01183 << std::endl; 01184 libmesh_error(); 01185 } 01186 01187 const unsigned int curr_n_vars = this->n_vars(); 01188 01189 const unsigned int next_first_component = this->n_components(); 01190 01191 // Add the variable group to the list 01192 _variable_groups.push_back((active_subdomains == NULL) ? 01193 VariableGroup(this, vars, curr_n_vars, 01194 next_first_component, type) : 01195 VariableGroup(this, vars, curr_n_vars, 01196 next_first_component, type, *active_subdomains)); 01197 01198 const VariableGroup &vg (_variable_groups.back()); 01199 01200 // Add each component of the group individually 01201 for (unsigned int v=0; v<vars.size(); v++) 01202 { 01203 _variables.push_back (vg(v)); 01204 _variable_numbers[vars[v]] = curr_n_vars+v; 01205 } 01206 01207 libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars()); 01208 01209 // BSK - Defer this now to System::init_data() so we can detect 01210 // VariableGroups 12/28/2012 01211 // // Add the variable group to the _dof_map 01212 // _dof_map->add_variable_group (vg); 01213 01214 // Return the number of the new variable 01215 return curr_n_vars+vars.size()-1; 01216 }
| NumericVector< Number > & libMesh::System::add_vector | ( | const std::string & | vec_name, | |
| const bool | projections = true, |
|||
| const ParallelType | type = PARALLEL | |||
| ) |
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 675 of file system.C.
References _can_add_vectors, _dof_map, _vector_projections, _vector_types, _vectors, libMeshEnums::GHOSTED, have_vector(), libMesh::NumericVector< T >::init(), n_dofs(), and n_local_dofs().
Referenced by add_adjoint_rhs(), add_adjoint_solution(), add_sensitivity_rhs(), add_sensitivity_solution(), libMesh::ExplicitSystem::add_system_rhs(), add_weighted_sensitivity_adjoint_solution(), add_weighted_sensitivity_solution(), libMesh::UnsteadySolver::init(), libMesh::ContinuationSystem::init_data(), libMesh::NewmarkSystem::NewmarkSystem(), read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().
00678 { 00679 // Return the vector if it is already there. 00680 if (this->have_vector(vec_name)) 00681 return *(_vectors[vec_name]); 00682 00683 // Otherwise build the vector 00684 NumericVector<Number>* buf = NumericVector<Number>::build().release(); 00685 _vectors.insert (std::make_pair (vec_name, buf)); 00686 _vector_projections.insert (std::make_pair (vec_name, projections)); 00687 00688 _vector_types.insert (std::make_pair (vec_name, type)); 00689 00690 // Initialize it if necessary 00691 if (!_can_add_vectors) 00692 { 00693 if(type == GHOSTED) 00694 { 00695 #ifdef LIBMESH_ENABLE_GHOSTED 00696 buf->init (this->n_dofs(), this->n_local_dofs(), 00697 _dof_map->get_send_list(), false, 00698 GHOSTED); 00699 #else 00700 std::cerr << "Cannot initialize ghosted vectors when they are not enabled." << std::endl; 00701 libmesh_error(); 00702 #endif 00703 } 00704 else 00705 buf->init (this->n_dofs(), this->n_local_dofs(), false, type); 00706 } 00707 00708 return *buf; 00709 }
| NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 |
) |
- 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 986 of file system.C.
References add_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
00987 { 00988 std::ostringstream adjoint_name; 00989 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 00990 00991 return this->add_vector(adjoint_name.str()); 00992 }
| NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution | ( | ) |
- Returns:
- a reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.
Definition at line 935 of file system.C.
References add_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().
00936 { 00937 return this->add_vector("weighted_sensitivity_solution"); 00938 }
| void libMesh::System::adjoint_qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, | |
| const ParameterVector & | parameters, | |||
| SensitivityData & | sensitivities | |||
| ) | [inline, virtual] |
Solves for parameter sensitivities using the adjoint method.
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| std::pair< unsigned int, Real > libMesh::System::adjoint_solve | ( | const QoISet & | qoi_indices = QoISet() |
) | [inline, virtual] |
Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is NULL. Must be overloaded in derived systems.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
This method is only implemented in some derived classes.
Reimplemented in libMesh::DifferentiableSystem, and libMesh::ImplicitSystem.
Definition at line 2087 of file system.h.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error(), and libMesh::AdjointRefinementEstimator::estimate_error().
| void libMesh::System::assemble | ( | ) | [virtual] |
Prepares matrix and _dof_map for matrix assembly. Does not actually assemble anything. For matrix assembly, use the assemble() in derived classes. Should be overloaded in derived classes.
Reimplemented in libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::FrequencySystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, and libMesh::NewmarkSystem.
Definition at line 466 of file system.C.
References user_assembly().
Referenced by libMesh::ImplicitSystem::assemble(), libMesh::EigenSystem::assemble(), and libMesh::ExplicitSystem::solve().
00467 { 00468 // Log how long the user's assembly code takes 00469 START_LOG("assemble()", "System"); 00470 00471 // Call the user-specified assembly function 00472 this->user_assembly(); 00473 00474 // Stop logging the user code 00475 STOP_LOG("assemble()", "System"); 00476 }
Calls user qoi function. Can be overloaded in derived classes.
Reimplemented in libMesh::ExplicitSystem, and libMesh::FEMSystem.
Definition at line 480 of file system.C.
References user_QOI().
Referenced by libMesh::ExplicitSystem::assemble_qoi().
00481 { 00482 // Log how long the user's assembly code takes 00483 START_LOG("assemble_qoi()", "System"); 00484 00485 // Call the user-specified quantity of interest function 00486 this->user_QOI(qoi_indices); 00487 00488 // Stop logging the user code 00489 STOP_LOG("assemble_qoi()", "System"); 00490 }
Calls user qoi derivative function. Can be overloaded in derived classes.
Reimplemented in libMesh::ExplicitSystem, and libMesh::FEMSystem.
Definition at line 494 of file system.C.
References user_QOI_derivative().
Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative().
00495 { 00496 // Log how long the user's assembly code takes 00497 START_LOG("assemble_qoi_derivative()", "System"); 00498 00499 // Call the user-specified quantity of interest function 00500 this->user_QOI_derivative(qoi_indices); 00501 00502 // Stop logging the user code 00503 STOP_LOG("assemble_qoi_derivative()", "System"); 00504 }
| void libMesh::System::assemble_residual_derivatives | ( | const ParameterVector & | parameters | ) | [inline, virtual] |
Calls residual parameter derivative function.
Library subclasses use finite differences by default.
This should assemble the sensitivity rhs vectors to hold -(partial R / partial p_i), making them ready to solve the forward sensitivity equation.
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| void libMesh::System::attach_assemble_function | ( | void | fptrEquationSystems &es,const std::string &name | ) |
Register a user function to use in assembling the system matrix and RHS.
Definition at line 1753 of file system.C.
References _assemble_system_function, _assemble_system_object, and libMesh::out.
01755 { 01756 libmesh_assert(fptr); 01757 01758 if (_assemble_system_object != NULL) 01759 { 01760 libmesh_here(); 01761 libMesh::out << "WARNING: Cannot specify both assembly function and object!" 01762 << std::endl; 01763 01764 _assemble_system_object = NULL; 01765 } 01766 01767 _assemble_system_function = fptr; 01768 }
| void libMesh::System::attach_assemble_object | ( | System::Assembly & | assemble_in | ) |
Register a user object to use in assembling the system matrix and RHS.
Definition at line 1772 of file system.C.
References _assemble_system_function, _assemble_system_object, and libMesh::out.
01773 { 01774 if (_assemble_system_function != NULL) 01775 { 01776 libmesh_here(); 01777 libMesh::out << "WARNING: Cannot specify both assembly object and function!" 01778 << std::endl; 01779 01780 _assemble_system_function = NULL; 01781 } 01782 01783 _assemble_system_object = &assemble_in; 01784 }
| void libMesh::System::attach_constraint_function | ( | void | fptrEquationSystems &es,const std::string &name | ) |
Register a user function for imposing constraints.
Definition at line 1788 of file system.C.
References _constrain_system_function, _constrain_system_object, and libMesh::out.
01790 { 01791 libmesh_assert(fptr); 01792 01793 if (_constrain_system_object != NULL) 01794 { 01795 libmesh_here(); 01796 libMesh::out << "WARNING: Cannot specify both constraint function and object!" 01797 << std::endl; 01798 01799 _constrain_system_object = NULL; 01800 } 01801 01802 _constrain_system_function = fptr; 01803 }
| void libMesh::System::attach_constraint_object | ( | System::Constraint & | constrain | ) |
Register a user object for imposing constraints.
Definition at line 1807 of file system.C.
References _constrain_system_function, _constrain_system_object, and libMesh::out.
01808 { 01809 if (_constrain_system_function != NULL) 01810 { 01811 libmesh_here(); 01812 libMesh::out << "WARNING: Cannot specify both constraint object and function!" 01813 << std::endl; 01814 01815 _constrain_system_function = NULL; 01816 } 01817 01818 _constrain_system_object = &constrain; 01819 }
| void libMesh::System::attach_init_function | ( | void | fptrEquationSystems &es,const std::string &name | ) |
Register a user function to use in initializing the system.
Definition at line 1718 of file system.C.
References _init_system_function, _init_system_object, and libMesh::out.
01720 { 01721 libmesh_assert(fptr); 01722 01723 if (_init_system_object != NULL) 01724 { 01725 libmesh_here(); 01726 libMesh::out << "WARNING: Cannot specify both initialization function and object!" 01727 << std::endl; 01728 01729 _init_system_object = NULL; 01730 } 01731 01732 _init_system_function = fptr; 01733 }
| void libMesh::System::attach_init_object | ( | System::Initialization & | init_in | ) |
Register a user class to use to initialize the system. Note this is exclusive with the attach_init_function.
Definition at line 1737 of file system.C.
References _init_system_function, _init_system_object, and libMesh::out.
01738 { 01739 if (_init_system_function != NULL) 01740 { 01741 libmesh_here(); 01742 libMesh::out << "WARNING: Cannot specify both initialization object and function!" 01743 << std::endl; 01744 01745 _init_system_function = NULL; 01746 } 01747 01748 _init_system_object = &init_in; 01749 }
| void libMesh::System::attach_QOI_derivative | ( | void | fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices | ) |
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
| void libMesh::System::attach_QOI_derivative_object | ( | QOIDerivative & | qoi_derivative | ) |
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 1879 of file system.C.
References _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, and libMesh::out.
01880 { 01881 if (_qoi_evaluate_derivative_function != NULL) 01882 { 01883 libmesh_here(); 01884 libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!" 01885 << std::endl; 01886 01887 _qoi_evaluate_derivative_function = NULL; 01888 } 01889 01890 _qoi_evaluate_derivative_object = &qoi_derivative; 01891 }
| void libMesh::System::attach_QOI_function | ( | void | fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices | ) |
Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi
| void libMesh::System::attach_QOI_object | ( | QOI & | qoi | ) |
Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi
Definition at line 1843 of file system.C.
References _qoi_evaluate_function, _qoi_evaluate_object, and libMesh::out.
01844 { 01845 if (_qoi_evaluate_function != NULL) 01846 { 01847 libmesh_here(); 01848 libMesh::out << "WARNING: Cannot specify both QOI object and function!" 01849 << std::endl; 01850 01851 _qoi_evaluate_function = NULL; 01852 } 01853 01854 _qoi_evaluate_object = &qoi_in; 01855 }
| void libMesh::System::boundary_project_solution | ( | const std::set< boundary_id_type > & | b, | |
| const std::vector< unsigned int > & | variables, | |||
| Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| const Parameters & | parameters | |||
| ) |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects components of an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 641 of file system_projection.C.
00652 { 00653 WrappedFunction<Number> f(*this, fptr, ¶meters); 00654 WrappedFunction<Gradient> g(*this, gptr, ¶meters); 00655 this->boundary_project_solution(b, variables, &f, &g); 00656 }
| void libMesh::System::boundary_project_solution | ( | const std::set< boundary_id_type > & | b, | |
| const std::vector< unsigned int > & | variables, | |||
| FunctionBase< Number > * | f, | |||
| FunctionBase< Gradient > * | g = NULL | |||
| ) |
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 665 of file system_projection.C.
00669 { 00670 this->boundary_project_vector(b, variables, *solution, f, g); 00671 00672 solution->localize(*current_local_solution); 00673 }
| void libMesh::System::boundary_project_vector | ( | const std::set< boundary_id_type > & | b, | |
| const std::vector< unsigned int > & | variables, | |||
| Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| const Parameters & | parameters, | |||
| NumericVector< Number > & | new_vector | |||
| ) | const |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects an arbitrary boundary function via L2 projections and nodal interpolations on each element.
Definition at line 684 of file system_projection.C.
00696 { 00697 WrappedFunction<Number> f(*this, fptr, ¶meters); 00698 WrappedFunction<Gradient> g(*this, gptr, ¶meters); 00699 this->boundary_project_vector(b, variables, new_vector, &f, &g); 00700 }
| void libMesh::System::boundary_project_vector | ( | const std::set< boundary_id_type > & | b, | |
| const std::vector< unsigned int > & | variables, | |||
| NumericVector< Number > & | new_vector, | |||
| FunctionBase< Number > * | f, | |||
| FunctionBase< Gradient > * | g = NULL | |||
| ) | const |
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 arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 707 of file system_projection.C.
References libMesh::NumericVector< T >::close(), and libMesh::Threads::parallel_for().
00712 { 00713 START_LOG ("boundary_project_vector()", "System"); 00714 00715 Threads::parallel_for 00716 (ConstElemRange (this->get_mesh().active_local_elements_begin(), 00717 this->get_mesh().active_local_elements_end() ), 00718 BoundaryProjectSolution(b, variables, *this, f, g, 00719 this->get_equation_systems().parameters, 00720 new_vector) 00721 ); 00722 00723 // We don't do SCALAR dofs when just projecting the boundary, so 00724 // we're done here. 00725 00726 new_vector.close(); 00727 00728 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00729 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector); 00730 #endif 00731 00732 STOP_LOG("boundary_project_vector()", "System"); 00733 }
| Real libMesh::System::calculate_norm | ( | const NumericVector< Number > & | v, | |
| const SystemNorm & | norm | |||
| ) | const |
- Returns:
- a norm of the vector
v, usingcomponent_normandcomponent_scaleto choose and weight the norms of each variable.
Definition at line 1400 of file system.C.
References _dof_map, std::abs(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::TypeTensor< T >::add_scaled(), libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< Real >::build(), libMesh::CommWorld, libMesh::FEType::default_quadrature_rule(), libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::AutoPtr< Tp >::get(), get_dof_map(), get_mesh(), libMeshEnums::H1, libMeshEnums::H1_SEMINORM, libMeshEnums::H2, libMeshEnums::H2_SEMINORM, libMesh::SystemNorm::is_discrete(), libMeshEnums::L1, libMesh::NumericVector< T >::l1_norm(), libMeshEnums::L2, libMesh::NumericVector< T >::l2_norm(), libMeshEnums::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), libMesh::Parallel::Communicator::max(), std::max(), libMesh::MeshBase::mesh_dimension(), n_vars(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMeshEnums::SERIAL, libMesh::TypeTensor< T >::size(), libMesh::TypeVector< T >::size(), libMesh::NumericVector< T >::size(), libMesh::TypeTensor< T >::size_sq(), libMesh::TypeVector< T >::size_sq(), libMesh::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMeshEnums::W1_INF_SEMINORM, libMeshEnums::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().
01402 { 01403 // This function must be run on all processors at once 01404 parallel_only(); 01405 01406 START_LOG ("calculate_norm()", "System"); 01407 01408 // Zero the norm before summation 01409 Real v_norm = 0.; 01410 01411 if (norm.is_discrete()) 01412 { 01413 STOP_LOG ("calculate_norm()", "System"); 01414 //Check to see if all weights are 1.0 and all types are equal 01415 FEMNormType norm_type0 = norm.type(0); 01416 unsigned int check_var = 0; 01417 for (; check_var != this->n_vars(); ++check_var) 01418 if((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0)) 01419 break; 01420 01421 //All weights were 1.0 so just do the full vector discrete norm 01422 if(check_var == this->n_vars()) 01423 { 01424 if(norm_type0 == DISCRETE_L1) 01425 return v.l1_norm(); 01426 if(norm_type0 == DISCRETE_L2) 01427 return v.l2_norm(); 01428 if(norm_type0 == DISCRETE_L_INF) 01429 return v.linfty_norm(); 01430 else 01431 libmesh_error(); 01432 } 01433 01434 for (unsigned int var=0; var != this->n_vars(); ++var) 01435 { 01436 // Skip any variables we don't need to integrate 01437 if (norm.weight(var) == 0.0) 01438 continue; 01439 01440 v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var)); 01441 } 01442 01443 return v_norm; 01444 } 01445 01446 // Localize the potentially parallel vector 01447 AutoPtr<NumericVector<Number> > local_v = NumericVector<Number>::build(); 01448 local_v->init(v.size(), true, SERIAL); 01449 v.localize (*local_v, _dof_map->get_send_list()); 01450 01451 unsigned int dim = this->get_mesh().mesh_dimension(); 01452 01453 // I'm not sure how best to mix Hilbert norms on some variables (for 01454 // which we'll want to square then sum then square root) with norms 01455 // like L_inf (for which we'll just want to take an absolute value 01456 // and then sum). 01457 bool using_hilbert_norm = true, 01458 using_nonhilbert_norm = true; 01459 01460 // Loop over all variables 01461 for (unsigned int var=0; var != this->n_vars(); ++var) 01462 { 01463 // Skip any variables we don't need to integrate 01464 Real norm_weight_sq = norm.weight_sq(var); 01465 if (norm_weight_sq == 0.0) 01466 continue; 01467 Real norm_weight = norm.weight(var); 01468 01469 // Check for unimplemented norms (rather than just returning 0). 01470 FEMNormType norm_type = norm.type(var); 01471 if((norm_type==H1) || 01472 (norm_type==H2) || 01473 (norm_type==L2) || 01474 (norm_type==H1_SEMINORM) || 01475 (norm_type==H2_SEMINORM)) 01476 { 01477 if (!using_hilbert_norm) 01478 libmesh_not_implemented(); 01479 using_nonhilbert_norm = false; 01480 } 01481 else if ((norm_type==L1) || 01482 (norm_type==L_INF) || 01483 (norm_type==W1_INF_SEMINORM) || 01484 (norm_type==W2_INF_SEMINORM)) 01485 { 01486 if (!using_nonhilbert_norm) 01487 libmesh_not_implemented(); 01488 using_hilbert_norm = false; 01489 } 01490 else 01491 libmesh_not_implemented(); 01492 01493 const FEType& fe_type = this->get_dof_map().variable_type(var); 01494 AutoPtr<QBase> qrule = 01495 fe_type.default_quadrature_rule (dim); 01496 AutoPtr<FEBase> fe 01497 (FEBase::build(dim, fe_type)); 01498 fe->attach_quadrature_rule (qrule.get()); 01499 01500 const std::vector<Real>& JxW = fe->get_JxW(); 01501 const std::vector<std::vector<Real> >* phi = NULL; 01502 if (norm_type == H1 || 01503 norm_type == H2 || 01504 norm_type == L2 || 01505 norm_type == L1 || 01506 norm_type == L_INF) 01507 phi = &(fe->get_phi()); 01508 01509 const std::vector<std::vector<RealGradient> >* dphi = NULL; 01510 if (norm_type == H1 || 01511 norm_type == H2 || 01512 norm_type == H1_SEMINORM || 01513 norm_type == W1_INF_SEMINORM) 01514 dphi = &(fe->get_dphi()); 01515 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 01516 const std::vector<std::vector<RealTensor> >* d2phi = NULL; 01517 if (norm_type == H2 || 01518 norm_type == H2_SEMINORM || 01519 norm_type == W2_INF_SEMINORM) 01520 d2phi = &(fe->get_d2phi()); 01521 #endif 01522 01523 std::vector<dof_id_type> dof_indices; 01524 01525 // Begin the loop over the elements 01526 MeshBase::const_element_iterator el = 01527 this->get_mesh().active_local_elements_begin(); 01528 const MeshBase::const_element_iterator end_el = 01529 this->get_mesh().active_local_elements_end(); 01530 01531 for ( ; el != end_el; ++el) 01532 { 01533 const Elem* elem = *el; 01534 01535 fe->reinit (elem); 01536 01537 this->get_dof_map().dof_indices (elem, dof_indices, var); 01538 01539 const unsigned int n_qp = qrule->n_points(); 01540 01541 const unsigned int n_sf = libmesh_cast_int<unsigned int> 01542 (dof_indices.size()); 01543 01544 // Begin the loop over the Quadrature points. 01545 for (unsigned int qp=0; qp<n_qp; qp++) 01546 { 01547 if (norm_type == L1) 01548 { 01549 Number u_h = 0.; 01550 for (unsigned int i=0; i != n_sf; ++i) 01551 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]); 01552 v_norm += norm_weight * 01553 JxW[qp] * std::abs(u_h); 01554 } 01555 01556 if (norm_type == L_INF) 01557 { 01558 Number u_h = 0.; 01559 for (unsigned int i=0; i != n_sf; ++i) 01560 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]); 01561 v_norm = std::max(v_norm, norm_weight * std::abs(u_h)); 01562 } 01563 01564 if (norm_type == H1 || 01565 norm_type == H2 || 01566 norm_type == L2) 01567 { 01568 Number u_h = 0.; 01569 for (unsigned int i=0; i != n_sf; ++i) 01570 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]); 01571 v_norm += norm_weight_sq * 01572 JxW[qp] * TensorTools::norm_sq(u_h); 01573 } 01574 01575 if (norm_type == H1 || 01576 norm_type == H2 || 01577 norm_type == H1_SEMINORM) 01578 { 01579 Gradient grad_u_h; 01580 for (unsigned int i=0; i != n_sf; ++i) 01581 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i])); 01582 v_norm += norm_weight_sq * 01583 JxW[qp] * grad_u_h.size_sq(); 01584 } 01585 01586 if (norm_type == W1_INF_SEMINORM) 01587 { 01588 Gradient grad_u_h; 01589 for (unsigned int i=0; i != n_sf; ++i) 01590 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i])); 01591 v_norm = std::max(v_norm, norm_weight * grad_u_h.size()); 01592 } 01593 01594 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 01595 if (norm_type == H2 || 01596 norm_type == H2_SEMINORM) 01597 { 01598 Tensor hess_u_h; 01599 for (unsigned int i=0; i != n_sf; ++i) 01600 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i])); 01601 v_norm += norm_weight_sq * 01602 JxW[qp] * hess_u_h.size_sq(); 01603 } 01604 01605 if (norm_type == W2_INF_SEMINORM) 01606 { 01607 Tensor hess_u_h; 01608 for (unsigned int i=0; i != n_sf; ++i) 01609 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i])); 01610 v_norm = std::max(v_norm, norm_weight * hess_u_h.size()); 01611 } 01612 #endif 01613 } 01614 } 01615 } 01616 01617 if (using_hilbert_norm) 01618 { 01619 CommWorld.sum(v_norm); 01620 v_norm = std::sqrt(v_norm); 01621 } 01622 else 01623 { 01624 CommWorld.max(v_norm); 01625 } 01626 01627 STOP_LOG ("calculate_norm()", "System"); 01628 01629 return v_norm; 01630 }
| Real libMesh::System::calculate_norm | ( | const NumericVector< Number > & | v, | |
| unsigned int | var = 0, |
|||
| FEMNormType | norm_type = L2 | |||
| ) | const |
- Returns:
- a norm of variable
varin the vectorv, in the specified norm (e.g. L2, L_INF, H1)
Definition at line 1379 of file system.C.
References libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, discrete_var_norm(), libMeshEnums::L2, n_vars(), and libMesh::Real.
Referenced by libMesh::AdaptiveTimeSolver::calculate_norm(), and libMesh::UnsteadySolver::du().
01382 { 01383 //short circuit to save time 01384 if(norm_type == DISCRETE_L1 || 01385 norm_type == DISCRETE_L2 || 01386 norm_type == DISCRETE_L_INF) 01387 return discrete_var_norm(v,var,norm_type); 01388 01389 // Not a discrete norm 01390 std::vector<FEMNormType> norms(this->n_vars(), L2); 01391 std::vector<Real> weights(this->n_vars(), 0.0); 01392 norms[var] = norm_type; 01393 weights[var] = 1.0; 01394 Real val = this->calculate_norm(v, SystemNorm(norms, weights)); 01395 return val; 01396 }
| void libMesh::System::clear | ( | ) | [virtual] |
Clear all the data structures associated with the system.
Reimplemented in libMesh::ContinuationSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::FEMSystem, libMesh::FrequencySystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, libMesh::RBConstruction, libMesh::RBEIMConstruction, libMesh::RBSCMConstruction, libMesh::TransientRBConstruction, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, and libMesh::TransientSystem< RBConstruction >.
Definition at line 192 of file system.C.
References _can_add_vectors, _dof_map, _variable_numbers, _variables, _vector_projections, _vector_types, _vectors, current_local_solution, and solution.
Referenced by libMesh::ExplicitSystem::clear(), libMesh::EigenSystem::clear(), read_header(), and ~System().
00193 { 00194 _variables.clear(); 00195 00196 _variable_numbers.clear(); 00197 00198 _dof_map->clear (); 00199 00200 solution->clear (); 00201 00202 current_local_solution->clear (); 00203 00204 // clear any user-added vectors 00205 { 00206 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00207 { 00208 pos->second->clear (); 00209 delete pos->second; 00210 pos->second = NULL; 00211 } 00212 00213 _vectors.clear(); 00214 _vector_projections.clear(); 00215 _vector_types.clear(); 00216 _can_add_vectors = true; 00217 } 00218 00219 }
| bool libMesh::System::compare | ( | const System & | other_system, | |
| const Real | threshold, | |||
| const bool | verbose | |||
| ) | const [virtual] |
- Returns:
truewhen the other system contains identical data, up to the given threshold. Outputs some diagnostic info whenverboseis set.
Definition at line 525 of file system.C.
References _can_add_vectors, _sys_name, _vectors, libMesh::AutoPtr< Tp >::get(), get_vector(), n_vectors(), name(), libMesh::out, and solution.
Referenced by libMesh::EquationSystems::compare().
00528 { 00529 // we do not care for matrices, but for vectors 00530 libmesh_assert (!_can_add_vectors); 00531 libmesh_assert (!other_system._can_add_vectors); 00532 00533 if (verbose) 00534 { 00535 libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl; 00536 libMesh::out << " comparing matrices not supported." << std::endl; 00537 libMesh::out << " comparing names..."; 00538 } 00539 00540 // compare the name: 0 means identical 00541 const int name_result = _sys_name.compare(other_system.name()); 00542 if (verbose) 00543 { 00544 if (name_result == 0) 00545 libMesh::out << " identical." << std::endl; 00546 else 00547 libMesh::out << " names not identical." << std::endl; 00548 libMesh::out << " comparing solution vector..."; 00549 } 00550 00551 00552 // compare the solution: -1 means identical 00553 const int solu_result = solution->compare (*other_system.solution.get(), 00554 threshold); 00555 00556 if (verbose) 00557 { 00558 if (solu_result == -1) 00559 libMesh::out << " identical up to threshold." << std::endl; 00560 else 00561 libMesh::out << " first difference occured at index = " 00562 << solu_result << "." << std::endl; 00563 } 00564 00565 00566 // safety check, whether we handle at least the same number 00567 // of vectors 00568 std::vector<int> ov_result; 00569 00570 if (this->n_vectors() != other_system.n_vectors()) 00571 { 00572 if (verbose) 00573 { 00574 libMesh::out << " Fatal difference. This system handles " 00575 << this->n_vectors() << " add'l vectors," << std::endl 00576 << " while the other system handles " 00577 << other_system.n_vectors() 00578 << " add'l vectors." << std::endl 00579 << " Aborting comparison." << std::endl; 00580 } 00581 return false; 00582 } 00583 else if (this->n_vectors() == 0) 00584 { 00585 // there are no additional vectors... 00586 ov_result.clear (); 00587 } 00588 else 00589 { 00590 // compare other vectors 00591 for (const_vectors_iterator pos = _vectors.begin(); 00592 pos != _vectors.end(); ++pos) 00593 { 00594 if (verbose) 00595 libMesh::out << " comparing vector \"" 00596 << pos->first << "\" ..."; 00597 00598 // assume they have the same name 00599 const NumericVector<Number>& other_system_vector = 00600 other_system.get_vector(pos->first); 00601 00602 ov_result.push_back(pos->second->compare (other_system_vector, 00603 threshold)); 00604 00605 if (verbose) 00606 { 00607 if (ov_result[ov_result.size()-1] == -1) 00608 libMesh::out << " identical up to threshold." << std::endl; 00609 else 00610 libMesh::out << " first difference occured at" << std::endl 00611 << " index = " << ov_result[ov_result.size()-1] << "." << std::endl; 00612 } 00613 00614 } 00615 00616 } // finished comparing additional vectors 00617 00618 00619 bool overall_result; 00620 00621 // sum up the results 00622 if ((name_result==0) && (solu_result==-1)) 00623 { 00624 if (ov_result.size()==0) 00625 overall_result = true; 00626 else 00627 { 00628 bool ov_identical; 00629 unsigned int n = 0; 00630 do 00631 { 00632 ov_identical = (ov_result[n]==-1); 00633 n++; 00634 } 00635 while (ov_identical && n<ov_result.size()); 00636 overall_result = ov_identical; 00637 } 00638 } 00639 else 00640 overall_result = false; 00641 00642 if (verbose) 00643 { 00644 libMesh::out << " finished comparisons, "; 00645 if (overall_result) 00646 libMesh::out << "found no differences." << std::endl << std::endl; 00647 else 00648 libMesh::out << "found differences." << std::endl << std::endl; 00649 } 00650 00651 return overall_result; 00652 }
| Number libMesh::System::current_solution | ( | const dof_id_type | global_dof_number | ) | const |
- Returns:
- the current solution for the specified global DOF.
Definition at line 181 of file system.C.
References _dof_map, and current_local_solution.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
00182 { 00183 // Check the sizes 00184 libmesh_assert_less (global_dof_number, _dof_map->n_dofs()); 00185 libmesh_assert_less (global_dof_number, current_local_solution->size()); 00186 00187 return (*current_local_solution)(global_dof_number); 00188 }
| void libMesh::System::deactivate | ( | ) | [inline] |
| void libMesh::System::disable_cache | ( | ) | [inline, virtual] |
Avoids use of any cached data that might affect any solve result. Should be overloaded in derived systems.
Reimplemented in libMesh::ImplicitSystem.
Definition at line 2068 of file system.h.
References assemble_before_solve.
02068 { assemble_before_solve = true; }
| void libMesh::ReferenceCounter::disable_print_counter_info | ( | ) | [static, inherited] |
Definition at line 106 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00107 { 00108 _enable_print_counter = false; 00109 return; 00110 }
| Real libMesh::System::discrete_var_norm | ( | const NumericVector< Number > & | v, | |
| unsigned int | var, | |||
| FEMNormType | norm_type | |||
| ) | const [private] |
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.
Definition at line 1360 of file system.C.
References libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, local_dof_indices(), libMesh::NumericVector< T >::subset_l1_norm(), libMesh::NumericVector< T >::subset_l2_norm(), and libMesh::NumericVector< T >::subset_linfty_norm().
Referenced by calculate_norm().
01363 { 01364 std::set<dof_id_type> var_indices; 01365 local_dof_indices(var, var_indices); 01366 01367 if(norm_type == DISCRETE_L1) 01368 return v.subset_l1_norm(var_indices); 01369 if(norm_type == DISCRETE_L2) 01370 return v.subset_l2_norm(var_indices); 01371 if(norm_type == DISCRETE_L_INF) 01372 return v.subset_linfty_norm(var_indices); 01373 else 01374 libmesh_error(); 01375 }
| void libMesh::ReferenceCounter::enable_print_counter_info | ( | ) | [static, inherited] |
Methods to enable/disable the reference counter output from print_info()
Definition at line 100 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
00101 { 00102 _enable_print_counter = true; 00103 return; 00104 }
| void libMesh::System::forward_qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, | |
| const ParameterVector & | parameters, | |||
| SensitivityData & | sensitivities | |||
| ) | [inline, virtual] |
Solves for parameter sensitivities using the forward method.
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| const NumericVector< Number > & libMesh::System::get_adjoint_rhs | ( | unsigned int | i = 0 |
) | const |
- Returns:
- a reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.
Definition at line 1036 of file system.C.
References get_vector().
01037 { 01038 std::ostringstream adjoint_rhs_name; 01039 adjoint_rhs_name << "adjoint_rhs" << i; 01040 01041 return this->get_vector(adjoint_rhs_name.str()); 01042 }
| NumericVector< Number > & libMesh::System::get_adjoint_rhs | ( | unsigned int | i = 0 |
) |
- 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 1026 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
01027 { 01028 std::ostringstream adjoint_rhs_name; 01029 adjoint_rhs_name << "adjoint_rhs" << i; 01030 01031 return this->get_vector(adjoint_rhs_name.str()); 01032 }
| const NumericVector< Number > & libMesh::System::get_adjoint_solution | ( | unsigned int | i = 0 |
) | const |
- Returns:
- a reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.
Definition at line 976 of file system.C.
References get_vector().
00977 { 00978 std::ostringstream adjoint_name; 00979 adjoint_name << "adjoint_solution" << i; 00980 00981 return this->get_vector(adjoint_name.str()); 00982 }
| NumericVector< Number > & libMesh::System::get_adjoint_solution | ( | unsigned int | i = 0 |
) |
- Returns:
- a reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.
Definition at line 966 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
00967 { 00968 std::ostringstream adjoint_name; 00969 adjoint_name << "adjoint_solution" << i; 00970 00971 return this->get_vector(adjoint_name.str()); 00972 }
| void libMesh::System::get_all_variable_numbers | ( | std::vector< unsigned int > & | all_variable_numbers | ) | const |
Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.
Definition at line 1259 of file system.C.
References _variable_numbers, and n_vars().
01260 { 01261 all_variable_numbers.resize(n_vars()); 01262 01263 // Make sure the variable exists 01264 std::map<std::string, unsigned short int>::const_iterator 01265 it = _variable_numbers.begin(); 01266 std::map<std::string, unsigned short int>::const_iterator 01267 it_end = _variable_numbers.end(); 01268 01269 unsigned int count = 0; 01270 for( ; it != it_end; ++it) 01271 { 01272 all_variable_numbers[count] = it->second; 01273 count++; 01274 } 01275 }
| DofMap & libMesh::System::get_dof_map | ( | ) | [inline] |
| const DofMap & libMesh::System::get_dof_map | ( | ) | const [inline] |
- Returns:
- a constant reference to this system's
_dof_map.
Definition at line 1850 of file system.h.
References _dof_map.
Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), calculate_norm(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMFunction_libMesh(), DMJacobian_libMesh(), DMLibMeshSetSystem(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::UnsteadySolver::init_data(), libMesh::ImplicitSystem::init_matrices(), libMesh::EigenSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::ProjectSolution::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ErrorVector::plot_error(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), project_vector(), re_update(), read_parallel_data(), read_SCALAR_dofs(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EquationSystems::reinit(), libMesh::EigenSystem::reinit(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::PetscDiffSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().
01851 { 01852 return *_dof_map; 01853 }
| EquationSystems& libMesh::System::get_equation_systems | ( | ) | [inline] |
- Returns:
- a reference to this system's parent EquationSystems object.
Definition at line 684 of file system.h.
References _equation_systems.
00684 { return _equation_systems; }
| const EquationSystems& libMesh::System::get_equation_systems | ( | ) | const [inline] |
- Returns:
- a constant reference to this system's parent EquationSystems object.
Definition at line 679 of file system.h.
References _equation_systems.
Referenced by libMesh::NewmarkSystem::clear(), libMesh::FrequencySystem::clear_all(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::FrequencySystem::init_data(), libMesh::FrequencySystem::n_frequencies(), project_vector(), libMesh::FrequencySystem::set_current_frequency(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), and libMesh::WrappedFunction< Output >::WrappedFunction().
00679 { return _equation_systems; }
| std::string libMesh::ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 47 of file reference_counter.C.
References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().
Referenced by libMesh::ReferenceCounter::print_info().
00048 { 00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00050 00051 std::ostringstream oss; 00052 00053 oss << '\n' 00054 << " ---------------------------------------------------------------------------- \n" 00055 << "| Reference count information |\n" 00056 << " ---------------------------------------------------------------------------- \n"; 00057 00058 for (Counts::iterator it = _counts.begin(); 00059 it != _counts.end(); ++it) 00060 { 00061 const std::string name(it->first); 00062 const unsigned int creations = it->second.first; 00063 const unsigned int destructions = it->second.second; 00064 00065 oss << "| " << name << " reference count information:\n" 00066 << "| Creations: " << creations << '\n' 00067 << "| Destructions: " << destructions << '\n'; 00068 } 00069 00070 oss << " ---------------------------------------------------------------------------- \n"; 00071 00072 return oss.str(); 00073 00074 #else 00075 00076 return ""; 00077 00078 #endif 00079 }
| std::string libMesh::System::get_info | ( | ) | const |
- Returns:
- a string containing information about the system.
Definition at line 1634 of file system.C.
References libMesh::Utility::enum_to_string< FEFamily >(), libMesh::Utility::enum_to_string< InfMapType >(), libMesh::Utility::enum_to_string< Order >(), libMesh::FEType::family, get_dof_map(), libMesh::DofMap::get_info(), libMesh::FEType::inf_map, n_constrained_dofs(), n_dofs(), n_local_constrained_dofs(), n_local_dofs(), n_matrices(), n_variable_groups(), libMesh::VariableGroup::n_variables(), n_vectors(), libMesh::VariableGroup::name(), name(), number(), libMesh::FEType::order, libMesh::FEType::radial_family, libMesh::FEType::radial_order, system_type(), libMesh::Variable::type(), libMesh::DofMap::variable_group(), and variable_group().
01635 { 01636 std::ostringstream oss; 01637 01638 01639 const std::string& sys_name = this->name(); 01640 01641 oss << " System #" << this->number() << ", \"" << sys_name << "\"\n" 01642 << " Type \"" << this->system_type() << "\"\n" 01643 << " Variables="; 01644 01645 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 01646 { 01647 const VariableGroup &vg_description (this->variable_group(vg)); 01648 01649 if (vg_description.n_variables() > 1) oss << "{ "; 01650 for (unsigned int vn=0; vn<vg_description.n_variables(); vn++) 01651 oss << "\"" << vg_description.name(vn) << "\" "; 01652 if (vg_description.n_variables() > 1) oss << "} "; 01653 } 01654 01655 oss << '\n'; 01656 01657 oss << " Finite Element Types="; 01658 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS 01659 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 01660 oss << "\"" 01661 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family) 01662 << "\" "; 01663 #else 01664 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 01665 { 01666 oss << "\"" 01667 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family) 01668 << "\", \"" 01669 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family) 01670 << "\" "; 01671 } 01672 01673 oss << '\n' << " Infinite Element Mapping="; 01674 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 01675 oss << "\"" 01676 << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map) 01677 << "\" "; 01678 #endif 01679 01680 oss << '\n'; 01681 01682 oss << " Approximation Orders="; 01683 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 01684 { 01685 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS 01686 oss << "\"" 01687 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order) 01688 << "\" "; 01689 #else 01690 oss << "\"" 01691 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order) 01692 << "\", \"" 01693 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order) 01694 << "\" "; 01695 #endif 01696 } 01697 01698 oss << '\n'; 01699 01700 oss << " n_dofs()=" << this->n_dofs() << '\n'; 01701 oss << " n_local_dofs()=" << this->n_local_dofs() << '\n'; 01702 #ifdef LIBMESH_ENABLE_CONSTRAINTS 01703 oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n'; 01704 oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n'; 01705 #endif 01706 01707 oss << " " << "n_vectors()=" << this->n_vectors() << '\n'; 01708 oss << " " << "n_matrices()=" << this->n_matrices() << '\n'; 01709 // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n'; 01710 01711 oss << this->get_dof_map().get_info(); 01712 01713 return oss.str(); 01714 }
| MeshBase & libMesh::System::get_mesh | ( | ) | [inline] |
| const MeshBase & libMesh::System::get_mesh | ( | ) | const [inline] |
- Returns:
- a constant reference to this systems's
_mesh.
Definition at line 1834 of file system.h.
References _mesh.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), calculate_norm(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMLibMeshSetSystem(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::SystemSubsetBySubdomain::init(), init_data(), libMesh::ImplicitSystem::init_matrices(), libMesh::EigenSystem::init_matrices(), local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ProjectSolution::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), point_gradient(), point_hessian(), point_value(), libMesh::FEMSystem::postprocess(), project_vector(), read_header(), read_legacy_data(), read_parallel_data(), read_serialized_vector(), read_serialized_vectors(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), write_header(), write_parallel_data(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().
01835 { 01836 return _mesh; 01837 }
| const NumericVector< Number > & libMesh::System::get_sensitivity_rhs | ( | unsigned int | i = 0 |
) | const |
- Returns:
- a reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.
Definition at line 1066 of file system.C.
References get_vector().
01067 { 01068 std::ostringstream sensitivity_rhs_name; 01069 sensitivity_rhs_name << "sensitivity_rhs" << i; 01070 01071 return this->get_vector(sensitivity_rhs_name.str()); 01072 }
| NumericVector< Number > & libMesh::System::get_sensitivity_rhs | ( | unsigned int | i = 0 |
) |
- 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 1056 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
01057 { 01058 std::ostringstream sensitivity_rhs_name; 01059 sensitivity_rhs_name << "sensitivity_rhs" << i; 01060 01061 return this->get_vector(sensitivity_rhs_name.str()); 01062 }
| const NumericVector< Number > & libMesh::System::get_sensitivity_solution | ( | unsigned int | i = 0 |
) | const |
- Returns:
- a reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.
Definition at line 925 of file system.C.
References get_vector().
00926 { 00927 std::ostringstream sensitivity_name; 00928 sensitivity_name << "sensitivity_solution" << i; 00929 00930 return this->get_vector(sensitivity_name.str()); 00931 }
| NumericVector< Number > & libMesh::System::get_sensitivity_solution | ( | unsigned int | i = 0 |
) |
- Returns:
- a reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.
Definition at line 915 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
00916 { 00917 std::ostringstream sensitivity_name; 00918 sensitivity_name << "sensitivity_solution" << i; 00919 00920 return this->get_vector(sensitivity_name.str()); 00921 }
| NumericVector< Number > & libMesh::System::get_vector | ( | const unsigned int | vec_num | ) |
- Returns:
- a writeable reference to this system's additional vector number
vec_num(where the vectors are counted starting with 0).
Definition at line 838 of file system.C.
References vectors_begin(), and vectors_end().
00839 { 00840 vectors_iterator v = vectors_begin(); 00841 vectors_iterator v_end = vectors_end(); 00842 unsigned int num = 0; 00843 while((num<vec_num) && (v!=v_end)) 00844 { 00845 num++; 00846 ++v; 00847 } 00848 libmesh_assert (v != v_end); 00849 return *(v->second); 00850 }
| const NumericVector< Number > & libMesh::System::get_vector | ( | const unsigned int | vec_num | ) | const |
- Returns:
- a const reference to this system's additional vector number
vec_num(where the vectors are counted starting with 0).
Definition at line 822 of file system.C.
References vectors_begin(), and vectors_end().
00823 { 00824 const_vectors_iterator v = vectors_begin(); 00825 const_vectors_iterator v_end = vectors_end(); 00826 unsigned int num = 0; 00827 while((num<vec_num) && (v!=v_end)) 00828 { 00829 num++; 00830 ++v; 00831 } 00832 libmesh_assert (v != v_end); 00833 return *(v->second); 00834 }
| NumericVector< Number > & libMesh::System::get_vector | ( | const std::string & | vec_name | ) |
- Returns:
- a writeable reference to this system's additional vector named
vec_name. Access is only granted when the vector is already properly initialized.
Definition at line 803 of file system.C.
References _vectors, and libMesh::err.
00804 { 00805 // Make sure the vector exists 00806 vectors_iterator pos = _vectors.find(vec_name); 00807 00808 if (pos == _vectors.end()) 00809 { 00810 libMesh::err << "ERROR: vector " 00811 << vec_name 00812 << " does not exist in this system!" 00813 << std::endl; 00814 libmesh_error(); 00815 } 00816 00817 return *(pos->second); 00818 }
| const NumericVector< Number > & libMesh::System::get_vector | ( | const std::string & | vec_name | ) | const |
- 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 784 of file system.C.
References _vectors, and libMesh::err.
Referenced by libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), compare(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), get_adjoint_rhs(), get_adjoint_solution(), get_sensitivity_rhs(), get_sensitivity_solution(), get_weighted_sensitivity_adjoint_solution(), get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().
00785 { 00786 // Make sure the vector exists 00787 const_vectors_iterator pos = _vectors.find(vec_name); 00788 00789 if (pos == _vectors.end()) 00790 { 00791 libMesh::err << "ERROR: vector " 00792 << vec_name 00793 << " does not exist in this system!" 00794 << std::endl; 00795 libmesh_error(); 00796 } 00797 00798 return *(pos->second); 00799 }
| const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 |
) | const |
- 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 1006 of file system.C.
References get_vector().
01007 { 01008 std::ostringstream adjoint_name; 01009 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 01010 01011 return this->get_vector(adjoint_name.str()); 01012 }
| NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 |
) |
- 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 996 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
00997 { 00998 std::ostringstream adjoint_name; 00999 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 01000 01001 return this->get_vector(adjoint_name.str()); 01002 }
| const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution | ( | ) | const |
- Returns:
- a reference to the solution of the last weighted sensitivity solve
Definition at line 949 of file system.C.
References get_vector().
00950 { 00951 return this->get_vector("weighted_sensitivity_solution"); 00952 }
| NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution | ( | ) |
- Returns:
- a reference to the solution of the last weighted sensitivity solve
Definition at line 942 of file system.C.
References get_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().
00943 { 00944 return this->get_vector("weighted_sensitivity_solution"); 00945 }
| bool libMesh::System::has_variable | ( | const std::string & | var | ) | const |
- Returns:
- true if a variable named
varexists in this System
Definition at line 1232 of file system.C.
References _variable_numbers.
Referenced by libMesh::GMVIO::copy_nodal_solution().
01233 { 01234 return _variable_numbers.count(var); 01235 }
| bool libMesh::System::have_vector | ( | const std::string & | vec_name | ) | const [inline] |
- Returns:
trueif thisSystemhas a vector associated with the given name,falseotherwise.
Definition at line 2018 of file system.h.
References _vectors.
Referenced by add_vector(), and remove_vector().
02019 { 02020 return (_vectors.count(vec_name)); 02021 }
| void libMesh::System::identify_variable_groups | ( | const bool | ivg | ) | [inline] |
Toggle automatic VariableGroup identification.
Definition at line 2002 of file system.h.
References _identify_variable_groups.
02003 { 02004 _identify_variable_groups = ivg; 02005 }
| bool libMesh::System::identify_variable_groups | ( | ) | const [inline] |
- Returns:
truewhenVariableGroupstructures should be automatically identified,falseotherwise.
Definition at line 1994 of file system.h.
References _identify_variable_groups.
Referenced by add_variable().
01995 { 01996 return _identify_variable_groups; 01997 }
| void libMesh::ReferenceCounter::increment_constructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 163 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
00164 { 00165 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00166 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00167 00168 p.first++; 00169 }
| void libMesh::ReferenceCounter::increment_destructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 176 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
00177 { 00178 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00179 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00180 00181 p.second++; 00182 }
| void libMesh::System::init | ( | ) |
Initializes degrees of freedom on the current mesh. Sets the
Definition at line 223 of file system.C.
References _basic_system_only, init_data(), n_vars(), and user_initialization().
00224 { 00225 // First initialize any required data: 00226 // either only the basic System data 00227 if (_basic_system_only) 00228 System::init_data(); 00229 // or all the derived class' data too 00230 else 00231 this->init_data(); 00232 00233 // If no variables have been added to this system 00234 // don't do anything 00235 if(!this->n_vars()) 00236 return; 00237 00238 // Then call the user-provided intialization function 00239 this->user_initialization(); 00240 }
| void libMesh::System::init_data | ( | ) | [protected, virtual] |
Initializes the data for the system. Note that this is called before any user-supplied intitialization function so that all required storage will be available.
Reimplemented in libMesh::ContinuationSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::FEMSystem, libMesh::FrequencySystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::RBEIMConstruction, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, and libMesh::TransientSystem< RBConstruction >.
Definition at line 244 of file system.C.
References _can_add_vectors, _dof_map, _vector_types, _vectors, current_local_solution, libMesh::err, get_mesh(), libMeshEnums::GHOSTED, mesh, n_dofs(), n_local_dofs(), n_variable_groups(), libMeshEnums::PARALLEL, libMeshEnums::SERIAL, solution, and user_constrain().
Referenced by init(), libMesh::ExplicitSystem::init_data(), and libMesh::EigenSystem::init_data().
00245 { 00246 MeshBase &mesh = this->get_mesh(); 00247 00248 // Add all variable groups to our underlying DofMap 00249 for (unsigned int vg=0; vg<this->n_variable_groups(); vg++) 00250 _dof_map->add_variable_group(this->variable_group(vg)); 00251 00252 // Distribute the degrees of freedom on the mesh 00253 _dof_map->distribute_dofs (mesh); 00254 00255 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00256 00257 // Recreate any hanging node constraints 00258 _dof_map->create_dof_constraints(mesh); 00259 00260 // Apply any user-defined constraints 00261 this->user_constrain(); 00262 00263 // Expand any recursive constraints 00264 _dof_map->process_constraints(mesh); 00265 00266 #endif 00267 00268 // And clean up the send_list before we first use it 00269 _dof_map->prepare_send_list(); 00270 00271 // Resize the solution conformal to the current mesh 00272 solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00273 00274 // Resize the current_local_solution for the current mesh 00275 #ifdef LIBMESH_ENABLE_GHOSTED 00276 current_local_solution->init (this->n_dofs(), this->n_local_dofs(), 00277 _dof_map->get_send_list(), false, 00278 GHOSTED); 00279 #else 00280 current_local_solution->init (this->n_dofs(), false, SERIAL); 00281 #endif 00282 00283 // from now on, no chance to add additional vectors 00284 _can_add_vectors = false; 00285 00286 // initialize & zero other vectors, if necessary 00287 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00288 { 00289 ParallelType type = _vector_types[pos->first]; 00290 00291 if (type == GHOSTED) 00292 { 00293 #ifdef LIBMESH_ENABLE_GHOSTED 00294 pos->second->init (this->n_dofs(), this->n_local_dofs(), 00295 _dof_map->get_send_list(), false, 00296 GHOSTED); 00297 #else 00298 libMesh::err << "Cannot initialize ghosted vectors when they are not enabled." << std::endl; 00299 libmesh_error(); 00300 #endif 00301 } 00302 else if (type == SERIAL) 00303 { 00304 pos->second->init (this->n_dofs(), false, type); 00305 } 00306 else 00307 { 00308 libmesh_assert_equal_to(type, PARALLEL); 00309 pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type); 00310 } 00311 } 00312 }
| bool libMesh::System::is_adjoint_already_solved | ( | ) | const [inline] |
Accessor for the adjoint_already_solved boolean
Definition at line 359 of file system.h.
References adjoint_already_solved.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
00360 { return adjoint_already_solved;}
| void libMesh::System::local_dof_indices | ( | const unsigned int | var, | |
| std::set< dof_id_type > & | var_indices | |||
| ) | const |
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.
Definition at line 1278 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(), get_dof_map(), and get_mesh().
Referenced by discrete_var_norm().
01280 { 01281 // Make sure the set is clear 01282 var_indices.clear(); 01283 01284 std::vector<dof_id_type> dof_indices; 01285 01286 // Begin the loop over the elements 01287 MeshBase::const_element_iterator el = 01288 this->get_mesh().active_local_elements_begin(); 01289 const MeshBase::const_element_iterator end_el = 01290 this->get_mesh().active_local_elements_end(); 01291 01292 const dof_id_type 01293 first_local = this->get_dof_map().first_dof(), 01294 end_local = this->get_dof_map().end_dof(); 01295 01296 for ( ; el != end_el; ++el) 01297 { 01298 const Elem* elem = *el; 01299 this->get_dof_map().dof_indices (elem, dof_indices, var); 01300 01301 for(unsigned int i=0; i<dof_indices.size(); i++) 01302 { 01303 dof_id_type dof = dof_indices[i]; 01304 01305 //If the dof is owned by the local processor 01306 if(first_local <= dof && dof < end_local) 01307 var_indices.insert(dof_indices[i]); 01308 } 01309 } 01310 }
| dof_id_type libMesh::System::n_active_dofs | ( | ) | const [inline] |
Returns the number of active degrees of freedom for this System.
Definition at line 2010 of file system.h.
References n_constrained_dofs(), and n_dofs().
02011 { 02012 return this->n_dofs() - this->n_constrained_dofs(); 02013 }
| unsigned int libMesh::System::n_components | ( | ) | const [inline] |
- 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 1914 of file system.h.
References _variables, libMesh::Variable::first_scalar_number(), and libMesh::Variable::n_components().
Referenced by add_variables(), libMesh::WrappedFunction< Output >::operator()(), and project_vector().
01915 { 01916 if (_variables.empty()) 01917 return 0; 01918 01919 const Variable& last = _variables.back(); 01920 return last.first_scalar_number() + last.n_components(); 01921 }
| dof_id_type libMesh::System::n_constrained_dofs | ( | ) | const |
- Returns:
- the total number of constrained degrees of freedom in the system.
Definition at line 144 of file system.C.
References _dof_map.
Referenced by get_info(), and n_active_dofs().
00145 { 00146 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00147 00148 return _dof_map->n_constrained_dofs(); 00149 00150 #else 00151 00152 return 0; 00153 00154 #endif 00155 }
| dof_id_type libMesh::System::n_dofs | ( | ) | const |
- Returns:
- the number of degrees of freedom in the system
Definition at line 137 of file system.C.
References _dof_map.
Referenced by add_vector(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::UnsteadySolver::init_data(), init_data(), n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), project_vector(), read_legacy_data(), libMesh::UnsteadySolver::reinit(), reinit(), and restrict_vectors().
00138 { 00139 return _dof_map->n_dofs(); 00140 }
| dof_id_type libMesh::System::n_local_constrained_dofs | ( | ) | const |
- Returns:
- the number of constrained degrees of freedom on this processor.
Definition at line 159 of file system.C.
References _dof_map.
Referenced by get_info().
00160 { 00161 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00162 00163 return _dof_map->n_local_constrained_dofs(); 00164 00165 #else 00166 00167 return 0; 00168 00169 #endif 00170 }
| dof_id_type libMesh::System::n_local_dofs | ( | ) | const |
- Returns:
- the number of degrees of freedom local to this processor
Definition at line 174 of file system.C.
References _dof_map, and libMesh::processor_id().
Referenced by add_vector(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::UnsteadySolver::init_data(), init_data(), project_vector(), libMesh::UnsteadySolver::reinit(), reinit(), and restrict_vectors().
00175 { 00176 return _dof_map->n_dofs_on_processor (libMesh::processor_id()); 00177 }
| unsigned int libMesh::System::n_matrices | ( | ) | const [inline, virtual] |
- Returns:
- the number of matrices handled by this system.
This will return 0 by default but can be overriden.
Reimplemented in libMesh::EigenSystem, and libMesh::ImplicitSystem.
Definition at line 2032 of file system.h.
Referenced by get_info().
| static unsigned int libMesh::ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 79 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
00080 { return _n_objects; }
| unsigned int libMesh::System::n_variable_groups | ( | ) | const [inline] |
- Returns:
- the number of
VariableGroupvariable groups in the system
Definition at line 1906 of file system.h.
References _variable_groups.
Referenced by add_variable(), get_info(), and init_data().
01907 { 01908 return libmesh_cast_int<unsigned int>(_variable_groups.size()); 01909 }
| unsigned int libMesh::System::n_vars | ( | ) | const [inline] |
- Returns:
- the number of variables in the system
Definition at line 1898 of file system.h.
References _variables.
Referenced by libMesh::DiffContext::add_localized_vector(), add_variable(), add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), calculate_norm(), libMesh::WrappedFunction< Output >::component(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::FEMContext(), get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), init(), libMesh::FEMSystem::init_context(), libMesh::WrappedFunction< Output >::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::FEMContext::pre_fe_reinit(), project_vector(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), read_serialized_vector(), read_serialized_vectors(), reinit(), libMesh::EquationSystems::reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), write_header(), write_parallel_data(), write_serialized_blocked_dof_objects(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().
01899 { 01900 return libmesh_cast_int<unsigned int>(_variables.size()); 01901 }
| unsigned int libMesh::System::n_vectors | ( | ) | const [inline] |
- Returns:
- the number of vectors (in addition to the solution) handled by this system This is the size of the
_vectorsmap
Definition at line 2026 of file system.h.
References _vectors.
Referenced by libMesh::ExplicitSystem::add_system_rhs(), compare(), get_info(), and write_header().
02027 { 02028 return libmesh_cast_int<unsigned int>(_vectors.size()); 02029 }
| const std::string & libMesh::System::name | ( | ) | const [inline] |
- Returns:
- the system name.
Definition at line 1818 of file system.h.
References _sys_name.
Referenced by compare(), libMesh::WrappedFunction< Output >::component(), DMLibMeshSetUpName_Private(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactSolution::ExactSolution(), libMesh::ExactErrorEstimator::find_squared_element_error(), get_info(), libMesh::WrappedFunction< Output >::operator()(), libMesh::FrequencySystem::solve(), user_assembly(), user_constrain(), user_initialization(), user_QOI(), user_QOI_derivative(), write_header(), write_parallel_data(), and write_serialized_data().
01819 { 01820 return _sys_name; 01821 }
| unsigned int libMesh::System::number | ( | ) | const [inline] |
- Returns:
- the system number.
Definition at line 1826 of file system.h.
References _sys_number.
Referenced by libMesh::ExactSolution::_compute_error(), add_variable(), add_variables(), libMesh::ExactErrorEstimator::find_squared_element_error(), get_info(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), libMesh::HPCoarsenTest::select_refinement(), write_parallel_data(), write_serialized_blocked_dof_objects(), and zero_variable().
01827 { 01828 return _sys_number; 01829 }
| Gradient libMesh::System::point_gradient | ( | unsigned int | var, | |
| const Point & | p, | |||
| const Elem & | e | |||
| ) | const |
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 2110 of file system.C.
References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< Real >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::processor_id(), and libMesh::DofObject::processor_id().
02111 { 02112 libmesh_assert_equal_to (e.processor_id(), libMesh::processor_id()); 02113 02114 // Ensuring that the given point is really in the element is an 02115 // expensive assert, but as long as debugging is turned on we might 02116 // as well try to catch a particularly nasty potential error 02117 libmesh_assert (e.contains_point(p)); 02118 02119 // Get the dof map to get the proper indices for our computation 02120 const DofMap& dof_map = this->get_dof_map(); 02121 02122 // Need dof_indices for phi[i][j] 02123 std::vector<dof_id_type> dof_indices; 02124 02125 // Fill in the dof_indices for our element 02126 dof_map.dof_indices (&e, dof_indices, var); 02127 02128 // Get the no of dofs assciated with this point 02129 const unsigned int num_dofs = libmesh_cast_int<unsigned int> 02130 (dof_indices.size()); 02131 02132 FEType fe_type = dof_map.variable_type(0); 02133 02134 // Build a FE again so we can calculate u(p) 02135 AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type)); 02136 02137 // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h 02138 // Build a vector of point co-ordinates to send to reinit 02139 std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p)); 02140 02141 // Get the values of the shape function derivatives 02142 const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi(); 02143 02144 // Reinitialize the element and compute the shape function values at coor 02145 fe->reinit (&e, &coor); 02146 02147 // Get ready to accumulate a gradient 02148 Gradient grad_u; 02149 02150 for (unsigned int l=0; l<num_dofs; l++) 02151 { 02152 grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l])); 02153 } 02154 02155 return grad_u; 02156 }
| Gradient libMesh::System::point_gradient | ( | unsigned int | var, | |
| const Point & | p, | |||
| const bool | insist_on_success = true | |||
| ) | const |
Returns the gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.
Definition at line 2062 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::CommWorld, libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::n_processors(), libMesh::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
02063 { 02064 // This function must be called on every processor; there's no 02065 // telling where in the partition p falls. 02066 parallel_only(); 02067 02068 // And every processor had better agree about which point we're 02069 // looking for 02070 #ifndef NDEBUG 02071 CommWorld.verify(p); 02072 #endif // NDEBUG 02073 02074 // Get a reference to the mesh object associated with the system object that calls this function 02075 const MeshBase &mesh = this->get_mesh(); 02076 02077 // Use an existing PointLocator or create a new one 02078 AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator(); 02079 PointLocatorBase& locator = *locator_ptr; 02080 02081 if (!insist_on_success) 02082 locator.enable_out_of_mesh_mode(); 02083 02084 // Get a pointer to the element that contains P 02085 const Elem *e = locator(p); 02086 02087 Gradient grad_u; 02088 02089 if (e && e->processor_id() == libMesh::processor_id()) 02090 grad_u = point_gradient(var, p, *e); 02091 02092 // If I have an element containing p, then let's let everyone know 02093 processor_id_type lowest_owner = 02094 (e && (e->processor_id() == libMesh::processor_id())) ? 02095 libMesh::processor_id() : libMesh::n_processors(); 02096 CommWorld.min(lowest_owner); 02097 02098 // Everybody should get their value from a processor that was able 02099 // to compute it. 02100 // If nobody admits owning the point, we may have a problem. 02101 if (lowest_owner != libMesh::n_processors()) 02102 CommWorld.broadcast(grad_u, lowest_owner); 02103 else 02104 libmesh_assert(!insist_on_success); 02105 02106 return grad_u; 02107 }
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 2208 of file system.C.
References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< Real >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::processor_id(), and libMesh::DofObject::processor_id().
02209 { 02210 libmesh_assert_equal_to (e.processor_id(), libMesh::processor_id()); 02211 02212 // Ensuring that the given point is really in the element is an 02213 // expensive assert, but as long as debugging is turned on we might 02214 // as well try to catch a particularly nasty potential error 02215 libmesh_assert (e.contains_point(p)); 02216 02217 // Get the dof map to get the proper indices for our computation 02218 const DofMap& dof_map = this->get_dof_map(); 02219 02220 // Need dof_indices for phi[i][j] 02221 std::vector<dof_id_type> dof_indices; 02222 02223 // Fill in the dof_indices for our element 02224 dof_map.dof_indices (&e, dof_indices, var); 02225 02226 // Get the no of dofs assciated with this point 02227 const unsigned int num_dofs = libmesh_cast_int<unsigned int> 02228 (dof_indices.size()); 02229 02230 FEType fe_type = dof_map.variable_type(0); 02231 02232 // Build a FE again so we can calculate u(p) 02233 AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type)); 02234 02235 // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h 02236 // Build a vector of point co-ordinates to send to reinit 02237 std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p)); 02238 02239 // Get the values of the shape function derivatives 02240 const std::vector<std::vector<RealTensor> >& d2phi = fe->get_d2phi(); 02241 02242 // Reinitialize the element and compute the shape function values at coor 02243 fe->reinit (&e, &coor); 02244 02245 // Get ready to accumulate a hessian 02246 Tensor hess_u; 02247 02248 for (unsigned int l=0; l<num_dofs; l++) 02249 { 02250 hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l])); 02251 } 02252 02253 return hess_u; 02254 }
| Tensor libMesh::System::point_hessian | ( | unsigned int | var, | |
| const Point & | p, | |||
| const bool | insist_on_success = true | |||
| ) | const |
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 2161 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::CommWorld, libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::n_processors(), libMesh::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
02162 { 02163 // This function must be called on every processor; there's no 02164 // telling where in the partition p falls. 02165 parallel_only(); 02166 02167 // And every processor had better agree about which point we're 02168 // looking for 02169 #ifndef NDEBUG 02170 CommWorld.verify(p); 02171 #endif // NDEBUG 02172 02173 // Get a reference to the mesh object associated with the system object that calls this function 02174 const MeshBase &mesh = this->get_mesh(); 02175 02176 // Use an existing PointLocator or create a new one 02177 AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator(); 02178 PointLocatorBase& locator = *locator_ptr; 02179 02180 if (!insist_on_success) 02181 locator.enable_out_of_mesh_mode(); 02182 02183 // Get a pointer to the element that contains P 02184 const Elem *e = locator(p); 02185 02186 Tensor hess_u; 02187 02188 if (e && e->processor_id() == libMesh::processor_id()) 02189 hess_u = point_hessian(var, p, *e); 02190 02191 // If I have an element containing p, then let's let everyone know 02192 processor_id_type lowest_owner = 02193 (e && (e->processor_id() == libMesh::processor_id())) ? 02194 libMesh::processor_id() : libMesh::n_processors(); 02195 CommWorld.min(lowest_owner); 02196 02197 // Everybody should get their value from a processor that was able 02198 // to compute it. 02199 // If nobody admits owning the point, we may have a problem. 02200 if (lowest_owner != libMesh::n_processors()) 02201 CommWorld.broadcast(hess_u, lowest_owner); 02202 else 02203 libmesh_assert(!insist_on_success); 02204 02205 return hess_u; 02206 }
Returns the value of the solution variable var at the physical point p contained in local Elem e
This version of point_value can be run in serial, but assumes e is in the local mesh partition.
Definition at line 2012 of file system.C.
References libMesh::FEGenericBase< Real >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::processor_id(), and libMesh::DofObject::processor_id().
02013 { 02014 libmesh_assert_equal_to (e.processor_id(), libMesh::processor_id()); 02015 02016 // Ensuring that the given point is really in the element is an 02017 // expensive assert, but as long as debugging is turned on we might 02018 // as well try to catch a particularly nasty potential error 02019 libmesh_assert (e.contains_point(p)); 02020 02021 // Get the dof map to get the proper indices for our computation 02022 const DofMap& dof_map = this->get_dof_map(); 02023 02024 // Need dof_indices for phi[i][j] 02025 std::vector<dof_id_type> dof_indices; 02026 02027 // Fill in the dof_indices for our element 02028 dof_map.dof_indices (&e, dof_indices, var); 02029 02030 // Get the no of dofs assciated with this point 02031 const unsigned int num_dofs = libmesh_cast_int<unsigned int> 02032 (dof_indices.size()); 02033 02034 FEType fe_type = dof_map.variable_type(0); 02035 02036 // Build a FE so we can calculate u(p) 02037 AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type)); 02038 02039 // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h 02040 // Build a vector of point co-ordinates to send to reinit 02041 std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p)); 02042 02043 // Get the shape function values 02044 const std::vector<std::vector<Real> >& phi = fe->get_phi(); 02045 02046 // Reinitialize the element and compute the shape function values at coor 02047 fe->reinit (&e, &coor); 02048 02049 // Get ready to accumulate a value 02050 Number u = 0; 02051 02052 for (unsigned int l=0; l<num_dofs; l++) 02053 { 02054 u += phi[l][0]*this->current_solution (dof_indices[l]); 02055 } 02056 02057 return u; 02058 }
| Number libMesh::System::point_value | ( | unsigned int | var, | |
| const Point & | p, | |||
| const bool | insist_on_success = true | |||
| ) | const |
Returns the value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p.
Note that this function uses MeshBase::sub_point_locator(); users may or may not want to call MeshBase::clear_point_locator() afterward. Also, point_locator() is expensive (N log N for initial construction, log N for evaluations). Avoid using this function in any context where you are already looping over elements.
Because the element containing p may lie on any processor, this function is parallel-only.
By default this method expects the point to reside inside the domain and will abort if no element can be found which contains . The optional parameter insist_on_success can be set to false to allow the method to return 0 when the point is not located.
Definition at line 1965 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::CommWorld, libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::n_processors(), libMesh::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
01966 { 01967 // This function must be called on every processor; there's no 01968 // telling where in the partition p falls. 01969 parallel_only(); 01970 01971 // And every processor had better agree about which point we're 01972 // looking for 01973 #ifndef NDEBUG 01974 CommWorld.verify(p); 01975 #endif // NDEBUG 01976 01977 // Get a reference to the mesh object associated with the system object that calls this function 01978 const MeshBase &mesh = this->get_mesh(); 01979 01980 // Use an existing PointLocator or create a new one 01981 AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator(); 01982 PointLocatorBase& locator = *locator_ptr; 01983 01984 if (!insist_on_success) 01985 locator.enable_out_of_mesh_mode(); 01986 01987 // Get a pointer to the element that contains P 01988 const Elem *e = locator(p); 01989 01990 Number u = 0; 01991 01992 if (e && e->processor_id() == libMesh::processor_id()) 01993 u = point_value(var, p, *e); 01994 01995 // If I have an element containing p, then let's let everyone know 01996 processor_id_type lowest_owner = 01997 (e && (e->processor_id() == libMesh::processor_id())) ? 01998 libMesh::processor_id() : libMesh::n_processors(); 01999 CommWorld.min(lowest_owner); 02000 02001 // Everybody should get their value from a processor that was able 02002 // to compute it. 02003 // If nobody admits owning the point, we have a problem. 02004 if (lowest_owner != libMesh::n_processors()) 02005 CommWorld.broadcast(u, lowest_owner); 02006 else 02007 libmesh_assert(!insist_on_success); 02008 02009 return u; 02010 }
| void libMesh::ReferenceCounter::print_info | ( | std::ostream & | out = libMesh::out |
) | [static, inherited] |
Prints the reference information, by default to libMesh::out.
Definition at line 88 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().
00089 { 00090 if( _enable_print_counter ) out_stream << ReferenceCounter::get_info(); 00091 }
| void libMesh::System::project_solution | ( | Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| const Parameters & | parameters | |||
| ) | const |
Projects arbitrary functions onto the current solution. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 450 of file system_projection.C.
References project_solution().
00459 { 00460 WrappedFunction<Number> f(*this, fptr, ¶meters); 00461 WrappedFunction<Gradient> g(*this, gptr, ¶meters); 00462 this->project_solution(&f, &g); 00463 }
| void libMesh::System::project_solution | ( | FEMFunctionBase< Number > * | f, | |
| FEMFunctionBase< Gradient > * | g = NULL | |||
| ) | const |
Projects arbitrary functions onto the current solution. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 483 of file system_projection.C.
References _dof_map, current_local_solution, project_vector(), and solution.
00485 { 00486 this->project_vector(*solution, f, g); 00487 00488 solution->localize(*current_local_solution, _dof_map->get_send_list()); 00489 }
| void libMesh::System::project_solution | ( | FunctionBase< Number > * | f, | |
| FunctionBase< Gradient > * | g = NULL | |||
| ) | const |
Projects arbitrary functions onto the current solution. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 470 of file system_projection.C.
References _dof_map, current_local_solution, project_vector(), and solution.
Referenced by project_solution().
00472 { 00473 this->project_vector(*solution, f, g); 00474 00475 solution->localize(*current_local_solution, _dof_map->get_send_list()); 00476 }
| bool& libMesh::System::project_solution_on_reinit | ( | void | ) | [inline] |
Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. The solution will be projected unless project_solution_on_reinit() = false is called.
Definition at line 761 of file system.h.
References _solution_projection.
Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemorySolutionHistory::store().
00762 { return _solution_projection; }
| void libMesh::System::project_vector | ( | const NumericVector< Number > & | old_v, | |
| NumericVector< Number > & | new_v | |||
| ) | const [protected] |
Projects the vector defined on the old mesh onto the new mesh. The original vector is unchanged and the new vector is passed through the second argument.
This method projects the vector via L2 projections or nodal interpolations on each element.
This method projects a solution from an old mesh to a current, refined mesh. The input vector old_v gives the solution on the old mesh, while the new_v gives the solution (to be computed) on the new mesh.
Definition at line 272 of file system_projection.C.
References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::err, libMesh::FEType::family, libMesh::AutoPtr< Tp >::get(), get_dof_map(), get_mesh(), libMeshEnums::GHOSTED, libMesh::NumericVector< T >::init(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), n_dofs(), n_local_dofs(), libMesh::n_processors(), n_vars(), libMeshEnums::PARALLEL, libMesh::Threads::parallel_for(), libMesh::Threads::parallel_reduce(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMeshEnums::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::Variable::type(), libMesh::NumericVector< T >::type(), libMesh::BuildProjectionList::unique(), and variable().
00274 { 00275 START_LOG ("project_vector()", "System"); 00276 00283 new_v.clear(); 00284 00285 #ifdef LIBMESH_ENABLE_AMR 00286 00287 // Resize the new vector and get a serial version. 00288 NumericVector<Number> *new_vector_ptr = NULL; 00289 AutoPtr<NumericVector<Number> > new_vector_built; 00290 NumericVector<Number> *local_old_vector; 00291 AutoPtr<NumericVector<Number> > local_old_vector_built; 00292 const NumericVector<Number> *old_vector_ptr = NULL; 00293 00294 ConstElemRange active_local_elem_range 00295 (this->get_mesh().active_local_elements_begin(), 00296 this->get_mesh().active_local_elements_end()); 00297 00298 // If the old vector was uniprocessor, make the new 00299 // vector uniprocessor 00300 if (old_v.type() == SERIAL) 00301 { 00302 new_v.init (this->n_dofs(), false, SERIAL); 00303 new_vector_ptr = &new_v; 00304 old_vector_ptr = &old_v; 00305 } 00306 00307 // Otherwise it is a parallel, distributed vector, which 00308 // we need to localize. 00309 else if (old_v.type() == PARALLEL) 00310 { 00311 // Build a send list for efficient localization 00312 BuildProjectionList projection_list(*this); 00313 Threads::parallel_reduce (active_local_elem_range, 00314 projection_list); 00315 00316 // Create a sorted, unique send_list 00317 projection_list.unique(); 00318 00319 new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00320 new_vector_built = NumericVector<Number>::build(); 00321 local_old_vector_built = NumericVector<Number>::build(); 00322 new_vector_ptr = new_vector_built.get(); 00323 local_old_vector = local_old_vector_built.get(); 00324 new_vector_ptr->init(this->n_dofs(), false, SERIAL); 00325 local_old_vector->init(old_v.size(), false, SERIAL); 00326 old_v.localize(*local_old_vector, projection_list.send_list); 00327 local_old_vector->close(); 00328 old_vector_ptr = local_old_vector; 00329 } 00330 else if (old_v.type() == GHOSTED) 00331 { 00332 // Build a send list for efficient localization 00333 BuildProjectionList projection_list(*this); 00334 Threads::parallel_reduce (active_local_elem_range, 00335 projection_list); 00336 00337 // Create a sorted, unique send_list 00338 projection_list.unique(); 00339 00340 new_v.init (this->n_dofs(), this->n_local_dofs(), 00341 this->get_dof_map().get_send_list(), false, GHOSTED); 00342 00343 local_old_vector_built = NumericVector<Number>::build(); 00344 new_vector_ptr = &new_v; 00345 local_old_vector = local_old_vector_built.get(); 00346 local_old_vector->init(old_v.size(), old_v.local_size(), 00347 projection_list.send_list, false, GHOSTED); 00348 old_v.localize(*local_old_vector, projection_list.send_list); 00349 local_old_vector->close(); 00350 old_vector_ptr = local_old_vector; 00351 } 00352 else // unknown old_v.type() 00353 { 00354 libMesh::err << "ERROR: Unknown old_v.type() == " << old_v.type() 00355 << std::endl; 00356 libmesh_error(); 00357 } 00358 00359 // Note that the above will have zeroed the new_vector. 00360 // Just to be sure, assert that new_vector_ptr and old_vector_ptr 00361 // were successfully set before trying to deref them. 00362 libmesh_assert(new_vector_ptr); 00363 libmesh_assert(old_vector_ptr); 00364 00365 NumericVector<Number> &new_vector = *new_vector_ptr; 00366 const NumericVector<Number> &old_vector = *old_vector_ptr; 00367 00368 Threads::parallel_for (active_local_elem_range, 00369 ProjectVector(*this, 00370 old_vector, 00371 new_vector) 00372 ); 00373 00374 // Copy the SCALAR dofs from old_vector to new_vector 00375 // Note: We assume that all SCALAR dofs are on the 00376 // processor with highest ID 00377 if(libMesh::processor_id() == (libMesh::n_processors()-1)) 00378 { 00379 const DofMap& dof_map = this->get_dof_map(); 00380 for (unsigned int var=0; var<this->n_vars(); var++) 00381 if(this->variable(var).type().family == SCALAR) 00382 { 00383 // We can just map SCALAR dofs directly across 00384 std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices; 00385 dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false); 00386 dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true); 00387 const unsigned int new_n_dofs = 00388 libmesh_cast_int<unsigned int>(new_SCALAR_indices.size()); 00389 00390 for (unsigned int i=0; i<new_n_dofs; i++) 00391 { 00392 new_vector.set( new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]) ); 00393 } 00394 } 00395 } 00396 00397 new_vector.close(); 00398 00399 // If the old vector was serial, we probably need to send our values 00400 // to other processors 00401 // 00402 // FIXME: I'm not sure how to make a NumericVector do that without 00403 // creating a temporary parallel vector to use localize! - RHS 00404 if (old_v.type() == SERIAL) 00405 { 00406 AutoPtr<NumericVector<Number> > dist_v = NumericVector<Number>::build(); 00407 dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00408 dist_v->close(); 00409 00410 for (dof_id_type i=0; i!=dist_v->size(); i++) 00411 if (new_vector(i) != 0.0) 00412 dist_v->set(i, new_vector(i)); 00413 00414 dist_v->close(); 00415 00416 dist_v->localize (new_v, this->get_dof_map().get_send_list()); 00417 new_v.close(); 00418 } 00419 // If the old vector was parallel, we need to update it 00420 // and free the localized copies 00421 else if (old_v.type() == PARALLEL) 00422 { 00423 // We may have to set dof values that this processor doesn't 00424 // own in certain special cases, like LAGRANGE FIRST or 00425 // HERMITE THIRD elements on second-order meshes 00426 for (dof_id_type i=0; i!=new_v.size(); i++) 00427 if (new_vector(i) != 0.0) 00428 new_v.set(i, new_vector(i)); 00429 new_v.close(); 00430 } 00431 00432 this->get_dof_map().enforce_constraints_exactly(*this, &new_v); 00433 00434 #else 00435 00436 // AMR is disabled: simply copy the vector 00437 new_v = old_v; 00438 00439 #endif // #ifdef LIBMESH_ENABLE_AMR 00440 00441 STOP_LOG("project_vector()", "System"); 00442 }
| void libMesh::System::project_vector | ( | NumericVector< Number > & | vector | ) | const [protected] |
Projects the vector defined on the old mesh onto the new mesh.
Definition at line 255 of file system_projection.C.
References libMesh::NumericVector< T >::clone(), and project_vector().
00256 { 00257 // Create a copy of the vector, which currently 00258 // contains the old data. 00259 AutoPtr<NumericVector<Number> > 00260 old_vector (vector.clone()); 00261 00262 // Project the old vector to the new vector 00263 this->project_vector (*old_vector, vector); 00264 }
| void libMesh::System::project_vector | ( | Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | |||
| const Parameters & | parameters, | |||
| NumericVector< Number > & | new_vector | |||
| ) | const |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 496 of file system_projection.C.
References project_vector().
00506 { 00507 WrappedFunction<Number> f(*this, fptr, ¶meters); 00508 WrappedFunction<Gradient> g(*this, gptr, ¶meters); 00509 this->project_vector(new_vector, &f, &g); 00510 }
| void libMesh::System::project_vector | ( | NumericVector< Number > & | new_vector, | |
| FEMFunctionBase< Number > * | f, | |||
| FEMFunctionBase< Gradient > * | g = NULL | |||
| ) | const |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 579 of file system_projection.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::n_processors(), n_vars(), libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), time, libMesh::Variable::type(), variable(), and variable_scalar_number().
00582 { 00583 START_LOG ("project_fem_vector()", "System"); 00584 00585 Threads::parallel_for 00586 (ConstElemRange (this->get_mesh().active_local_elements_begin(), 00587 this->get_mesh().active_local_elements_end() ), 00588 ProjectFEMSolution(*this, f, g, new_vector) 00589 ); 00590 00591 // Also, load values into the SCALAR dofs 00592 // Note: We assume that all SCALAR dofs are on the 00593 // processor with highest ID 00594 if(libMesh::processor_id() == (libMesh::n_processors()-1)) 00595 { 00596 // FIXME: Do we want to first check for SCALAR vars before building this? [PB] 00597 FEMContext context( *this ); 00598 00599 const DofMap& dof_map = this->get_dof_map(); 00600 for (unsigned int var=0; var<this->n_vars(); var++) 00601 if(this->variable(var).type().family == SCALAR) 00602 { 00603 // FIXME: We reinit with an arbitrary element in case the user 00604 // doesn't override FEMFunctionBase::component. Is there 00605 // any use case we're missing? [PB] 00606 Elem *el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin())); 00607 context.pre_fe_reinit( *this, el ); 00608 00609 std::vector<dof_id_type> SCALAR_indices; 00610 dof_map.SCALAR_dof_indices (SCALAR_indices, var); 00611 const unsigned int n_SCALAR_dofs = 00612 libmesh_cast_int<unsigned int>(SCALAR_indices.size()); 00613 00614 for (unsigned int i=0; i<n_SCALAR_dofs; i++) 00615 { 00616 const dof_id_type global_index = SCALAR_indices[i]; 00617 const unsigned int component_index = 00618 this->variable_scalar_number(var,i); 00619 00620 new_vector.set(global_index, f->component(context, component_index, Point(), this->time)); 00621 } 00622 } 00623 } 00624 00625 new_vector.close(); 00626 00627 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00628 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector); 00629 #endif 00630 00631 STOP_LOG("project_fem_vector()", "System"); 00632 }
| void libMesh::System::project_vector | ( | NumericVector< Number > & | new_vector, | |
| FunctionBase< Number > * | f, | |||
| FunctionBase< Gradient > * | g = NULL | |||
| ) | const |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 516 of file system_projection.C.
References libMesh::NumericVector< T >::close(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, get_dof_map(), get_equation_systems(), get_mesh(), n_components(), libMesh::n_processors(), n_vars(), libMesh::Threads::parallel_for(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), time, libMesh::Variable::type(), variable(), and variable_scalar_number().
Referenced by project_solution(), project_vector(), and restrict_vectors().
00519 { 00520 START_LOG ("project_vector()", "System"); 00521 00522 Threads::parallel_for 00523 (ConstElemRange (this->get_mesh().active_local_elements_begin(), 00524 this->get_mesh().active_local_elements_end() ), 00525 ProjectSolution(*this, f, g, 00526 this->get_equation_systems().parameters, 00527 new_vector) 00528 ); 00529 00530 // Also, load values into the SCALAR dofs 00531 // Note: We assume that all SCALAR dofs are on the 00532 // processor with highest ID 00533 if(libMesh::processor_id() == (libMesh::n_processors()-1)) 00534 { 00535 // We get different scalars as different 00536 // components from a new-style f functor. 00537 DenseVector<Number> fout(this->n_components()); 00538 bool filled_fout = false; 00539 00540 const DofMap& dof_map = this->get_dof_map(); 00541 for (unsigned int var=0; var<this->n_vars(); var++) 00542 if(this->variable(var).type().family == SCALAR) 00543 { 00544 if (!filled_fout) 00545 { 00546 (*f) (Point(), this->time, fout); 00547 filled_fout = true; 00548 } 00549 00550 std::vector<dof_id_type> SCALAR_indices; 00551 dof_map.SCALAR_dof_indices (SCALAR_indices, var); 00552 const unsigned int n_SCALAR_dofs = 00553 libmesh_cast_int<unsigned int>(SCALAR_indices.size()); 00554 00555 for (unsigned int i=0; i<n_SCALAR_dofs; i++) 00556 { 00557 const dof_id_type global_index = SCALAR_indices[i]; 00558 const unsigned int component_index = 00559 this->variable_scalar_number(var,i); 00560 new_vector.set(global_index, fout(component_index)); 00561 } 00562 } 00563 } 00564 00565 new_vector.close(); 00566 00567 #ifdef LIBMESH_ENABLE_CONSTRAINTS 00568 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector); 00569 #endif 00570 00571 STOP_LOG("project_vector()", "System"); 00572 }
| void libMesh::System::prolong_vectors | ( | ) | [virtual] |
Prolong vectors after the mesh has refined
Definition at line 368 of file system.C.
References restrict_vectors().
Referenced by libMesh::EquationSystems::reinit().
00369 { 00370 #ifdef LIBMESH_ENABLE_AMR 00371 // Currently project_vector handles both restriction and prolongation 00372 this->restrict_vectors(); 00373 #endif 00374 }
| void libMesh::System::qoi_parameter_hessian | ( | const QoISet & | qoi_indices, | |
| const ParameterVector & | parameters, | |||
| SensitivityData & | hessian | |||
| ) | [inline, virtual] |
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| void libMesh::System::qoi_parameter_hessian_vector_product | ( | const QoISet & | qoi_indices, | |
| const ParameterVector & | parameters, | |||
| const ParameterVector & | vector, | |||
| SensitivityData & | product | |||
| ) | [inline, virtual] |
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j].
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| void libMesh::System::qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, | |
| const ParameterVector & | parameters, | |||
| SensitivityData & | sensitivities | |||
| ) | [virtual] |
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
Note that parameters is a const vector, not a vector-of-const; parameter values in this vector need to be mutable for finite differencing to work.
Automatically chooses the forward method for problems with more quantities of interest than parameters, or the adjoint method otherwise.
This method is only usable in derived classes which overload an implementation.
Definition at line 509 of file system.C.
References libMesh::ParameterVector::size(), and libMesh::QoISet::size().
00512 { 00513 // Forward sensitivities are more efficient for Nq > Np 00514 if (qoi_indices.size(*this) > parameters.size()) 00515 forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities); 00516 // Adjoint sensitivities are more efficient for Np > Nq, 00517 // and an adjoint may be more reusable than a forward 00518 // solution sensitivity in the Np == Nq case. 00519 else 00520 adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities); 00521 }
| void libMesh::System::re_update | ( | ) | [virtual] |
Re-update the local values when the mesh has changed. This method takes the data updated by update() and makes it up-to-date on the current mesh.
Reimplemented in libMesh::TransientSystem< RBConstruction >.
Definition at line 431 of file system.C.
References current_local_solution, get_dof_map(), libMesh::DofMap::get_send_list(), n_vars(), and solution.
00432 { 00433 parallel_only(); 00434 00435 // If this system is empty... don't do anything! 00436 if(!this->n_vars()) 00437 return; 00438 00439 const std::vector<dof_id_type>& send_list = this->get_dof_map().get_send_list (); 00440 00441 // Check sizes 00442 libmesh_assert_equal_to (current_local_solution->size(), solution->size()); 00443 // Not true with ghosted vectors 00444 // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size()); 00445 // libmesh_assert (!send_list.empty()); 00446 libmesh_assert_less_equal (send_list.size(), solution->size()); 00447 00448 // Create current_local_solution from solution. This will 00449 // put a local copy of solution into current_local_solution. 00450 solution->localize (*current_local_solution, send_list); 00451 }
| void libMesh::System::read_header | ( | Xdr & | io, | |
| const std::string & | version, | |||
| const bool | read_header = true, |
|||
| const bool | read_additional_data = true, |
|||
| const bool | read_legacy_format = false | |||
| ) |
Reads the basic data header for this System.
Definition at line 113 of file system_io.C.
References _additional_data_written, _written_var_indices, add_variable(), add_vector(), libMesh::Parallel::Communicator::broadcast(), clear(), libMesh::CommWorld, libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::FEType::inf_map, libMesh::MeshBase::mesh_dimension(), libMeshEnums::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), variable_number(), libMesh::Xdr::version(), and libMeshEnums::XYZ.
Referenced by libMesh::EquationSystems::_read_impl().
00118 { 00119 // This method implements the input of a 00120 // System object, embedded in the output of 00121 // an EquationSystems<T_sys>. This warrants some 00122 // documentation. The output file essentially 00123 // consists of 5 sections: 00124 // 00125 // for this system 00126 // 00127 // 5.) The number of variables in the system (unsigned int) 00128 // 00129 // for each variable in the system 00130 // 00131 // 6.) The name of the variable (string) 00132 // 00133 // 6.1.) Variable subdmains 00134 // 00135 // 7.) Combined in an FEType: 00136 // - The approximation order(s) of the variable 00137 // (Order Enum, cast to int/s) 00138 // - The finite element family/ies of the variable 00139 // (FEFamily Enum, cast to int/s) 00140 // 00141 // end variable loop 00142 // 00143 // 8.) The number of additional vectors (unsigned int), 00144 // 00145 // for each additional vector in the system object 00146 // 00147 // 9.) the name of the additional vector (string) 00148 // 00149 // end system 00150 libmesh_assert (io.reading()); 00151 00152 // Possibly clear data structures and start from scratch. 00153 if (read_header_in) 00154 this->clear (); 00155 00156 // Figure out if we need to read infinite element information. 00157 // This will be true if the version string contains " with infinite elements" 00158 const bool read_ifem_info = 00159 (version.rfind(" with infinite elements") < version.size()) || 00160 libMesh::on_command_line ("--read_ifem_systems"); 00161 00162 00163 { 00164 // 5.) 00165 // Read the number of variables in the system 00166 unsigned int nv=0; 00167 if (libMesh::processor_id() == 0) 00168 io.data (nv); 00169 CommWorld.broadcast(nv); 00170 00171 _written_var_indices.clear(); 00172 _written_var_indices.resize(nv, 0); 00173 00174 for (unsigned int var=0; var<nv; var++) 00175 { 00176 // 6.) 00177 // Read the name of the var-th variable 00178 std::string var_name; 00179 if (libMesh::processor_id() == 0) 00180 io.data (var_name); 00181 CommWorld.broadcast(var_name); 00182 00183 // 6.1.) 00184 std::set<subdomain_id_type> domains; 00185 if (io.version() >= LIBMESH_VERSION_ID(0,7,2)) 00186 { 00187 std::vector<subdomain_id_type> domain_array; 00188 if (libMesh::processor_id() == 0) 00189 io.data (domain_array); 00190 for (std::vector<subdomain_id_type>::iterator it = domain_array.begin(); it != domain_array.end(); ++it) 00191 domains.insert(*it); 00192 } 00193 CommWorld.broadcast(domains); 00194 00195 // 7.) 00196 // Read the approximation order(s) of the var-th variable 00197 int order=0; 00198 if (libMesh::processor_id() == 0) 00199 io.data (order); 00200 CommWorld.broadcast(order); 00201 00202 00203 // do the same for infinite element radial_order 00204 int rad_order=0; 00205 if (read_ifem_info) 00206 { 00207 if (libMesh::processor_id() == 0) 00208 io.data(rad_order); 00209 CommWorld.broadcast(rad_order); 00210 } 00211 00212 00213 // Read the finite element type of the var-th variable 00214 int fam=0; 00215 if (libMesh::processor_id() == 0) 00216 io.data (fam); 00217 CommWorld.broadcast(fam); 00218 FEType type; 00219 type.order = static_cast<Order>(order); 00220 type.family = static_cast<FEFamily>(fam); 00221 00222 // Check for incompatibilities. The shape function indexing was 00223 // changed for the monomial and xyz finite element families to 00224 // simplify extension to arbitrary p. The consequence is that 00225 // old restart files will not be read correctly. This is expected 00226 // to be an unlikely occurance, but catch it anyway. 00227 if (read_legacy_format) 00228 if ((type.family == MONOMIAL || type.family == XYZ) && 00229 ((type.order > 2 && this->get_mesh().mesh_dimension() == 2) || 00230 (type.order > 1 && this->get_mesh().mesh_dimension() == 3))) 00231 { 00232 libmesh_here(); 00233 libMesh::out << "*****************************************************************\n" 00234 << "* WARNING: reading a potentially incompatible restart file!!! *\n" 00235 << "* contact libmesh-users@lists.sourceforge.net for more details *\n" 00236 << "*****************************************************************" 00237 << std::endl; 00238 } 00239 00240 // Read additional information for infinite elements 00241 int radial_fam=0; 00242 int i_map=0; 00243 if (read_ifem_info) 00244 { 00245 if (libMesh::processor_id() == 0) 00246 io.data (radial_fam); 00247 CommWorld.broadcast(radial_fam); 00248 if (libMesh::processor_id() == 0) 00249 io.data (i_map); 00250 CommWorld.broadcast(i_map); 00251 } 00252 00253 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00254 00255 type.radial_order = static_cast<Order>(rad_order); 00256 type.radial_family = static_cast<FEFamily>(radial_fam); 00257 type.inf_map = static_cast<InfMapType>(i_map); 00258 00259 #endif 00260 00261 if (read_header_in) 00262 { 00263 if (domains.empty()) 00264 _written_var_indices[var] = this->add_variable (var_name, type); 00265 else 00266 _written_var_indices[var] = this->add_variable (var_name, type, &domains); 00267 } 00268 else 00269 _written_var_indices[var] = this->variable_number(var_name); 00270 } 00271 } 00272 00273 // 8.) 00274 // Read the number of additional vectors. 00275 unsigned int nvecs=0; 00276 if (libMesh::processor_id() == 0) 00277 io.data (nvecs); 00278 CommWorld.broadcast(nvecs); 00279 00280 // If nvecs > 0, this means that write_additional_data 00281 // was true when this file was written. We will need to 00282 // make use of this fact later. 00283 if (nvecs > 0) 00284 this->_additional_data_written = true; 00285 00286 for (unsigned int vec=0; vec<nvecs; vec++) 00287 { 00288 // 9.) 00289 // Read the name of the vec-th additional vector 00290 std::string vec_name; 00291 if (libMesh::processor_id() == 0) 00292 io.data (vec_name); 00293 CommWorld.broadcast(vec_name); 00294 00295 if (read_additional_data) 00296 { 00297 // Systems now can handle adding post-initialization vectors 00298 // libmesh_assert(this->_can_add_vectors); 00299 // Some systems may have added their own vectors already 00300 // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0); 00301 00302 this->add_vector(vec_name); 00303 } 00304 } 00305 }
| void libMesh::System::read_legacy_data | ( | Xdr & | io, | |
| const bool | read_additional_data = true | |||
| ) |
Reads additional data, namely vectors, for this System.
Definition at line 309 of file system_io.C.
References _additional_data_written, _vectors, _written_var_indices, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::Parallel::Communicator::broadcast(), libMesh::CommWorld, libMesh::Xdr::data(), end, get_mesh(), libMesh::DofObject::invalid_id, n_dofs(), n_vars(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), number(), libMesh::processor_id(), libMesh::Xdr::reading(), solution, and libMesh::zero.
00311 { 00312 libmesh_deprecated(); 00313 00314 // This method implements the output of the vectors 00315 // contained in this System object, embedded in the 00316 // output of an EquationSystems<T_sys>. 00317 // 00318 // 10.) The global solution vector, re-ordered to be node-major 00319 // (More on this later.) 00320 // 00321 // for each additional vector in the object 00322 // 00323 // 11.) The global additional vector, re-ordered to be 00324 // node-major (More on this later.) 00325 libmesh_assert (io.reading()); 00326 00327 // read and reordering buffers 00328 std::vector<Number> global_vector; 00329 std::vector<Number> reordered_vector; 00330 00331 // 10.) 00332 // Read and set the solution vector 00333 { 00334 if (libMesh::processor_id() == 0) 00335 io.data (global_vector); 00336 CommWorld.broadcast(global_vector); 00337 00338 // Remember that the stored vector is node-major. 00339 // We need to put it into whatever application-specific 00340 // ordering we may have using the dof_map. 00341 reordered_vector.resize(global_vector.size()); 00342 00343 //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl; 00344 //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl; 00345 00346 libmesh_assert_equal_to (global_vector.size(), this->n_dofs()); 00347 00348 dof_id_type cnt=0; 00349 00350 const unsigned int sys = this->number(); 00351 const unsigned int nv = this->_written_var_indices.size(); 00352 libmesh_assert_less_equal (nv, this->n_vars()); 00353 00354 for (unsigned int data_var=0; data_var<nv; data_var++) 00355 { 00356 const unsigned int var = _written_var_indices[data_var]; 00357 00358 // First reorder the nodal DOF values 00359 { 00360 MeshBase::node_iterator 00361 it = this->get_mesh().nodes_begin(), 00362 end = this->get_mesh().nodes_end(); 00363 00364 for (; it != end; ++it) 00365 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00366 { 00367 libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index), 00368 DofObject::invalid_id); 00369 00370 libmesh_assert_less (cnt, global_vector.size()); 00371 00372 reordered_vector[(*it)->dof_number(sys, var, index)] = 00373 global_vector[cnt++]; 00374 } 00375 } 00376 00377 // Then reorder the element DOF values 00378 { 00379 MeshBase::element_iterator 00380 it = this->get_mesh().active_elements_begin(), 00381 end = this->get_mesh().active_elements_end(); 00382 00383 for (; it != end; ++it) 00384 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00385 { 00386 libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index), 00387 DofObject::invalid_id); 00388 00389 libmesh_assert_less (cnt, global_vector.size()); 00390 00391 reordered_vector[(*it)->dof_number(sys, var, index)] = 00392 global_vector[cnt++]; 00393 } 00394 } 00395 } 00396 00397 *(this->solution) = reordered_vector; 00398 } 00399 00400 // For each additional vector, simply go through the list. 00401 // ONLY attempt to do this IF additional data was actually 00402 // written to the file for this system (controlled by the 00403 // _additional_data_written flag). 00404 if (this->_additional_data_written) 00405 { 00406 std::map<std::string, NumericVector<Number>* >::iterator 00407 pos = this->_vectors.begin(); 00408 00409 for (; pos != this->_vectors.end(); ++pos) 00410 { 00411 // 11.) 00412 // Read the values of the vec-th additional vector. 00413 // Prior do _not_ clear, but fill with zero, since the 00414 // additional vectors _have_ to have the same size 00415 // as the solution vector 00416 std::fill (global_vector.begin(), global_vector.end(), libMesh::zero); 00417 00418 if (libMesh::processor_id() == 0) 00419 io.data (global_vector); 00420 CommWorld.broadcast(global_vector); 00421 00422 // If read_additional_data==true, then we will keep this vector, otherwise 00423 // we are going to throw it away. 00424 if (read_additional_data) 00425 { 00426 // Remember that the stored vector is node-major. 00427 // We need to put it into whatever application-specific 00428 // ordering we may have using the dof_map. 00429 std::fill (reordered_vector.begin(), 00430 reordered_vector.end(), 00431 libMesh::zero); 00432 00433 reordered_vector.resize(global_vector.size()); 00434 00435 libmesh_assert_equal_to (global_vector.size(), this->n_dofs()); 00436 00437 dof_id_type cnt=0; 00438 00439 const unsigned int sys = this->number(); 00440 const unsigned int nv = this->_written_var_indices.size(); 00441 libmesh_assert_less_equal (nv, this->n_vars()); 00442 00443 for (unsigned int data_var=0; data_var<nv; data_var++) 00444 { 00445 const unsigned int var = _written_var_indices[data_var]; 00446 // First reorder the nodal DOF values 00447 { 00448 MeshBase::node_iterator 00449 it = this->get_mesh().nodes_begin(), 00450 end = this->get_mesh().nodes_end(); 00451 00452 for (; it!=end; ++it) 00453 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00454 { 00455 libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index), 00456 DofObject::invalid_id); 00457 00458 libmesh_assert_less (cnt, global_vector.size()); 00459 00460 reordered_vector[(*it)->dof_number(sys, var, index)] = 00461 global_vector[cnt++]; 00462 } 00463 } 00464 00465 // Then reorder the element DOF values 00466 { 00467 MeshBase::element_iterator 00468 it = this->get_mesh().active_elements_begin(), 00469 end = this->get_mesh().active_elements_end(); 00470 00471 for (; it!=end; ++it) 00472 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00473 { 00474 libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index), 00475 DofObject::invalid_id); 00476 00477 libmesh_assert_less (cnt, global_vector.size()); 00478 00479 reordered_vector[(*it)->dof_number(sys, var, index)] = 00480 global_vector[cnt++]; 00481 } 00482 } 00483 } 00484 00485 // use the overloaded operator=(std::vector) to assign the values 00486 *(pos->second) = reordered_vector; 00487 } 00488 } 00489 } // end if (_additional_data_written) 00490 }
| void libMesh::System::read_parallel_data | ( | Xdr & | io, | |
| const bool | read_additional_data | |||
| ) |
Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.
Definition at line 494 of file system_io.C.
References _vectors, _written_var_indices, libMesh::Xdr::data(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::n_processors(), n_vars(), number(), libMesh::processor_id(), libMesh::Xdr::reading(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), solution, libMesh::Variable::type(), and variable().
00496 { 00516 // PerfLog pl("IO Performance",false); 00517 // pl.push("read_parallel_data"); 00518 dof_id_type total_read_size = 0; 00519 00520 libmesh_assert (io.reading()); 00521 libmesh_assert (io.is_open()); 00522 00523 // build the ordered nodes and element maps. 00524 // when writing/reading parallel files we need to iterate 00525 // over our nodes/elements in order of increasing global id(). 00526 // however, this is not guaranteed to be ordering we obtain 00527 // by using the node_iterators/element_iterators directly. 00528 // so build a set, sorted by id(), that provides the ordering. 00529 // further, for memory economy build the set but then transfer 00530 // its contents to vectors, which will be sorted. 00531 std::vector<const DofObject*> ordered_nodes, ordered_elements; 00532 { 00533 std::set<const DofObject*, CompareDofObjectsByID> 00534 ordered_nodes_set (this->get_mesh().local_nodes_begin(), 00535 this->get_mesh().local_nodes_end()); 00536 00537 ordered_nodes.insert(ordered_nodes.end(), 00538 ordered_nodes_set.begin(), 00539 ordered_nodes_set.end()); 00540 } 00541 { 00542 std::set<const DofObject*, CompareDofObjectsByID> 00543 ordered_elements_set (this->get_mesh().local_elements_begin(), 00544 this->get_mesh().local_elements_end()); 00545 00546 ordered_elements.insert(ordered_elements.end(), 00547 ordered_elements_set.begin(), 00548 ordered_elements_set.end()); 00549 } 00550 00551 std::vector<Number> io_buffer; 00552 00553 // 9.) 00554 // 00555 // Actually read the solution components 00556 // for the ith system to disk 00557 io.data(io_buffer); 00558 00559 total_read_size += io_buffer.size(); 00560 00561 const unsigned int sys_num = this->number(); 00562 const unsigned int nv = this->_written_var_indices.size(); 00563 libmesh_assert_less_equal (nv, this->n_vars()); 00564 00565 dof_id_type cnt=0; 00566 00567 // Loop over each non-SCALAR variable and each node, and read out the value. 00568 for (unsigned int data_var=0; data_var<nv; data_var++) 00569 { 00570 const unsigned int var = _written_var_indices[data_var]; 00571 if(this->variable(var).type().family != SCALAR) 00572 { 00573 // First read the node DOF values 00574 for (std::vector<const DofObject*>::const_iterator 00575 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 00576 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00577 { 00578 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 00579 DofObject::invalid_id); 00580 libmesh_assert_less (cnt, io_buffer.size()); 00581 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00582 } 00583 00584 // Then read the element DOF values 00585 for (std::vector<const DofObject*>::const_iterator 00586 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 00587 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00588 { 00589 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 00590 DofObject::invalid_id); 00591 libmesh_assert_less (cnt, io_buffer.size()); 00592 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00593 } 00594 } 00595 } 00596 00597 // Finally, read the SCALAR variables on the last processor 00598 for (unsigned int data_var=0; data_var<nv; data_var++) 00599 { 00600 const unsigned int var = _written_var_indices[data_var]; 00601 if(this->variable(var).type().family == SCALAR) 00602 { 00603 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 00604 { 00605 const DofMap& dof_map = this->get_dof_map(); 00606 std::vector<dof_id_type> SCALAR_dofs; 00607 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 00608 00609 for(unsigned int i=0; i<SCALAR_dofs.size(); i++) 00610 { 00611 this->solution->set( SCALAR_dofs[i], io_buffer[cnt++] ); 00612 } 00613 } 00614 } 00615 } 00616 00617 // And we're done setting solution entries 00618 this->solution->close(); 00619 00620 // Only read additional vectors if wanted 00621 if (read_additional_data) 00622 { 00623 std::map<std::string, NumericVector<Number>* >::const_iterator 00624 pos = _vectors.begin(); 00625 00626 for(; pos != this->_vectors.end(); ++pos) 00627 { 00628 cnt=0; 00629 io_buffer.clear(); 00630 00631 // 10.) 00632 // 00633 // Actually read the additional vector components 00634 // for the ith system to disk 00635 io.data(io_buffer); 00636 00637 total_read_size += io_buffer.size(); 00638 00639 // Loop over each non-SCALAR variable and each node, and read out the value. 00640 for (unsigned int data_var=0; data_var<nv; data_var++) 00641 { 00642 const unsigned int var = _written_var_indices[data_var]; 00643 if(this->variable(var).type().family != SCALAR) 00644 { 00645 // First read the node DOF values 00646 for (std::vector<const DofObject*>::const_iterator 00647 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 00648 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00649 { 00650 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 00651 DofObject::invalid_id); 00652 libmesh_assert_less (cnt, io_buffer.size()); 00653 pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00654 } 00655 00656 // Then read the element DOF values 00657 for (std::vector<const DofObject*>::const_iterator 00658 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 00659 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00660 { 00661 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 00662 DofObject::invalid_id); 00663 libmesh_assert_less (cnt, io_buffer.size()); 00664 pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00665 } 00666 } 00667 } 00668 00669 // Finally, read the SCALAR variables on the last processor 00670 for (unsigned int data_var=0; data_var<nv; data_var++) 00671 { 00672 const unsigned int var = _written_var_indices[data_var]; 00673 if(this->variable(var).type().family == SCALAR) 00674 { 00675 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 00676 { 00677 const DofMap& dof_map = this->get_dof_map(); 00678 std::vector<dof_id_type> SCALAR_dofs; 00679 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 00680 00681 for(unsigned int i=0; i<SCALAR_dofs.size(); i++) 00682 { 00683 pos->second->set( SCALAR_dofs[i], io_buffer[cnt++] ); 00684 } 00685 } 00686 } 00687 } 00688 00689 // And we're done setting entries for this variable 00690 pos->second->close(); 00691 } 00692 } 00693 00694 // const Real 00695 // dt = pl.get_elapsed_time(), 00696 // rate = total_read_size*sizeof(Number)/dt; 00697 00698 // std::cerr << "Read " << total_read_size << " \"Number\" values\n" 00699 // << " Elapsed time = " << dt << '\n' 00700 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n"; 00701 00702 // pl.pop("read_parallel_data"); 00703 }
| unsigned int libMesh::System::read_SCALAR_dofs | ( | const unsigned int | var, | |
| Xdr & | io, | |||
| NumericVector< Number > & | vec | |||
| ) | const [private] |
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.
Returns the number of dofs read.
Definition at line 1080 of file system_io.C.
References libMesh::Parallel::Communicator_World, libMesh::CommWorld, libMesh::Xdr::data_stream(), get_dof_map(), libMesh::n_processors(), libMesh::FEType::order, libMesh::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), libMesh::Parallel::Communicator::send(), libMesh::NumericVector< T >::set(), libMesh::Variable::type(), and variable().
Referenced by read_serialized_vector(), and read_serialized_vectors().
01083 { 01084 unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned. 01085 01086 // Processor 0 will read the block from the buffer stream and send it to the last processor 01087 const unsigned int n_SCALAR_dofs = this->variable(var).type().order; 01088 std::vector<Number> input_buffer(n_SCALAR_dofs); 01089 if (libMesh::processor_id() == 0) 01090 { 01091 io.data_stream(&input_buffer[0], n_SCALAR_dofs); 01092 } 01093 01094 #ifdef LIBMESH_HAVE_MPI 01095 if ( libMesh::n_processors() > 1 ) 01096 { 01097 const Parallel::MessageTag val_tag = Parallel::Communicator_World.get_unique_tag(321); 01098 01099 // Post the receive on the last processor 01100 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 01101 CommWorld.receive(0, input_buffer, val_tag); 01102 01103 // Send the data to processor 0 01104 if (libMesh::processor_id() == 0) 01105 CommWorld.send(libMesh::n_processors()-1, input_buffer, val_tag); 01106 } 01107 #endif 01108 01109 // Finally, set the SCALAR values 01110 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 01111 { 01112 const DofMap& dof_map = this->get_dof_map(); 01113 std::vector<dof_id_type> SCALAR_dofs; 01114 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 01115 01116 for(unsigned int i=0; i<SCALAR_dofs.size(); i++) 01117 { 01118 vec.set (SCALAR_dofs[i], input_buffer[i]); 01119 ++n_assigned_vals; 01120 } 01121 } 01122 01123 return n_assigned_vals; 01124 }
| dof_id_type libMesh::System::read_serialized_blocked_dof_objects | ( | const dof_id_type | n_objects, | |
| const iterator_type | begin, | |||
| const iterator_type | end, | |||
| Xdr & | io, | |||
| const std::vector< NumericVector< Number > * > & | vecs, | |||
| const unsigned int | var_to_read = libMesh::invalid_uint | |||
| ) | const [inline, private] |
Reads an input vector from the stream io and assigns the values to a set of DofObjects. This method uses blocked input and is safe to call on a distributed memory-mesh. Unless otherwise specified, all variables are read.
Definition at line 772 of file system_io.C.
References _written_var_indices, libMesh::Parallel::any_source, libMesh::Parallel::Communicator_World, libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::Threads::Thread::join(), libMesh::NumericVector< T >::last_local_index(), std::min(), libMesh::n_processors(), n_vars(), number(), libMesh::Parallel::Communicator::probe(), libMesh::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::NumericVector< T >::set(), libMesh::Parallel::Communicator::sum(), and libMesh::Parallel::wait().
Referenced by read_serialized_vector(), and read_serialized_vectors().
00778 { 00779 //------------------------------------------------------- 00780 // General order: (IO format 0.7.4 & greater) 00781 // 00782 // for (objects ...) 00783 // for (vecs ....) 00784 // for (vars ....) 00785 // for (comps ...) 00786 // 00787 // where objects are nodes or elements, sorted to be 00788 // partition independent, 00789 // vecs are one or more *identically distributed* solution 00790 // coefficient vectors, vars are one or more variables 00791 // to write, and comps are all the components for said 00792 // vars on the object. 00793 00794 typedef std::vector<NumericVector<Number>*>::const_iterator vec_iterator_type; 00795 00796 // variables to read. Unless specified otherwise, defaults to _written_var_indices. 00797 std::vector<unsigned int> vars_to_read (_written_var_indices); 00798 00799 if (var_to_read != libMesh::invalid_uint) 00800 { 00801 vars_to_read.clear(); 00802 vars_to_read.push_back(var_to_read); 00803 } 00804 00805 const unsigned int 00806 sys_num = this->number(), 00807 num_vecs = libmesh_cast_int<unsigned int>(vecs.size()), 00808 num_vars = _written_var_indices.size(); // must be <= current number of variables! 00809 const dof_id_type 00810 io_blksize = std::min(max_io_blksize, n_objs), 00811 num_blks = std::ceil(static_cast<double>(n_objs)/static_cast<double>(io_blksize)); 00812 00813 libmesh_assert_less_equal (num_vars, this->n_vars()); 00814 00815 unsigned int n_read_values=0; 00816 00817 std::vector<std::vector<dof_id_type> > xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks 00818 std::vector<std::vector<Number> > recv_vals(num_blks); // The raw values for the local objects in all blocks 00819 std::vector<Parallel::Request> 00820 id_requests(num_blks), val_requests(num_blks); 00821 00822 // ------------------------------------------------------ 00823 // First pass - count the number of objects in each block 00824 // traverse all the objects and figure out which block they 00825 // will utlimately live in. 00826 std::vector<std::size_t> 00827 xfer_ids_size (num_blks,0), 00828 recv_vals_size (num_blks,0); 00829 00830 00831 for (iterator_type it=begin; it!=end; ++it) 00832 { 00833 const dof_id_type 00834 id = (*it)->id(), 00835 block = id/io_blksize; 00836 00837 libmesh_assert_less (block, num_blks); 00838 00839 xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables 00840 00841 dof_id_type n_comp_tot=0; 00842 for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin(); 00843 var_it!=vars_to_read.end(); ++var_it) 00844 n_comp_tot += (*it)->n_comp(sys_num, *var_it); // for each variable, we will receive the nonzero components 00845 00846 recv_vals_size[block] += n_comp_tot*num_vecs; 00847 } 00848 00849 // knowing the recv_vals_size[block] for each processor allows 00850 // us to sum them and find the global size for each block. 00851 std::vector<std::size_t> tot_vals_size(recv_vals_size); 00852 CommWorld.sum (tot_vals_size); 00853 00854 00855 //------------------------------------------ 00856 // Collect the ids & number of values needed 00857 // for all local objects, binning them into 00858 // 'blocks' that will be sent to processor 0 00859 for (dof_id_type blk=0; blk<num_blks; blk++) 00860 { 00861 // Each processor should build up its transfer buffers for its 00862 // local objects in [first_object,last_object). 00863 const dof_id_type 00864 first_object = blk*io_blksize, 00865 last_object = std::min(static_cast<dof_id_type>((blk+1)*io_blksize), 00866 n_objs); 00867 00868 // convenience 00869 std::vector<dof_id_type> &ids (xfer_ids[blk]); 00870 std::vector<Number> &vals (recv_vals[blk]); 00871 00872 // we now know the number of values we will store for each block, 00873 // so we can do efficient preallocation 00874 ids.clear(); ids.reserve (xfer_ids_size[blk]); 00875 vals.resize(recv_vals_size[blk]); 00876 00877 if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive 00878 for (iterator_type it=begin; it!=end; ++it) 00879 if (((*it)->id() >= first_object) && // object in [first_object,last_object) 00880 ((*it)->id() < last_object)) 00881 { 00882 ids.push_back((*it)->id()); 00883 00884 unsigned int n_comp_tot=0; 00885 00886 for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin(); 00887 var_it!=vars_to_read.end(); ++var_it) 00888 n_comp_tot += (*it)->n_comp(sys_num,*var_it); 00889 00890 ids.push_back (n_comp_tot*num_vecs); 00891 } 00892 00893 #ifdef LIBMESH_HAVE_MPI 00894 Parallel::MessageTag id_tag = Parallel::Communicator_World.get_unique_tag(100*num_blks + blk); 00895 Parallel::MessageTag val_tag = Parallel::Communicator_World.get_unique_tag(200*num_blks + blk); 00896 00897 // nonblocking send the data for this block 00898 CommWorld.send (0, ids, id_requests[blk], id_tag); 00899 00900 // Go ahead and post the receive too 00901 CommWorld.receive (0, vals, val_requests[blk], val_tag); 00902 #endif 00903 } 00904 00905 //--------------------------------------------------- 00906 // Here processor 0 will read and distribute the data. 00907 // We have to do this block-wise to ensure that we 00908 // do not exhaust memory on processor 0. 00909 00910 // give these variables scope outside the block to avoid reallocation 00911 std::vector<std::vector<dof_id_type> > recv_ids (libMesh::n_processors()); 00912 std::vector<std::vector<Number> > send_vals (libMesh::n_processors()); 00913 std::vector<Parallel::Request> reply_requests (libMesh::n_processors()); 00914 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise 00915 std::vector<Number> input_vals; // The input buffer for the current block 00916 00917 for (dof_id_type blk=0; blk<num_blks; blk++) 00918 { 00919 // Each processor should build up its transfer buffers for its 00920 // local objects in [first_object,last_object). 00921 const dof_id_type 00922 first_object = blk*io_blksize, 00923 last_object = std::min(static_cast<dof_id_type>((blk+1)*io_blksize), 00924 n_objs), 00925 n_objects_blk = last_object - first_object; 00926 00927 // Processor 0 has a special job. It needs to gather the requested indices 00928 // in [first_object,last_object) from all processors, read the data from 00929 // disk, and reply 00930 if (libMesh::processor_id() == 0) 00931 { 00932 // we know the input buffer size for this block and can begin reading it now 00933 input_vals.resize(tot_vals_size[blk]); 00934 00935 // a ThreadedIO object to perform asychronous file IO 00936 ThreadedIO threaded_io(io, input_vals); 00937 Threads::Thread async_io(threaded_io); 00938 00939 Parallel::MessageTag id_tag = Parallel::Communicator_World.get_unique_tag(100*num_blks + blk); 00940 Parallel::MessageTag val_tag = Parallel::Communicator_World.get_unique_tag(200*num_blks + blk); 00941 00942 // offset array. this will define where each object's values 00943 // map into the actual input_vals buffer. this must get 00944 // 0-initialized because 0-component objects are not actually sent 00945 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0); 00946 recv_vals_size.resize(libMesh::n_processors()); // reuse this to count how many values are going to each processor 00947 00948 unsigned int n_vals_blk = 0; 00949 00950 // loop over all processors and process their index request 00951 for (unsigned int comm_step=0; comm_step<libMesh::n_processors(); comm_step++) 00952 { 00953 #ifdef LIBMESH_HAVE_MPI 00954 // blocking receive indices for this block, imposing no particular order on processor 00955 Parallel::Status id_status (CommWorld.probe (Parallel::any_source, id_tag)); 00956 std::vector<dof_id_type> &ids (recv_ids[id_status.source()]); 00957 std::size_t &n_vals_proc (recv_vals_size[id_status.source()]); 00958 CommWorld.receive (id_status.source(), ids, id_tag); 00959 #else 00960 // straight copy without MPI 00961 std::vector<dof_id_type> &ids (recv_ids[0]); 00962 std::size_t &n_vals_proc (recv_vals_size[0]); 00963 ids = xfer_ids[blk]; 00964 #endif 00965 00966 n_vals_proc = 0; 00967 00968 // note its possible we didn't receive values for objects in 00969 // this block if they have no components allocated. 00970 for (std::size_t idx=0; idx<ids.size(); idx+=2) 00971 { 00972 const dof_id_type 00973 local_idx = ids[idx+0]-first_object, 00974 n_vals_tot_allvecs = ids[idx+1]; 00975 00976 libmesh_assert_less (local_idx, n_objects_blk); 00977 00978 obj_val_offsets[local_idx] = n_vals_tot_allvecs; 00979 n_vals_proc += n_vals_tot_allvecs; 00980 } 00981 00982 n_vals_blk += n_vals_proc; 00983 } 00984 00985 // We need the offests into the input_vals vector for each object. 00986 // fortunately, this is simply the partial sum of the total number 00987 // of components for each object 00988 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(), 00989 obj_val_offsets.begin()); 00990 00991 libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back()); 00992 libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]); 00993 00994 // Wait for read completion 00995 async_io.join(); 00996 00997 n_read_values += 00998 libmesh_cast_int<dof_id_type>(input_vals.size()); 00999 01000 // pack data replies for each processor 01001 for (processor_id_type proc=0; proc<libMesh::n_processors(); proc++) 01002 { 01003 const std::vector<dof_id_type> &ids (recv_ids[proc]); 01004 std::vector<Number> &vals (send_vals[proc]); 01005 const std::size_t &n_vals_proc (recv_vals_size[proc]); 01006 01007 vals.clear(); vals.reserve(n_vals_proc); 01008 01009 for (std::size_t idx=0; idx<ids.size(); idx+=2) 01010 { 01011 const dof_id_type 01012 local_idx = ids[idx+0]-first_object, 01013 n_vals_tot_allvecs = ids[idx+1]; 01014 01015 std::vector<Number>::const_iterator in_vals(input_vals.begin()); 01016 if (local_idx != 0) 01017 std::advance (in_vals, obj_val_offsets[local_idx-1]); 01018 01019 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals) 01020 { 01021 libmesh_assert (in_vals != input_vals.end()); 01022 //std::cout << "*in_vals=" << *in_vals << '\n'; 01023 vals.push_back(*in_vals); 01024 } 01025 } 01026 01027 #ifdef LIBMESH_HAVE_MPI 01028 // send the relevant values to this processor 01029 CommWorld.send (proc, vals, reply_requests[proc], val_tag); 01030 #else 01031 recv_vals[blk] = vals; 01032 #endif 01033 } 01034 } // end processor 0 read/reply 01035 01036 // all processors complete the (already posted) read for this block 01037 { 01038 Parallel::wait (val_requests[blk]); 01039 01040 const std::vector<Number> &vals (recv_vals[blk]); 01041 std::vector<Number>::const_iterator val_it(vals.begin()); 01042 01043 if (!recv_vals[blk].empty()) // nonzero values to receive 01044 for (iterator_type it=begin; it!=end; ++it) 01045 if (((*it)->id() >= first_object) && // object in [first_object,last_object) 01046 ((*it)->id() < last_object)) 01047 // unpack & set the values 01048 for (vec_iterator_type vec_it=vecs.begin(); vec_it!=vecs.end(); ++vec_it) 01049 { 01050 NumericVector<Number> &vec(**vec_it); 01051 01052 for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin(); 01053 var_it!=vars_to_read.end(); ++var_it) 01054 { 01055 const unsigned int n_comp = (*it)->n_comp(sys_num,*var_it); 01056 01057 for (unsigned int comp=0; comp<n_comp; comp++, ++val_it) 01058 { 01059 const dof_id_type dof_index = (*it)->dof_number (sys_num, *var_it, comp); 01060 libmesh_assert (val_it != vals.end()); 01061 libmesh_assert_greater_equal (dof_index, vec.first_local_index()); 01062 libmesh_assert_less (dof_index, vec.last_local_index()); 01063 //std::cout << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n'; 01064 vec.set (dof_index, *val_it); 01065 } 01066 } 01067 } 01068 } 01069 01070 // processor 0 needs to make sure all replies have been handed off 01071 if (libMesh::processor_id () == 0) 01072 Parallel::wait(reply_requests); 01073 } 01074 01075 return n_read_values; 01076 }
| void libMesh::System::read_serialized_data | ( | Xdr & | io, | |
| const bool | read_additional_data = true | |||
| ) |
Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
Definition at line 707 of file system_io.C.
References _vectors, libMesh::Xdr::comment(), libMesh::processor_id(), read_serialized_vector(), and solution.
00709 { 00710 // This method implements the input of the vectors 00711 // contained in this System object, embedded in the 00712 // output of an EquationSystems<T_sys>. 00713 // 00714 // 10.) The global solution vector, re-ordered to be node-major 00715 // (More on this later.) 00716 // 00717 // for each additional vector in the object 00718 // 00719 // 11.) The global additional vector, re-ordered to be 00720 // node-major (More on this later.) 00721 parallel_only(); 00722 std::string comment; 00723 00724 // PerfLog pl("IO Performance",false); 00725 // pl.push("read_serialized_data"); 00726 std::size_t total_read_size = 0; 00727 00728 // 10.) 00729 // Read the global solution vector 00730 { 00731 total_read_size += 00732 this->read_serialized_vector(io, *this->solution); 00733 00734 // get the comment 00735 if (libMesh::processor_id() == 0) 00736 io.comment (comment); 00737 } 00738 00739 // 11.) 00740 // Only read additional vectors if wanted 00741 if (read_additional_data) 00742 { 00743 std::map<std::string, NumericVector<Number>* >::const_iterator 00744 pos = _vectors.begin(); 00745 00746 for(; pos != this->_vectors.end(); ++pos) 00747 { 00748 total_read_size += 00749 this->read_serialized_vector(io, *pos->second); 00750 00751 // get the comment 00752 if (libMesh::processor_id() == 0) 00753 io.comment (comment); 00754 00755 } 00756 } 00757 00758 // const Real 00759 // dt = pl.get_elapsed_time(), 00760 // rate = total_read_size*sizeof(Number)/dt; 00761 00762 // std::cout << "Read " << total_read_size << " \"Number\" values\n" 00763 // << " Elapsed time = " << dt << '\n' 00764 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n"; 00765 00766 // pl.pop("read_serialized_data"); 00767 }
| numeric_index_type libMesh::System::read_serialized_vector | ( | Xdr & | io, | |
| NumericVector< Number > & | vec | |||
| ) | [private] |
Reads a vector for this System. This method may safely be called on a distributed-memory mesh.
Returns the length of the vector read.
Definition at line 1128 of file system_io.C.
References _written_var_indices, libMesh::Parallel::Communicator::broadcast(), libMesh::NumericVector< T >::close(), libMesh::CommWorld, libMesh::Xdr::data(), get_mesh(), libMeshEnums::GHOSTED, libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, libMesh::n_processors(), n_vars(), libMeshEnums::PARALLEL, libMesh::processor_id(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMeshEnums::SCALAR, libMesh::Parallel::Communicator::sum(), libMesh::NumericVector< T >::type(), variable(), and libMesh::Xdr::version().
Referenced by read_serialized_data().
01129 { 01130 parallel_only(); 01131 01132 #ifndef NDEBUG 01133 // In parallel we better be reading a parallel vector -- if not 01134 // we will not set all of its components below!! 01135 if (libMesh::n_processors() > 1) 01136 { 01137 libmesh_assert (vec.type() == PARALLEL || 01138 vec.type() == GHOSTED); 01139 } 01140 #endif 01141 01142 libmesh_assert (io.reading()); 01143 01144 // vector length 01145 unsigned int vector_length=0, n_assigned_vals=0; 01146 01147 // Get the buffer size 01148 if (libMesh::processor_id() == 0) 01149 io.data(vector_length, "# vector length"); 01150 CommWorld.broadcast(vector_length); 01151 01152 const unsigned int 01153 nv = this->_written_var_indices.size(); 01154 const dof_id_type 01155 n_nodes = this->get_mesh().n_nodes(), 01156 n_elem = this->get_mesh().n_elem(); 01157 01158 libmesh_assert_less_equal (nv, this->n_vars()); 01159 01160 // for newer versions, read variables node/elem major 01161 if (io.version() >= LIBMESH_VERSION_ID(0,7,4)) 01162 { 01163 //--------------------------------- 01164 // Collect the values for all nodes 01165 n_assigned_vals += 01166 this->read_serialized_blocked_dof_objects (n_nodes, 01167 this->get_mesh().local_nodes_begin(), 01168 this->get_mesh().local_nodes_end(), 01169 io, 01170 std::vector<NumericVector<Number>*> (1,&vec)); 01171 01172 01173 //------------------------------------ 01174 // Collect the values for all elements 01175 n_assigned_vals += 01176 this->read_serialized_blocked_dof_objects (n_elem, 01177 this->get_mesh().local_elements_begin(), 01178 this->get_mesh().local_elements_end(), 01179 io, 01180 std::vector<NumericVector<Number>*> (1,&vec)); 01181 } 01182 01183 // for older versions, read variables var-major 01184 else 01185 { 01186 // Loop over each variable in the system, and then each node/element in the mesh. 01187 for (unsigned int data_var=0; data_var<nv; data_var++) 01188 { 01189 const unsigned int var = _written_var_indices[data_var]; 01190 if(this->variable(var).type().family != SCALAR) 01191 { 01192 //--------------------------------- 01193 // Collect the values for all nodes 01194 n_assigned_vals += 01195 this->read_serialized_blocked_dof_objects (n_nodes, 01196 this->get_mesh().local_nodes_begin(), 01197 this->get_mesh().local_nodes_end(), 01198 io, 01199 std::vector<NumericVector<Number>*> (1,&vec), 01200 var); 01201 01202 01203 //------------------------------------ 01204 // Collect the values for all elements 01205 n_assigned_vals += 01206 this->read_serialized_blocked_dof_objects (n_elem, 01207 this->get_mesh().local_elements_begin(), 01208 this->get_mesh().local_elements_end(), 01209 io, 01210 std::vector<NumericVector<Number>*> (1,&vec), 01211 var); 01212 } // end variable loop 01213 } 01214 } 01215 01216 //------------------------------------------- 01217 // Finally loop over all the SCALAR variables 01218 for (unsigned int data_var=0; data_var<nv; data_var++) 01219 { 01220 const unsigned int var = _written_var_indices[data_var]; 01221 if(this->variable(var).type().family == SCALAR) 01222 { 01223 n_assigned_vals += 01224 this->read_SCALAR_dofs (var, io, vec); 01225 } 01226 } 01227 01228 vec.close(); 01229 01230 #ifndef NDEBUG 01231 CommWorld.sum (n_assigned_vals); 01232 libmesh_assert_equal_to (n_assigned_vals, vector_length); 01233 #endif 01234 01235 return vector_length; 01236 }
| dof_id_type libMesh::System::read_serialized_vectors | ( | Xdr & | io, | |
| const std::vector< NumericVector< Number > * > & | vectors | |||
| ) | const |
Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.
Definition at line 2164 of file system_io.C.
References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, n_vars(), libMesh::processor_id(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMeshEnums::SCALAR, libMesh::Variable::type(), and variable().
02166 { 02167 parallel_only(); 02168 02169 // Error checking 02170 // #ifndef NDEBUG 02171 // // In parallel we better be reading a parallel vector -- if not 02172 // // we will not set all of its components below!! 02173 // if (libMesh::n_processors() > 1) 02174 // { 02175 // libmesh_assert (vec.type() == PARALLEL || 02176 // vec.type() == GHOSTED); 02177 // } 02178 // #endif 02179 02180 libmesh_assert (io.reading()); 02181 02182 // sizes 02183 unsigned int num_vecs=0; 02184 dof_id_type vector_length=0; 02185 02186 if (libMesh::processor_id() == 0) 02187 { 02188 // Get the number of vectors 02189 io.data(num_vecs); 02190 // Get the buffer size 02191 io.data(vector_length); 02192 02193 libmesh_assert_equal_to (num_vecs, vectors.size()); 02194 02195 if (num_vecs != 0) 02196 { 02197 libmesh_assert_not_equal_to (vectors[0], 0); 02198 libmesh_assert_equal_to (vectors[0]->size(), vector_length); 02199 } 02200 } 02201 02202 // no need to actually communicate these. 02203 // CommWorld.broadcast(num_vecs); 02204 // CommWorld.broadcast(vector_length); 02205 02206 // Cache these - they are not free! 02207 const dof_id_type 02208 n_nodes = this->get_mesh().n_nodes(), 02209 n_elem = this->get_mesh().n_elem(); 02210 02211 dof_id_type read_length = 0.; 02212 02213 //--------------------------------- 02214 // Collect the values for all nodes 02215 read_length += 02216 this->read_serialized_blocked_dof_objects (n_nodes, 02217 this->get_mesh().local_nodes_begin(), 02218 this->get_mesh().local_nodes_end(), 02219 io, 02220 vectors); 02221 02222 //------------------------------------ 02223 // Collect the values for all elements 02224 read_length += 02225 this->read_serialized_blocked_dof_objects (n_elem, 02226 this->get_mesh().local_elements_begin(), 02227 this->get_mesh().local_elements_end(), 02228 io, 02229 vectors); 02230 02231 //------------------------------------------- 02232 // Finally loop over all the SCALAR variables 02233 for (unsigned int vec=0; vec<vectors.size(); vec++) 02234 for (unsigned int var=0; var<this->n_vars(); var++) 02235 if(this->variable(var).type().family == SCALAR) 02236 { 02237 libmesh_assert_not_equal_to (vectors[vec], 0); 02238 02239 read_length += 02240 this->read_SCALAR_dofs (var, io, *vectors[vec]); 02241 } 02242 02243 //--------------------------------------- 02244 // last step - must close all the vectors 02245 for (unsigned int vec=0; vec<vectors.size(); vec++) 02246 { 02247 libmesh_assert_not_equal_to (vectors[vec], 0); 02248 vectors[vec]->close(); 02249 } 02250 02251 return read_length; 02252 }
| void libMesh::System::reinit | ( | ) | [virtual] |
Reinitializes degrees of freedom and other required data on the current mesh. Note that the matrix is not initialized at this time since it may not be required for all applications. Should be overloaded in derived classes.
Reimplemented in libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, and libMesh::TransientSystem< RBConstruction >.
Definition at line 378 of file system.C.
References current_local_solution, n_dofs(), n_local_dofs(), n_vars(), libMeshEnums::PARALLEL, and solution.
Referenced by libMesh::ExplicitSystem::reinit(), and libMesh::EigenSystem::reinit().
00379 { 00380 #ifdef LIBMESH_ENABLE_AMR 00381 //If no variables have been added to this system 00382 //don't do anything 00383 if(!this->n_vars()) 00384 return; 00385 00386 // Constraints get handled in EquationSystems::reinit now 00387 // _dof_map->create_dof_constraints(this->get_mesh()); 00388 00389 // Update the solution based on the projected 00390 // current_local_solution. 00391 solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL); 00392 00393 libmesh_assert_equal_to (solution->size(), current_local_solution->size()); 00394 // Not true with ghosted vectors 00395 // libmesh_assert_equal_to (solution->size(), current_local_solution->local_size()); 00396 00397 const dof_id_type first_local_dof = solution->first_local_index(); 00398 const dof_id_type local_size = solution->local_size(); 00399 00400 for (dof_id_type i=0; i<local_size; i++) 00401 solution->set(i+first_local_dof, 00402 (*current_local_solution)(i+first_local_dof)); 00403 00404 solution->close(); 00405 #endif 00406 }
| void libMesh::System::remove_vector | ( | const std::string & | vec_name | ) |
Removes the additional vector vec_name from this system
Definition at line 711 of file system.C.
References _vector_projections, _vector_types, _vectors, and have_vector().
00712 { 00713 //Return if the vector does not exist 00714 if ( !(this->have_vector(vec_name)) ) 00715 return; 00716 00717 _vectors[vec_name]->clear(); 00718 delete _vectors[vec_name]; 00719 _vectors[vec_name] = NULL; 00720 00721 _vectors.erase(vec_name); 00722 _vector_projections.erase(vec_name); 00723 _vector_types.erase(vec_name); 00724 }
| NumericVector< Number > * libMesh::System::request_vector | ( | const unsigned int | vec_num | ) |
- Returns:
- a writeable pointer to this system's additional vector number
vec_num(where the vectors are counted starting with 0), or returnsNULLif the system has no such vector.
Definition at line 767 of file system.C.
References vectors_begin(), and vectors_end().
00768 { 00769 vectors_iterator v = vectors_begin(); 00770 vectors_iterator v_end = vectors_end(); 00771 unsigned int num = 0; 00772 while((num<vec_num) && (v!=v_end)) 00773 { 00774 num++; 00775 ++v; 00776 } 00777 if (v==v_end) 00778 return NULL; 00779 return v->second; 00780 }
| const NumericVector< Number > * libMesh::System::request_vector | ( | const unsigned int | vec_num | ) | const |
- Returns:
- a const pointer to this system's additional vector number
vec_num(where the vectors are counted starting with 0), or returnsNULLif the system has no such vector.
Definition at line 750 of file system.C.
References vectors_begin(), and vectors_end().
00751 { 00752 const_vectors_iterator v = vectors_begin(); 00753 const_vectors_iterator v_end = vectors_end(); 00754 unsigned int num = 0; 00755 while((num<vec_num) && (v!=v_end)) 00756 { 00757 num++; 00758 ++v; 00759 } 00760 if (v==v_end) 00761 return NULL; 00762 return v->second; 00763 }
| NumericVector< Number > * libMesh::System::request_vector | ( | const std::string & | vec_name | ) |
- Returns:
- a pointer to the vector if this
Systemhas a vector associated with the given name,NULLotherwise.
Definition at line 738 of file system.C.
References _vectors.
00739 { 00740 vectors_iterator pos = _vectors.find(vec_name); 00741 00742 if (pos == _vectors.end()) 00743 return NULL; 00744 00745 return pos->second; 00746 }
| const NumericVector< Number > * libMesh::System::request_vector | ( | const std::string & | vec_name | ) | const |
- Returns:
- a const pointer to the vector if this
Systemhas a vector associated with the given name,NULLotherwise.
Definition at line 726 of file system.C.
References _vectors.
00727 { 00728 const_vectors_iterator pos = _vectors.find(vec_name); 00729 00730 if (pos == _vectors.end()) 00731 return NULL; 00732 00733 return pos->second; 00734 }
| void libMesh::System::restrict_solve_to | ( | const SystemSubset * | subset, | |
| const SubsetSolveMode | subset_solve_mode = SUBSET_ZERO | |||
| ) | [virtual] |
After calling this method, any solve will be restricted to the given subdomain. To disable this mode, call this method with subset being a NULL pointer.
Reimplemented in libMesh::LinearImplicitSystem.
| void libMesh::System::restrict_vectors | ( | ) | [virtual] |
Restrict vectors after the mesh has coarsened
Definition at line 316 of file system.C.
References _dof_map, _solution_projection, _vector_projections, _vector_types, _vectors, current_local_solution, libMesh::err, libMeshEnums::GHOSTED, n_dofs(), n_local_dofs(), project_vector(), and solution.
Referenced by prolong_vectors(), and libMesh::EquationSystems::reinit().
00317 { 00318 #ifdef LIBMESH_ENABLE_AMR 00319 // Restrict the _vectors on the coarsened cells 00320 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00321 { 00322 NumericVector<Number>* v = pos->second; 00323 00324 if (_vector_projections[pos->first]) 00325 this->project_vector (*v); 00326 else 00327 { 00328 ParallelType type = _vector_types[pos->first]; 00329 00330 if(type == GHOSTED) 00331 { 00332 #ifdef LIBMESH_ENABLE_GHOSTED 00333 pos->second->init (this->n_dofs(), this->n_local_dofs(), 00334 _dof_map->get_send_list(), false, 00335 GHOSTED); 00336 #else 00337 libMesh::err << "Cannot initialize ghosted vectors when they are not enabled." << std::endl; 00338 libmesh_error(); 00339 #endif 00340 } 00341 else 00342 pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type); 00343 } 00344 } 00345 00346 const std::vector<dof_id_type>& send_list = _dof_map->get_send_list (); 00347 00348 // Restrict the solution on the coarsened cells 00349 if (_solution_projection) 00350 this->project_vector (*solution); 00351 00352 #ifdef LIBMESH_ENABLE_GHOSTED 00353 current_local_solution->init(this->n_dofs(), 00354 this->n_local_dofs(), send_list, 00355 false, GHOSTED); 00356 #else 00357 current_local_solution->init(this->n_dofs()); 00358 #endif 00359 00360 if (_solution_projection) 00361 solution->localize (*current_local_solution, send_list); 00362 00363 #endif // LIBMESH_ENABLE_AMR 00364 }
| std::pair< unsigned int, Real > libMesh::System::sensitivity_solve | ( | const ParameterVector & | parameters | ) | [inline, virtual] |
Solves the sensitivity system, for the provided parameters. Must be overloaded in derived systems.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| void libMesh::System::set_adjoint_already_solved | ( | bool | setting | ) | [inline] |
Setter for the adjoint_already_solved boolean
Definition at line 365 of file system.h.
References adjoint_already_solved.
00366 { adjoint_already_solved = setting;}
| void libMesh::System::set_basic_system_only | ( | ) | [inline] |
Sets the system to be "basic only": i.e. advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()
Definition at line 1890 of file system.h.
References _basic_system_only.
Referenced by libMesh::EquationSystems::_read_impl().
01891 { 01892 _basic_system_only = true; 01893 }
| void libMesh::System::set_vector_preservation | ( | const std::string & | vec_name, | |
| bool | preserve | |||
| ) |
Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.
Definition at line 887 of file system.C.
References _vector_projections.
00889 { 00890 _vector_projections[vec_name] = preserve; 00891 }
| virtual void libMesh::System::solve | ( | ) | [inline, virtual] |
Solves the system. Should be overloaded in derived systems.
Reimplemented in libMesh::CondensedEigenSystem, libMesh::ContinuationSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::FEMSystem, libMesh::FrequencySystem, libMesh::LinearImplicitSystem, and libMesh::NonlinearImplicitSystem.
| sys_type& libMesh::System::system | ( | ) | [inline] |
- Returns:
- a clever pointer to the system.
Reimplemented in libMesh::CondensedEigenSystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::NonlinearImplicitSystem, libMesh::RBConstruction, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, and libMesh::TransientSystem< RBConstruction >.
| virtual std::string libMesh::System::system_type | ( | ) | const [inline, virtual] |
- Returns:
- the type of system, helpful in identifying which system type to use when reading equation system data from file. Should be overloaded in derived classes.
Reimplemented in libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::FrequencySystem, libMesh::ImplicitSystem, libMesh::LinearImplicitSystem, libMesh::NewmarkSystem, libMesh::NonlinearImplicitSystem, libMesh::RBConstruction, and libMesh::TransientSystem< RBConstruction >.
Definition at line 458 of file system.h.
Referenced by get_info().
| void libMesh::System::update | ( | ) | [virtual] |
Update the local values to reflect the solution on neighboring processors.
Definition at line 410 of file system.C.
References _dof_map, current_local_solution, and solution.
Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::FEMSystem::assembly(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::GMVIO::copy_nodal_solution(), DMFunction_libMesh(), DMJacobian_libMesh(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::postprocess(), libMesh::NonlinearImplicitSystem::solve(), libMesh::NewtonSolver::solve(), libMesh::LinearImplicitSystem::solve(), and libMesh::ExplicitSystem::solve().
00411 { 00412 libmesh_assert(solution->closed()); 00413 00414 const std::vector<dof_id_type>& send_list = _dof_map->get_send_list (); 00415 00416 // Check sizes 00417 libmesh_assert_equal_to (current_local_solution->size(), solution->size()); 00418 // More processors than elements => empty send_list 00419 // libmesh_assert (!send_list.empty()); 00420 libmesh_assert_less_equal (send_list.size(), solution->size()); 00421 00422 // Create current_local_solution from solution. This will 00423 // put a local copy of solution into current_local_solution. 00424 // Only the necessary values (specified by the send_list) 00425 // are copied to minimize communication 00426 solution->localize (*current_local_solution, send_list); 00427 }
| void libMesh::System::update_global_solution | ( | std::vector< Number > & | global_soln, | |
| const unsigned int | dest_proc | |||
| ) | const |
| void libMesh::System::update_global_solution | ( | std::vector< Number > & | global_soln | ) | const |
Fill the input vector global_soln so that it contains the global solution on all processors. Requires communication with all other processors.
Definition at line 656 of file system.C.
References solution.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::ExactErrorEstimator::estimate_error(), and libMesh::EquationSystems::get_solution().
| void libMesh::System::user_assembly | ( | ) | [virtual] |
Calls user's attached assembly function, or is overloaded by the user in derived classes.
Definition at line 1909 of file system.C.
References _assemble_system_function, _assemble_system_object, _equation_systems, libMesh::System::Assembly::assemble(), and name().
Referenced by assemble().
01910 { 01911 // Call the user-provided assembly function, 01912 // if it was provided 01913 if (_assemble_system_function != NULL) 01914 this->_assemble_system_function (_equation_systems, this->name()); 01915 01916 // ...or the user-provided assembly object. 01917 else if (_assemble_system_object != NULL) 01918 this->_assemble_system_object->assemble(); 01919 }
| void libMesh::System::user_constrain | ( | ) | [virtual] |
Calls user's attached constraint function, or is overloaded by the user in derived classes.
Definition at line 1923 of file system.C.
References _constrain_system_function, _constrain_system_object, _equation_systems, libMesh::System::Constraint::constrain(), and name().
Referenced by libMesh::EquationSystems::allgather(), init_data(), and libMesh::EquationSystems::reinit().
01924 { 01925 // Call the user-provided constraint function, 01926 // if it was provided 01927 if (_constrain_system_function!= NULL) 01928 this->_constrain_system_function(_equation_systems, this->name()); 01929 01930 // ...or the user-provided constraint object. 01931 else if (_constrain_system_object != NULL) 01932 this->_constrain_system_object->constrain(); 01933 }
| void libMesh::System::user_initialization | ( | ) | [virtual] |
Calls user's attached initialization function, or is overloaded by the user in derived classes.
Definition at line 1895 of file system.C.
References _equation_systems, _init_system_function, _init_system_object, libMesh::System::Initialization::initialize(), and name().
Referenced by init(), and libMesh::NewmarkSystem::initial_conditions().
01896 { 01897 // Call the user-provided intialization function, 01898 // if it was provided 01899 if (_init_system_function != NULL) 01900 this->_init_system_function (_equation_systems, this->name()); 01901 01902 // ...or the user-provided initialization object. 01903 else if (_init_system_object != NULL) 01904 this->_init_system_object->initialize(); 01905 }
| void libMesh::System::user_QOI | ( | const QoISet & | qoi_indices | ) | [virtual] |
Calls user's attached quantity of interest function, or is overloaded by the user in derived classes.
Definition at line 1937 of file system.C.
References _equation_systems, _qoi_evaluate_function, _qoi_evaluate_object, name(), and libMesh::System::QOI::qoi().
Referenced by assemble_qoi().
01938 { 01939 // Call the user-provided quantity of interest function, 01940 // if it was provided 01941 if (_qoi_evaluate_function != NULL) 01942 this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices); 01943 01944 // ...or the user-provided QOI function object. 01945 else if (_qoi_evaluate_object != NULL) 01946 this->_qoi_evaluate_object->qoi(qoi_indices); 01947 }
| void libMesh::System::user_QOI_derivative | ( | const QoISet & | qoi_indices | ) | [virtual] |
Calls user's attached quantity of interest derivative function, or is overloaded by the user in derived classes.
Definition at line 1951 of file system.C.
References _equation_systems, _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, name(), and libMesh::System::QOIDerivative::qoi_derivative().
Referenced by assemble_qoi_derivative().
01952 { 01953 // Call the user-provided quantity of interest derivative, 01954 // if it was provided 01955 if (_qoi_evaluate_derivative_function != NULL) 01956 this->_qoi_evaluate_derivative_function(_equation_systems, this->name(), qoi_indices); 01957 01958 // ...or the user-provided QOI derivative function object. 01959 else if (_qoi_evaluate_derivative_object != NULL) 01960 this->_qoi_evaluate_derivative_object->qoi_derivative(qoi_indices); 01961 }
| const Variable & libMesh::System::variable | ( | unsigned int | var | ) | const [inline] |
Return a constant reference to Variable var.
Definition at line 1926 of file system.h.
References _variables.
Referenced by libMesh::EquationSystems::build_solution_vector(), libMesh::WrappedFunction< Output >::component(), libMesh::EquationSystems::get_solution(), libMesh::WrappedFunction< Output >::operator()(), project_vector(), read_parallel_data(), read_SCALAR_dofs(), read_serialized_vector(), read_serialized_vectors(), write_header(), write_parallel_data(), write_serialized_vector(), and write_serialized_vectors().
01927 { 01928 libmesh_assert_less (i, _variables.size()); 01929 01930 return _variables[i]; 01931 }
| const VariableGroup & libMesh::System::variable_group | ( | unsigned int | vg | ) | const [inline] |
Return a constant reference to VariableGroup vg.
Definition at line 1936 of file system.h.
References _variable_groups.
Referenced by get_info().
01937 { 01938 libmesh_assert_less (vg, _variable_groups.size()); 01939 01940 return _variable_groups[vg]; 01941 }
| const std::string & libMesh::System::variable_name | ( | const unsigned int | i | ) | const [inline] |
- Returns:
- the name of variable
i.
Definition at line 1946 of file system.h.
References _variables.
Referenced by add_variable(), add_variables(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::WrappedFunction< Output >::component(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactSolution::ExactSolution(), libMesh::EquationSystems::get_solution(), libMesh::WrappedFunction< Output >::operator()(), and write_header().
01947 { 01948 libmesh_assert_less (i, _variables.size()); 01949 01950 return _variables[i].name(); 01951 }
| unsigned short int libMesh::System::variable_number | ( | const std::string & | var | ) | const |
- Returns:
- the variable number assoicated with the user-specified variable named
var.
Definition at line 1239 of file system.C.
References _variable_numbers, _variables, and libMesh::err.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), read_header(), variable_scalar_number(), variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
01240 { 01241 // Make sure the variable exists 01242 std::map<std::string, unsigned short int>::const_iterator 01243 pos = _variable_numbers.find(var); 01244 01245 if (pos == _variable_numbers.end()) 01246 { 01247 libMesh::err << "ERROR: variable " 01248 << var 01249 << " does not exist in this system!" 01250 << std::endl; 01251 libmesh_error(); 01252 } 01253 libmesh_assert_equal_to (_variables[pos->second].name(), var); 01254 01255 return pos->second; 01256 }
| unsigned int libMesh::System::variable_scalar_number | ( | unsigned int | var_num, | |
| unsigned int | component | |||
| ) | const [inline] |
- Returns:
- an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as
var_num
Irony: currently our only non-scalar-valued variable type is SCALAR.
Definition at line 1967 of file system.h.
References _variables.
01969 { 01970 return _variables[var_num].first_scalar_number() + component; 01971 }
| unsigned int libMesh::System::variable_scalar_number | ( | const std::string & | var, | |
| unsigned int | component | |||
| ) | const [inline] |
- Returns:
- an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as
variable_number(var)
Irony: currently our only non-scalar-valued variable type is SCALAR.
Definition at line 1957 of file system.h.
References variable_number().
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::WrappedFunction< Output >::component(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::WrappedFunction< Output >::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::ProjectSolution::operator()(), and project_vector().
01959 { 01960 return variable_scalar_number(this->variable_number(var), component); 01961 }
| const FEType & libMesh::System::variable_type | ( | const std::string & | var | ) | const [inline] |
- Returns:
- the finite element type for variable
var.
Definition at line 1986 of file system.h.
References _variables, and variable_number().
01987 { 01988 return _variables[this->variable_number(var)].type(); 01989 }
| const FEType & libMesh::System::variable_type | ( | const unsigned int | i | ) | const [inline] |
- Returns:
- the finite element type variable number
i.
Definition at line 1976 of file system.h.
References _variables.
Referenced by add_variable(), add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::GMVIO::copy_nodal_solution(), libMesh::FEMContext::FEMContext(), libMesh::EquationSystems::get_solution(), write_header(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
01977 { 01978 libmesh_assert_less (i, _variables.size()); 01979 01980 return _variables[i].type(); 01981 }
| const std::string & libMesh::System::vector_name | ( | const NumericVector< Number > & | vec_reference | ) | const |
- Returns:
- the name of a system vector, given a reference to that vector
Definition at line 868 of file system.C.
References vectors_begin(), and vectors_end().
00869 { 00870 const_vectors_iterator v = vectors_begin(); 00871 const_vectors_iterator v_end = vectors_end(); 00872 00873 for(; v != v_end; ++v) 00874 { 00875 // Check if the current vector is the one whose name we want 00876 if(&vec_reference == v->second) 00877 break; // exit loop if it is 00878 } 00879 00880 // Before returning, make sure we didnt loop till the end and not find any match 00881 libmesh_assert (v != v_end); 00882 00883 // Return the string associated with the current vector 00884 return v->first; 00885 }
| const std::string & libMesh::System::vector_name | ( | const unsigned int | vec_num | ) | const |
- Returns:
- the name of this system's additional vector number
vec_num(where the vectors are counted starting with 0).
Definition at line 854 of file system.C.
References vectors_begin(), and vectors_end().
00855 { 00856 const_vectors_iterator v = vectors_begin(); 00857 const_vectors_iterator v_end = vectors_end(); 00858 unsigned int num = 0; 00859 while((num<vec_num) && (v!=v_end)) 00860 { 00861 num++; 00862 ++v; 00863 } 00864 libmesh_assert (v != v_end); 00865 return v->first; 00866 }
| bool libMesh::System::vector_preservation | ( | const std::string & | vec_name | ) | const |
- Returns:
- the boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.
Definition at line 895 of file system.C.
References _vector_projections.
Referenced by libMesh::MemorySolutionHistory::store().
00896 { 00897 if (_vector_projections.find(vec_name) == _vector_projections.end()) 00898 return false; 00899 00900 return _vector_projections.find(vec_name)->second; 00901 }
| System::const_vectors_iterator libMesh::System::vectors_begin | ( | ) | const [inline] |
| System::vectors_iterator libMesh::System::vectors_begin | ( | ) | [inline] |
Beginning of vectors container
Definition at line 2038 of file system.h.
References _vectors.
Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), get_vector(), request_vector(), libMesh::MemorySolutionHistory::store(), libMesh::VTKIO::system_vectors_to_vtk(), and vector_name().
02039 { 02040 return _vectors.begin(); 02041 }
| System::const_vectors_iterator libMesh::System::vectors_end | ( | ) | const [inline] |
| System::vectors_iterator libMesh::System::vectors_end | ( | ) | [inline] |
End of vectors container
Definition at line 2050 of file system.h.
References _vectors.
Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), get_vector(), request_vector(), libMesh::MemorySolutionHistory::store(), libMesh::VTKIO::system_vectors_to_vtk(), and vector_name().
02051 { 02052 return _vectors.end(); 02053 }
| std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_adjoint_solve | ( | const ParameterVector & | parameters, | |
| const ParameterVector & | weights, | |||
| const QoISet & | qoi_indices = QoISet() | |||
| ) | [inline, virtual] |
Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
Assumes that adjoint_solve has already calculated z for each qoi in qoi_indices.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_solve | ( | const ParameterVector & | parameters, | |
| const ParameterVector & | weights | |||
| ) | [inline, virtual] |
Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
This method is only implemented in some derived classes.
Reimplemented in libMesh::ImplicitSystem.
| void libMesh::System::write_header | ( | Xdr & | io, | |
| const std::string & | version, | |||
| const bool | write_additional_data | |||
| ) | const |
Writes the basic data header for this System.
This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:
for this system
5.) The number of variables in the system (unsigned int)
for each variable in the system
6.) The name of the variable (string)
6.1.) subdomain where the variable lives
7.) Combined in an FEType:
- The approximation order(s) of the variable (Order Enum, cast to int/s)
- The finite element family/ies of the variable (FEFamily Enum, cast to int/s)
end variable loop
8.) The number of additional vectors (unsigned int),
for each additional vector in the system object
9.) the name of the additional vector (string)
end system
Definition at line 1240 of file system_io.C.
References _vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::FEType::inf_map, n_vars(), n_vectors(), name(), libMesh::FEType::order, libMesh::MeshBase::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, variable(), variable_name(), variable_type(), and libMesh::Xdr::writing().
01243 { 01277 libmesh_assert (io.writing()); 01278 01279 01280 // Only write the header information 01281 // if we are processor 0. 01282 if (this->get_mesh().processor_id() != 0) 01283 return; 01284 01285 std::string comment; 01286 char buf[80]; 01287 01288 // 5.) 01289 // Write the number of variables in the system 01290 01291 { 01292 // set up the comment 01293 comment = "# No. of Variables in System \""; 01294 comment += this->name(); 01295 comment += "\""; 01296 01297 unsigned int nv = this->n_vars(); 01298 io.data (nv, comment.c_str()); 01299 } 01300 01301 01302 for (unsigned int var=0; var<this->n_vars(); var++) 01303 { 01304 // 6.) 01305 // Write the name of the var-th variable 01306 { 01307 // set up the comment 01308 comment = "# Name, Variable No. "; 01309 std::sprintf(buf, "%d", var); 01310 comment += buf; 01311 comment += ", System \""; 01312 comment += this->name(); 01313 comment += "\""; 01314 01315 std::string var_name = this->variable_name(var); 01316 io.data (var_name, comment.c_str()); 01317 } 01318 01319 // 6.1.) Variable subdomains 01320 { 01321 // set up the comment 01322 comment = "# Subdomains, Variable \""; 01323 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01324 comment += buf; 01325 comment += "\", System \""; 01326 comment += this->name(); 01327 comment += "\""; 01328 01329 const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains(); 01330 std::vector<subdomain_id_type> domain_array; 01331 domain_array.assign(domains.begin(), domains.end()); 01332 io.data (domain_array, comment.c_str()); 01333 } 01334 01335 // 7.) 01336 // Write the approximation order of the var-th variable 01337 // in this system 01338 { 01339 // set up the comment 01340 comment = "# Approximation Order, Variable \""; 01341 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01342 comment += buf; 01343 comment += "\", System \""; 01344 comment += this->name(); 01345 comment += "\""; 01346 01347 int order = static_cast<int>(this->variable_type(var).order); 01348 io.data (order, comment.c_str()); 01349 } 01350 01351 01352 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 01353 01354 // do the same for radial_order 01355 { 01356 comment = "# Radial Approximation Order, Variable \""; 01357 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01358 comment += buf; 01359 comment += "\", System \""; 01360 comment += this->name(); 01361 comment += "\""; 01362 01363 int rad_order = static_cast<int>(this->variable_type(var).radial_order); 01364 io.data (rad_order, comment.c_str()); 01365 } 01366 01367 #endif 01368 01369 // Write the Finite Element type of the var-th variable 01370 // in this System 01371 { 01372 // set up the comment 01373 comment = "# FE Family, Variable \""; 01374 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01375 comment += buf; 01376 comment += "\", System \""; 01377 comment += this->name(); 01378 comment += "\""; 01379 01380 const FEType& type = this->variable_type(var); 01381 int fam = static_cast<int>(type.family); 01382 io.data (fam, comment.c_str()); 01383 01384 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 01385 01386 comment = "# Radial FE Family, Variable \""; 01387 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01388 comment += buf; 01389 comment += "\", System \""; 01390 comment += this->name(); 01391 comment += "\""; 01392 01393 int radial_fam = static_cast<int>(type.radial_family); 01394 io.data (radial_fam, comment.c_str()); 01395 01396 comment = "# Infinite Mapping Type, Variable \""; 01397 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 01398 comment += buf; 01399 comment += "\", System \""; 01400 comment += this->name(); 01401 comment += "\""; 01402 01403 int i_map = static_cast<int>(type.inf_map); 01404 io.data (i_map, comment.c_str()); 01405 #endif 01406 } 01407 } // end of the variable loop 01408 01409 // 8.) 01410 // Write the number of additional vectors in the System. 01411 // If write_additional_data==false, then write zero for 01412 // the number of additional vectors. 01413 { 01414 { 01415 // set up the comment 01416 comment = "# No. of Additional Vectors, System \""; 01417 comment += this->name(); 01418 comment += "\""; 01419 01420 unsigned int nvecs = write_additional_data ? this->n_vectors () : 0; 01421 io.data (nvecs, comment.c_str()); 01422 } 01423 01424 if (write_additional_data) 01425 { 01426 std::map<std::string, NumericVector<Number>* >::const_iterator 01427 vec_pos = this->_vectors.begin(); 01428 unsigned int cnt=0; 01429 01430 for (; vec_pos != this->_vectors.end(); ++vec_pos) 01431 { 01432 // 9.) 01433 // write the name of the cnt-th additional vector 01434 comment = "# Name of "; 01435 std::sprintf(buf, "%d", cnt++); 01436 comment += buf; 01437 comment += "th vector"; 01438 std::string vec_name = vec_pos->first; 01439 01440 io.data (vec_name, comment.c_str()); 01441 } 01442 } 01443 } 01444 }
| void libMesh::System::write_parallel_data | ( | Xdr & | io, | |
| const bool | write_additional_data | |||
| ) | const |
Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.
Definition at line 1448 of file system_io.C.
References _vectors, libMesh::Xdr::data(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::DofObject::invalid_id, libMesh::n_processors(), n_vars(), name(), number(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), solution, libMesh::Variable::type(), variable(), and libMesh::Xdr::writing().
01450 { 01470 // PerfLog pl("IO Performance",false); 01471 // pl.push("write_parallel_data"); 01472 std::size_t total_written_size = 0; 01473 01474 std::string comment; 01475 01476 libmesh_assert (io.writing()); 01477 01478 std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size()); 01479 01480 // build the ordered nodes and element maps. 01481 // when writing/reading parallel files we need to iterate 01482 // over our nodes/elements in order of increasing global id(). 01483 // however, this is not guaranteed to be ordering we obtain 01484 // by using the node_iterators/element_iterators directly. 01485 // so build a set, sorted by id(), that provides the ordering. 01486 // further, for memory economy build the set but then transfer 01487 // its contents to vectors, which will be sorted. 01488 std::vector<const DofObject*> ordered_nodes, ordered_elements; 01489 { 01490 std::set<const DofObject*, CompareDofObjectsByID> 01491 ordered_nodes_set (this->get_mesh().local_nodes_begin(), 01492 this->get_mesh().local_nodes_end()); 01493 01494 ordered_nodes.insert(ordered_nodes.end(), 01495 ordered_nodes_set.begin(), 01496 ordered_nodes_set.end()); 01497 } 01498 { 01499 std::set<const DofObject*, CompareDofObjectsByID> 01500 ordered_elements_set (this->get_mesh().local_elements_begin(), 01501 this->get_mesh().local_elements_end()); 01502 01503 ordered_elements.insert(ordered_elements.end(), 01504 ordered_elements_set.begin(), 01505 ordered_elements_set.end()); 01506 } 01507 01508 const unsigned int sys_num = this->number(); 01509 const unsigned int nv = this->n_vars(); 01510 01511 // Loop over each non-SCALAR variable and each node, and write out the value. 01512 for (unsigned int var=0; var<nv; var++) 01513 if (this->variable(var).type().family != SCALAR) 01514 { 01515 // First write the node DOF values 01516 for (std::vector<const DofObject*>::const_iterator 01517 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 01518 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01519 { 01520 //libMesh::out << "(*it)->id()=" << (*it)->id() << std::endl; 01521 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 01522 DofObject::invalid_id); 01523 01524 io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp))); 01525 } 01526 01527 // Then write the element DOF values 01528 for (std::vector<const DofObject*>::const_iterator 01529 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 01530 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01531 { 01532 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 01533 DofObject::invalid_id); 01534 01535 io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp))); 01536 } 01537 } 01538 01539 // Finally, write the SCALAR data on the last processor 01540 for (unsigned int var=0; var<this->n_vars(); var++) 01541 if(this->variable(var).type().family == SCALAR) 01542 { 01543 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 01544 { 01545 const DofMap& dof_map = this->get_dof_map(); 01546 std::vector<dof_id_type> SCALAR_dofs; 01547 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 01548 01549 for(unsigned int i=0; i<SCALAR_dofs.size(); i++) 01550 { 01551 io_buffer.push_back( (*this->solution)(SCALAR_dofs[i]) ); 01552 } 01553 } 01554 } 01555 01556 // 9.) 01557 // 01558 // Actually write the reordered solution vector 01559 // for the ith system to disk 01560 01561 // set up the comment 01562 { 01563 comment = "# System \""; 01564 comment += this->name(); 01565 comment += "\" Solution Vector"; 01566 } 01567 01568 io.data (io_buffer, comment.c_str()); 01569 01570 total_written_size += io_buffer.size(); 01571 01572 // Only write additional vectors if wanted 01573 if (write_additional_data) 01574 { 01575 std::map<std::string, NumericVector<Number>* >::const_iterator 01576 pos = _vectors.begin(); 01577 01578 for(; pos != this->_vectors.end(); ++pos) 01579 { 01580 io_buffer.clear(); io_buffer.reserve( pos->second->local_size()); 01581 01582 // Loop over each non-SCALAR variable and each node, and write out the value. 01583 for (unsigned int var=0; var<nv; var++) 01584 if(this->variable(var).type().family != SCALAR) 01585 { 01586 // First write the node DOF values 01587 for (std::vector<const DofObject*>::const_iterator 01588 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 01589 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01590 { 01591 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 01592 DofObject::invalid_id); 01593 01594 io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp))); 01595 } 01596 01597 // Then write the element DOF values 01598 for (std::vector<const DofObject*>::const_iterator 01599 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 01600 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01601 { 01602 libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp), 01603 DofObject::invalid_id); 01604 01605 io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp))); 01606 } 01607 } 01608 01609 // Finally, write the SCALAR data on the last processor 01610 for (unsigned int var=0; var<this->n_vars(); var++) 01611 if(this->variable(var).type().family == SCALAR) 01612 { 01613 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 01614 { 01615 const DofMap& dof_map = this->get_dof_map(); 01616 std::vector<dof_id_type> SCALAR_dofs; 01617 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 01618 01619 for(unsigned int i=0; i<SCALAR_dofs.size(); i++) 01620 { 01621 io_buffer.push_back( (*pos->second)(SCALAR_dofs[i]) ); 01622 } 01623 } 01624 } 01625 01626 // 10.) 01627 // 01628 // Actually write the reordered additional vector 01629 // for this system to disk 01630 01631 // set up the comment 01632 { 01633 comment = "# System \""; 01634 comment += this->name(); 01635 comment += "\" Additional Vector \""; 01636 comment += pos->first; 01637 comment += "\""; 01638 } 01639 01640 io.data (io_buffer, comment.c_str()); 01641 01642 total_written_size += io_buffer.size(); 01643 } 01644 } 01645 01646 // const Real 01647 // dt = pl.get_elapsed_time(), 01648 // rate = total_written_size*sizeof(Number)/dt; 01649 01650 // std::cerr << "Write " << total_written_size << " \"Number\" values\n" 01651 // << " Elapsed time = " << dt << '\n' 01652 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n"; 01653 01654 // pl.pop("write_parallel_data"); 01655 }
| unsigned int libMesh::System::write_SCALAR_dofs | ( | const NumericVector< Number > & | vec, | |
| const unsigned int | var, | |||
| Xdr & | io | |||
| ) | const [private] |
Writes the SCALAR dofs associated with var to the stream io.
Returns the number of values written.
Definition at line 2065 of file system_io.C.
References libMesh::CommWorld, libMesh::Xdr::data_stream(), get_dof_map(), libMesh::n_processors(), libMesh::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), and libMesh::Parallel::Communicator::send().
Referenced by write_serialized_vector(), and write_serialized_vectors().
02068 { 02069 unsigned int written_length=0; 02070 std::vector<Number> vals; // The raw values for the local objects in the current block 02071 // Collect the SCALARs for the current variable 02072 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 02073 { 02074 const DofMap& dof_map = this->get_dof_map(); 02075 std::vector<dof_id_type> SCALAR_dofs; 02076 dof_map.SCALAR_dof_indices(SCALAR_dofs, var); 02077 const unsigned int n_scalar_dofs = libmesh_cast_int<unsigned int> 02078 (SCALAR_dofs.size()); 02079 02080 for(unsigned int i=0; i<n_scalar_dofs; i++) 02081 { 02082 vals.push_back( vec(SCALAR_dofs[i]) ); 02083 } 02084 } 02085 02086 #ifdef LIBMESH_HAVE_MPI 02087 if ( libMesh::n_processors() > 1 ) 02088 { 02089 const Parallel::MessageTag val_tag(1); 02090 02091 // Post the receive on processor 0 02092 if ( libMesh::processor_id() == 0 ) 02093 { 02094 CommWorld.receive(libMesh::n_processors()-1, vals, val_tag); 02095 } 02096 02097 // Send the data to processor 0 02098 if (libMesh::processor_id() == (libMesh::n_processors()-1)) 02099 { 02100 CommWorld.send(0, vals, val_tag); 02101 } 02102 } 02103 #endif 02104 02105 // ------------------------------------------------------- 02106 // Write the output on processor 0. 02107 if (libMesh::processor_id() == 0) 02108 { 02109 io.data_stream (&vals[0], vals.size()); 02110 written_length += libmesh_cast_int<unsigned int>(vals.size()); 02111 } 02112 02113 return written_length; 02114 }
| dof_id_type libMesh::System::write_serialized_blocked_dof_objects | ( | const std::vector< const NumericVector< Number > * > & | vecs, | |
| const dof_id_type | n_objects, | |||
| const iterator_type | begin, | |||
| const iterator_type | end, | |||
| Xdr & | io, | |||
| const unsigned int | var_to_write = libMesh::invalid_uint | |||
| ) | const [inline, private] |
Writes an output vector to the stream io for a set of DofObjects. This method uses blocked output and is safe to call on a distributed memory-mesh.
Returns the number of values written
Definition at line 1770 of file system_io.C.
References libMesh::Parallel::any_source, libMesh::Parallel::Communicator::broadcast(), libMesh::Parallel::Communicator_World, libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::AutoPtr< Tp >::get(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::NumericVector< T >::last_local_index(), std::min(), libMesh::n_processors(), n_vars(), number(), libMesh::Parallel::Communicator::probe(), libMesh::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::AutoPtr< Tp >::reset(), libMesh::Parallel::Communicator::send(), and libMesh::Parallel::wait().
Referenced by write_serialized_vector(), and write_serialized_vectors().
01776 { 01777 //------------------------------------------------------- 01778 // General order: (IO format 0.7.4 & greater) 01779 // 01780 // for (objects ...) 01781 // for (vecs ....) 01782 // for (vars ....) 01783 // for (comps ...) 01784 // 01785 // where objects are nodes or elements, sorted to be 01786 // partition independent, 01787 // vecs are one or more *identically distributed* solution 01788 // coefficient vectors, vars are one or more variables 01789 // to write, and comps are all the components for said 01790 // vars on the object. 01791 01792 typedef std::vector<const NumericVector<Number>*>::const_iterator vec_iterator_type; 01793 01794 // We will write all variables unless requested otherwise. 01795 std::vector<unsigned int> vars_to_write(1, var_to_write); 01796 01797 if (var_to_write == libMesh::invalid_uint) 01798 { 01799 vars_to_write.clear(); vars_to_write.reserve(this->n_vars()); 01800 for (unsigned int var=0; var<this->n_vars(); var++) 01801 vars_to_write.push_back(var); 01802 } 01803 01804 const dof_id_type 01805 io_blksize = std::min(max_io_blksize, n_objs); 01806 01807 const unsigned int 01808 sys_num = this->number(), 01809 num_vecs = libmesh_cast_int<unsigned int>(vecs.size()), 01810 num_blks = std::ceil(static_cast<double>(n_objs)/static_cast<double>(io_blksize)); 01811 01812 // std::cout << "io_blksize = " << io_blksize 01813 // << ", num_objects = " << n_objs 01814 // << ", num_blks = " << num_blks 01815 // << std::endl; 01816 01817 dof_id_type written_length=0; // The numer of values written. This will be returned 01818 std::vector<std::vector<dof_id_type> > xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks 01819 std::vector<std::vector<Number> > send_vals(num_blks); // The raw values for the local objects in all blocks 01820 std::vector<Parallel::Request> 01821 id_requests(num_blks), val_requests(num_blks); // send request handle for each block 01822 01823 // ------------------------------------------------------ 01824 // First pass - count the number of objects in each block 01825 // traverse all the objects and figure out which block they 01826 // will utlimately live in. 01827 std::vector<unsigned int> 01828 xfer_ids_size (num_blks,0), 01829 send_vals_size (num_blks,0); 01830 01831 for (iterator_type it=begin; it!=end; ++it) 01832 { 01833 const dof_id_type 01834 id = (*it)->id(), 01835 block = id/io_blksize; 01836 01837 libmesh_assert_less (block, num_blks); 01838 01839 xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables 01840 01841 unsigned int n_comp_tot=0; 01842 01843 for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin(); 01844 var_it!=vars_to_write.end(); ++var_it) 01845 n_comp_tot += (*it)->n_comp(sys_num, *var_it); // for each variable, we will store the nonzero components 01846 01847 send_vals_size[block] += n_comp_tot*num_vecs; 01848 } 01849 01850 //----------------------------------------- 01851 // Collect the values for all local objects, 01852 // binning them into 'blocks' that will be 01853 // sent to processor 0 01854 for (unsigned int blk=0; blk<num_blks; blk++) 01855 { 01856 // libMesh::out << "Writing object block " << blk << std::endl; 01857 01858 // Each processor should build up its transfer buffers for its 01859 // local objects in [first_object,last_object). 01860 const dof_id_type 01861 first_object = blk*io_blksize, 01862 last_object = std::min(static_cast<dof_id_type>((blk+1)*io_blksize), 01863 n_objs); 01864 01865 // convenience 01866 std::vector<dof_id_type> &ids (xfer_ids[blk]); 01867 std::vector<Number> &vals (send_vals[blk]); 01868 01869 // we now know the number of values we will store for each block, 01870 // so we can do efficient preallocation 01871 ids.clear(); ids.reserve (xfer_ids_size[blk]); 01872 vals.clear(); vals.reserve (send_vals_size[blk]); 01873 01874 if (send_vals_size[blk] != 0) // only send if we have nonzero components to write 01875 for (iterator_type it=begin; it!=end; ++it) 01876 if (((*it)->id() >= first_object) && // object in [first_object,last_object) 01877 ((*it)->id() < last_object)) 01878 { 01879 ids.push_back((*it)->id()); 01880 01881 // count the total number of nonzeros transferred for this object 01882 { 01883 unsigned int n_comp_tot=0; 01884 01885 for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin(); 01886 var_it!=vars_to_write.end(); ++var_it) 01887 n_comp_tot += (*it)->n_comp(sys_num,*var_it); 01888 01889 ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise... 01890 } 01891 01892 // pack the values to send 01893 for (vec_iterator_type vec_it=vecs.begin(); vec_it!=vecs.end(); ++vec_it) 01894 { 01895 const NumericVector<Number> &vec(**vec_it); 01896 01897 for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin(); 01898 var_it!=vars_to_write.end(); ++var_it) 01899 { 01900 const unsigned int n_comp = (*it)->n_comp(sys_num,*var_it); 01901 01902 for (unsigned int comp=0; comp<n_comp; comp++) 01903 { 01904 libmesh_assert_greater_equal ((*it)->dof_number(sys_num, *var_it, comp), vec.first_local_index()); 01905 libmesh_assert_less ((*it)->dof_number(sys_num, *var_it, comp), vec.last_local_index()); 01906 vals.push_back(vec((*it)->dof_number(sys_num, *var_it, comp))); 01907 } 01908 } 01909 } 01910 } 01911 01912 #ifdef LIBMESH_HAVE_MPI 01913 Parallel::MessageTag id_tag = Parallel::Communicator_World.get_unique_tag(100*num_blks + blk); 01914 Parallel::MessageTag val_tag = Parallel::Communicator_World.get_unique_tag(200*num_blks + blk); 01915 01916 // nonblocking send the data for this block 01917 CommWorld.send (0, ids, id_requests[blk], id_tag); 01918 CommWorld.send (0, vals, val_requests[blk], val_tag); 01919 #endif 01920 } 01921 01922 01923 if (libMesh::processor_id() == 0) 01924 { 01925 std::vector<std::vector<dof_id_type> > recv_ids (libMesh::n_processors()); 01926 std::vector<std::vector<Number> > recv_vals (libMesh::n_processors()); 01927 std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise 01928 std::vector<Number> output_vals; // The output buffer for the current block 01929 01930 // a ThreadedIO object to perform asychronous file IO 01931 ThreadedIO threaded_io(io, output_vals); 01932 AutoPtr<Threads::Thread> async_io; 01933 01934 for (unsigned int blk=0; blk<num_blks; blk++) 01935 { 01936 // Each processor should build up its transfer buffers for its 01937 // local objects in [first_object,last_object). 01938 const dof_id_type 01939 first_object = blk*io_blksize, 01940 last_object = std::min(static_cast<dof_id_type>((blk+1)*io_blksize), 01941 n_objs), 01942 n_objects_blk = last_object - first_object; 01943 01944 // offset array. this will define where each object's values 01945 // map into the actual output_vals buffer. this must get 01946 // 0-initialized because 0-component objects are not actually sent 01947 obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0); 01948 01949 dof_id_type n_val_recvd_blk=0; 01950 01951 // tags to select data received 01952 Parallel::MessageTag id_tag (Parallel::Communicator_World.get_unique_tag(100*num_blks + blk)); 01953 Parallel::MessageTag val_tag (Parallel::Communicator_World.get_unique_tag(200*num_blks + blk)); 01954 01955 // receive this block of data from all processors. 01956 for (unsigned int comm_step=0; comm_step<libMesh::n_processors(); comm_step++) 01957 { 01958 #ifdef LIBMESH_HAVE_MPI 01959 // blocking receive indices for this block, imposing no particular order on processor 01960 Parallel::Status id_status (CommWorld.probe (Parallel::any_source, id_tag)); 01961 std::vector<dof_id_type> &ids (recv_ids[id_status.source()]); 01962 CommWorld.receive (id_status.source(), ids, id_tag); 01963 #else 01964 std::vector<dof_id_type> &ids (recv_ids[0]); 01965 #endif 01966 01967 // note its possible we didn't receive values for objects in 01968 // this block if they have no components allocated. 01969 for (dof_id_type idx=0; idx<ids.size(); idx+=2) 01970 { 01971 const dof_id_type 01972 local_idx = ids[idx+0]-first_object, 01973 n_vals_tot_allvecs = ids[idx+1]; 01974 01975 libmesh_assert_less (local_idx, n_objects_blk); 01976 libmesh_assert_less (local_idx, obj_val_offsets.size()); 01977 01978 obj_val_offsets[local_idx] = n_vals_tot_allvecs; 01979 } 01980 01981 #ifdef LIBMESH_HAVE_MPI 01982 // blocking receive values for this block, imposing no particular order on processor 01983 Parallel::Status val_status (CommWorld.probe (Parallel::any_source, val_tag)); 01984 std::vector<Number> &vals (recv_vals[val_status.source()]); 01985 CommWorld.receive (val_status.source(), vals, val_tag); 01986 #else 01987 // straight copy without MPI 01988 std::vector<Number> &vals (recv_vals[0]); 01989 vals = send_vals[blk]; 01990 #endif 01991 01992 n_val_recvd_blk += vals.size(); 01993 } 01994 01995 // We need the offests into the output_vals vector for each object. 01996 // fortunately, this is simply the partial sum of the total number 01997 // of components for each object 01998 std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(), 01999 obj_val_offsets.begin()); 02000 02001 // wait on any previous asynchronous IO - this *must* complete before 02002 // we start messing with the output_vals buffer! 02003 if (async_io.get()) async_io->join(); 02004 02005 // this is the actual output buffer that will be written to disk. 02006 // at ths point we finally know wha size it will be. 02007 output_vals.resize(n_val_recvd_blk); 02008 02009 // pack data from all processors into output values 02010 for (unsigned int proc=0; proc<libMesh::n_processors(); proc++) 02011 { 02012 const std::vector<dof_id_type> &ids (recv_ids [proc]); 02013 const std::vector<Number> &vals(recv_vals[proc]); 02014 std::vector<Number>::const_iterator proc_vals(vals.begin()); 02015 02016 for (dof_id_type idx=0; idx<ids.size(); idx+=2) 02017 { 02018 const dof_id_type 02019 local_idx = ids[idx+0]-first_object, 02020 n_vals_tot_allvecs = ids[idx+1]; 02021 02022 // put this object's data into the proper location 02023 // in the output buffer 02024 std::vector<Number>::iterator out_vals(output_vals.begin()); 02025 if (local_idx != 0) 02026 std::advance (out_vals, obj_val_offsets[local_idx-1]); 02027 02028 for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals) 02029 { 02030 libmesh_assert (out_vals != output_vals.end()); 02031 libmesh_assert (proc_vals != vals.end()); 02032 *out_vals = *proc_vals; 02033 } 02034 } 02035 } 02036 02037 // output_vals buffer is now filled for this block. 02038 // write it to disk 02039 async_io.reset(new Threads::Thread(threaded_io)); 02040 written_length += output_vals.size(); 02041 } 02042 02043 // wait on any previous asynchronous IO - this *must* complete before 02044 // our stuff goes out of scope 02045 async_io->join(); 02046 } 02047 02048 Parallel::wait(id_requests); 02049 Parallel::wait(val_requests); 02050 02051 // we need some synchronization here. Because this method 02052 // can be called for a range of nodes, then a range of elements, 02053 // we need some mechanism to prevent processors from racing past 02054 // to the next range and overtaking ongoing communication. one 02055 // approach would be to figure out unique tags for each range, 02056 // but for now we just impose a barrier here. And might as 02057 // well have it do some useful work. 02058 CommWorld.broadcast(written_length); 02059 02060 return written_length; 02061 }
| void libMesh::System::write_serialized_data | ( | Xdr & | io, | |
| const bool | write_additional_data = true | |||
| ) | const |
Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Definition at line 1659 of file system_io.C.
References _vectors, libMesh::Xdr::comment(), name(), libMesh::processor_id(), solution, and write_serialized_vector().
01661 { 01675 parallel_only(); 01676 std::string comment; 01677 01678 // PerfLog pl("IO Performance",false); 01679 // pl.push("write_serialized_data"); 01680 std::size_t total_written_size = 0; 01681 01682 total_written_size += 01683 this->write_serialized_vector(io, *this->solution); 01684 01685 // set up the comment 01686 if (libMesh::processor_id() == 0) 01687 { 01688 comment = "# System \""; 01689 comment += this->name(); 01690 comment += "\" Solution Vector"; 01691 01692 io.comment (comment); 01693 } 01694 01695 // Only write additional vectors if wanted 01696 if (write_additional_data) 01697 { 01698 std::map<std::string, NumericVector<Number>* >::const_iterator 01699 pos = _vectors.begin(); 01700 01701 for(; pos != this->_vectors.end(); ++pos) 01702 { 01703 total_written_size += 01704 this->write_serialized_vector(io, *pos->second); 01705 01706 // set up the comment 01707 if (libMesh::processor_id() == 0) 01708 { 01709 comment = "# System \""; 01710 comment += this->name(); 01711 comment += "\" Additional Vector \""; 01712 comment += pos->first; 01713 comment += "\""; 01714 io.comment (comment); 01715 } 01716 } 01717 } 01718 01719 // const Real 01720 // dt = pl.get_elapsed_time(), 01721 // rate = total_written_size*sizeof(Number)/dt; 01722 01723 // std::cout << "Write " << total_written_size << " \"Number\" values\n" 01724 // << " Elapsed time = " << dt << '\n' 01725 // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n"; 01726 01727 // pl.pop("write_serialized_data"); 01728 01729 01730 01731 01732 // // test the new method 01733 // { 01734 // std::vector<std::string> names; 01735 // std::vector<NumericVector<Number>*> vectors_to_write; 01736 01737 // names.push_back("Solution Vector"); 01738 // vectors_to_write.push_back(this->solution.get()); 01739 01740 // // Only write additional vectors if wanted 01741 // if (write_additional_data) 01742 // { 01743 // std::map<std::string, NumericVector<Number>* >::const_iterator 01744 // pos = _vectors.begin(); 01745 01746 // for(; pos != this->_vectors.end(); ++pos) 01747 // { 01748 // names.push_back("Additional Vector " + pos->first); 01749 // vectors_to_write.push_back(pos->second); 01750 // } 01751 // } 01752 01753 // total_written_size = 01754 // this->write_serialized_vectors (io, names, vectors_to_write); 01755 01756 // const Real 01757 // dt2 = pl.get_elapsed_time(), 01758 // rate2 = total_written_size*sizeof(Number)/(dt2-dt); 01759 01760 // std::cout << "Write (new) " << total_written_size << " \"Number\" values\n" 01761 // << " Elapsed time = " << (dt2-dt) << '\n' 01762 // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n"; 01763 01764 // } 01765 }
| dof_id_type libMesh::System::write_serialized_vector | ( | Xdr & | io, | |
| const NumericVector< Number > & | vec | |||
| ) | const [private] |
Writes a vector for this System. This method may safely be called on a distributed-memory mesh.
Returns the number of values written.
Definition at line 2118 of file system_io.C.
References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::MeshTools::n_elem(), n_nodes, n_vars(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::NumericVector< T >::size(), libMesh::Variable::type(), variable(), write_SCALAR_dofs(), write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().
Referenced by write_serialized_data().
02119 { 02120 parallel_only(); 02121 02122 libmesh_assert (io.writing()); 02123 02124 dof_id_type vec_length = vec.size(); 02125 if (libMesh::processor_id() == 0) io.data (vec_length, "# vector length"); 02126 02127 dof_id_type written_length = 0; 02128 02129 //--------------------------------- 02130 // Collect the values for all nodes 02131 written_length += 02132 this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number>*>(1,&vec), 02133 this->get_mesh().n_nodes(), 02134 this->get_mesh().local_nodes_begin(), 02135 this->get_mesh().local_nodes_end(), 02136 io); 02137 02138 //------------------------------------ 02139 // Collect the values for all elements 02140 written_length += 02141 this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number>*>(1,&vec), 02142 this->get_mesh().n_elem(), 02143 this->get_mesh().local_elements_begin(), 02144 this->get_mesh().local_elements_end(), 02145 io); 02146 02147 //------------------------------------------- 02148 // Finally loop over all the SCALAR variables 02149 for (unsigned int var=0; var<this->n_vars(); var++) 02150 if(this->variable(var).type().family == SCALAR) 02151 { 02152 written_length += 02153 this->write_SCALAR_dofs (vec, var, io); 02154 } 02155 02156 if (libMesh::processor_id() == 0) 02157 libmesh_assert_equal_to (written_length, vec_length); 02158 02159 return written_length; 02160 }
| dof_id_type libMesh::System::write_serialized_vectors | ( | Xdr & | io, | |
| const std::vector< const NumericVector< Number > * > & | vectors | |||
| ) | const |
Serialize & write a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.
Definition at line 2256 of file system_io.C.
References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_nodes(), n_nodes, n_vars(), libMesh::processor_id(), libMeshEnums::SCALAR, libMesh::Variable::type(), variable(), write_SCALAR_dofs(), write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().
02258 { 02259 parallel_only(); 02260 02261 libmesh_assert (io.writing()); 02262 02263 // Cache these - they are not free! 02264 const dof_id_type 02265 n_nodes = this->get_mesh().n_nodes(), 02266 n_elem = this->get_mesh().n_elem(); 02267 02268 dof_id_type written_length = 0.; 02269 02270 if (libMesh::processor_id() == 0) 02271 { 02272 unsigned int 02273 n_vec = libmesh_cast_int<unsigned int>(vectors.size()); 02274 dof_id_type 02275 vec_size = vectors.empty() ? 0 : vectors[0]->size(); 02276 // Set the number of vectors 02277 io.data(n_vec, "# number of vectors"); 02278 // Set the buffer size 02279 io.data(vec_size, "# vector length"); 02280 } 02281 02282 //--------------------------------- 02283 // Collect the values for all nodes 02284 written_length += 02285 this->write_serialized_blocked_dof_objects (vectors, 02286 n_nodes, 02287 this->get_mesh().local_nodes_begin(), 02288 this->get_mesh().local_nodes_end(), 02289 io); 02290 02291 //------------------------------------ 02292 // Collect the values for all elements 02293 written_length += 02294 this->write_serialized_blocked_dof_objects (vectors, 02295 n_elem, 02296 this->get_mesh().local_elements_begin(), 02297 this->get_mesh().local_elements_end(), 02298 io); 02299 02300 //------------------------------------------- 02301 // Finally loop over all the SCALAR variables 02302 for (unsigned int vec=0; vec<vectors.size(); vec++) 02303 for (unsigned int var=0; var<this->n_vars(); var++) 02304 if(this->variable(var).type().family == SCALAR) 02305 { 02306 libmesh_assert_not_equal_to (vectors[vec], 0); 02307 02308 written_length += 02309 this->write_SCALAR_dofs (*vectors[vec], var, io); 02310 } 02311 02312 return written_length; 02313 }
| void libMesh::System::zero_variable | ( | NumericVector< Number > & | v, | |
| unsigned int | var_num | |||
| ) | const |
Zeroes all dofs in v that correspond to variable number var_num.
Definition at line 1314 of file system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DofObject::dof_number(), get_mesh(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), mesh, libMesh::DofObject::n_comp(), n_vars(), number(), and libMesh::NumericVector< T >::set().
01315 { 01316 /* Make sure the call makes sense. */ 01317 libmesh_assert_less (var_num, this->n_vars()); 01318 01319 /* Get a reference to the mesh. */ 01320 const MeshBase& mesh = this->get_mesh(); 01321 01322 /* Check which system we are. */ 01323 const unsigned int sys_num = this->number(); 01324 01325 /* Loop over nodes. */ 01326 { 01327 MeshBase::const_node_iterator it = mesh.local_nodes_begin(); 01328 const MeshBase::const_node_iterator end_it = mesh.local_nodes_end(); 01329 for ( ; it != end_it; ++it) 01330 { 01331 const Node* node = *it; 01332 unsigned int n_comp = node->n_comp(sys_num,var_num); 01333 for(unsigned int i=0; i<n_comp; i++) 01334 { 01335 const dof_id_type index = node->dof_number(sys_num,var_num,i); 01336 v.set(index,0.0); 01337 } 01338 } 01339 } 01340 01341 /* Loop over elements. */ 01342 { 01343 MeshBase::const_element_iterator it = mesh.active_local_elements_begin(); 01344 const MeshBase::const_element_iterator end_it = mesh.active_local_elements_end(); 01345 for ( ; it != end_it; ++it) 01346 { 01347 const Elem* elem = *it; 01348 unsigned int n_comp = elem->n_comp(sys_num,var_num); 01349 for(unsigned int i=0; i<n_comp; i++) 01350 { 01351 const dof_id_type index = elem->dof_number(sys_num,var_num,i); 01352 v.set(index,0.0); 01353 } 01354 } 01355 } 01356 }
Member Data Documentation
bool libMesh::System::_active [private] |
Flag stating if the system is active or not.
Definition at line 1740 of file system.h.
Referenced by activate(), active(), and deactivate().
bool libMesh::System::_additional_data_written [private] |
This flag is used only when *reading* in a system from file. Based on the system header, it keeps track of whether or not additional vectors were actually written for this file.
Definition at line 1791 of file system.h.
Referenced by read_header(), and read_legacy_data().
void(* libMesh::System::_assemble_system_function)(EquationSystems &es, const std::string &name) [private] |
Function that assembles the system.
Referenced by attach_assemble_function(), attach_assemble_object(), user_assembly(), and ~System().
Assembly* libMesh::System::_assemble_system_object [private] |
Object that assembles the system.
Definition at line 1656 of file system.h.
Referenced by attach_assemble_function(), attach_assemble_object(), user_assembly(), and ~System().
bool libMesh::System::_basic_system_only [private] |
Holds true if the components of more advanced system types (e.g. system matrices) should not be initialized.
Definition at line 1772 of file system.h.
Referenced by init(), and set_basic_system_only().
bool libMesh::System::_can_add_vectors [private] |
true when additional vectors do not require immediate initialization, false otherwise.
Definition at line 1778 of file system.h.
Referenced by add_vector(), clear(), compare(), and init_data().
void(* libMesh::System::_constrain_system_function)(EquationSystems &es, const std::string &name) [private] |
Function to impose constraints.
Referenced by attach_constraint_function(), attach_constraint_object(), user_constrain(), and ~System().
Object that constrains the system.
Definition at line 1667 of file system.h.
Referenced by attach_constraint_function(), attach_constraint_object(), user_constrain(), and ~System().
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 118 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::get_info(), libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().
AutoPtr<DofMap> libMesh::System::_dof_map [private] |
Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
Definition at line 1697 of file system.h.
Referenced by add_vector(), calculate_norm(), clear(), current_solution(), get_dof_map(), init_data(), n_constrained_dofs(), n_dofs(), n_local_constrained_dofs(), n_local_dofs(), project_solution(), restrict_vectors(), and update().
bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited] |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 137 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().
Constant reference to the EquationSystems object used for the simulation.
Definition at line 1703 of file system.h.
Referenced by get_equation_systems(), user_assembly(), user_constrain(), user_initialization(), user_QOI(), and user_QOI_derivative().
bool libMesh::System::_identify_variable_groups [private] |
true when VariableGroup structures should be automatically identified, false otherwise. Defaults to true.
Definition at line 1784 of file system.h.
Referenced by identify_variable_groups().
void(* libMesh::System::_init_system_function)(EquationSystems &es, const std::string &name) [private] |
Function that initializes the system.
Referenced by attach_init_function(), attach_init_object(), user_initialization(), and ~System().
Object that initializes the system.
Definition at line 1645 of file system.h.
Referenced by attach_init_function(), attach_init_object(), user_initialization(), and ~System().
MeshBase& libMesh::System::_mesh [private] |
Constant reference to the mesh data structure used for the simulation.
Definition at line 1709 of file system.h.
Referenced by get_mesh().
Threads::spin_mutex libMesh::ReferenceCounter::_mutex [static, protected, inherited] |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 131 of file reference_counter.h.
Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited] |
The number of objects. Print the reference count information when the number returns to 0.
Definition at line 126 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
void(* libMesh::System::_qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) [private] |
Function to evaluate quantity of interest derivative
Referenced by attach_QOI_derivative_object(), user_QOI_derivative(), and ~System().
Object to compute derivatives of quantities of interest.
Definition at line 1691 of file system.h.
Referenced by attach_QOI_derivative_object(), user_QOI_derivative(), and ~System().
void(* libMesh::System::_qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) [private] |
Function to evaluate quantity of interest
Referenced by attach_QOI_object(), user_QOI(), and ~System().
QOI* libMesh::System::_qoi_evaluate_object [private] |
Object to compute quantities of interest.
Definition at line 1679 of file system.h.
Referenced by attach_QOI_object(), user_QOI(), and ~System().
bool libMesh::System::_solution_projection [private] |
Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed. This is true by default.
Definition at line 1766 of file system.h.
Referenced by project_solution_on_reinit(), and restrict_vectors().
const std::string libMesh::System::_sys_name [private] |
const unsigned int libMesh::System::_sys_number [private] |
std::vector<VariableGroup> libMesh::System::_variable_groups [private] |
The VariableGroup in this System.
Definition at line 1729 of file system.h.
Referenced by add_variable(), add_variables(), n_variable_groups(), and variable_group().
std::map<std::string, unsigned short int> libMesh::System::_variable_numbers [private] |
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition at line 1735 of file system.h.
Referenced by add_variable(), add_variables(), clear(), get_all_variable_numbers(), has_variable(), and variable_number().
std::vector<Variable> libMesh::System::_variables [private] |
Definition at line 1724 of file system.h.
Referenced by add_variable(), add_variables(), clear(), n_components(), n_vars(), variable(), variable_name(), variable_number(), variable_scalar_number(), and variable_type().
std::map<std::string, bool> libMesh::System::_vector_projections [private] |
Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.
Definition at line 1754 of file system.h.
Referenced by add_vector(), clear(), remove_vector(), restrict_vectors(), set_vector_preservation(), and vector_preservation().
std::map<std::string, ParallelType> libMesh::System::_vector_types [private] |
Holds the type of a vector
Definition at line 1759 of file system.h.
Referenced by add_vector(), clear(), init_data(), remove_vector(), and restrict_vectors().
std::map<std::string, NumericVector<Number>* > libMesh::System::_vectors [private] |
Some systems need an arbitrary number of vectors. This map allows names to be associated with arbitrary vectors. All the vectors in this map will be distributed in the same way as the solution vector.
Definition at line 1748 of file system.h.
Referenced by add_vector(), clear(), compare(), get_vector(), have_vector(), init_data(), n_vectors(), read_legacy_data(), read_parallel_data(), read_serialized_data(), remove_vector(), request_vector(), restrict_vectors(), vectors_begin(), vectors_end(), write_header(), write_parallel_data(), and write_serialized_data().
std::vector<unsigned int> libMesh::System::_written_var_indices [private] |
This vector is used only when *reading* in a system from file. Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.
Definition at line 1803 of file system.h.
Referenced by read_header(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), and read_serialized_vector().
bool libMesh::System::adjoint_already_solved [private] |
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.
Definition at line 1810 of file system.h.
Referenced by is_adjoint_already_solved(), and set_adjoint_already_solved().
Flag which tells the system to whether or not to call the user assembly function during each call to solve(). By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)
You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.
The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.
Definition at line 1371 of file system.h.
Referenced by libMesh::ImplicitSystem::adjoint_solve(), disable_cache(), libMesh::ImplicitSystem::disable_cache(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::LinearImplicitSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::CondensedEigenSystem::solve().
All the values I need to compute my contribution to the simulation at hand. Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.
Definition at line 1430 of file system.h.
Referenced by libMesh::NonlinearImplicitSystem::assembly(), clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), current_solution(), DMFunction_libMesh(), DMJacobian_libMesh(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), init_data(), project_solution(), re_update(), reinit(), restrict_vectors(), and update().
A member int that can be employed to indicate increased or reduced quadrature order.
Note for FEMSystem users: By default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.
Definition at line 1403 of file system.h.
Referenced by libMesh::FEMContext::FEMContext().
| std::vector<Number> libMesh::System::qoi |
Values of the quantities of interest. This vector needs to be both resized and filled by the user before any quantity of interest assembly is done and before any sensitivities are calculated.
Definition at line 1449 of file system.h.
Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::FEMSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::DifferentiableSystem::attach_qoi(), libMesh::DiffContext::DiffContext(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::FEMContext::pre_fe_reinit(), libMesh::QoISet::size(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
Data structure to hold solution values.
Definition at line 1418 of file system.h.
Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UnsteadySolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::LinearImplicitSystem::assembly(), libMesh::FEMSystem::assembly(), clear(), compare(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::GMVIO::copy_nodal_solution(), DMCreateGlobalVector_libMesh(), DMFunction_libMesh(), DMJacobian_libMesh(), libMesh::UnsteadySolver::du(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::EigenSystem::get_eigenpair(), libMesh::CondensedEigenSystem::get_eigenpair(), init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), project_solution(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_data(), reinit(), restrict_vectors(), libMesh::MemorySolutionHistory::retrieve(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TwostepTimeSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::NewtonSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), update(), update_global_solution(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), write_parallel_data(), and write_serialized_data().
For time-dependent problems, this is the time t at the beginning of the current timestep.
Note for DifferentiableSystem users: do *not* access this time during an assembly! Use the DiffContext::time value instead to get correct results.
Definition at line 1441 of file system.h.
Referenced by libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::MemorySolutionHistory::find_stored_entry(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::ProjectSolution::operator()(), project_vector(), libMesh::EquationSystems::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::TwostepTimeSolver::solve(), and libMesh::MemorySolutionHistory::store().
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. stabilized methods. False by default.
Note for FEMSystem users: Warning: if this variable is set to true, it must be before init_data() is called.
Definition at line 1388 of file system.h.
Referenced by libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), libMesh::SteadySolver::element_residual(), libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::FEMContext::pre_fe_reinit(), libMesh::SteadySolver::side_residual(), libMesh::EulerSolver::side_residual(), and libMesh::Euler2Solver::side_residual().
The documentation for this class was generated from the following files:
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:40 UTC
Hosted By: