LibMesh 数据结构类

转载 2016年08月30日 15:41:53

LibMesh 数据结构类

212人阅读 评论(0) 收藏 举报



 可见, SparseMatrix类的继承关系和linearsolver类很一致, SparseMatrix类的方法主要是矩阵操作,类似petsc里面的过程了。到稀疏矩阵,问题基本落到解线性方程组了。所以,支持各类稀疏矩阵solver中的矩阵操作方法。






  工厂模式生产 build



  2        switch (dim)

  3        {

  4                //0D

  5                case 0:

  6                {

  7                  switch (

  8                  {

  9                  case CLOUGH:

 10                        {

 11                          AutoPtr<FEBase> ap(new FE<0, CLOUGH>(fet));

 12                          return ap;

 13                        }

 14                  case HERMITE:

 15                        {

 16                          AutoPtr<FEBase> ap(new FE<0, HERMITE>(fet));

 17                          return ap;

 18                        }


 20                  case LAGRANGE:

 21                        {

 22                          AutoPtr<FEBase> ap(new FE<0, LAGRANGE>(fet));

 23                          return ap;

 24                        }


 26                  case L2_LAGRANGE:

 27                        {

 28                          AutoPtr<FEBase> ap(new FE<0, L2_LAGRANGE>(fet));

 29                          return ap;


 31                //      ...


 33                   default:

 34                        libmesh_error_msg("ERROR:Bad = " <<;

 35                  }

 36                }


 38                // 1D ...

 39                // 2D ...

 40                // 3D ...

 41        }

 42        AutoPtr<FEBase> ap(NULL);

 43        return ap;


    get_phi() 返回积分点处phi

    get_dphi(), get_dphidx(), get_d2phidx2(), get_d2phidxi2() 返回phi的一阶,二阶(global坐标,local坐标)在积分点上的偏导

    get_xyz(), 返回积分点处坐标

         get_JxW(), get_dxyzdeta(), get_d2xyzdeta2(), get_dxidx(), 返回jacobian,global对local坐标的一阶,二阶偏导

         get_type(), return element type that the current shape functions have been calculated for.


         get_fe_map(),  return the mapping object

        This class forms the foundation from which generic finite elements may be derived. All calls to static members of the FE classes should be requested through FEInterface, this interface class offers sort-of runtime polymorphism for the templates FE classes. Even internal library classes, such as DoFMap, request the number of DoF's through this interface class. This class is well " at the heart " of the library, so things here should better remain unchanged.

     QBase 模版类


        工厂生产build : 通过string_name生成各类具体的积分方法,运行时多态设计。

        type(), 返回具体积分方法

        get_elem_type(), 返回单元类型

        get_p_level(), 返回 p_level refinement


       get_points(),  返回一个vector,存master单元上的积分点位置


       qp(const unsigned int i) const, 返回参考单元(master element)上第i个积分点

        w(const unsigned int i) const,

        init(const ElemType, unsigned int p_level) 

 58 switch(_dim)

 59 {

 60        case 0:

 61                this->init_0D(_type, _p_level);

 62                return ;

 63        case 1:

 64                this->init_1D(_type, _p_level);

 65                return ;

 66        case 2:

 67                this->init_2D(_type, _p_level);

 68                return ;

 69        case 3:

 70                this->init_3D(_type, _p_level);

 71                return ;

 72         default:

 73                libmesh_error_msg("Invalid dimension _dim = " << _dim);

 74 }

       get_order(), 返回积分规则的阶数

       继承类如 QGauss, 重写QBase所有方法,QGauss::build()返回父类smart指针


       QBase class provides basic functionality from which various quadrature rules can be derived, the class contains "dim" dimensional points describing the quadrature locations ( referenced to a master object) and associated weights.




     This class handles the numbering of DoF on a mesh. For system of equations, the class supports  a fixed number of variables. DoF are numbered such that sequential, contiguous blocks belong to distinct processors, so that the resulting data structures will work well with parallel linear algebra packages.







     variable() , return variable 


      n_variables(), returns the number of variables in global solution vector. Defaults to 1, should be 1 for a scalar equation, 3 for 2D incompressible NS(u, v, p) ...

     has_blocked_representation(), returns true if variables are capable of being stored in a blocked form. 


     n_dofs(), return the total number of DoF in the problem

     n_local_dofs(), return number of DoF on current processor

     first_dof(), first_old_dof(), last_dof(), end_dof(), end_old_dof()

    dof_indices()  fills the vector "di" with global DoF indices for the element

  2libMesh::DofMap::dof_indices(const Elem*const elem, std::vector<dof_id_type>& di) const

  3 {

  4        libmesh_assert( !elem || elem->active());

  5        di.clear();


  7        const unsigned int n_vars = this->n_variables();


  9        std::vector<Node*> elem_nodes;

 10        if(elem)

 11        {

 12                elem_nodes.resize(elem->n_nodes(),NULL);

 13                for(unsignedint i=0; i<elem->n_nodes(); i++)

 14                        elem_nodes[i] = elem->get_node(i);

 15        }


 17         //get DoF numbers

 18        for(unsignedint v=0; v<n_vars; v++)

 19        {

 20                if(this->variable(v).type().family == SCALAR &&

 21                    (!elem ||this->variable(v).active_on_subdomain(elem->subdomain_id())))

 22                {

 23                        std::vector<dof_id_type> di_new;

 24                        this->SCALAR_dof_indices(di_new, v);

 25                        di_insert(di.end(), di_new.begin(), di_new.end());

 26                }

 27                else if(elem)

 28                        dof_indices(elem, di, v, elem_nodes);

 29        }

 30 }

  extract_local_vector()  ??, 类似petsc里面从 global 到 local映射,会将local vector的边界给填充上。




 create_dof_constraints(), ??? lots of constraints dealings ???


add_dirichlet_boundary(const DirichletBoundary& dirichlet_boundary),  adds a copy of the specified Dirichlet boundary to the system



 note: 处理稀疏性排列和约束条件的方法



 共有函数:包括DoF, 节点,边界,邻接,拓扑关系,refine-level的操作。

                  has_neighbor(const Elem* elem) const,  return true if the element "elem" is a neighbor of current element

                  on_boundary() , return true if this element has a side coincident with a boundary

                  length(const unsigned int n1, const unsigned int n2), return the magnitude of the distance between nodes "n1" and "n2"

  DofObject defines an abstract base class for objects that have DoF associated with them, including Elem and Node

  Elem is the base class from which all geometric entities(elements) are derived  


     共有变量:  AutoPtr<BoundaryInfo> 


 this class provides all the data necessary to describe a geometric entity. it allows for description of a "dim" dimensional object that lives in LIBMESH_DIM space.

A mesh is made of nodes and elements, and this class provides data structures to store and access both. A mesh may be partitioned into a number of subdomains, and this class provides that functionality. Furthermore, provides functions for reading and writing a mesh in various formats 

  MeshData 类:

          This class handles actual data and corresponding I/O on entities(nodes, elements) of meshes, MeshData can be used when dealing with files that contain nodal or element oriented data, numbered in the same format as a corresponding mesh file or with a LIBMESH element and node indices.

  DirichletBoundary 类:


          the class associates Dirichlet Boundary values with a given set of mesh boundary ids and system variable ids. 

         Dirichlet values must be supplied as the input function "f", or gradient values as "g"

         Dirichlet functions are allowed to return NaN, if this is encountered, DoF values in a patch around NaN will be unconstrained


          静态成员变量  boundary_d_type 


          添加/删除node, edge, side,

          boundary_ids(Node* ) return the boundary ids associated with Node

          n_boundary_id(Node*)  return the number of boundary ids associated with Node

          edge_boundary_ids(const Elem *const elem, const unsigned short int edge), return list of boundary ids associated with "edge" of "elem"

          has_boundary_id(), returns true iff the given side of the given element is associated with the given id

          get_boundary_ids(),  returns the user specified boundary ids

  The class contains contains information relevant to boundary conditions: it does not hold actual boundary condition data, but can mark element faces and nodes with ids useful for identifying the type of boundary condition. It can also build a mesh that just includes boundary elements/faces


 FunctionBase类:zero function

LibMesh 数据结构类

SparseMatrix模版类      可见, SparseMatrix类的继承关系和linearsolver类很一致, SparseMatrix类的方法主要是矩阵操作,类似petsc里面的过程...
  • lizhengjiang
  • lizhengjiang
  • 2015年02月25日 14:40
  • 559

libmesh 测试

libmesh是基于m p
  • lizhengjiang
  • lizhengjiang
  • 2014年09月16日 04:56
  • 2048

一个算例 介绍 libmesh 的类

  • lizhengjiang
  • lizhengjiang
  • 2014年09月19日 12:40
  • 827

Building libmesh with Petsc support

Building libmesh with Petsc support (2013-04-15 08:39:22) 转载▼ 标签: cuda petsc ubuntu ...
  • zyex1108
  • zyex1108
  • 2016年08月30日 15:37
  • 342

osgearth mac/linux 下 cmake 编译安装

前一篇学习了cmake 使用。今天来安装osgearth。          参见官方文档,需要先安装几个lib:  gdal, curl, geos。  分别下载独立安装,没什么问题。      ...
  • lizhengjiang
  • lizhengjiang
  • 2015年04月11日 02:24
  • 939


数据有逻辑结构和存储结构,逻辑结构又有四种:list,tree,set,graph。存储结构有顺序印象和非顺序印象,因此有顺序存储结构和链式存储结构。java JDK为常用的数据结构定义了一些Inte...
  • qq_37804737
  • qq_37804737
  • 2017年09月25日 22:40
  • 182


不相交集类是解决等价关系问题的一种非常有效的手段!等价关系是一种关系R,他满足自反性,对称性与传递性。有人说散列是最艺术的数据结构,优先队列是最优雅的数据结构 而不相交集类就是最简洁的数据结构!这些说...
  • u013708970
  • u013708970
  • 2014年03月30日 20:20
  • 1624


runtime class object
  • u011342466
  • u011342466
  • 2016年03月07日 20:06
  • 801


List接口 List是有序的Collection,使用此接口能够精确的控制每个元素插入的位置。用户能够使用索引(元素在 List中的位置,类似于数组下标)来访问List中的元素,这类似于...
  • DengDeng_G
  • DengDeng_G
  • 2018年01月10日 11:33
  • 102


//=====================Stack.h================= #include using namespace std; template class Stac...
  • hushiwei1993
  • hushiwei1993
  • 2015年07月17日 11:36
  • 541
您举报文章:LibMesh 数据结构类