fluidity详解

1.fluidity编译过程

1.1.femtools库调用方法

  1. 编译fluidity/femtools目录下所有文件,打包为libfemtools.a静态库文件;
  2. 通过-lfemtools参数,并指定libfemtools.a静态库位置,即可调用 femtools 库内所有函数

2.fluidity主函数位置

fluidity可执行文件有4个,分别为:

  1. fluidity
  2. Burgers_Equation
  3. Hybridized_Helmholtz_Solver
  4. Shallow_Water

其中,Burgers_Equation、Hybridized_Helmholtz_Solver、Shallow_Water主程序源文件都在文件夹./main内,分别为./main/Burgers_Equation.F90./main/Hybridized_Helmholtz_Solver.F90./main/Shallow_Water.F90

fluidity可执行文件源程序为最外层文件./main.cpp,main()函数则通过调用mainfl()函数来进行计算:

 // Start fortran mainif(fl_command_line_options.count("simulation_name")){mainfl();    }else{usage(argv[0]);exit(-1);}

mainfl()源程序位置为./main/mainfl.F90,主要调用fluids()函数:

     !######################################################!      Normal Fluidity Model!######################################################call tic(TICTOC_ID_SIMULATION)ewrite(1, *) "Calling fluids from mainfl"call fluids()ewrite(1, *) "Exited fluids"call toc(TICTOC_ID_SIMULATION)call tictoc_report(2, TICTOC_ID_SIMULATION)

fluids()函数源程序位置为./main/Fluids.F90

编译fluidity可执行文件函数调用顺序为main.cpp =>./main/mainfl.F90 =>./main/Fluids.F90

3.fluidity数据结构

fluidity数据结构层次:

下层数据(quadrature_type、element_type、mesh_type)构成上层数据(element_type、mesh_type、scalar_field、vector_field、tensor_field)类型基本元素,最上层为fluidity使用的标量、矢量、矩阵等数据类型。
下面逐个介绍基本数据类型:

3.1.quadrature_type

  type quadrature_type!!< A data type which describes quadrature information. For most!!< developers, quadrature can be treated as an opaque data type which!!< will only be encountered when creating element_type variables to!!< represent shape functions.  integer :: dim !! Dimension of the elements for which quadrature!!< is required.  integer :: degree !! Degree of accuracy of quadrature. integer :: vertices !! Number of vertices of the element.integer :: ngi !! Number of quadrature points.real, pointer :: weight(:)=>null() !! Quadrature weights.real, pointer :: l(:,:)=>null() !! Locations of quadrature points.character(len=0) :: name !! Fake name for reference counting.!! Reference count to prevent memory leaks.type(refcount_type), pointer :: refcount=>null()integer :: familyend type quadrature_type

quadrature_type包含了基本单元信息,包括

  1. dim 维度
  2. degree 多项式阶数
  3. vertices 节点个数
  4. ngi 正交节点个数
  5. weight(:) 权重
  6. l(:,:) 正交节点位置
  7. name
  8. refcount
  9. family

这些信息都是构成基本单元层面的。

    !!< Given information about a quadrature, return a quad type encoding!!< that quadrature.function make_quadrature(vertices, dim, degree, ngi, family, stat) result (quad)integer :: lfamilyinteger :: wandzura_rule_idx, wandzura_rule_degree, max_wandzura_rule, wandzura_orderreal, dimension(2, 3) :: wandzura_ref_trireal, dimension(3, 3) :: wandzura_ref_mapreal, dimension(:, :), allocatable :: tmp_coordinatesinteger :: giinteger :: gm_rule, gm_order, vertexreal, dimension(:, :), allocatable :: gm_ref_simplexreal, dimension(:, :), allocatable :: gm_ref_mapif (present(family)) thenlfamily = familyelselfamily = FAMILY_COOLSend iffamily_if: if (lfamily == FAMILY_COOLS) then

