LibMesh::LinearImplicitSystem 类接口


    #include<linear_implicit_system.h>

     继承关系:

   共有类型:

    sys_type   --->  LinearImplicitSystem

    Parent      --->  ImplicitSystem

    矩阵/向量  (常量)迭代器


   共有成员函数:

    构造函数, 参数(EquationSystems&, const std::string&, const unsigned int)

    析构函数

    system(), 返回系统this 指针

    虚函数clear(), init_data(), reinit(), 都重写自ImplicitSystem

    assemble()虚函数,为矩阵组集准备matrix, dof_map,实际并没有开始组集。需要子类具体实现

   { ImplicitSystem::assemble(); }

   solve()虚函数: 实际组集矩阵并求解线性方程组  Ax=b

  3 const EquationSystem& es = this->get_equation_system(); 

  4 

  5 linear_solver->init();

  6 

  7 const Real tol = es.parameters.get<Real> ("linear solver tolerance");

  8 

  9 const unsigned int maxits = es.parameters.get<unsigned int>("linear solver m    aximum iterations");

 10 

 11 rval = linear_solver->solve(*matrix, this->request_matrix("Preconditioner"),     *solution, *rhs, tol, maxits);

 12 

 13 //store # of linear iterations and final residual

 14 _n_linear_iterations = rval.first;

 15 _final_linear_residual = rval.second;

 16 

 17 this->update();


 get_linear_solver(), 返回线性求解器指针

 assembly(), 组集rhs, jacobian的残茶项???????

 22 //residual R(u(p), p) := A(p) * u(p) - b(p)

 23 // /part(R)/part(u) = A

  system_type() , 返回系统类型(newmark, frequency, reconstruction等)

  n_linear_iterations(), 返回当前(最近)求解器迭代步数

  final_linear_residual(),

  get_linear_solve_parameters(), 返回最大迭代步数和tolerance

  assemble_residual_derivatives() ?????

  adjoint_solve() ?????

 sensitivity_solve() ????

  add_matrix()  在方程系统中添加额外的矩阵,必须在assemble之前完成。而且用户必须自己初始化这些矩阵。all additional matrices have the same sparsity pattern as the matrix used during solution ?????

 26 SparseMatrix<Number>* buf = SparseMatrix<Number>::build(this->comm()).release();

 27 _matrices.insert(std::make_pair(mat_name, buf));

 28 return *buf;

    request_matrix(), return the additional matrix above

    get_matrix(),  返回附加矩阵的(常量)引用,none of these matrices is involved in the solution process ???? 而且仅当这类矩阵已经初始化才能访问

    n_matrix(), 返回系统中矩阵数目

    libMesh::System::update(),  update local values to reflect the solution on neighboring processors.

    project_solution() ,  project an arbitrary function onto the solution/vector/boundary_solution via L2 projections and nodal interpolations on each element

    project_vector()

    boundary_project_solution()

    update_global_solution(), fill the inure vector "global_soln" so that it contains the global solution on all processors, requires communication with all other processors

 30 {

 31         global_soln.resize(solution->size());

 32         solution->localize(global_soln);

 33 }

    get_mesh(),  return a (const) reference to this system's _mesh

    get_dof_map()

    get_equation_systems()

    add_vector(),  adds additional vector to current system, all additional vector are similarly distributed like solution and initialized to zero.   

    By default, vectors added through "add_vector" are projected to changed grids by "reinit()"    

 25 {

 26 SparseMatrix<Number>* buf = SparseMatrix<Number>::build(this->comm()).release();

 27 _matrices.insert(std::make_pair(mat_name, buf));

 28 return *buf;

 29 

 30 {

 31         global_soln.resize(solution->size());

 32         solution->localize(global_soln);

 33 }

 34 

 35 if(this->have_vector(vec_name))

 36         return *(_vectors[vec_name]);

 37 

 38 NumericVector<Number>* buf = NumericVector<Number>::build(this->comm()).release();

 39 _vectors.insert(std::make_pair(vec_name, buf));

 40 _vector_projections.insert(std::make_pair(vec_name, projections));

 41 _vector_types.insert(std::make_pair(vec_name, type));

 42 

 43 buf->init(this->n_dofs(), this->n_local_dofs(), false, type); //to zero them pass "false" 

 44 

 45 return *buf;

 46 }

       get_vector(),

       n_vectors(),

       n_vars(), return the number of current system

       n_components(), return total number of scalar components in system's variables

       n_dofs(), return the number of DoF in current system

       n_active_dofs(), n_constrained_dofs(),

      n_local_dofs(),  return the number of DoF local to this processor

 48 {return _dof_map->n_dofs_on_processor(this->processor_id());}

      add_variable(), adds the variables "var" to the list of variables for current system, and return the index number of new variable

      variable(), return constant reference to "Variable" var

      get_all_variable_numbers(),  fills "all_variable_numbers" with all the variable numbers   

      variable_scalar_number(),  returns an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (vector_valued) variable in the system in order

     variable_type(), return finite element type variable number i

     calculate_norm(), return a norm of variable "var" in the vector v, in specified norm (L2, L_INF, H1)

     read_serialized_data, 

    read_serialized_vectors,

    write_serialized_data,

    write_parallel_data,

    attach_init_function, register a user defined function to use in initializing the system, 传入udf指针

 52 {

 53         libmesh_assert(fptr);

 54         if(_init_system_object != NULL)

 55         {

 56                 libmesh_here();

 57                 libMesh::out<< " Warning: cannot specify both initialization function and  

    object" << std::endl;

 58                 _init_system_object = NULL;

 59         }

 60         _init_system_function = fptr;

 61 }

    attach_init_object(), register a user defined class to initialize the system

    attach_assemble_function(),  register a user function to use in assembling the system matrix and RHS

   attach_constraint_function(), 

   current_solution(), return the current solution for specified global DOF

  point_value(),  return the value of solution variable "var" at the physical point "p" in the mesh

  point_gradient(), 

  zero_variable(NumericVector<Number>& v, unsigned int var_num) const, zeros all DOFs in "v" that correspond to variable number "var_num"

 63 const MeshBase& mesh = this->get_mesh();

 64 //loop over node

 65 {

 66         MeshBase::const_node_iterator it = mesh.local_nodes_begin();

 67         const MeshBase::const_node_iterator end_it = mesh.local_nodes_end();

 68         for(; it != end; ++it)

 69         {

 70                 const Noe* node = *it;

 71                 unsigned int n_comp = node->n_comp(sys_num, var_num);

 72                 for(unsigned int i=0; i<n_comp; i++)

 73                 {

 74                         const dof_id_type index = node->dof_number(sys_num, var_num, i);

 75                         v.set(index, 0.0);

 76                 }

 77         }

 78 }

 79 //loop over elements

 80 {

 81         MeshBase::const_element_iterator it = mesh.active_local_elements_bgin();

 82         const MeshBase::const_element_iterator end_it = mesh_active_local_elements_end();

 83         for(; it != end_it; ++it)

 84         {

 85                 const Elem* elem = *it;

 86                 unsigned int n_comp = elem->n_comp(sys_num, var_num);

 87                 for(unsigned int i=0; i<n_comp; i++)

 88                 {

 89                         const dof_id_type index = elem->dof_number(sys_num, var_num, i);

 90                         v.set(index, 0.0);

 91                 }

 92         }

 93 }


静态公共成员函数:

get_info()

print_info() 


公共变量:

AutoPtr<LinearSolver<Number> >  linear_solver;

SparseMatrix*  matrix;

NumericVector* rhs;

AutoPtr<NumericVector<Number> > solution

AutoPtr<NumericVector<Number> > current_local_solution

Real   time


参考


NewmarkSystem子类

51  // ------------------------------------------------------------
52  // NewmarkSystem class definition
53 
55 {
56  public:
57 
63  const std::string& name,
64  const unsigned int number);
65 
69  ~NewmarkSystem ();
70 
71 
76 
// 重写LinearImplicitSystem部分函数
81  virtual void clear ();
82 
87  virtual void reinit ();
88 
93  virtual void assemble ();
94 
99  virtual std::string system_type () const { return "Newmark"; }
100 
101 
102  //---------------------------------------------------------
103  // These members are specific to the Newmark system
104  //
105 
109  void initial_conditions ();
110 
115  void compute_matrix ();
116 
120  void update_rhs ();
121 
125  void update_u_v_a ();
126 
132  void set_newmark_parameters ( const Real delta_T = _default_timestep,
133  const Real alpha = _default_alpha,
134  const Real delta = _default_delta);
135 





 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值