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 main
if(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数据结构层次:

![Field type heirarchy icon](/Users/mac/Documents/Blog/cnblogs/fluidity详解/Field type heirarchy.png =550x350)

下层数据(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 :: family
end 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 :: lfamily
integer :: wandzura_rule_idx, wandzura_rule_degree, max_wandzura_rule, wandzura_order
real, dimension(2, 3) :: wandzura_ref_tri
real, dimension(3, 3) :: wandzura_ref_map
real, dimension(:, :), allocatable :: tmp_coordinates
integer :: gi integer :: gm_rule, gm_order, vertex
real, dimension(:, :), allocatable :: gm_ref_simplex
real, dimension(:, :), allocatable :: gm_ref_map if (present(family)) then
lfamily = family
else
lfamily = FAMILY_COOLS
end if family_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) then
write (quadrature_error_message, '(a,i0,a)') ...
end if ! OK. First let's figure out which rule we want to use.
if (.not. present(degree)) then
write (quadrature_error_message, '(a,i0,a)') ...
end if call wandzura_rule_num(max_wandzura_rule)
do wandzura_rule_idx=1,max_wandzura_rule
call wandzura_degree(wandzura_rule_idx, wandzura_rule_degree)
!! degree=idx*5
if (wandzura_rule_degree >= degree) exit
!! 当Wandzura精度超过指定精度后跳出循环
end do if (wandzura_rule_degree < degree) then
!! 循环结束后Wandzura最大精度为30,指定精度不能超过30
write error message ..
end if call wandzura_order_num(wandzura_rule_idx, wandzura_order)
!! 获得 wandzura_order(三角形单元中节点总个数) = ngi
call allocate(quad, vertices, wandzura_order, coords=3)
allocate(tmp_coordinates(2, wandzura_order))
quad%degree = wandzura_rule_degree
quad%dim = 2 call wandzura_rule(wandzura_rule_idx, wandzura_order, tmp_coordinates, quad%weight)
!! 获得 wandzura 节点坐标 tmp_coordinates;积分权重 quad%weight wandzura_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_order
quad%l(gi, 1:2) = tmp_coordinates(:, gi); quad%l(gi, 3) = 1.0
quad%l(gi, :) = matmul(wandzura_ref_map, quad%l(gi, :))
end do

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

	interface allocate
module procedure allocate_quad
end interface
......
subroutine allocate_quad(quad, vertices, ngi, coords, stat)
allocate(quad%weight(ngi), quad%l(ngi,coords), stat=lstat)
quad%vertices=vertices
quad%ngi=ngi
nullify(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 = lfamily
end 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) :: quadrature
type(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 element
type(constraints_type), pointer :: constraints=>null()
!! Reference count to prevent memory leaks.
type(refcount_type), pointer :: refcount=>null()
!! Dummy name to satisfy reference counting
character(len=0) :: name
end 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, boundaries
integer :: degree ! Degree of polynomials.
integer :: dimension ! 2D or 3D
integer :: nodes
integer :: type=ELEMENT_LAGRANGIAN
integer :: 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_val
end type ele_numbering_type
	type polynomial
real, dimension(:), pointer :: coefs=>null()
integer :: degree=-1
end 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 allocated
logical :: wrapped=.true.
type(element_type) :: shape
integer :: elements
integer :: nodes
character(len=FIELD_NAME_LEN) :: name
!! path to options in the options tree
#ifdef DDEBUG
character(len=OPTION_PATH_LEN) :: option_path="/uninitialised_path/"
#else
character(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 mesh
type(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 below
integer, 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)

fluidity详解的更多相关文章

  1. Linq之旅:Linq入门详解(Linq to Objects)

    示例代码下载:Linq之旅:Linq入门详解(Linq to Objects) 本博文详细介绍 .NET 3.5 中引入的重要功能:Language Integrated Query(LINQ,语言集 ...

  2. 架构设计:远程调用服务架构设计及zookeeper技术详解(下篇)

    一.下篇开头的废话 终于开写下篇了,这也是我写远程调用框架的第三篇文章,前两篇都被博客园作为[编辑推荐]的文章,很兴奋哦,嘿嘿~~~~,本人是个很臭美的人,一定得要截图为证: 今天是2014年的第一天 ...

  3. EntityFramework Core 1.1 Add、Attach、Update、Remove方法如何高效使用详解

    前言 我比较喜欢安静,大概和我喜欢研究和琢磨技术原因相关吧,刚好到了元旦节,这几天可以好好学习下EF Core,同时在项目当中用到EF Core,借此机会给予比较深入的理解,这里我们只讲解和EF 6. ...

  4. Java 字符串格式化详解

    Java 字符串格式化详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 文中如有纰漏,欢迎大家留言指出. 在 Java 的 String 类中,可以使用 format() 方法 ...

  5. Android Notification 详解(一)——基本操作

    Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...

  6. Android Notification 详解——基本操作

    Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...

  7. Git初探--笔记整理和Git命令详解

    几个重要的概念 首先先明确几个概念: WorkPlace : 工作区 Index: 暂存区 Repository: 本地仓库/版本库 Remote: 远程仓库 当在Remote(如Github)上面c ...

  8. Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)

    Android XML shape 标签使用详解   一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...

  9. Node.js npm 详解

    一.npm简介 安装npm请阅读我之前的文章Hello Node中npm安装那一部分,不过只介绍了linux平台,如果是其它平台,有前辈写了更加详细的介绍. npm的全称:Node Package M ...

随机推荐

  1. 395.至少有 K 个重复字符的最长子串

    题目 给你一个字符串 s 和一个整数 k ,请你找出 s 中的最长子串, 要求该子串中的每一字符出现次数都不少于k .返回这一子串的长度. 示例 1: 输入:s = "aaabb" ...

  2. [敏捷软工团队博客]Beta阶段使用指南

    软件工程教学实践平台使用指南 项目地址:http://20.185.223.195:8000/ 项目团队:the agiles 进入界面如图: 目录 软件工程教学实践平台使用指南 学生端 登录 iss ...

  3. 热身 for computer industry

    项目 内容 作业属于 班级博客 作业要求 作业要求 个人课程目标 掌握软件工程基础知识 具体有助方面 个人认知与规划 其他参考文献 博客Ⅰ 博客 Ⅱ 选择计算机 你为什么选择计算机专业?你认为你的条件 ...

  4. FastAPI 学习之路(二十九)使用(哈希)密码和 JWT Bearer 令牌的 OAuth2

    既然我们已经有了所有的安全流程,就让我们来使用 JWT 令牌和安全哈希密码让应用程序真正地安全. 关于 JWT 它是一个将 JSON 对象编码为密集且没有空格的长字符串的标准.字符串看起来像这样: e ...

  5. Noip模拟81 2021.10.20

    T1 语言 比较简单的题,然后就瞎写了,所以考场上就我一个写了线段树的,所以我的常数.... 所以就枚举动词的位置,找前面后面有没有出现$4$即可 1 #include<bits/stdc++. ...

  6. Java:检查异常与未检查异常

    一.异常的介绍 Throwable 是 Java 中所有错误和异常的超类.Java 虚拟机仅抛出属于此类(或其子类之一)的实例对象,或者是 throw 语句也可以抛出该对象.同样,catch 子句中的 ...

  7. Git新建本地分支

    作为一名码农,Git的使用就像家常便饭,时时刻刻都要用到. 通常我们在开发或者调试某个功能的时候,一般会从主分支新开一个单独的分支仅供自己使用,当我们开发完成后在提交合并请求给管理员,管理员进行代码审 ...

  8. cf17A Noldbach problem(额,,,素数,,,)

    题意: 判断从[2,N]中是否有超过[包括]K个数满足:等于一加两个相邻的素数. 思路: 枚举. 也可以:筛完素数,枚举素数,直到相邻素数和超过N.统计个数 代码: int n,k; int prim ...

  9. Nessus home版插件更新

    1,进入服务器停止服务 service nessusd stop 2,进入目录执行命令获取Challenge code cd /opt/nessus/sbin/ ./nessuscli fetch - ...

  10. 测试平台系列(71) Python定时任务方案

    大家好~我是米洛! 我正在从0到1打造一个开源的接口测试平台, 也在编写一套与之对应的完整教程,希望大家多多支持. 欢迎关注我的公众号测试开发坑货,获取最新文章教程! 定时任务 定时任务,顾名思义: ...