下面根据lfamily取值对quad进行赋值,lfamily三个值分别为

  1. FAMILY_COOLS = 0
  2. FAMILY_WANDZURA = 1
  3. FAMILY_GM = 2
family_if: else if (lfamily == FAMILY_WANDZURA) then! Make sure we're on triangles.if (dim /= 2 .or. vertices /= 3) thenwrite (quadrature_error_message, '(a,i0,a)') ...end if! OK. First let's figure out which rule we want to use.if (.not. present(degree)) thenwrite (quadrature_error_message, '(a,i0,a)') ...end ifcall wandzura_rule_num(max_wandzura_rule)do wandzura_rule_idx=1,max_wandzura_rulecall wandzura_degree(wandzura_rule_idx, wandzura_rule_degree)  !! degree=idx*5if (wandzura_rule_degree >= degree) exit !! 当Wandzura精度超过指定精度后跳出循环end doif (wandzura_rule_degree < degree) then !! 循环结束后Wandzura最大精度为30,指定精度不能超过30write error message ..end ifcall wandzura_order_num(wandzura_rule_idx, wandzura_order)!! 获得 wandzura_order(三角形单元中节点总个数) = ngicall allocate(quad, vertices, wandzura_order, coords=3)allocate(tmp_coordinates(2, wandzura_order))quad%degree = wandzura_rule_degreequad%dim = 2call wandzura_rule(wandzura_rule_idx, wandzura_order, tmp_coordinates, quad%weight)!! 获得 wandzura 节点坐标 tmp_coordinates;积分权重 quad%weightwandzura_ref_tri(:, 1) = (/0, 0/)wandzura_ref_tri(:, 2) = (/1, 0/)wandzura_ref_tri(:, 3) = (/0, 1/)call local_coords_matrix_positions(wandzura_ref_tri, wandzura_ref_map)do gi=1,wandzura_orderquad%l(gi, 1:2) = tmp_coordinates(:, gi); quad%l(gi, 3) = 1.0quad%l(gi, :) = matmul(wandzura_ref_map, quad%l(gi, :))end do

在这之中有个重要的子函数调用,call allocate(quad, vertices, wandzura_order, coords=3),目的就是为结构体quad申请内存空间。下面检查下子函数allocate的内容,

    interface allocatemodule procedure allocate_quadend interface......subroutine allocate_quad(quad, vertices, ngi, coords, stat)allocate(quad%weight(ngi), quad%l(ngi,coords), stat=lstat)quad%vertices=verticesquad%ngi=nginullify(quad%refcount)call addref(quad)end subroutine allocate_quad

