📄 system.h
字号:
/** * User-provided assembly function. Can be overloaded * in derived classes. */ virtual void user_assembly (); /** * User provided constraint function. */ virtual void user_constrain (); /** * Re-update the local values when the mesh has changed. * This method takes the data updated by \p update() and * makes it up-to-date on the current mesh. */ virtual void re_update (); /** * Restrict vectors after the mesh has coarsened */ virtual void restrict_vectors (); /** * Prolong vectors after the mesh has refined */ virtual void prolong_vectors (); /** * Flag which tells the system to whether or not to * call the user assembly function during each call to solve(). * By default, every call to solve() begins with a call to the * user assemble, so this flag is true. (For explicit systems, * "solving" the system occurs during the assembly step, so this * flag is always true for explicit systems.) * * You will only want to set this to false if you need direct * control over when the system is assembled, and are willing to * track the state of its assembly yourself. An example of such a * case is an implicit system with multiple right hand sides. In * this instance, a single assembly would likely be followed with * multiple calls to solve. * * The frequency system and Newmark system have their own versions * of this flag, called _finished_assemble, which might be able to * be replaced with this more general concept. */ bool assemble_before_solve; //-------------------------------------------------- // The solution and solution access members /** * @returns the current solution for the specified global * DOF. */ Number current_solution (const unsigned int global_dof_number) const; /** * Data structure to hold solution values. */ AutoPtr<NumericVector<Number> > solution; /** * All the values I need to compute my contribution * to the simulation at hand. Think of this as the * current solution with any ghost values needed from * other processors. This vector is necessarily larger * than the \p solution vector in the case of a parallel * simulation. The \p update() member is used to synchronize * the contents of the \p solution and \p current_local_solution * vectors. */ AutoPtr<NumericVector<Number> > current_local_solution;protected: /** * 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. */ virtual void init_data (); /** * Projects the vector defined on the old mesh onto the * new mesh. */ void project_vector (NumericVector<Number>&) const; /** * 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. */ void project_vector (const NumericVector<Number>&, NumericVector<Number>&) const; private: /** * Reads an input vector from the stream \p io and assigns * the values to a set of \p DofObjects. This method uses * blocked input and is safe to call on a distributed memory-mesh. */ 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; /** * Reads a vector for this System. * This method may safely be called on a distributed-memory mesh. */ void read_serialized_vector (Xdr& io, NumericVector<Number> &vec); /** * Writes an output vector to the stream \p io for a set of \p DofObjects. * This method uses blocked output and is safe to call on a distributed memory-mesh. */ 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; /** * Writes a vector for this System. * This method may safely be called on a distributed-memory mesh. */ void write_serialized_vector (Xdr& io, const NumericVector<Number> &vec) const; /** * Function that initializes the system. */ void (* _init_system) (EquationSystems& es, const std::string& name); /** * Function that assembles the system. */ void (* _assemble_system) (EquationSystems& es, const std::string& name); /** * Function to impose constraints. */ void (* _constrain_system) (EquationSystems& es, const std::string& name ); /** * Data structure describing the relationship between * nodes, variables, etc... and degrees of freedom. */ AutoPtr<DofMap> _dof_map; /** * Constant reference to the \p EquationSystems object * used for the simulation. */ EquationSystems& _equation_systems; /** * Constant reference to the \p mesh data structure used * for the simulation. */ MeshBase& _mesh; /** * A name associated with this system. */ const std::string _sys_name; /** * The number associated with this system */ const unsigned int _sys_number; /** * The names of the variables associated with this * system. */ std::vector<std::string> _var_names; /** * The finite element type for the variables associated * with this system. */ std::map<std::string, FEType> _var_type; /** * The variable numbers corresponding to user-specified * names. */ std::map<std::string, unsigned short int> _var_num; /** * Flag stating if the system is active or not. */ bool _active; /** * Some systems need an arbitrary number of vectors. * This map allows names to be associated with arbitrary * vectors. All the vectors in this map will be distributed * in the same way as the solution vector. */ std::map<std::string, NumericVector<Number>* > _vectors; /** * Holds true if a vector by that name should be projected * onto a changed grid, false if it should be zeroed. */ std::map<std::string, bool> _vector_projections; /** * Holds true if the solution vector should be projected * onto a changed grid, false if it should be zeroed. * This is true by default. */ bool _solution_projection; /** * \p true when additional vectors may still be added, \p false otherwise. */ bool _can_add_vectors; /** * This flag is used only when *reading* in a system from file. * Based on the system header, it keeps track of whether or not * additional vectors were actually written for this file. */ bool _additional_data_written; /** * This class implements projecting a vector from * an old mesh to the newly refined mesh. This * may be exectued in parallel on multiple threads. */ class ProjectVector { private: const System &system; const NumericVector<Number> &old_vector; NumericVector<Number> &new_vector; public: ProjectVector (const System &system_in, const NumericVector<Number> &old_v_in, NumericVector<Number> &new_v_in) : system(system_in), old_vector(old_v_in), new_vector(new_v_in) {} void operator()(const ConstElemRange &range) const; }; /** * This class implements projecting a vector from * an old mesh to the newly refined mesh. This * may be exectued in parallel on multiple threads. */ class ProjectSolution { private: const System &system; Number (* fptr)(const Point& p, const Parameters& parameters, const std::string& sys_name, const std::string& unknown_name); Gradient (* gptr)(const Point& p, const Parameters& parameters, const std::string& sys_name, const std::string& unknown_name); Parameters ¶meters; NumericVector<Number> &new_vector; public: ProjectSolution (const System &system_in, Number fptr_in(const Point& p, const Parameters& parameters, const std::string& sys_name, const std::string& unknown_name), Gradient gptr_in(const Point& p, const Parameters& parameters, const std::string& sys_name, const std::string& unknown_name), Parameters ¶meters_in, NumericVector<Number> &new_v_in) : system(system_in), fptr(fptr_in), gptr(gptr_in), parameters(parameters_in), new_vector(new_v_in) {} void operator()(const ConstElemRange &range) const; };};// ------------------------------------------------------------// System inline methodsinlineconst std::string & System::name() const{ return _sys_name;}inlineunsigned int System::number() const{ return _sys_number;}inlineconst MeshBase & System::get_mesh() const{ return _mesh;}inlineMeshBase & System::get_mesh(){ return _mesh;}inlineconst DofMap & System::get_dof_map() const{ return *_dof_map;}inlineDofMap & System::get_dof_map(){ return *_dof_map;}inlinebool System::active() const{ return _active; }inlinevoid System::activate (){ _active = true;}inlinevoid System::deactivate (){ _active = false;}inlineunsigned int System::n_vars() const{ return _var_names.size();}inlineconst std::string & System::variable_name (const unsigned int i) const{ libmesh_assert (i < n_vars()); return _var_names[i];}inlineconst FEType & System::variable_type (const unsigned int i) const{ return variable_type(_var_names[i]);}inlineconst FEType & System::variable_type (const std::string& var) const{ std::map<std::string, FEType>::const_iterator pos = _var_type.find(var); libmesh_assert (pos != _var_type.end()); return pos->second;}inlineunsigned int System::n_active_dofs() const{ return this->n_dofs() - this->n_constrained_dofs();}inlinebool System::have_vector (const std::string& vec_name) const{ return (_vectors.count(vec_name));}inlineunsigned int System::n_vectors () const{ return _vectors.size(); }inlineSystem::vectors_iterator System::vectors_begin (){ return _vectors.begin();}inlineSystem::const_vectors_iterator System::vectors_begin () const{ return _vectors.begin();}inlineSystem::vectors_iterator System::vectors_end (){ return _vectors.end();}inlineSystem::const_vectors_iterator System::vectors_end () const{ return _vectors.end();}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -