System Class Reference
#include <system.h>

Classes | |
| class | BuildProjectionList |
| class | ProjectSolution |
| class | ProjectVector |
| class | Variable |
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 | |
| 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 | solve ()=0 |
| 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()) |
| 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_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 (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), Parameters ¶meters) 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), 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 () |
| 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) |
| 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) |
| NumericVector< Number > & | add_adjoint_solution (unsigned int i=0) |
| NumericVector< Number > & | get_adjoint_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_adjoint_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_sensitivity_solution (unsigned int i=0) |
| NumericVector< Number > & | get_sensitivity_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_sensitivity_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_weighted_sensitivity_adjoint_solution (unsigned int i=0) |
| NumericVector< Number > & | get_weighted_sensitivity_adjoint_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_weighted_sensitivity_solution () |
| NumericVector< Number > & | get_weighted_sensitivity_solution () |
| const NumericVector< Number > & | get_weighted_sensitivity_solution () const |
| NumericVector< Number > & | add_adjoint_rhs (unsigned int i=0) |
| NumericVector< Number > & | get_adjoint_rhs (unsigned int i=0) |
| const NumericVector< Number > & | get_adjoint_rhs (unsigned int i=0) const |
| NumericVector< Number > & | add_sensitivity_rhs (unsigned int i=0) |
| NumericVector< Number > & | get_sensitivity_rhs (unsigned int i=0) |
| const NumericVector< Number > & | get_sensitivity_rhs (unsigned int i=0) const |
| unsigned int | n_vectors () const |
| unsigned int | n_vars () const |
| unsigned int | n_dofs () const |
| unsigned int | n_active_dofs () const |
| unsigned int | n_constrained_dofs () const |
| unsigned int | 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) |
| const Variable & | variable (unsigned int var) 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 |
| const FEType & | variable_type (const unsigned int i) const |
| const FEType & | variable_type (const std::string &var) const |
| Real | calculate_norm (NumericVector< Number > &v, unsigned int var=0, FEMNormType norm_type=L2) const |
| Real | calculate_norm (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) |
| 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 |
| 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_assemble_function (void fptr(EquationSystems &es, const std::string &name)) |
| void | attach_constraint_function (void fptr(EquationSystems &es, const std::string &name)) |
| void | attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)) |
| void | attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)) |
| 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 () |
| Number | current_solution (const unsigned int global_dof_number) const |
| void | local_dof_indices (const unsigned int var, std::set< unsigned int > &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 () |
| static unsigned int | n_objects () |
Public Attributes | |
| bool | assemble_before_solve |
| AutoPtr< NumericVector< Number > > | solution |
| AutoPtr< NumericVector< Number > > | current_local_solution |
| std::vector< Number > | qoi |
Protected Types | |
| typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Protected Member Functions | |
| System (EquationSystems &es, const std::string &name, const unsigned int number) | |
| 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 |
Private Member Functions | |
| Real | discrete_var_norm (NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const |
| template<typename iterator_type > | |
| unsigned int | read_serialized_blocked_dof_objects (const unsigned int var, const unsigned int n_objects, const iterator_type begin, const iterator_type end, Xdr &io, NumericVector< Number > &vec) const |
| void | read_serialized_vector (Xdr &io, NumericVector< Number > &vec) |
| template<typename iterator_type > | |
| unsigned int | write_serialized_blocked_dof_objects (const NumericVector< Number > &vec, const unsigned int var, const unsigned int n_objects, const iterator_type begin, const iterator_type end, Xdr &io) const |
| void | write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const |
Private Attributes | |
| void(* | _init_system )(EquationSystems &es, const std::string &name) |
| void(* | _assemble_system )(EquationSystems &es, const std::string &name) |
| void(* | _constrain_system )(EquationSystems &es, const std::string &name) |
| void(* | _qoi_evaluate )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) |
| void(* | _qoi_evaluate_derivative )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) |
| AutoPtr< DofMap > | _dof_map |
| EquationSystems & | _equation_systems |
| MeshBase & | _mesh |
| const std::string | _sys_name |
| const unsigned int | _sys_number |
| std::vector< System::Variable > | _variables |
| 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 |
| bool | _solution_projection |
| bool | _can_add_vectors |
| bool | _additional_data_written |
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 anEqnSystems<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 68 of file system.h.
Member Typedef Documentation
| typedef std::map<std::string, NumericVector<Number>* >::const_iterator System::const_vectors_iterator |
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 105 of file reference_counter.h.
| typedef System System::sys_type |
The type of system.
Reimplemented in ContinuationSystem, DifferentiableSystem, EigenSystem, ExplicitSystem, FEMSystem, ImplicitSystem, LinearImplicitSystem, NewmarkSystem, and NonlinearImplicitSystem.
| typedef std::map<std::string, NumericVector<Number>* >::iterator System::vectors_iterator |
Constructor & Destructor Documentation
| System::System | ( | EquationSystems & | es, | |
| const std::string & | name, | |||
| const unsigned int | number | |||
| ) | [protected] |
Constructor. Optionally initializes required data structures. Protected so that this base class cannot be explicitly instantiated.
Definition at line 48 of file system.C.
00050 : 00051 00052 assemble_before_solve (true), 00053 solution (NumericVector<Number>::build()), 00054 current_local_solution (NumericVector<Number>::build()), 00055 qoi (0), 00056 _init_system (NULL), 00057 _assemble_system (NULL), 00058 _constrain_system (NULL), 00059 _dof_map (new DofMap(number)), 00060 _equation_systems (es), 00061 _mesh (es.get_mesh()), 00062 _sys_name (name), 00063 _sys_number (number), 00064 _active (true), 00065 _solution_projection (true), 00066 _can_add_vectors (true), 00067 _additional_data_written (false) 00068 { 00069 }
| System::~System | ( | ) | [virtual] |
Destructor.
Definition at line 73 of file system.C.
References _assemble_system, _init_system, clear(), and libMesh::closed().
00074 { 00075 // Null-out the function pointers. Since this 00076 // class is getting destructed it is pointless, 00077 // but a good habit. 00078 _init_system = _assemble_system = NULL; 00079 00080 // Clear data 00081 this->clear (); 00082 00083 libmesh_assert (!libMesh::closed()); 00084 }
Member Function Documentation
| void System::activate | ( | ) | [inline] |
| bool System::active | ( | ) | const [inline] |
| NumericVector< Number > & 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 824 of file system.C.
References add_vector().
Referenced by FEMSystem::assemble_qoi_derivative(), and ExplicitSystem::assemble_qoi_derivative().
00825 { 00826 OStringStream adjoint_rhs_name; 00827 adjoint_rhs_name << "adjoint_rhs" << i; 00828 00829 return this->add_vector(adjoint_rhs_name.str()); 00830 }
| NumericVector< Number > & 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 764 of file system.C.
References add_vector().
Referenced by ImplicitSystem::adjoint_solve().
00765 { 00766 OStringStream adjoint_name; 00767 adjoint_name << "adjoint_solution" << i; 00768 00769 return this->add_vector(adjoint_name.str()); 00770 }
| NumericVector< Number > & 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 854 of file system.C.
References add_vector().
Referenced by ImplicitSystem::assemble_residual_derivatives().
00855 { 00856 OStringStream sensitivity_rhs_name; 00857 sensitivity_rhs_name << "sensitivity_rhs" << i; 00858 00859 return this->add_vector(sensitivity_rhs_name.str()); 00860 }
| NumericVector< Number > & 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 714 of file system.C.
References add_vector().
00715 { 00716 OStringStream sensitivity_name; 00717 sensitivity_name << "sensitivity_solution" << i; 00718 00719 return this->add_vector(sensitivity_name.str()); 00720 }
| unsigned int 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 923 of file system.C.
References add_variable().
00927 { 00928 return this->add_variable(var, 00929 FEType(order, family), 00930 active_subdomains); 00931 }
| unsigned int 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 884 of file system.C.
References _dof_map, _variable_numbers, _variables, n_vars(), number(), variable_name(), and variable_type().
Referenced by add_variable(), ErrorVector::plot_error(), and read_header().
00887 { 00888 // Make sure the variable isn't there already 00889 // or if it is, that it's the type we want 00890 for (unsigned int v=0; v<this->n_vars(); v++) 00891 if (this->variable_name(v) == var) 00892 { 00893 if (this->variable_type(v) == type) 00894 return _variables[v].number(); 00895 00896 std::cerr << "ERROR: incompatible variable " 00897 << var 00898 << " has already been added for this system!" 00899 << std::endl; 00900 libmesh_error(); 00901 } 00902 00903 const unsigned int curr_n_vars = this->n_vars(); 00904 00905 // Add the variable to the list 00906 _variables.push_back((active_subdomains == NULL) ? 00907 Variable(var, curr_n_vars, type) : 00908 Variable(var, curr_n_vars, type, *active_subdomains)); 00909 00910 libmesh_assert ((curr_n_vars+1) == this->n_vars()); 00911 00912 _variable_numbers[var] = curr_n_vars; 00913 00914 // Add the variable to the _dof_map 00915 _dof_map->add_variable (_variables.back()); 00916 00917 // Return the number of the new variable 00918 return curr_n_vars; 00919 }
| NumericVector< Number > & System::add_vector | ( | const std::string & | vec_name, | |
| const bool | projections = true | |||
| ) |
Adds the additional vector vec_name to this system. Only allowed prior to init(). 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 549 of file system.C.
References _can_add_vectors, _vector_projections, _vectors, have_vector(), NumericVector< T >::init(), n_dofs(), n_local_dofs(), and libMeshEnums::PARALLEL.
Referenced by add_adjoint_rhs(), add_adjoint_solution(), add_sensitivity_rhs(), add_sensitivity_solution(), ExplicitSystem::add_system_rhs(), add_weighted_sensitivity_solution(), UnsteadySolver::init(), ContinuationSystem::init_data(), NewmarkSystem::NewmarkSystem(), read_header(), FrequencySystem::set_frequencies(), FrequencySystem::set_frequencies_by_range(), and FrequencySystem::set_frequencies_by_steps().
00551 { 00552 // Return the vector if it is already there. 00553 if (this->have_vector(vec_name)) 00554 return *(_vectors[vec_name]); 00555 00556 // Otherwise build the vector 00557 NumericVector<Number>* buf = NumericVector<Number>::build().release(); 00558 _vectors.insert (std::make_pair (vec_name, buf)); 00559 _vector_projections.insert (std::make_pair (vec_name, projections)); 00560 00561 // Initialize it if necessary 00562 if (!_can_add_vectors) 00563 buf->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00564 00565 return *buf; 00566 }
| NumericVector< Number > & 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 794 of file system.C.
References get_vector().
Referenced by ImplicitSystem::weighted_sensitivity_adjoint_solve().
00795 { 00796 OStringStream adjoint_name; 00797 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 00798 00799 return this->get_vector(adjoint_name.str()); 00800 }
| NumericVector< Number > & 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 743 of file system.C.
References add_vector().
Referenced by ImplicitSystem::weighted_sensitivity_solve().
00744 { 00745 return this->add_vector("weighted_sensitivity_solution"); 00746 }
| virtual void 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 ImplicitSystem.
Definition at line 254 of file system.h.
| virtual std::pair<unsigned int, Real> 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 ImplicitSystem.
Definition at line 205 of file system.h.
Referenced by AdjointResidualErrorEstimator::estimate_error().
| void 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 DifferentiableSystem, EigenSystem, FrequencySystem, ImplicitSystem, LinearImplicitSystem, and NewmarkSystem.
Definition at line 340 of file system.C.
References user_assembly().
Referenced by ImplicitSystem::assemble(), EigenSystem::assemble(), and ExplicitSystem::solve().
00341 { 00342 // Log how long the user's matrix assembly code takes 00343 START_LOG("assemble()", "System"); 00344 00345 // Call the user-specified assembly function 00346 this->user_assembly(); 00347 00348 // Stop logging the user code 00349 STOP_LOG("assemble()", "System"); 00350 }
Calls user qoi function. Can be overloaded in derived classes.
Reimplemented in ExplicitSystem, and FEMSystem.
Definition at line 354 of file system.C.
References user_QOI().
Referenced by ExplicitSystem::assemble_qoi().
00355 { 00356 // Log how long the user's matrix assembly code takes 00357 START_LOG("assemble_qoi()", "System"); 00358 00359 // Call the user-specified quantity of interest function 00360 this->user_QOI(qoi_indices); 00361 00362 // Stop logging the user code 00363 STOP_LOG("assemble_qoi()", "System"); 00364 }
Calls user qoi derivative function. Can be overloaded in derived classes.
Reimplemented in ExplicitSystem, and FEMSystem.
Definition at line 368 of file system.C.
References user_QOI_derivative().
Referenced by ExplicitSystem::assemble_qoi_derivative().
00369 { 00370 // Log how long the user's matrix assembly code takes 00371 START_LOG("assemble_qoi_derivative()", "System"); 00372 00373 // Call the user-specified quantity of interest function 00374 this->user_QOI_derivative(qoi_indices); 00375 00376 // Stop logging the user code 00377 STOP_LOG("assemble_qoi_derivative()", "System"); 00378 }
| virtual void 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 ImplicitSystem.
Definition at line 158 of file system.h.
| void 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 1316 of file system.C.
References _assemble_system.
01318 { 01319 libmesh_assert (fptr != NULL); 01320 01321 _assemble_system = fptr; 01322 }
| void System::attach_constraint_function | ( | void | fptrEquationSystems &es,const std::string &name | ) |
Register a user function for imposing constraints.
Definition at line 1326 of file system.C.
References _constrain_system.
01328 { 01329 libmesh_assert (fptr != NULL); 01330 01331 _constrain_system = fptr; 01332 }
| void System::attach_init_function | ( | void | fptrEquationSystems &es,const std::string &name | ) |
Register a user function to use in initializing the system.
Definition at line 1306 of file system.C.
References _init_system.
01308 { 01309 libmesh_assert (fptr != NULL); 01310 01311 _init_system = fptr; 01312 }
| void 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 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
| Real System::calculate_norm | ( | 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 1077 of file system.C.
References _dof_map, MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), TypeTensor< T >::add_scaled(), TypeVector< T >::add_scaled(), FEBase::build(), FEType::default_quadrature_rule(), dim, libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, discrete_var_norm(), DofMap::dof_indices(), AutoPtr< Tp >::get(), get_dof_map(), get_mesh(), libMeshEnums::H1, libMeshEnums::H1_SEMINORM, libMeshEnums::H2, libMeshEnums::H2_SEMINORM, SystemNorm::is_discrete(), NumericVector< T >::l1_norm(), libMeshEnums::L2, NumericVector< T >::l2_norm(), libmesh_norm(), NumericVector< T >::linfty_norm(), NumericVector< T >::localize(), MeshBase::mesh_dimension(), n_vars(), libMeshEnums::SERIAL, NumericVector< T >::size(), TypeTensor< T >::size_sq(), TypeVector< T >::size_sq(), SystemNorm::type(), DofMap::variable_type(), SystemNorm::weight(), and SystemNorm::weight_sq().
01079 { 01080 // This function must be run on all processors at once 01081 parallel_only(); 01082 01083 START_LOG ("calculate_norm()", "System"); 01084 01085 // Zero the norm before summation 01086 Real v_norm = 0.; 01087 01088 if (norm.is_discrete()) 01089 { 01090 STOP_LOG ("calculate_norm()", "System"); 01091 //Check to see if all weights are 1.0 01092 unsigned int check_var = 0; 01093 for (; check_var != this->n_vars(); ++check_var) 01094 if(norm.weight(check_var) != 1.0) 01095 break; 01096 01097 //All weights were 1.0 so just do the full vector discrete norm 01098 if(check_var == this->n_vars()) 01099 { 01100 FEMNormType norm_type = norm.type(0); 01101 01102 if(norm_type == DISCRETE_L1) 01103 return v.l1_norm(); 01104 if(norm_type == DISCRETE_L2) 01105 return v.l2_norm(); 01106 if(norm_type == DISCRETE_L_INF) 01107 return v.linfty_norm(); 01108 else 01109 libmesh_error(); 01110 } 01111 01112 for (unsigned int var=0; var != this->n_vars(); ++var) 01113 { 01114 // Skip any variables we don't need to integrate 01115 if (norm.weight(var) == 0.0) 01116 continue; 01117 01118 v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var)); 01119 } 01120 01121 return v_norm; 01122 } 01123 01124 // Localize the potentially parallel vector 01125 AutoPtr<NumericVector<Number> > local_v = NumericVector<Number>::build(); 01126 local_v->init(v.size(), true, SERIAL); 01127 v.localize (*local_v, _dof_map->get_send_list()); 01128 01129 unsigned int dim = this->get_mesh().mesh_dimension(); 01130 01131 // Loop over all variables 01132 for (unsigned int var=0; var != this->n_vars(); ++var) 01133 { 01134 // Skip any variables we don't need to integrate 01135 if (norm.weight(var) == 0.0) 01136 continue; 01137 01138 const FEType& fe_type = this->get_dof_map().variable_type(var); 01139 AutoPtr<QBase> qrule = 01140 fe_type.default_quadrature_rule (dim); 01141 AutoPtr<FEBase> fe 01142 (FEBase::build(dim, fe_type)); 01143 fe->attach_quadrature_rule (qrule.get()); 01144 01145 const std::vector<Real>& JxW = fe->get_JxW(); 01146 const std::vector<std::vector<Real> >* phi = NULL; 01147 if (norm.type(var) == H1 || 01148 norm.type(var) == H2 || 01149 norm.type(var) == L2) 01150 phi = &(fe->get_phi()); 01151 01152 const std::vector<std::vector<RealGradient> >* dphi = NULL; 01153 if (norm.type(var) == H1 || 01154 norm.type(var) == H2 || 01155 norm.type(var) == H1_SEMINORM) 01156 dphi = &(fe->get_dphi()); 01157 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 01158 const std::vector<std::vector<RealTensor> >* d2phi = NULL; 01159 if (norm.type(var) == H2 || 01160 norm.type(var) == H2_SEMINORM) 01161 d2phi = &(fe->get_d2phi()); 01162 #endif 01163 01164 std::vector<unsigned int> dof_indices; 01165 01166 // Begin the loop over the elements 01167 MeshBase::const_element_iterator el = 01168 this->get_mesh().active_local_elements_begin(); 01169 const MeshBase::const_element_iterator end_el = 01170 this->get_mesh().active_local_elements_end(); 01171 01172 for ( ; el != end_el; ++el) 01173 { 01174 const Elem* elem = *el; 01175 01176 fe->reinit (elem); 01177 01178 this->get_dof_map().dof_indices (elem, dof_indices, var); 01179 01180 const unsigned int n_qp = qrule->n_points(); 01181 01182 const unsigned int n_sf = dof_indices.size(); 01183 01184 // Begin the loop over the Quadrature points. 01185 for (unsigned int qp=0; qp<n_qp; qp++) 01186 { 01187 if (norm.type(var) == H1 || 01188 norm.type(var) == H2 || 01189 norm.type(var) == L2) 01190 { 01191 Number u_h = 0.; 01192 for (unsigned int i=0; i != n_sf; ++i) 01193 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]); 01194 v_norm += norm.weight_sq(var) * 01195 JxW[qp] * libmesh_norm(u_h); 01196 } 01197 01198 if (norm.type(var) == H1 || 01199 norm.type(var) == H2 || 01200 norm.type(var) == H1_SEMINORM) 01201 { 01202 Gradient grad_u_h; 01203 for (unsigned int i=0; i != n_sf; ++i) 01204 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i])); 01205 v_norm += norm.weight_sq(var) * 01206 JxW[qp] * grad_u_h.size_sq(); 01207 } 01208 01209 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 01210 if (norm.type(var) == H2 || 01211 norm.type(var) == H2_SEMINORM) 01212 { 01213 Tensor hess_u_h; 01214 for (unsigned int i=0; i != n_sf; ++i) 01215 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i])); 01216 v_norm += norm.weight_sq(var) * 01217 JxW[qp] * hess_u_h.size_sq(); 01218 } 01219 #endif 01220 } 01221 } 01222 } 01223 01224 Parallel::sum(v_norm); 01225 01226 STOP_LOG ("calculate_norm()", "System"); 01227 01228 return std::sqrt(v_norm); 01229 }
| Real System::calculate_norm | ( | 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, H0, H1)
Definition at line 1056 of file system.C.
References libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, discrete_var_norm(), libMeshEnums::L2, and n_vars().
Referenced by AdaptiveTimeSolver::calculate_norm(), and UnsteadySolver::du().
01059 { 01060 //short circuit to save time 01061 if(norm_type == DISCRETE_L1 || 01062 norm_type == DISCRETE_L2 || 01063 norm_type == DISCRETE_L_INF) 01064 return discrete_var_norm(v,var,norm_type); 01065 01066 // Not a discrete norm 01067 std::vector<FEMNormType> norms(this->n_vars(), L2); 01068 std::vector<Real> weights(this->n_vars(), 0.0); 01069 norms[var] = norm_type; 01070 weights[var] = 1.0; 01071 Real val = this->calculate_norm(v, SystemNorm(norms, weights)); 01072 return val; 01073 }
| void System::clear | ( | ) | [virtual] |
Clear all the data structures associated with the system.
Reimplemented in ContinuationSystem, DifferentiableSystem, EigenSystem, ExplicitSystem, FEMSystem, FrequencySystem, ImplicitSystem, LinearImplicitSystem, NewmarkSystem, and NonlinearImplicitSystem.
Definition at line 128 of file system.C.
References _can_add_vectors, _dof_map, _variable_numbers, _variables, _vector_projections, _vectors, current_local_solution, and solution.
Referenced by ExplicitSystem::clear(), EigenSystem::clear(), read_header(), and ~System().
00129 { 00130 _variables.clear(); 00131 00132 _variable_numbers.clear(); 00133 00134 _dof_map->clear (); 00135 00136 solution->clear (); 00137 00138 current_local_solution->clear (); 00139 00140 // clear any user-added vectors 00141 { 00142 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00143 { 00144 pos->second->clear (); 00145 delete pos->second; 00146 pos->second = NULL; 00147 } 00148 00149 _vectors.clear(); 00150 _vector_projections.clear(); 00151 _can_add_vectors = true; 00152 } 00153 00154 }
| bool 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 399 of file system.C.
References _can_add_vectors, _sys_name, _vectors, get_vector(), n_vectors(), name(), and solution.
Referenced by EquationSystems::compare().
00402 { 00403 // we do not care for matrices, but for vectors 00404 libmesh_assert (!_can_add_vectors); 00405 libmesh_assert (!other_system._can_add_vectors); 00406 00407 if (verbose) 00408 { 00409 std::cout << " Systems \"" << _sys_name << "\"" << std::endl; 00410 std::cout << " comparing matrices not supported." << std::endl; 00411 std::cout << " comparing names..."; 00412 } 00413 00414 // compare the name: 0 means identical 00415 const int name_result = _sys_name.compare(other_system.name()); 00416 if (verbose) 00417 { 00418 if (name_result == 0) 00419 std::cout << " identical." << std::endl; 00420 else 00421 std::cout << " names not identical." << std::endl; 00422 std::cout << " comparing solution vector..."; 00423 } 00424 00425 00426 // compare the solution: -1 means identical 00427 const int solu_result = solution->compare (*other_system.solution.get(), 00428 threshold); 00429 00430 if (verbose) 00431 { 00432 if (solu_result == -1) 00433 std::cout << " identical up to threshold." << std::endl; 00434 else 00435 std::cout << " first difference occured at index = " 00436 << solu_result << "." << std::endl; 00437 } 00438 00439 00440 // safety check, whether we handle at least the same number 00441 // of vectors 00442 std::vector<int> ov_result; 00443 00444 if (this->n_vectors() != other_system.n_vectors()) 00445 { 00446 if (verbose) 00447 { 00448 std::cout << " Fatal difference. This system handles " 00449 << this->n_vectors() << " add'l vectors," << std::endl 00450 << " while the other system handles " 00451 << other_system.n_vectors() 00452 << " add'l vectors." << std::endl 00453 << " Aborting comparison." << std::endl; 00454 } 00455 return false; 00456 } 00457 else if (this->n_vectors() == 0) 00458 { 00459 // there are no additional vectors... 00460 ov_result.clear (); 00461 } 00462 else 00463 { 00464 // compare other vectors 00465 for (const_vectors_iterator pos = _vectors.begin(); 00466 pos != _vectors.end(); ++pos) 00467 { 00468 if (verbose) 00469 std::cout << " comparing vector \"" 00470 << pos->first << "\" ..."; 00471 00472 // assume they have the same name 00473 const NumericVector<Number>& other_system_vector = 00474 other_system.get_vector(pos->first); 00475 00476 ov_result.push_back(pos->second->compare (other_system_vector, 00477 threshold)); 00478 00479 if (verbose) 00480 { 00481 if (ov_result[ov_result.size()-1] == -1) 00482 std::cout << " identical up to threshold." << std::endl; 00483 else 00484 std::cout << " first difference occured at" << std::endl 00485 << " index = " << ov_result[ov_result.size()-1] << "." << std::endl; 00486 } 00487 00488 } 00489 00490 } // finished comparing additional vectors 00491 00492 00493 bool overall_result; 00494 00495 // sum up the results 00496 if ((name_result==0) && (solu_result==-1)) 00497 { 00498 if (ov_result.size()==0) 00499 overall_result = true; 00500 else 00501 { 00502 bool ov_identical; 00503 unsigned int n = 0; 00504 do 00505 { 00506 ov_identical = (ov_result[n]==-1); 00507 n++; 00508 } 00509 while (ov_identical && n<ov_result.size()); 00510 overall_result = ov_identical; 00511 } 00512 } 00513 else 00514 overall_result = false; 00515 00516 if (verbose) 00517 { 00518 std::cout << " finished comparisons, "; 00519 if (overall_result) 00520 std::cout << "found no differences." << std::endl << std::endl; 00521 else 00522 std::cout << "found differences." << std::endl << std::endl; 00523 } 00524 00525 return overall_result; 00526 }
| Number System::current_solution | ( | const unsigned int | global_dof_number | ) | const |
- Returns:
- the current solution for the specified global DOF.
Definition at line 117 of file system.C.
References current_local_solution, and n_dofs().
Referenced by ExactSolution::_compute_error(), HPCoarsenTest::add_projection(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), FEMSystem::eulerian_residual(), PatchRecoveryErrorEstimator::EstimateError::operator()(), FEMContext::reinit(), HPCoarsenTest::select_refinement(), VTKIO::solution_to_vtk(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().
00118 { 00119 // Check the sizes 00120 libmesh_assert (global_dof_number < _dof_map->n_dofs()); 00121 libmesh_assert (global_dof_number < current_local_solution->size()); 00122 00123 return (*current_local_solution)(global_dof_number); 00124 }
| void System::deactivate | ( | ) | [inline] |
| Real System::discrete_var_norm | ( | 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 1039 of file system.C.
References libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, local_dof_indices(), NumericVector< T >::subset_l1_norm(), NumericVector< T >::subset_l2_norm(), and NumericVector< T >::subset_linfty_norm().
Referenced by calculate_norm().
01042 { 01043 std::set<unsigned int> var_indices; 01044 local_dof_indices(var, var_indices); 01045 01046 if(norm_type == DISCRETE_L1) 01047 return v.subset_l1_norm(var_indices); 01048 if(norm_type == DISCRETE_L2) 01049 return v.subset_l2_norm(var_indices); 01050 if(norm_type == DISCRETE_L_INF) 01051 return v.subset_linfty_norm(var_indices); 01052 else 01053 libmesh_error(); 01054 }
| virtual void 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 ImplicitSystem.
Definition at line 264 of file system.h.
| const NumericVector< Number > & 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 844 of file system.C.
References get_vector().
00845 { 00846 OStringStream adjoint_rhs_name; 00847 adjoint_rhs_name << "adjoint_rhs" << i; 00848 00849 return this->get_vector(adjoint_rhs_name.str()); 00850 }
| NumericVector< Number > & 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 834 of file system.C.
References get_vector().
Referenced by ImplicitSystem::adjoint_solve(), FEMSystem::assemble_qoi_derivative(), and ImplicitSystem::weighted_sensitivity_adjoint_solve().
00835 { 00836 OStringStream adjoint_rhs_name; 00837 adjoint_rhs_name << "adjoint_rhs" << i; 00838 00839 return this->get_vector(adjoint_rhs_name.str()); 00840 }
| const NumericVector< Number > & 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 784 of file system.C.
References get_vector().
00785 { 00786 OStringStream adjoint_name; 00787 adjoint_name << "adjoint_solution" << i; 00788 00789 return this->get_vector(adjoint_name.str()); 00790 }
| NumericVector< Number > & 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 774 of file system.C.
References get_vector().
Referenced by ImplicitSystem::adjoint_solve(), AdjointResidualErrorEstimator::estimate_error(), and ImplicitSystem::weighted_sensitivity_adjoint_solve().
00775 { 00776 OStringStream adjoint_name; 00777 adjoint_name << "adjoint_solution" << i; 00778 00779 return this->get_vector(adjoint_name.str()); 00780 }
| DofMap & System::get_dof_map | ( | ) | [inline] |
| const DofMap & System::get_dof_map | ( | ) | const [inline] |
- Returns:
- a constant reference to this system's
_dof_map.
Definition at line 1350 of file system.h.
References _dof_map.
Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), ExactSolution::_compute_error(), HPCoarsenTest::add_projection(), ImplicitSystem::adjoint_solve(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), calculate_norm(), DofMap::enforce_constraints_exactly(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), get_info(), EigenSystem::init_data(), ImplicitSystem::init_matrices(), local_dof_indices(), DofMap::max_constraint_error(), FEMSystem::mesh_position_get(), UnsteadySolver::old_nonlinear_solution(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), ErrorVector::plot_error(), project_vector(), FEMContext::reinit(), EquationSystems::reinit(), HPCoarsenTest::select_refinement(), ImplicitSystem::sensitivity_solve(), UnsteadySolver::solve(), PetscDiffSolver::solve(), NewtonSolver::solve(), ImplicitSystem::weighted_sensitivity_adjoint_solve(), ImplicitSystem::weighted_sensitivity_solve(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().
01351 { 01352 return *_dof_map; 01353 }
| EquationSystems& System::get_equation_systems | ( | ) | [inline] |
- Returns:
- a reference to this system's parent EquationSystems object.
Definition at line 383 of file system.h.
References _equation_systems.
00383 { return _equation_systems; }
| const EquationSystems& System::get_equation_systems | ( | ) | const [inline] |
- Returns:
- a constant reference to this system's parent EquationSystems object.
Definition at line 378 of file system.h.
References _equation_systems.
Referenced by NewmarkSystem::clear(), FrequencySystem::clear_all(), ExactErrorEstimator::find_squared_element_error(), ImplicitSystem::get_linear_solve_parameters(), FrequencySystem::init_data(), FrequencySystem::n_frequencies(), FrequencySystem::set_current_frequency(), FrequencySystem::set_frequencies(), FrequencySystem::set_frequencies_by_range(), FrequencySystem::set_frequencies_by_steps(), NewmarkSystem::set_newmark_parameters(), NonlinearImplicitSystem::set_solver_parameters(), LinearImplicitSystem::solve(), FrequencySystem::solve(), and EigenSystem::solve().
00378 { return _equation_systems; }
| std::string ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and QuadratureRules::name().
Referenced by ReferenceCounter::print_info().
00046 { 00047 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00048 00049 std::ostringstream out; 00050 00051 out << '\n' 00052 << " ---------------------------------------------------------------------------- \n" 00053 << "| Reference count information |\n" 00054 << " ---------------------------------------------------------------------------- \n"; 00055 00056 for (Counts::iterator it = _counts.begin(); 00057 it != _counts.end(); ++it) 00058 { 00059 const std::string name(it->first); 00060 const unsigned int creations = it->second.first; 00061 const unsigned int destructions = it->second.second; 00062 00063 out << "| " << name << " reference count information:\n" 00064 << "| Creations: " << creations << '\n' 00065 << "| Destructions: " << destructions << '\n'; 00066 } 00067 00068 out << " ---------------------------------------------------------------------------- \n"; 00069 00070 return out.str(); 00071 00072 #else 00073 00074 return ""; 00075 00076 #endif 00077 }
| std::string System::get_info | ( | ) | const |
- Returns:
- a string containing information about the system.
Definition at line 1233 of file system.C.
References Utility::enum_to_string< FEFamily >(), Utility::enum_to_string< InfMapType >(), Utility::enum_to_string< Order >(), FEType::family, get_dof_map(), FEType::inf_map, n_constrained_dofs(), n_dofs(), n_local_dofs(), n_vars(), n_vectors(), name(), FEType::order, FEType::radial_family, FEType::radial_order, system_type(), variable_name(), and DofMap::variable_type().
01234 { 01235 std::ostringstream out; 01236 01237 01238 const std::string& sys_name = this->name(); 01239 01240 out << " System \"" << sys_name << "\"\n" 01241 << " Type \"" << this->system_type() << "\"\n" 01242 << " Variables="; 01243 01244 for (unsigned int vn=0; vn<this->n_vars(); vn++) 01245 out << "\"" << this->variable_name(vn) << "\" "; 01246 01247 out << '\n'; 01248 01249 out << " Finite Element Types="; 01250 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS 01251 for (unsigned int vn=0; vn<this->n_vars(); vn++) 01252 out << "\"" 01253 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).family) 01254 << "\" "; 01255 #else 01256 for (unsigned int vn=0; vn<this->n_vars(); vn++) 01257 { 01258 out << "\"" 01259 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).family) 01260 << "\", \"" 01261 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).radial_family) 01262 << "\" "; 01263 } 01264 01265 out << '\n' << " Infinite Element Mapping="; 01266 for (unsigned int vn=0; vn<this->n_vars(); vn++) 01267 out << "\"" 01268 << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_type(vn).inf_map) 01269 << "\" "; 01270 #endif 01271 01272 out << '\n'; 01273 01274 out << " Approximation Orders="; 01275 for (unsigned int vn=0; vn<this->n_vars(); vn++) 01276 { 01277 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS 01278 out << "\"" 01279 << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).order) 01280 << "\" "; 01281 #else 01282 out << "\"" 01283 << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).order) 01284 << "\", \"" 01285 << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).radial_order) 01286 << "\" "; 01287 #endif 01288 } 01289 01290 out << '\n'; 01291 01292 out << " n_dofs()=" << this->n_dofs() << '\n'; 01293 out << " n_local_dofs()=" << this->n_local_dofs() << '\n'; 01294 #ifdef LIBMESH_ENABLE_AMR 01295 out << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n'; 01296 #endif 01297 01298 out << " " << "n_vectors()=" << this->n_vectors() << '\n'; 01299 // out << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n'; 01300 01301 return out.str(); 01302 }
| MeshBase & System::get_mesh | ( | ) | [inline] |
| const MeshBase & System::get_mesh | ( | ) | const [inline] |
- Returns:
- a constant reference to this systems's
_mesh.
Definition at line 1334 of file system.h.
References _mesh.
Referenced by ExactSolution::_compute_error(), HPCoarsenTest::add_projection(), FEMSystem::assemble_qoi(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), calculate_norm(), PatchRecoveryErrorEstimator::estimate_error(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), AdjointResidualErrorEstimator::estimate_error(), init_data(), EigenSystem::init_data(), ImplicitSystem::init_matrices(), local_dof_indices(), DofMap::max_constraint_error(), FEMSystem::mesh_position_get(), FEMSystem::mesh_position_set(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), FEMSystem::postprocess(), project_vector(), read_header(), read_legacy_data(), read_parallel_data(), read_serialized_vector(), HPSingularity::select_refinement(), HPCoarsenTest::select_refinement(), write_header(), write_parallel_data(), write_serialized_vector(), and zero_variable().
01335 { 01336 return _mesh; 01337 }
| const NumericVector< Number > & 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 874 of file system.C.
References get_vector().
00875 { 00876 OStringStream sensitivity_rhs_name; 00877 sensitivity_rhs_name << "sensitivity_rhs" << i; 00878 00879 return this->get_vector(sensitivity_rhs_name.str()); 00880 }
| NumericVector< Number > & 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.
Definition at line 864 of file system.C.
References get_vector().
Referenced by ImplicitSystem::sensitivity_solve().
00865 { 00866 OStringStream sensitivity_rhs_name; 00867 sensitivity_rhs_name << "sensitivity_rhs" << i; 00868 00869 return this->get_vector(sensitivity_rhs_name.str()); 00870 }
| const NumericVector< Number > & 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 733 of file system.C.
References get_vector().
00734 { 00735 OStringStream sensitivity_name; 00736 sensitivity_name << "sensitivity_solution" << i; 00737 00738 return this->get_vector(sensitivity_name.str()); 00739 }
| NumericVector< Number > & 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 723 of file system.C.
References get_vector().
Referenced by ImplicitSystem::sensitivity_solve().
00724 { 00725 OStringStream sensitivity_name; 00726 sensitivity_name << "sensitivity_solution" << i; 00727 00728 return this->get_vector(sensitivity_name.str()); 00729 }
| NumericVector< Number > & 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 682 of file system.C.
References vectors_begin(), and vectors_end().
00683 { 00684 vectors_iterator v = vectors_begin(); 00685 vectors_iterator v_end = vectors_end(); 00686 unsigned int num = 0; 00687 while((num<vec_num) && (v!=v_end)) 00688 { 00689 num++; 00690 ++v; 00691 } 00692 libmesh_assert(v!=v_end); 00693 return *(v->second); 00694 }
| const NumericVector< Number > & 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 666 of file system.C.
References vectors_begin(), and vectors_end().
00667 { 00668 const_vectors_iterator v = vectors_begin(); 00669 const_vectors_iterator v_end = vectors_end(); 00670 unsigned int num = 0; 00671 while((num<vec_num) && (v!=v_end)) 00672 { 00673 num++; 00674 ++v; 00675 } 00676 libmesh_assert(v!=v_end); 00677 return *(v->second); 00678 }
| NumericVector< Number > & 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 647 of file system.C.
References _vectors.
00648 { 00649 // Make sure the vector exists 00650 vectors_iterator pos = _vectors.find(vec_name); 00651 00652 if (pos == _vectors.end()) 00653 { 00654 std::cerr << "ERROR: vector " 00655 << vec_name 00656 << " does not exist in this system!" 00657 << std::endl; 00658 libmesh_error(); 00659 } 00660 00661 return *(pos->second); 00662 }
| const NumericVector< Number > & 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 628 of file system.C.
References _vectors.
Referenced by add_weighted_sensitivity_adjoint_solution(), UnsteadySolver::advance_timestep(), AdaptiveTimeSolver::advance_timestep(), compare(), UnsteadySolver::du(), get_adjoint_rhs(), get_adjoint_solution(), get_sensitivity_rhs(), get_sensitivity_solution(), get_weighted_sensitivity_adjoint_solution(), get_weighted_sensitivity_solution(), NewmarkSystem::initial_conditions(), UnsteadySolver::solve(), TwostepTimeSolver::solve(), FrequencySystem::solve(), NewmarkSystem::update_rhs(), and NewmarkSystem::update_u_v_a().
00629 { 00630 // Make sure the vector exists 00631 const_vectors_iterator pos = _vectors.find(vec_name); 00632 00633 if (pos == _vectors.end()) 00634 { 00635 std::cerr << "ERROR: vector " 00636 << vec_name 00637 << " does not exist in this system!" 00638 << std::endl; 00639 libmesh_error(); 00640 } 00641 00642 return *(pos->second); 00643 }
| const NumericVector< Number > & 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 814 of file system.C.
References get_vector().
00815 { 00816 OStringStream adjoint_name; 00817 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 00818 00819 return this->get_vector(adjoint_name.str()); 00820 }
| NumericVector< Number > & 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 804 of file system.C.
References get_vector().
Referenced by ImplicitSystem::weighted_sensitivity_adjoint_solve().
00805 { 00806 OStringStream adjoint_name; 00807 adjoint_name << "weighted_sensitivity_adjoint_solution" << i; 00808 00809 return this->get_vector(adjoint_name.str()); 00810 }
| const NumericVector< Number > & System::get_weighted_sensitivity_solution | ( | ) | const |
- Returns:
- a reference to the solution of the last weighted sensitivity solve
Definition at line 757 of file system.C.
References get_vector().
00758 { 00759 return this->get_vector("weighted_sensitivity_solution"); 00760 }
| NumericVector< Number > & System::get_weighted_sensitivity_solution | ( | ) |
- Returns:
- a reference to the solution of the last weighted sensitivity solve
Definition at line 750 of file system.C.
References get_vector().
Referenced by ImplicitSystem::weighted_sensitivity_solve().
00751 { 00752 return this->get_vector("weighted_sensitivity_solution"); 00753 }
| bool System::has_variable | ( | const std::string & | var | ) | const |
- Returns:
- true if a variable named
varexists in this System
Definition at line 935 of file system.C.
References _variable_numbers.
Referenced by GMVIO::copy_nodal_solution().
00936 { 00937 return _variable_numbers.count(var); 00938 }
| bool System::have_vector | ( | const std::string & | vec_name | ) | const [inline] |
| void 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 149 of file reference_counter.h.
References ReferenceCounter::_counts, and Threads::spin_mtx.
Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().
00150 { 00151 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00152 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00153 00154 p.first++; 00155 }
| void 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 167 of file reference_counter.h.
References ReferenceCounter::_counts, and Threads::spin_mtx.
Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().
00168 { 00169 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00170 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00171 00172 p.second++; 00173 }
| void System::init | ( | ) |
Initializes degrees of freedom on the current mesh. Sets the
Definition at line 158 of file system.C.
References init_data(), n_vars(), and user_initialization().
00159 { 00160 // First initialize any required data 00161 this->init_data(); 00162 00163 //If no variables have been added to this system 00164 //don't do anything 00165 if(!this->n_vars()) 00166 return; 00167 00168 // Then call the user-provided intialization function 00169 this->user_initialization(); 00170 }
| void 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 ContinuationSystem, DifferentiableSystem, EigenSystem, ExplicitSystem, FEMSystem, FrequencySystem, and ImplicitSystem.
Definition at line 174 of file system.C.
References _can_add_vectors, _dof_map, _vectors, current_local_solution, get_mesh(), libMeshEnums::GHOSTED, mesh, n_dofs(), n_local_dofs(), libMeshEnums::PARALLEL, libMeshEnums::SERIAL, solution, and user_constrain().
Referenced by init(), ExplicitSystem::init_data(), and EigenSystem::init_data().
00175 { 00176 MeshBase &mesh = this->get_mesh(); 00177 00178 // Distribute the degrees of freedom on the mesh 00179 _dof_map->distribute_dofs (mesh); 00180 00181 #ifdef LIBMESH_ENABLE_AMR 00182 00183 // Recreate any hanging node constraints 00184 _dof_map->create_dof_constraints(mesh); 00185 00186 // Apply any user-defined constraints 00187 this->user_constrain(); 00188 00189 // Expand any recursive constraints 00190 _dof_map->process_constraints(); 00191 00192 // And clean up the send_list before we first use it 00193 _dof_map->prepare_send_list(); 00194 00195 #endif 00196 00197 // Resize the solution conformal to the current mesh 00198 solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00199 00200 // Resize the current_local_solution for the current mesh 00201 #ifdef LIBMESH_ENABLE_GHOSTED 00202 current_local_solution->init (this->n_dofs(), this->n_local_dofs(), 00203 _dof_map->get_send_list(), false, 00204 GHOSTED); 00205 #else 00206 current_local_solution->init (this->n_dofs(), false, SERIAL); 00207 #endif 00208 00209 // from now on, no chance to add additional vectors 00210 _can_add_vectors = false; 00211 00212 // initialize & zero other vectors, if necessary 00213 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00214 pos->second->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00215 }
| void System::local_dof_indices | ( | const unsigned int | var, | |
| std::set< unsigned int > & | 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 962 of file system.C.
References MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), DofMap::dof_indices(), DofMap::end_dof(), DofMap::first_dof(), get_dof_map(), and get_mesh().
Referenced by discrete_var_norm().
00963 { 00964 // Make sure the set is clear 00965 var_indices.clear(); 00966 00967 std::vector<unsigned int> dof_indices; 00968 00969 // Begin the loop over the elements 00970 MeshBase::const_element_iterator el = 00971 this->get_mesh().active_local_elements_begin(); 00972 const MeshBase::const_element_iterator end_el = 00973 this->get_mesh().active_local_elements_end(); 00974 00975 const unsigned int 00976 first_local = this->get_dof_map().first_dof(), 00977 end_local = this->get_dof_map().end_dof(); 00978 00979 for ( ; el != end_el; ++el) 00980 { 00981 const Elem* elem = *el; 00982 this->get_dof_map().dof_indices (elem, dof_indices, var); 00983 00984 for(unsigned int i=0; i<dof_indices.size(); i++) 00985 { 00986 unsigned int dof = dof_indices[i]; 00987 00988 //If the dof is owned by the local processor 00989 if(first_local <= dof && dof < end_local) 00990 var_indices.insert(dof_indices[i]); 00991 } 00992 } 00993 }
| unsigned int System::n_active_dofs | ( | ) | const [inline] |
Returns the number of active degrees of freedom for this System.
Definition at line 1436 of file system.h.
References n_constrained_dofs(), and n_dofs().
01437 { 01438 return this->n_dofs() - this->n_constrained_dofs(); 01439 }
| unsigned int System::n_constrained_dofs | ( | ) | const |
- Returns:
- the number of constrained degrees of freedom in the system.
Definition at line 95 of file system.C.
References _dof_map.
Referenced by get_info(), and n_active_dofs().
00096 { 00097 #ifdef LIBMESH_ENABLE_AMR 00098 00099 return _dof_map->n_constrained_dofs(); 00100 00101 #else 00102 00103 return 0; 00104 00105 #endif 00106 }
| unsigned int System::n_dofs | ( | ) | const |
- Returns:
- the number of degrees of freedom in the system
Definition at line 88 of file system.C.
References _dof_map.
Referenced by add_vector(), current_solution(), get_info(), init_data(), FEMSystem::mass_residual(), n_active_dofs(), System::ProjectVector::operator()(), project_vector(), read_legacy_data(), reinit(), restrict_vectors(), and UnsteadySolver::solve().
00089 { 00090 return _dof_map->n_dofs(); 00091 }
| unsigned int System::n_local_dofs | ( | ) | const |
- Returns:
- the number of degrees of freedom local to this processor
Definition at line 110 of file system.C.
References _dof_map, and libMesh::processor_id().
Referenced by add_vector(), get_info(), init_data(), project_vector(), read_serialized_blocked_dof_objects(), reinit(), restrict_vectors(), and UnsteadySolver::solve().
00111 { 00112 return _dof_map->n_dofs_on_processor (libMesh::processor_id()); 00113 }
| static unsigned int ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
00077 { return _n_objects; }
| unsigned int System::n_vars | ( | ) | const [inline] |
- Returns:
- the number of variables in the system
Definition at line 1390 of file system.h.
References _variables.
Referenced by add_variable(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), calculate_norm(), DiffContext::DiffContext(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), ErrorEstimator::estimate_errors(), FEMSystem::eulerian_residual(), ExactSolution::ExactSolution(), FEMContext::FEMContext(), get_info(), init(), FEMSystem::init_context(), DifferentiableSystem::init_data(), FEMSystem::mass_residual(), FEMSystem::mesh_position_get(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), project_vector(), re_update(), read_header(), read_legacy_data(), read_parallel_data(), read_serialized_vector(), reinit(), FEMContext::reinit(), EquationSystems::reinit(), HPCoarsenTest::select_refinement(), VTKIO::solution_to_vtk(), write_header(), write_parallel_data(), write_serialized_vector(), and zero_variable().
01391 { 01392 return _variables.size(); 01393 }
| unsigned int 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 1452 of file system.h.
References _vectors.
Referenced by ExplicitSystem::add_system_rhs(), compare(), get_info(), read_header(), and write_header().
01453 { 01454 return _vectors.size(); 01455 }
| const std::string & System::name | ( | ) | const [inline] |
- Returns:
- the system name.
Definition at line 1318 of file system.h.
References _sys_name.
Referenced by compare(), ExactErrorEstimator::estimate_error(), ExactSolution::ExactSolution(), ExactErrorEstimator::find_squared_element_error(), get_info(), System::ProjectVector::operator()(), project_vector(), FrequencySystem::solve(), user_assembly(), user_constrain(), user_initialization(), user_QOI(), user_QOI_derivative(), write_header(), write_parallel_data(), and write_serialized_data().
01319 { 01320 return _sys_name; 01321 }
| unsigned int System::number | ( | ) | const [inline] |
- Returns:
- the system number.
Definition at line 1326 of file system.h.
References _sys_number.
Referenced by add_variable(), FEMSystem::eulerian_residual(), FEMSystem::mesh_position_get(), FEMSystem::mesh_position_set(), FEMSystem::mesh_x_position(), FEMSystem::mesh_y_position(), FEMSystem::mesh_z_position(), FEMSystem::numerical_jacobian(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), HPCoarsenTest::select_refinement(), write_parallel_data(), write_serialized_blocked_dof_objects(), and zero_variable().
01327 { 01328 return _sys_number; 01329 }
| void ReferenceCounter::print_info | ( | ) | [static, inherited] |
Prints the reference information to std::cout.
Definition at line 83 of file reference_counter.C.
References ReferenceCounter::get_info().
00084 { 00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00086 00087 std::cout << ReferenceCounter::get_info(); 00088 00089 #endif 00090 }
| void 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, | |||
| Parameters & | parameters | |||
| ) | const |
Projects the continuous functions onto the current solution.
This method projects an analytic function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 237 of file system_projection.C.
References current_local_solution, project_vector(), and solution.
00246 { 00247 this->project_vector(fptr, gptr, parameters, *solution); 00248 00249 solution->localize(*current_local_solution); 00250 }
| bool& 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 445 of file system.h.
References _solution_projection.
00446 { return _solution_projection; }
| void 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 60 of file system_projection.C.
References NumericVector< T >::clear(), NumericVector< T >::close(), DofMap::enforce_constraints_exactly(), FEType::family, AutoPtr< Tp >::get(), get_dof_map(), get_mesh(), libMeshEnums::GHOSTED, NumericVector< T >::init(), NumericVector< T >::local_size(), NumericVector< T >::localize(), n_dofs(), n_local_dofs(), libMesh::n_processors(), n_vars(), libMeshEnums::PARALLEL, Threads::parallel_for(), Threads::parallel_reduce(), libMesh::processor_id(), libMeshEnums::SCALAR, DofMap::SCALAR_dof_indices(), System::BuildProjectionList::send_list, libMeshEnums::SERIAL, NumericVector< T >::set(), NumericVector< T >::size(), System::Variable::type(), NumericVector< T >::type(), System::BuildProjectionList::unique(), and variable().
00062 { 00063 START_LOG ("project_vector()", "System"); 00064 00071 new_v.clear(); 00072 00073 #ifdef LIBMESH_ENABLE_AMR 00074 00075 // Resize the new vector and get a serial version. 00076 NumericVector<Number> *new_vector_ptr = NULL; 00077 AutoPtr<NumericVector<Number> > new_vector_built; 00078 NumericVector<Number> *local_old_vector; 00079 AutoPtr<NumericVector<Number> > local_old_vector_built; 00080 const NumericVector<Number> *old_vector_ptr = NULL; 00081 00082 ConstElemRange active_local_elem_range 00083 (this->get_mesh().active_local_elements_begin(), 00084 this->get_mesh().active_local_elements_end()); 00085 00086 // If the old vector was uniprocessor, make the new 00087 // vector uniprocessor 00088 if (old_v.type() == SERIAL) 00089 { 00090 new_v.init (this->n_dofs(), false, SERIAL); 00091 new_vector_ptr = &new_v; 00092 old_vector_ptr = &old_v; 00093 } 00094 00095 // Otherwise it is a parallel, distributed vector, which 00096 // we need to localize. 00097 else if (old_v.type() == PARALLEL) 00098 { 00099 // Build a send list for efficient localization 00100 BuildProjectionList projection_list(*this); 00101 Threads::parallel_reduce (active_local_elem_range, 00102 projection_list); 00103 00104 // Create a sorted, unique send_list 00105 projection_list.unique(); 00106 00107 new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00108 new_vector_built = NumericVector<Number>::build(); 00109 local_old_vector_built = NumericVector<Number>::build(); 00110 new_vector_ptr = new_vector_built.get(); 00111 local_old_vector = local_old_vector_built.get(); 00112 new_vector_ptr->init(this->n_dofs(), false, SERIAL); 00113 local_old_vector->init(old_v.size(), false, SERIAL); 00114 old_v.localize(*local_old_vector, projection_list.send_list); 00115 local_old_vector->close(); 00116 old_vector_ptr = local_old_vector; 00117 } 00118 else if (old_v.type() == GHOSTED) 00119 { 00120 // Build a send list for efficient localization 00121 BuildProjectionList projection_list(*this); 00122 Threads::parallel_reduce (active_local_elem_range, 00123 projection_list); 00124 00125 // Create a sorted, unique send_list 00126 projection_list.unique(); 00127 00128 new_v.init (this->n_dofs(), this->n_local_dofs(), 00129 this->get_dof_map().get_send_list(), false, GHOSTED); 00130 00131 local_old_vector_built = NumericVector<Number>::build(); 00132 new_vector_ptr = &new_v; 00133 local_old_vector = local_old_vector_built.get(); 00134 local_old_vector->init(old_v.size(), old_v.local_size(), 00135 projection_list.send_list, false, GHOSTED); 00136 old_v.localize(*local_old_vector, projection_list.send_list); 00137 local_old_vector->close(); 00138 old_vector_ptr = local_old_vector; 00139 } 00140 else // unknown old_v.type() 00141 { 00142 std::cerr << "ERROR: Unknown old_v.type() == " << old_v.type() 00143 << std::endl; 00144 libmesh_error(); 00145 } 00146 00147 // Note that the above will have zeroed the new_vector. 00148 // Just to be sure, assert that new_vector_ptr and old_vector_ptr 00149 // were successfully set before trying to deref them. 00150 libmesh_assert(new_vector_ptr); 00151 libmesh_assert(old_vector_ptr); 00152 00153 NumericVector<Number> &new_vector = *new_vector_ptr; 00154 const NumericVector<Number> &old_vector = *old_vector_ptr; 00155 00156 Threads::parallel_for (active_local_elem_range, 00157 ProjectVector(*this, 00158 old_vector, 00159 new_vector) 00160 ); 00161 00162 // Copy the SCALAR dofs from old_vector to new_vector 00163 // Note: We assume that all SCALAR dofs are on the 00164 // processor with highest ID 00165 if(libMesh::processor_id() == (libMesh::n_processors()-1)) 00166 { 00167 const DofMap& dof_map = this->get_dof_map(); 00168 for (unsigned int var=0; var<this->n_vars(); var++) 00169 if(this->variable(var).type().family == SCALAR) 00170 { 00171 // We can just map SCALAR dofs directly across 00172 std::vector<unsigned int> new_SCALAR_indices, old_SCALAR_indices; 00173 dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false); 00174 dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true); 00175 const unsigned int new_n_dofs = new_SCALAR_indices.size(); 00176 00177 for (unsigned int i=0; i<new_n_dofs; i++) 00178 { 00179 new_vector.set( new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]) ); 00180 } 00181 } 00182 } 00183 00184 new_vector.close(); 00185 00186 // If the old vector was serial, we probably need to send our values 00187 // to other processors 00188 // 00189 // FIXME: I'm not sure how to make a NumericVector do that without 00190 // creating a temporary parallel vector to use localize! - RHS 00191 if (old_v.type() == SERIAL) 00192 { 00193 AutoPtr<NumericVector<Number> > dist_v = NumericVector<Number>::build(); 00194 dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00195 dist_v->close(); 00196 00197 for (unsigned int i=0; i!=dist_v->size(); i++) 00198 if (new_vector(i) != 0.0) 00199 dist_v->set(i, new_vector(i)); 00200 00201 dist_v->close(); 00202 00203 dist_v->localize (new_v, this->get_dof_map().get_send_list()); 00204 new_v.close(); 00205 } 00206 // If the old vector was parallel, we need to update it 00207 // and free the localized copies 00208 else if (old_v.type() == PARALLEL) 00209 { 00210 // We may have to set dof values that this processor doesn't 00211 // own in certain special cases, like LAGRANGE FIRST or 00212 // HERMITE THIRD elements on second-order meshes 00213 for (unsigned int i=0; i!=new_v.size(); i++) 00214 if (new_vector(i) != 0.0) 00215 new_v.set(i, new_vector(i)); 00216 new_v.close(); 00217 } 00218 00219 this->get_dof_map().enforce_constraints_exactly(*this, &new_v); 00220 00221 #else 00222 00223 // AMR is disabled: simply copy the vector 00224 new_v = old_v; 00225 00226 #endif // #ifdef LIBMESH_ENABLE_AMR 00227 00228 STOP_LOG("project_vector()", "System"); 00229 }
| void System::project_vector | ( | NumericVector< Number > & | vector | ) | const [protected] |
Projects the vector defined on the old mesh onto the new mesh.
Definition at line 43 of file system_projection.C.
References NumericVector< T >::clone(), and project_vector().
00044 { 00045 // Create a copy of the vector, which currently 00046 // contains the old data. 00047 AutoPtr<NumericVector<Number> > 00048 old_vector (vector.clone()); 00049 00050 // Project the old vector to the new vector 00051 this->project_vector (*old_vector, vector); 00052 }
| void 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, | |||
| Parameters & | parameters, | |||
| NumericVector< Number > & | new_vector | |||
| ) | const |
Projects the continuous functions onto the current mesh.
This method projects an analytic function via L2 projections and nodal interpolations on each element.
Definition at line 258 of file system_projection.C.
References NumericVector< T >::close(), DofMap::enforce_constraints_exactly(), FEType::family, get_dof_map(), get_mesh(), libMesh::n_processors(), n_vars(), name(), Threads::parallel_for(), libMesh::processor_id(), libMeshEnums::SCALAR, DofMap::SCALAR_dof_indices(), NumericVector< T >::set(), System::Variable::type(), variable(), and variable_name().
Referenced by project_solution(), project_vector(), and restrict_vectors().
00268 { 00269 START_LOG ("project_vector()", "System"); 00270 00271 Threads::parallel_for (ConstElemRange (this->get_mesh().active_local_elements_begin(), 00272 this->get_mesh().active_local_elements_end(), 00273 1000), 00274 ProjectSolution(*this, 00275 fptr, 00276 gptr, 00277 parameters, 00278 new_vector) 00279 ); 00280 00281 // Also, load values into the SCALAR dofs 00282 // Note: We assume that all SCALAR dofs are on the 00283 // processor with highest ID 00284 if(libMesh::processor_id() == (libMesh::n_processors()-1)) 00285 { 00286 const DofMap& dof_map = this->get_dof_map(); 00287 for (unsigned int var=0; var<this->n_vars(); var++) 00288 if(this->variable(var).type().family == SCALAR) 00289 { 00290 std::vector<unsigned int> SCALAR_indices; 00291 dof_map.SCALAR_dof_indices (SCALAR_indices, var); 00292 const unsigned int n_SCALAR_dofs = SCALAR_indices.size(); 00293 00294 for (unsigned int i=0; i<n_SCALAR_dofs; i++) 00295 { 00296 const unsigned int index = SCALAR_indices[i]; 00297 00298 // We pass the point (i,0,0) to the fptr to distinguish 00299 // the different scalars within the SCALAR variable 00300 Point p_i(i,0,0); 00301 new_vector.set( index, fptr(p_i, 00302 parameters, 00303 this->name(), 00304 this->variable_name(var)) 00305 ); 00306 } 00307 } 00308 } 00309 00310 new_vector.close(); 00311 00312 #ifdef LIBMESH_ENABLE_AMR 00313 this->get_dof_map().enforce_constraints_exactly(*this, &new_vector); 00314 #endif 00315 00316 STOP_LOG("project_vector()", "System"); 00317 }
| void System::prolong_vectors | ( | ) | [virtual] |
Prolong vectors after the mesh has refined
Definition at line 255 of file system.C.
References restrict_vectors().
Referenced by EquationSystems::reinit().
00256 { 00257 #ifdef LIBMESH_ENABLE_AMR 00258 // Currently project_vector handles both restriction and prolongation 00259 this->restrict_vectors(); 00260 #endif 00261 }
| virtual void 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 ImplicitSystem.
Definition at line 281 of file system.h.
| void 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 383 of file system.C.
References ParameterVector::size(), and QoISet::size().
00386 { 00387 // Forward sensitivities are more efficient for Nq > Np 00388 if (qoi_indices.size(*this) > parameters.size()) 00389 forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities); 00390 // Adjoint sensitivities are more efficient for Np > Nq, 00391 // and an adjoint may be more reusable than a forward 00392 // solution sensitivity in the Np == Nq case. 00393 else 00394 adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities); 00395 }
| void 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.
Definition at line 314 of file system.C.
References current_local_solution, Utility::iota(), n_vars(), and solution.
00315 { 00316 //const std::vector<unsigned int>& send_list = _dof_map->get_send_list (); 00317 00318 // If this system is empty... don't do anything! 00319 if(!this->n_vars()) 00320 return; 00321 00322 // Explicitly build a send_list 00323 std::vector<unsigned int> send_list(solution->size()); 00324 Utility::iota (send_list.begin(), send_list.end(), 0); 00325 00326 // Check sizes 00327 libmesh_assert (current_local_solution->size() == solution->size()); 00328 // Not true with ghosted vectors 00329 // libmesh_assert (current_local_solution->local_size() == solution->size()); 00330 libmesh_assert (!send_list.empty()); 00331 libmesh_assert (send_list.size() <= solution->size()); 00332 00333 // Create current_local_solution from solution. This will 00334 // put a local copy of solution into current_local_solution. 00335 solution->localize (*current_local_solution, send_list); 00336 }
| void 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 78 of file system_io.C.
References _additional_data_written, _can_add_vectors, add_variable(), add_vector(), clear(), Xdr::data(), FEType::family, get_mesh(), FEType::inf_map, MeshBase::mesh_dimension(), libMeshEnums::MONOMIAL, n_vars(), n_vectors(), libMesh::on_command_line(), FEType::order, libMesh::processor_id(), FEType::radial_family, FEType::radial_order, Xdr::reading(), type, and libMeshEnums::XYZ.
Referenced by EquationSystems::_read_impl().
00083 { 00084 // This method implements the input of a 00085 // System object, embedded in the output of 00086 // an EquationSystems<T_sys>. This warrants some 00087 // documentation. The output file essentially 00088 // consists of 5 sections: 00089 // 00090 // for this system 00091 // 00092 // 5.) The number of variables in the system (unsigned int) 00093 // 00094 // for each variable in the system 00095 // 00096 // 6.) The name of the variable (string) 00097 // 00098 // 7.) Combined in an FEType: 00099 // - The approximation order(s) of the variable 00100 // (Order Enum, cast to int/s) 00101 // - The finite element family/ies of the variable 00102 // (FEFamily Enum, cast to int/s) 00103 // 00104 // end variable loop 00105 // 00106 // 8.) The number of additional vectors (unsigned int), 00107 // 00108 // for each additional vector in the system object 00109 // 00110 // 9.) the name of the additional vector (string) 00111 // 00112 // end system 00113 libmesh_assert (io.reading()); 00114 00115 // Possibly clear data structures and start from scratch. 00116 if (read_header) 00117 this->clear (); 00118 00119 // Figure out if we need to read infinite element information. 00120 // This will be true if the version string contains " with infinite elements" 00121 const bool read_ifem_info = 00122 (version.rfind(" with infinite elements") < version.size()) || 00123 libMesh::on_command_line ("--read_ifem_systems"); 00124 00125 00126 { 00127 // 5.) 00128 // Read the number of variables in the system 00129 unsigned int n_vars=0; 00130 if (libMesh::processor_id() == 0) io.data (n_vars); 00131 Parallel::broadcast(n_vars); 00132 00133 for (unsigned int var=0; var<n_vars; var++) 00134 { 00135 // 6.) 00136 // Read the name of the var-th variable 00137 std::string var_name; 00138 if (libMesh::processor_id() == 0) io.data (var_name); 00139 Parallel::broadcast(var_name); 00140 00141 // 7.) 00142 // Read the approximation order(s) of the var-th variable 00143 int order=0; 00144 if (libMesh::processor_id() == 0) io.data (order); 00145 Parallel::broadcast(order); 00146 00147 00148 // do the same for infinite element radial_order 00149 int rad_order=0; 00150 if (read_ifem_info) 00151 { 00152 if (libMesh::processor_id() == 0) io.data(rad_order); 00153 Parallel::broadcast(rad_order); 00154 } 00155 00156 00157 // Read the finite element type of the var-th variable 00158 int fam=0; 00159 if (libMesh::processor_id() == 0) io.data (fam); 00160 Parallel::broadcast(fam); 00161 FEType type; 00162 type.order = static_cast<Order>(order); 00163 type.family = static_cast<FEFamily>(fam); 00164 00165 // Check for incompatibilities. The shape function indexing was 00166 // changed for the monomial and xyz finite element families to 00167 // simplify extension to arbitrary p. The consequence is that 00168 // old restart files will not be read correctly. This is expected 00169 // to be an unlikely occurance, but catch it anyway. 00170 if (read_legacy_format) 00171 if ((type.family == MONOMIAL || type.family == XYZ) && 00172 ((type.order > 2 && this->get_mesh().mesh_dimension() == 2) || 00173 (type.order > 1 && this->get_mesh().mesh_dimension() == 3))) 00174 { 00175 libmesh_here(); 00176 std::cout << "*****************************************************************\n" 00177 << "* WARNING: reading a potentially incompatible restart file!!! *\n" 00178 << "* contact libmesh-users@lists.sourceforge.net for more details *\n" 00179 << "*****************************************************************" 00180 << std::endl; 00181 } 00182 00183 // Read additional information for infinite elements 00184 int radial_fam=0; 00185 int i_map=0; 00186 if (read_ifem_info) 00187 { 00188 if (libMesh::processor_id() == 0) io.data (radial_fam); 00189 Parallel::broadcast(radial_fam); 00190 if (libMesh::processor_id() == 0) io.data (i_map); 00191 Parallel::broadcast(i_map); 00192 } 00193 00194 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00195 00196 type.radial_order = static_cast<Order>(rad_order); 00197 type.radial_family = static_cast<FEFamily>(radial_fam); 00198 type.inf_map = static_cast<InfMapType>(i_map); 00199 00200 #endif 00201 00202 if (read_header) 00203 this->add_variable (var_name, type); 00204 } 00205 } 00206 00207 // 8.) 00208 // Read the number of additional vectors. 00209 unsigned int n_vectors=0; 00210 if (libMesh::processor_id() == 0) io.data (n_vectors); 00211 Parallel::broadcast(n_vectors); 00212 00213 // If n_vectors > 0, this means that write_additional_data 00214 // was true when this file was written. We will need to 00215 // make use of this fact later. 00216 if (n_vectors > 0) 00217 this->_additional_data_written = true; 00218 00219 for (unsigned int vec=0; vec<n_vectors; vec++) 00220 { 00221 // 9.) 00222 // Read the name of the vec-th additional vector 00223 std::string vec_name; 00224 if (libMesh::processor_id() == 0) io.data (vec_name); 00225 Parallel::broadcast(vec_name); 00226 00227 if (read_additional_data) 00228 { 00229 // sanity checks 00230 libmesh_assert(this->_can_add_vectors); 00231 // Some systems may have added their own vectors already 00232 // libmesh_assert(this->_vectors.count(vec_name) == 0); 00233 00234 this->add_vector(vec_name); 00235 } 00236 } 00237 }
| void System::read_legacy_data | ( | Xdr & | io, | |
| const bool | read_additional_data = true | |||
| ) |
Reads additional data, namely vectors, for this System.
Definition at line 241 of file system_io.C.
References _additional_data_written, _vectors, MeshBase::active_elements_begin(), MeshBase::active_elements_end(), Xdr::data(), get_mesh(), DofObject::invalid_id, n_dofs(), n_vars(), MeshBase::nodes_begin(), MeshBase::nodes_end(), number(), libMesh::processor_id(), Xdr::reading(), solution, and libMesh::zero.
00243 { 00244 libmesh_deprecated(); 00245 00246 // This method implements the output of the vectors 00247 // contained in this System object, embedded in the 00248 // output of an EquationSystems<T_sys>. 00249 // 00250 // 10.) The global solution vector, re-ordered to be node-major 00251 // (More on this later.) 00252 // 00253 // for each additional vector in the object 00254 // 00255 // 11.) The global additional vector, re-ordered to be 00256 // node-major (More on this later.) 00257 libmesh_assert (io.reading()); 00258 00259 // read and reordering buffers 00260 std::vector<Number> global_vector; 00261 std::vector<Number> reordered_vector; 00262 00263 // 10.) 00264 // Read and set the solution vector 00265 { 00266 if (libMesh::processor_id() == 0) io.data (global_vector); 00267 Parallel::broadcast(global_vector); 00268 00269 // Remember that the stored vector is node-major. 00270 // We need to put it into whatever application-specific 00271 // ordering we may have using the dof_map. 00272 reordered_vector.resize(global_vector.size()); 00273 00274 //std::cout << "global_vector.size()=" << global_vector.size() << std::endl; 00275 //std::cout << "this->n_dofs()=" << this->n_dofs() << std::endl; 00276 00277 libmesh_assert (global_vector.size() == this->n_dofs()); 00278 00279 unsigned int cnt=0; 00280 00281 const unsigned int sys = this->number(); 00282 const unsigned int n_vars = this->n_vars(); 00283 00284 for (unsigned int var=0; var<n_vars; var++) 00285 { 00286 // First reorder the nodal DOF values 00287 { 00288 MeshBase::node_iterator 00289 it = this->get_mesh().nodes_begin(), 00290 end = this->get_mesh().nodes_end(); 00291 00292 for (; it != end; ++it) 00293 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00294 { 00295 libmesh_assert ((*it)->dof_number(sys, var, index) != 00296 DofObject::invalid_id); 00297 00298 libmesh_assert (cnt < global_vector.size()); 00299 00300 reordered_vector[(*it)->dof_number(sys, var, index)] = 00301 global_vector[cnt++]; 00302 } 00303 } 00304 00305 // Then reorder the element DOF values 00306 { 00307 MeshBase::element_iterator 00308 it = this->get_mesh().active_elements_begin(), 00309 end = this->get_mesh().active_elements_end(); 00310 00311 for (; it != end; ++it) 00312 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00313 { 00314 libmesh_assert ((*it)->dof_number(sys, var, index) != 00315 DofObject::invalid_id); 00316 00317 libmesh_assert (cnt < global_vector.size()); 00318 00319 reordered_vector[(*it)->dof_number(sys, var, index)] = 00320 global_vector[cnt++]; 00321 } 00322 } 00323 } 00324 00325 *(this->solution) = reordered_vector; 00326 } 00327 00328 // For each additional vector, simply go through the list. 00329 // ONLY attempt to do this IF additional data was actually 00330 // written to the file for this system (controlled by the 00331 // _additional_data_written flag). 00332 if (this->_additional_data_written) 00333 { 00334 std::map<std::string, NumericVector<Number>* >::iterator 00335 pos = this->_vectors.begin(); 00336 00337 for (; pos != this->_vectors.end(); ++pos) 00338 { 00339 // 11.) 00340 // Read the values of the vec-th additional vector. 00341 // Prior do _not_ clear, but fill with zero, since the 00342 // additional vectors _have_ to have the same size 00343 // as the solution vector 00344 std::fill (global_vector.begin(), global_vector.end(), libMesh::zero); 00345 00346 if (libMesh::processor_id() == 0) io.data (global_vector); 00347 Parallel::broadcast(global_vector); 00348 00349 // If read_additional_data==true, then we will keep this vector, otherwise 00350 // we are going to throw it away. 00351 if (read_additional_data) 00352 { 00353 // Remember that the stored vector is node-major. 00354 // We need to put it into whatever application-specific 00355 // ordering we may have using the dof_map. 00356 std::fill (reordered_vector.begin(), 00357 reordered_vector.end(), 00358 libMesh::zero); 00359 00360 reordered_vector.resize(global_vector.size()); 00361 00362 libmesh_assert (global_vector.size() == this->n_dofs()); 00363 00364 unsigned int cnt=0; 00365 00366 const unsigned int sys = this->number(); 00367 const unsigned int n_vars = this->n_vars(); 00368 00369 for (unsigned int var=0; var<n_vars; var++) 00370 { 00371 // First reorder the nodal DOF values 00372 { 00373 MeshBase::node_iterator 00374 it = this->get_mesh().nodes_begin(), 00375 end = this->get_mesh().nodes_end(); 00376 00377 for (; it!=end; ++it) 00378 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00379 { 00380 libmesh_assert ((*it)->dof_number(sys, var, index) != 00381 DofObject::invalid_id); 00382 00383 libmesh_assert (cnt < global_vector.size()); 00384 00385 reordered_vector[(*it)->dof_number(sys, var, index)] = 00386 global_vector[cnt++]; 00387 } 00388 } 00389 00390 // Then reorder the element DOF values 00391 { 00392 MeshBase::element_iterator 00393 it = this->get_mesh().active_elements_begin(), 00394 end = this->get_mesh().active_elements_end(); 00395 00396 for (; it!=end; ++it) 00397 for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++) 00398 { 00399 libmesh_assert ((*it)->dof_number(sys, var, index) != 00400 DofObject::invalid_id); 00401 00402 libmesh_assert (cnt < global_vector.size()); 00403 00404 reordered_vector[(*it)->dof_number(sys, var, index)] = 00405 global_vector[cnt++]; 00406 } 00407 } 00408 } 00409 00410 // use the overloaded operator=(std::vector) to assign the values 00411 *(pos->second) = reordered_vector; 00412 } 00413 } 00414 } // end if (_additional_data_written) 00415 }
| void 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 419 of file system_io.C.
References _vectors, Xdr::data(), get_mesh(), DofObject::invalid_id, Xdr::is_open(), n_vars(), number(), Xdr::reading(), and solution.
00421 { 00441 libmesh_assert (io.reading()); 00442 libmesh_assert (io.is_open()); 00443 00444 // build the ordered nodes and element maps. 00445 // when writing/reading parallel files we need to iterate 00446 // over our nodes/elements in order of increasing global id(). 00447 // however, this is not guaranteed to be ordering we obtain 00448 // by using the node_iterators/element_iterators directly. 00449 // so build a set, sorted by id(), that provides the ordering. 00450 // further, for memory economy build the set but then transfer 00451 // its contents to vectors, which will be sorted. 00452 std::vector<const DofObject*> ordered_nodes, ordered_elements; 00453 { 00454 std::set<const DofObject*, CompareDofObjectsByID> 00455 ordered_nodes_set (this->get_mesh().local_nodes_begin(), 00456 this->get_mesh().local_nodes_end()); 00457 00458 ordered_nodes.insert(ordered_nodes.end(), 00459 ordered_nodes_set.begin(), 00460 ordered_nodes_set.end()); 00461 } 00462 { 00463 std::set<const DofObject*, CompareDofObjectsByID> 00464 ordered_elements_set (this->get_mesh().local_elements_begin(), 00465 this->get_mesh().local_elements_end()); 00466 00467 ordered_elements.insert(ordered_elements.end(), 00468 ordered_elements_set.begin(), 00469 ordered_elements_set.end()); 00470 } 00471 00472 std::vector<Number> io_buffer; 00473 00474 // 9.) 00475 // 00476 // Actually read the solution components 00477 // for the ith system to disk 00478 io.data(io_buffer); 00479 00480 const unsigned int sys_num = this->number(); 00481 const unsigned int n_vars = this->n_vars(); 00482 00483 unsigned int cnt=0; 00484 00485 // Loop over each variable and each node, and read out the value. 00486 for (unsigned int var=0; var<n_vars; var++) 00487 { 00488 // First read the node DOF values 00489 for (std::vector<const DofObject*>::const_iterator 00490 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 00491 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00492 { 00493 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 00494 DofObject::invalid_id); 00495 libmesh_assert (cnt < io_buffer.size()); 00496 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00497 } 00498 00499 // Then read the element DOF values 00500 for (std::vector<const DofObject*>::const_iterator 00501 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 00502 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00503 { 00504 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 00505 DofObject::invalid_id); 00506 libmesh_assert (cnt < io_buffer.size()); 00507 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00508 } 00509 } 00510 00511 // Only read additional vectors if wanted 00512 if (read_additional_data) 00513 { 00514 std::map<std::string, NumericVector<Number>* >::const_iterator 00515 pos = _vectors.begin(); 00516 00517 for(; pos != this->_vectors.end(); ++pos) 00518 { 00519 cnt=0; 00520 io_buffer.clear(); 00521 00522 // 10.) 00523 // 00524 // Actually read the additional vector components 00525 // for the ith system to disk 00526 io.data(io_buffer); 00527 00528 // Loop over each variable and each node, and read out the value. 00529 for (unsigned int var=0; var<n_vars; var++) 00530 { 00531 // First read the node DOF values 00532 for (std::vector<const DofObject*>::const_iterator 00533 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 00534 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00535 { 00536 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 00537 DofObject::invalid_id); 00538 libmesh_assert (cnt < io_buffer.size()); 00539 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00540 } 00541 00542 // Then read the element DOF values 00543 for (std::vector<const DofObject*>::const_iterator 00544 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 00545 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 00546 { 00547 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 00548 DofObject::invalid_id); 00549 libmesh_assert (cnt < io_buffer.size()); 00550 this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]); 00551 } 00552 } 00553 } 00554 } 00555 }
| unsigned int System::read_serialized_blocked_dof_objects | ( | const unsigned int | var, | |
| const unsigned int | n_objects, | |||
| const iterator_type | begin, | |||
| const iterator_type | end, | |||
| Xdr & | io, | |||
| NumericVector< Number > & | vec | |||
| ) | 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.
Definition at line 608 of file system_io.C.
References Xdr::data_stream(), NumericVector< T >::first_local_index(), MeshTools::Generation::Private::idx(), libMesh::invalid_uint, io_blksize, NumericVector< T >::last_local_index(), std::min(), n_local_dofs(), libMesh::n_processors(), number(), libMesh::processor_id(), and NumericVector< T >::set().
Referenced by read_serialized_vector().
00614 { 00615 const unsigned int sys_num = this->number(); 00616 00617 std::vector<Number> input_buffer; // buffer to hold the input block read from io. 00618 std::vector<Number> local_values; 00619 std::vector<std::vector<unsigned int> > // The IDs from each processor which map to the objects 00620 recv_ids(libMesh::n_processors()); // read in the current block 00621 std::vector<unsigned int> idx_map; // Reordering map to traverse entry-wise rather than processor-wise 00622 unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned. 00623 00624 //----------------------------------- 00625 // Collect the values for all objects 00626 unsigned int first_object=0, last_object=0; 00627 00628 for (unsigned int blk=0; last_object<n_objects; blk++) 00629 { 00630 //std::cout << "Reading object block " << blk << std::endl; 00631 00632 // Each processor should build up its transfer buffers for its 00633 // local objects in [first_object,last_object). 00634 first_object = blk*io_blksize; 00635 last_object = std::min((blk+1)*io_blksize,n_objects); 00636 00637 // Clear the transfer buffers for this block. 00638 recv_ids[libMesh::processor_id()].clear(); 00639 unsigned int n_local_dofs=0; 00640 for (iterator_type it=begin; it!=end; ++it) 00641 if (((*it)->id() >= first_object) && // object in [first_object,last_object) 00642 ((*it)->id() < last_object) && 00643 (*it)->n_comp(sys_num,var)) // var has a nonzero # of components on this object 00644 { 00645 recv_ids[libMesh::processor_id()].push_back((*it)->id()); 00646 recv_ids[libMesh::processor_id()].push_back((*it)->n_comp(sys_num, var)); 00647 recv_ids[libMesh::processor_id()].push_back(n_local_dofs); 00648 n_local_dofs += (*it)->n_comp(sys_num, var); 00649 } 00650 00651 // Get the recv_ids for all other processors. 00652 { 00653 const unsigned int curr_vec_size = recv_ids[libMesh::processor_id()].size(); 00654 std::vector<unsigned int> recv_id_sizes(libMesh::n_processors()); 00655 Parallel::allgather(curr_vec_size, recv_id_sizes); 00656 for (unsigned int pid=0; pid<libMesh::n_processors(); pid++) 00657 { 00658 recv_ids[pid].resize(recv_id_sizes[pid]); 00659 Parallel::broadcast(recv_ids[pid], pid); 00660 } 00661 } 00662 00663 // create the idx map for all processors -- this will match the ordering 00664 // in the input buffer chunk which we are about to read. 00665 idx_map.resize(3*io_blksize); std::fill (idx_map.begin(), idx_map.end(), libMesh::invalid_uint); 00666 unsigned int tot_n_comp=0; 00667 for (unsigned int pid=0; pid<libMesh::n_processors(); pid++) 00668 for (unsigned int idx=0; idx<recv_ids[pid].size(); idx+=3) 00669 { 00670 const unsigned int local_idx = recv_ids[pid][idx+0]-first_object; 00671 libmesh_assert (local_idx < std::min(io_blksize,n_objects)); 00672 const unsigned int n_comp = recv_ids[pid][idx+1]; 00673 const unsigned int start_pos = recv_ids[pid][idx+2]; 00674 00675 idx_map[3*local_idx+0] = pid; 00676 idx_map[3*local_idx+1] = n_comp; 00677 idx_map[3*local_idx+2] = start_pos; // this tells us where the values 00678 // for this object will live in the local_values buffer 00679 tot_n_comp += n_comp; 00680 } 00681 00682 // Processor 0 will read the block from the buffer stream and send it to all other processors 00683 input_buffer.resize (tot_n_comp); 00684 if (libMesh::processor_id() == 0) io.data_stream(input_buffer.empty() ? NULL : &input_buffer[0], tot_n_comp); 00685 Parallel::broadcast(input_buffer); 00686 00687 // Extract the values corresponding to the local objects from the input_buffer 00688 // and place them into the local_values temporary buffer. 00689 { 00690 unsigned int processed_size=0; 00691 std::vector<Number>::const_iterator next_value = input_buffer.begin(); 00692 local_values.clear(); local_values.resize(n_local_dofs); 00693 00694 for (unsigned int idx=0; idx<idx_map.size(); idx+=3) 00695 if (idx_map[idx] != libMesh::invalid_uint) // this could happen when an object 00696 { // has no components for the current variable 00697 const unsigned int pid = idx_map[idx+0]; 00698 const unsigned int n_comp = idx_map[idx+1]; 00699 const unsigned int start_pos = idx_map[idx+2]; 00700 00701 for (unsigned int comp=0; comp<n_comp; comp++) 00702 { 00703 libmesh_assert (next_value != input_buffer.end()); 00704 if (pid == libMesh::processor_id()) 00705 { 00706 libmesh_assert ((start_pos+comp) < local_values.size()); 00707 local_values[start_pos+comp] = *next_value; 00708 } 00709 ++next_value; 00710 ++processed_size; 00711 } 00712 } 00713 libmesh_assert (processed_size == input_buffer.size()); 00714 } 00715 00716 // A subset of the components (potentially null set) will match our objects in 00717 // [first_object,last_object), and we will assign the corresponding values from 00718 // the local_values buffer. 00719 for (iterator_type it=begin; it!=end; ++it) 00720 if (((*it)->id() >= first_object) && // object in [first_object,last_object) 00721 ((*it)->id() < last_object) && 00722 (*it)->n_comp(sys_num,var)) // var has a nonzero # of components on this object 00723 { 00724 const unsigned int local_idx = (*it)->id()-first_object; 00725 libmesh_assert (local_idx < std::min(io_blksize,n_objects)); 00726 00727 #ifndef NDEBUG 00728 // We only need to check the pid when asserts are active 00729 const unsigned int pid = idx_map[3*local_idx+0]; 00730 #endif 00731 libmesh_assert (pid == libMesh::processor_id()); 00732 00733 const unsigned int n_comp = idx_map[3*local_idx+1]; 00734 const unsigned int start_pos = idx_map[3*local_idx+2]; 00735 00736 libmesh_assert (n_comp == (*it)->n_comp(sys_num, var)); 00737 00738 for (unsigned int comp=0; comp<n_comp; comp++) 00739 { 00740 libmesh_assert ((start_pos+comp) < local_values.size()); 00741 const Number &value = local_values[start_pos+comp]; 00742 const unsigned int dof_index = (*it)->dof_number (sys_num, var, comp); 00743 libmesh_assert (dof_index >= vec.first_local_index()); 00744 libmesh_assert (dof_index < vec.last_local_index()); 00745 //std::cout << "di=" << dof_index << ", val=" << value << std::endl; 00746 vec.set (dof_index, value); 00747 ++n_assigned_vals; 00748 } 00749 } 00750 } 00751 00752 return n_assigned_vals; 00753 }
| void 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 559 of file system_io.C.
References _vectors, Xdr::comment(), libMesh::processor_id(), read_serialized_vector(), and solution.
00561 { 00562 // This method implements the input of the vectors 00563 // contained in this System object, embedded in the 00564 // output of an EquationSystems<T_sys>. 00565 // 00566 // 10.) The global solution vector, re-ordered to be node-major 00567 // (More on this later.) 00568 // 00569 // for each additional vector in the object 00570 // 00571 // 11.) The global additional vector, re-ordered to be 00572 // node-major (More on this later.) 00573 parallel_only(); 00574 std::string comment; 00575 00576 // 10.) 00577 // Read the global solution vector 00578 { 00579 this->read_serialized_vector(io, *this->solution); 00580 00581 // get the comment 00582 if (libMesh::processor_id() == 0) 00583 io.comment (comment); 00584 } 00585 00586 // 11.) 00587 // Only read additional vectors if wanted 00588 if (read_additional_data) 00589 { 00590 std::map<std::string, NumericVector<Number>* >::const_iterator 00591 pos = _vectors.begin(); 00592 00593 for(; pos != this->_vectors.end(); ++pos) 00594 { 00595 this->read_serialized_vector(io, *pos->second); 00596 00597 // get the comment 00598 if (libMesh::processor_id() == 0) 00599 io.comment (comment); 00600 00601 } 00602 } 00603 }
| void 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.
Definition at line 757 of file system_io.C.
References NumericVector< T >::close(), Xdr::data(), get_mesh(), io_blksize, MeshTools::n_elem(), n_nodes, libMesh::n_processors(), n_vars(), libMeshEnums::PARALLEL, libMesh::processor_id(), read_serialized_blocked_dof_objects(), Xdr::reading(), and NumericVector< T >::type().
Referenced by read_serialized_data().
00758 { 00759 parallel_only(); 00760 00761 #ifndef NDEBUG 00762 // In parallel we better be reading a parallel vector -- if not 00763 // we will not set all of its components below!! 00764 if (libMesh::n_processors() > 1) 00765 libmesh_assert (vec.type() == PARALLEL); 00766 00767 // If this is not the same on all processors we're in trouble! 00768 Parallel::verify(io_blksize); 00769 #endif 00770 00771 libmesh_assert (io.reading()); 00772 00773 // vector length 00774 unsigned int vector_length=0, n_assigned_vals=0; 00775 00776 // Get the buffer size 00777 if (libMesh::processor_id() == 0) io.data(vector_length, "# vector length"); 00778 Parallel::broadcast(vector_length); 00779 00780 // Loop over each variable in the system, and then each node/element in the mesh. 00781 for (unsigned int var=0; var<this->n_vars(); var++) 00782 { 00783 //--------------------------------- 00784 // Collect the values for all nodes 00785 n_assigned_vals += 00786 this->read_serialized_blocked_dof_objects (var, 00787 this->get_mesh().n_nodes(), 00788 this->get_mesh().local_nodes_begin(), 00789 this->get_mesh().local_nodes_end(), 00790 io, 00791 vec); 00792 00793 00794 //------------------------------------ 00795 // Collect the values for all elements 00796 n_assigned_vals += 00797 this->read_serialized_blocked_dof_objects (var, 00798 this->get_mesh().n_elem(), 00799 this->get_mesh().local_elements_begin(), 00800 this->get_mesh().local_elements_end(), 00801 io, 00802 vec); 00803 } // end variable loop 00804 00805 vec.close(); 00806 00807 #ifndef NDEBUG 00808 Parallel::sum (n_assigned_vals); 00809 libmesh_assert (n_assigned_vals == vector_length); 00810 #endif 00811 }
| void 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 DifferentiableSystem, EigenSystem, ExplicitSystem, ImplicitSystem, LinearImplicitSystem, NewmarkSystem, and NonlinearImplicitSystem.
Definition at line 265 of file system.C.
References current_local_solution, n_dofs(), n_local_dofs(), n_vars(), libMeshEnums::PARALLEL, and solution.
Referenced by ExplicitSystem::reinit(), and EigenSystem::reinit().
00266 { 00267 #ifdef LIBMESH_ENABLE_AMR 00268 //If no variables have been added to this system 00269 //don't do anything 00270 if(!this->n_vars()) 00271 return; 00272 00273 // Constraints get handled in EquationSystems::reinit now 00274 // _dof_map->create_dof_constraints(this->get_mesh()); 00275 00276 // Update the solution based on the projected 00277 // current_local_solution. 00278 solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL); 00279 00280 libmesh_assert (solution->size() == current_local_solution->size()); 00281 // Not true with ghosted vectors 00282 // libmesh_assert (solution->size() == current_local_solution->local_size()); 00283 00284 const unsigned int first_local_dof = solution->first_local_index(); 00285 const unsigned int local_size = solution->local_size(); 00286 00287 for (unsigned int i=0; i<local_size; i++) 00288 solution->set(i+first_local_dof, 00289 (*current_local_solution)(i+first_local_dof)); 00290 #endif 00291 }
| NumericVector< Number > * 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 611 of file system.C.
References vectors_begin(), and vectors_end().
00612 { 00613 vectors_iterator v = vectors_begin(); 00614 vectors_iterator v_end = vectors_end(); 00615 unsigned int num = 0; 00616 while((num<vec_num) && (v!=v_end)) 00617 { 00618 num++; 00619 ++v; 00620 } 00621 if (v==v_end) 00622 return NULL; 00623 return v->second; 00624 }
| const NumericVector< Number > * 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 594 of file system.C.
References vectors_begin(), and vectors_end().
00595 { 00596 const_vectors_iterator v = vectors_begin(); 00597 const_vectors_iterator v_end = vectors_end(); 00598 unsigned int num = 0; 00599 while((num<vec_num) && (v!=v_end)) 00600 { 00601 num++; 00602 ++v; 00603 } 00604 if (v==v_end) 00605 return NULL; 00606 return v->second; 00607 }
| NumericVector< Number > * 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 582 of file system.C.
References _vectors.
00583 { 00584 vectors_iterator pos = _vectors.find(vec_name); 00585 00586 if (pos == _vectors.end()) 00587 return NULL; 00588 00589 return pos->second; 00590 }
| const NumericVector< Number > * 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 570 of file system.C.
References _vectors.
00571 { 00572 const_vectors_iterator pos = _vectors.find(vec_name); 00573 00574 if (pos == _vectors.end()) 00575 return NULL; 00576 00577 return pos->second; 00578 }
| void System::restrict_vectors | ( | ) | [virtual] |
Restrict vectors after the mesh has coarsened
Definition at line 219 of file system.C.
References _dof_map, _solution_projection, _vector_projections, _vectors, current_local_solution, libMeshEnums::GHOSTED, NumericVector< T >::init(), n_dofs(), n_local_dofs(), libMeshEnums::PARALLEL, project_vector(), and solution.
Referenced by prolong_vectors(), and EquationSystems::reinit().
00220 { 00221 #ifdef LIBMESH_ENABLE_AMR 00222 // Restrict the _vectors on the coarsened cells 00223 for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos) 00224 { 00225 NumericVector<Number>* v = pos->second; 00226 00227 if (_vector_projections[pos->first]) 00228 this->project_vector (*v); 00229 else 00230 v->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL); 00231 } 00232 00233 const std::vector<unsigned int>& send_list = _dof_map->get_send_list (); 00234 00235 // Restrict the solution on the coarsened cells 00236 if (_solution_projection) 00237 this->project_vector (*solution); 00238 00239 #ifdef LIBMESH_ENABLE_GHOSTED 00240 current_local_solution->init(this->n_dofs(), 00241 this->n_local_dofs(), send_list, 00242 false, GHOSTED); 00243 #else 00244 current_local_solution->init(this->n_dofs()); 00245 #endif 00246 00247 if (_solution_projection) 00248 solution->localize (*current_local_solution, send_list); 00249 00250 #endif // LIBMESH_ENABLE_AMR 00251 }
| virtual std::pair<unsigned int, Real> 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 ImplicitSystem.
Definition at line 176 of file system.h.
| virtual void System::solve | ( | ) | [pure virtual] |
Solves the system. Must be overloaded in derived systems.
Implemented in ContinuationSystem, DifferentiableSystem, EigenSystem, ExplicitSystem, FEMSystem, FrequencySystem, LinearImplicitSystem, and NonlinearImplicitSystem.
| sys_type& System::system | ( | ) | [inline] |
- Returns:
- a clever pointer to the system.
Reimplemented in EigenSystem, ExplicitSystem, ImplicitSystem, LinearImplicitSystem, and NonlinearImplicitSystem.
Definition at line 97 of file system.h.
| virtual std::string 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 EigenSystem, ExplicitSystem, FrequencySystem, ImplicitSystem, LinearImplicitSystem, NewmarkSystem, and NonlinearImplicitSystem.
Definition at line 306 of file system.h.
Referenced by get_info().
| void System::update | ( | ) | [virtual] |
Update the local values to reflect the solution on neighboring processors.
Definition at line 295 of file system.C.
References _dof_map, current_local_solution, and solution.
Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), FEMSystem::assemble_qoi(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), Problem_Interface::computeF(), GMVIO::copy_nodal_solution(), FEMSystem::mesh_position_get(), FEMSystem::postprocess(), NonlinearImplicitSystem::solve(), NewtonSolver::solve(), LinearImplicitSystem::solve(), and ExplicitSystem::solve().
00296 { 00297 const std::vector<unsigned int>& send_list = _dof_map->get_send_list (); 00298 00299 // Check sizes 00300 libmesh_assert (current_local_solution->size() == solution->size()); 00301 // More processors than elements => empty send_list 00302 // libmesh_assert (!send_list.empty()); 00303 libmesh_assert (send_list.size() <= solution->size()); 00304 00305 // Create current_local_solution from solution. This will 00306 // put a local copy of solution into current_local_solution. 00307 // Only the necessary values (specified by the send_list) 00308 // are copied to minimize communication 00309 solution->localize (*current_local_solution, send_list); 00310 }
| void System::update_global_solution | ( | std::vector< Number > & | global_soln, | |
| const unsigned int | dest_proc | |||
| ) | const |
Fill the input vector global_soln so that it contains the global solution on processor dest_proc. Requires communication with all other processors.
Definition at line 539 of file system.C.
References solution.
00541 { 00542 global_soln.resize (solution->size()); 00543 00544 solution->localize_to_one (global_soln, dest_proc); 00545 }
| void 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 530 of file system.C.
References solution.
Referenced by ExactSolution::_compute_error(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), and ExactErrorEstimator::estimate_error().
00531 { 00532 global_soln.resize (solution->size()); 00533 00534 solution->localize (global_soln); 00535 }
| void System::user_assembly | ( | ) | [virtual] |
Calls user's attached assembly function, or is overloaded by the user in derived classes.
Definition at line 1367 of file system.C.
References _assemble_system, _equation_systems, and name().
Referenced by assemble().
01368 { 01369 // Call the user-provided assembly function, 01370 // if it was provided 01371 if (_assemble_system != NULL) 01372 this->_assemble_system (_equation_systems, this->name()); 01373 }
| void System::user_constrain | ( | ) | [virtual] |
Calls user's attached constraint function, or is overloaded by the user in derived classes.
Definition at line 1377 of file system.C.
References _constrain_system, _equation_systems, and name().
Referenced by init_data(), and EquationSystems::reinit().
01378 { 01379 // Call the user-provided constraint function, 01380 // if it was provided 01381 if(_constrain_system!= NULL) 01382 this->_constrain_system(_equation_systems, this->name()); 01383 }
| void System::user_initialization | ( | ) | [virtual] |
Calls user's attached initialization function, or is overloaded by the user in derived classes.
Definition at line 1358 of file system.C.
References _equation_systems, _init_system, and name().
Referenced by init(), and NewmarkSystem::initial_conditions().
01359 { 01360 // Call the user-provided intialization function, 01361 // if it was provided 01362 if (_init_system != NULL) 01363 this->_init_system (_equation_systems, this->name()); 01364 }
| void 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 1387 of file system.C.
References _equation_systems, _qoi_evaluate, and name().
Referenced by assemble_qoi().
01388 { 01389 // Call the user-provided quantity of interest function, 01390 // if it was provided 01391 if(_qoi_evaluate != NULL) 01392 this->_qoi_evaluate(_equation_systems, this->name(), qoi_indices); 01393 }
| void 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 1397 of file system.C.
References _equation_systems, _qoi_evaluate_derivative, and name().
Referenced by assemble_qoi_derivative().
01398 { 01399 // Call the user-provided quantity of interest derivative, 01400 // if it was provided 01401 if(_qoi_evaluate_derivative != NULL) 01402 this->_qoi_evaluate_derivative(_equation_systems, this->name(), qoi_indices); 01403 }
| const System::Variable & System::variable | ( | unsigned int | var | ) | const [inline] |
Return a constant reference to Variable var.
Definition at line 1398 of file system.h.
References _variables.
Referenced by EquationSystems::build_solution_vector(), and project_vector().
01399 { 01400 libmesh_assert (i < _variables.size()); 01401 01402 return _variables[i]; 01403 }
| const std::string & System::variable_name | ( | const unsigned int | i | ) | const [inline] |
- Returns:
- the name of variable
i.
Definition at line 1408 of file system.h.
References _variables.
Referenced by add_variable(), KellyErrorEstimator::boundary_side_integration(), DiscontinuityMeasure::boundary_side_integration(), ExactErrorEstimator::estimate_error(), ExactSolution::ExactSolution(), get_info(), System::ProjectVector::operator()(), project_vector(), VTKIO::solution_to_vtk(), and write_header().
01409 { 01410 libmesh_assert (i < _variables.size()); 01411 01412 return _variables[i].name(); 01413 }
| unsigned short int System::variable_number | ( | const std::string & | var | ) | const |
- Returns:
- the variable number assoicated with the user-specified variable named
var.
Definition at line 942 of file system.C.
References _variable_numbers, and _variables.
Referenced by ExactSolution::_compute_error(), GMVIO::copy_nodal_solution(), ExactErrorEstimator::estimate_error(), ExactErrorEstimator::find_squared_element_error(), variable_type(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().
00943 { 00944 // Make sure the variable exists 00945 std::map<std::string, unsigned short int>::const_iterator 00946 pos = _variable_numbers.find(var); 00947 00948 if (pos == _variable_numbers.end()) 00949 { 00950 std::cerr << "ERROR: variable " 00951 << var 00952 << " does not exist in this system!" 00953 << std::endl; 00954 libmesh_error(); 00955 } 00956 libmesh_assert (_variables[pos->second].name() == var); 00957 00958 return pos->second; 00959 }
| const FEType & System::variable_type | ( | const std::string & | var | ) | const [inline] |
- Returns:
- the finite element type for variable
var.
Definition at line 1428 of file system.h.
References _variables, and variable_number().
01429 { 01430 return _variables[this->variable_number(var)].type(); 01431 }
| const FEType & System::variable_type | ( | const unsigned int | i | ) | const [inline] |
- Returns:
- the finite element type variable number
i.
Definition at line 1418 of file system.h.
References _variables.
Referenced by add_variable(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), GMVIO::copy_nodal_solution(), FEMContext::FEMContext(), write_header(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().
01419 { 01420 libmesh_assert (i < _variables.size()); 01421 01422 return _variables[i].type(); 01423 }
| const std::string & System::vector_name | ( | const unsigned int | vec_num | ) |
- Returns:
- the name of this system's additional vector number
vec_num(where the vectors are counted starting with 0).
Definition at line 698 of file system.C.
References vectors_begin(), and vectors_end().
00699 { 00700 const_vectors_iterator v = vectors_begin(); 00701 const_vectors_iterator v_end = vectors_end(); 00702 unsigned int num = 0; 00703 while((num<vec_num) && (v!=v_end)) 00704 { 00705 num++; 00706 ++v; 00707 } 00708 libmesh_assert(v!=v_end); 00709 return v->first; 00710 }
| System::const_vectors_iterator System::vectors_begin | ( | ) | const [inline] |
| System::vectors_iterator System::vectors_begin | ( | ) | [inline] |
Beginning of vectors container
Definition at line 1458 of file system.h.
References _vectors.
Referenced by get_vector(), request_vector(), VTKIO::system_vectors_to_vtk(), and vector_name().
01459 { 01460 return _vectors.begin(); 01461 }
| System::const_vectors_iterator System::vectors_end | ( | ) | const [inline] |
| System::vectors_iterator System::vectors_end | ( | ) | [inline] |
End of vectors container
Definition at line 1470 of file system.h.
References _vectors.
Referenced by get_vector(), request_vector(), VTKIO::system_vectors_to_vtk(), and vector_name().
01471 { 01472 return _vectors.end(); 01473 }
| virtual std::pair<unsigned int, Real> 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 ImplicitSystem.
Definition at line 223 of file system.h.
| virtual std::pair<unsigned int, Real> 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 ImplicitSystem.
Definition at line 190 of file system.h.
| void 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)
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 815 of file system_io.C.
References _vectors, Xdr::data(), FEType::family, get_mesh(), FEType::inf_map, n_vars(), n_vectors(), name(), FEType::order, MeshBase::processor_id(), FEType::radial_family, FEType::radial_order, type, variable_name(), variable_type(), and Xdr::writing().
00818 { 00850 libmesh_assert (io.writing()); 00851 00852 00853 // Only write the header information 00854 // if we are processor 0. 00855 if (this->get_mesh().processor_id() != 0) 00856 return; 00857 00858 std::string comment; 00859 char buf[80]; 00860 00861 // 5.) 00862 // Write the number of variables in the system 00863 00864 { 00865 // set up the comment 00866 comment = "# No. of Variables in System \""; 00867 comment += this->name(); 00868 comment += "\""; 00869 00870 unsigned int n_vars = this->n_vars(); 00871 io.data (n_vars, comment.c_str()); 00872 } 00873 00874 00875 for (unsigned int var=0; var<this->n_vars(); var++) 00876 { 00877 // 6.) 00878 // Write the name of the var-th variable 00879 { 00880 // set up the comment 00881 comment = "# Name, Variable No. "; 00882 std::sprintf(buf, "%d", var); 00883 comment += buf; 00884 comment += ", System \""; 00885 comment += this->name(); 00886 comment += "\""; 00887 00888 std::string var_name = this->variable_name(var); 00889 io.data (var_name, comment.c_str()); 00890 } 00891 00892 // 7.) 00893 // Write the approximation order of the var-th variable 00894 // in this system 00895 { 00896 // set up the comment 00897 comment = "# Approximation Order, Variable \""; 00898 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 00899 comment += buf; 00900 comment += "\", System \""; 00901 comment += this->name(); 00902 comment += "\""; 00903 00904 int order = static_cast<int>(this->variable_type(var).order); 00905 io.data (order, comment.c_str()); 00906 } 00907 00908 00909 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00910 00911 // do the same for radial_order 00912 { 00913 comment = "# Radial Approximation Order, Variable \""; 00914 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 00915 comment += buf; 00916 comment += "\", System \""; 00917 comment += this->name(); 00918 comment += "\""; 00919 00920 int rad_order = static_cast<int>(this->variable_type(var).radial_order); 00921 io.data (rad_order, comment.c_str()); 00922 } 00923 00924 #endif 00925 00926 // Write the Finite Element type of the var-th variable 00927 // in this System 00928 { 00929 // set up the comment 00930 comment = "# FE Family, Variable \""; 00931 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 00932 comment += buf; 00933 comment += "\", System \""; 00934 comment += this->name(); 00935 comment += "\""; 00936 00937 const FEType& type = this->variable_type(var); 00938 int fam = static_cast<int>(type.family); 00939 io.data (fam, comment.c_str()); 00940 00941 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00942 00943 comment = "# Radial FE Family, Variable \""; 00944 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 00945 comment += buf; 00946 comment += "\", System \""; 00947 comment += this->name(); 00948 comment += "\""; 00949 00950 int radial_fam = static_cast<int>(type.radial_family); 00951 io.data (radial_fam, comment.c_str()); 00952 00953 comment = "# Infinite Mapping Type, Variable \""; 00954 std::sprintf(buf, "%s", this->variable_name(var).c_str()); 00955 comment += buf; 00956 comment += "\", System \""; 00957 comment += this->name(); 00958 comment += "\""; 00959 00960 int i_map = static_cast<int>(type.inf_map); 00961 io.data (i_map, comment.c_str()); 00962 #endif 00963 } 00964 } // end of the variable loop 00965 00966 // 8.) 00967 // Write the number of additional vectors in the System. 00968 // If write_additional_data==false, then write zero for 00969 // the number of additional vectors. 00970 { 00971 { 00972 // set up the comment 00973 comment = "# No. of Additional Vectors, System \""; 00974 comment += this->name(); 00975 comment += "\""; 00976 00977 unsigned int n_vectors = write_additional_data ? this->n_vectors () : 0; 00978 io.data (n_vectors, comment.c_str()); 00979 } 00980 00981 if (write_additional_data) 00982 { 00983 std::map<std::string, NumericVector<Number>* >::const_iterator 00984 vec_pos = this->_vectors.begin(); 00985 unsigned int cnt=0; 00986 00987 for (; vec_pos != this->_vectors.end(); ++vec_pos) 00988 { 00989 // 9.) 00990 // write the name of the cnt-th additional vector 00991 comment = "# Name of "; 00992 std::sprintf(buf, "%d", cnt++); 00993 comment += buf; 00994 comment += "th vector"; 00995 std::string vec_name = vec_pos->first; 00996 00997 io.data (vec_name, comment.c_str()); 00998 } 00999 } 01000 } 01001 }
| void 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.
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 1213 of file system_io.C.
References _vectors, Xdr::data(), get_mesh(), DofObject::invalid_id, n_vars(), name(), number(), solution, and Xdr::writing().
01215 { 01235 std::string comment; 01236 01237 libmesh_assert (io.writing()); 01238 01239 std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size()); 01240 01241 // build the ordered nodes and element maps. 01242 // when writing/reading parallel files we need to iterate 01243 // over our nodes/elements in order of increasing global id(). 01244 // however, this is not guaranteed to be ordering we obtain 01245 // by using the node_iterators/element_iterators directly. 01246 // so build a set, sorted by id(), that provides the ordering. 01247 // further, for memory economy build the set but then transfer 01248 // its contents to vectors, which will be sorted. 01249 std::vector<const DofObject*> ordered_nodes, ordered_elements; 01250 { 01251 std::set<const DofObject*, CompareDofObjectsByID> 01252 ordered_nodes_set (this->get_mesh().local_nodes_begin(), 01253 this->get_mesh().local_nodes_end()); 01254 01255 ordered_nodes.insert(ordered_nodes.end(), 01256 ordered_nodes_set.begin(), 01257 ordered_nodes_set.end()); 01258 } 01259 { 01260 std::set<const DofObject*, CompareDofObjectsByID> 01261 ordered_elements_set (this->get_mesh().local_elements_begin(), 01262 this->get_mesh().local_elements_end()); 01263 01264 ordered_elements.insert(ordered_elements.end(), 01265 ordered_elements_set.begin(), 01266 ordered_elements_set.end()); 01267 } 01268 01269 const unsigned int sys_num = this->number(); 01270 const unsigned int n_vars = this->n_vars(); 01271 01272 // Loop over each variable and each node, and write out the value. 01273 for (unsigned int var=0; var<n_vars; var++) 01274 { 01275 // First write the node DOF values 01276 for (std::vector<const DofObject*>::const_iterator 01277 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it) 01278 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01279 { 01280 //std::cout << "(*it)->id()=" << (*it)->id() << std::endl; 01281 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 01282 DofObject::invalid_id); 01283 01284 io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp))); 01285 } 01286 01287 // Then write the element DOF values 01288 for (std::vector<const DofObject*>::const_iterator 01289 it = ordered_elements.begin(); it != ordered_elements.end(); ++it) 01290 for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++) 01291 { 01292 libmesh_assert ((*it)->dof_number(sys_num, var, comp) != 01293 DofObject::invalid_id); 01294 01295 io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp))); 01296 } 01297 } 01298