剩下最后一种定义quad方式:FAMILY_GM

    family_if:elseif (lfamily == FAMILY_GM) then......family_if:else......family_if:end if......quad%family = lfamilyend function make_quadrature`

3.2.element_type

  type element_type!!< Type to encode shape and quadrature information for an element.integer :: dim !! 2d or 3d?integer :: loc !! Number of nodes.integer :: ngi !! Number of gauss points.integer :: degree !! Polynomial degree of element.!! Shape functions: n is for the primitive function, dn is for partial derivatives, dn_s is for partial derivatives on surfaces. !! n is loc x ngi, dn is loc x ngi x dim!! dn_s is loc x ngi x face x dim real, pointer :: n(:,:)=>null(), dn(:,:,:)=>null()real, pointer :: n_s(:,:,:)=>null(), dn_s(:,:,:,:)=>null()!! Polynomials defining shape functions and their derivatives.type(polynomial), dimension(:,:), pointer :: spoly=>null(), dspoly=>null()!! Link back to the node numbering used for this element.type(ele_numbering_type), pointer :: numbering=>null()!! Link back to the quadrature used for this element.type(quadrature_type) :: quadraturetype(quadrature_type), pointer :: surface_quadrature=>null()!! Pointer to the superconvergence data for this element.type(superconvergence_type), pointer :: superconvergence=>null()!! Pointer to constraints data for this elementtype(constraints_type), pointer :: constraints=>null()!! Reference count to prevent memory leaks.type(refcount_type), pointer :: refcount=>null()!! Dummy name to satisfy reference countingcharacter(len=0) :: nameend type element_type

相较而言element_type就复杂了一点,

自定义类型:ele_numbering_type,与 polynomial

  type ele_numbering_type! Type to record element numbering details.! Differentiate tets from other elements.integer :: faces, vertices, edges, boundariesinteger :: degree ! Degree of polynomials.integer :: dimension ! 2D or 3Dinteger :: nodesinteger :: type=ELEMENT_LAGRANGIANinteger :: family! Map local count coordinates to local number.integer, dimension(:,:,:), pointer :: count2number! Map local number to local count coordinates.integer, dimension(:,:), pointer :: number2count! Count coordinate which is held constant for each element boundary.integer, dimension(:), pointer :: boundary_coord! Value of that count coordinate on the element boundary.integer, dimension(:), pointer :: boundary_valend type ele_numbering_type
    type polynomialreal, dimension(:), pointer :: coefs=>null()integer :: degree=-1end type polynomial

3.3.mesh_type

  type mesh_type!!< Mesh information for (among other things) fields.integer, dimension(:), pointer :: ndglno!! Flag for whether ndglno is allocatedlogical :: wrapped=.true.type(element_type) :: shapeinteger :: elementsinteger :: nodescharacter(len=FIELD_NAME_LEN) :: name!! path to options in the options tree
#ifdef DDEBUGcharacter(len=OPTION_PATH_LEN) :: option_path="/uninitialised_path/"
#elsecharacter(len=OPTION_PATH_LEN) :: option_path
#endif!! Degree of continuity of the field. 0 is for the conventional C0!! discretisation. -1 for DG.integer :: continuity=0!! Reference count for meshtype(refcount_type), pointer :: refcount=>null()!! Mesh face information for those meshes (eg discontinuous) which need it.type(mesh_faces), pointer :: faces=>null()!! Information on subdomain_ mesh, for partially prognostic solves:type(mesh_subdomain_mesh), pointer :: subdomain_mesh=>null()type(adjacency_cache), pointer :: adj_lists => null()!! array that for each node tells which column it is in!! (column numbers usually correspond to a node number in a surface mesh)integer, dimension(:), pointer :: columns => null()!! if this mesh is extruded this array says which horizontal mesh element each element is belowinteger, dimension(:), pointer :: element_columns => null()!! A list of ids marking different parts of the mesh!! so that initial conditions can be associated with it.integer, dimension(:), pointer :: region_ids=>null()!! Halo information for parallel simulations.type(halo_type), dimension(:), pointer :: halos=>null()type(halo_type), dimension(:), pointer :: element_halos=>null()type(integer_set_vector), dimension(:), pointer :: colourings=>null()!! A logical indicating if this mesh is periodic or not!! (does not tell you how periodic it is... i.e. true if!! any surface is periodic)logical :: periodic=.false.end type mesh_type

3.4.一维例子

test_1d.F90

    function read_triangle_simple(filename, quad_degree, quad_ngi, no_faces, quad_family, mdim) result (field)

转载于:https://www.cnblogs.com/li12242/p/4177175.html

fluidity详解相关推荐

  1. 从命令行到IDE,版本管理工具Git详解(远程仓库创建+命令行讲解+IDEA集成使用)

    首先,Git已经并不只是GitHub,而是所有基于Git的平台,只要在你的电脑上面下载了Git,你就可以通过Git去管理"基于Git的平台"上的代码,常用的平台有GitHub.Gi ...

  2. JVM年轻代,老年代,永久代详解​​​​​​​

    秉承不重复造轮子的原则,查看印象笔记分享连接↓↓↓↓ 传送门:JVM年轻代,老年代,永久代详解 速读摘要 最近被问到了这个问题,解释的不是很清晰,有一些概念略微模糊,在此进行整理和记录,分享给大家.在 ...

  3. docker常用命令详解

    docker常用命令详解 本文只记录docker命令在大部分情境下的使用,如果想了解每一个选项的细节,请参考官方文档,这里只作为自己以后的备忘记录下来. 根据自己的理解,总的来说分为以下几种: Doc ...

  4. 通俗易懂word2vec详解词嵌入-深度学习

    https://blog.csdn.net/just_so_so_fnc/article/details/103304995 skip-gram 原理没看完 https://blog.csdn.net ...

  5. 深度学习优化函数详解(5)-- Nesterov accelerated gradient (NAG) 优化算法

    深度学习优化函数详解系列目录 深度学习优化函数详解(0)– 线性回归问题 深度学习优化函数详解(1)– Gradient Descent 梯度下降法 深度学习优化函数详解(2)– SGD 随机梯度下降 ...

  6. CUDA之nvidia-smi命令详解---gpu

    nvidia-smi是用来查看GPU使用情况的.我常用这个命令判断哪几块GPU空闲,但是最近的GPU使用状态让我很困惑,于是把nvidia-smi命令显示的GPU使用表中各个内容的具体含义解释一下. ...

  7. Bert代码详解(一)重点详细

    这是bert的pytorch版本(与tensorflow一样的,这个更简单些,这个看懂了,tf也能看懂),地址:https://github.com/huggingface/pytorch-pretr ...

  8. CRF(条件随机场)与Viterbi(维特比)算法原理详解

    摘自:https://mp.weixin.qq.com/s/GXbFxlExDtjtQe-OPwfokA https://www.cnblogs.com/zhibei/p/9391014.html C ...

  9. pytorch nn.LSTM()参数详解

    输入数据格式: input(seq_len, batch, input_size) h0(num_layers * num_directions, batch, hidden_size) c0(num ...

最新文章

  1. 安装和使用花生壳(linux)
  2. python的工资为什么这么低-你拿着3k的工资,不明白为什么别人年薪 200万
  3. 一不小心,它成为了 GitHub Alibaba Group 下 Star 最多的开源项目
  4. JSDoc --JS API文档生成器
  5. K-序列求和 (逆元)
  6. 学习机软件测试,IBM P630 POWER4 AIX小型机适合软件测试及学习机
  7. c语言 动态链表,C语言的链表(篇章之二:动态链表)
  8. 男人有钱还是没钱,只需要关注他这三点,就明白了
  9. 自旋锁spin : spin_lock_irq , spin_lock_irqsave
  10. 除了 996 ICU,GitHub 上还有哪些奇葩的项目?
  11. HashMap深度解析
  12. 树莓派 红灯不亮_关闭树莓派的电源指示灯和状态指示灯
  13. java客户端实验_java实验(客户端) 2015106宋世超
  14. Oracle数据库常用Sql语句大全
  15. 速率法和终点法的区别_两点法终点法速率法.doc
  16. 流量宝流量真实有效吗?实测刷流量百度和CNZZ哪个更精准
  17. 傲腾服务器硬盘,Intel傲腾Optane硬盘实测:“高价U盘”,加速性能不错
  18. 简单CRM系统开发(一)
  19. mysql len函数的用法_SQL LEN() 函数
  20. 可视化——Excel2进阶

热门文章

  1. HierarchicalBeanFactory接口
  2. 【算法】 - 滑动窗口
  3. webpack --- 在项目中使用React
  4. Redis 初次尝试
  5. 成长的路上,痛并快乐着
  6. JDK自带的log-java.util.logging
  7. 新书品读《三级网络技术预测试卷与考点解析》,欢迎拍砖、跟砖提建议。
  8. 在多线程中使用UDP
  9. /dev/mtdN和/dev/mtdblockN的区别
  10. pthread_join/pthread_exit用法实例