fluidity詳解

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/273474.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/273474.shtml
英文地址,請注明出處:http://en.pswp.cn/news/273474.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mysql讀書筆記---if語句

IF(expr1,expr2,expr3) 如果expr1是TRUE(expr1<>0 and expr1<>NULL)&#xff0c;則IF()的返回值為expr2;否則返回值則為expr3。IF()的返回值為數字值或字符串值&#xff0c;具體情況視其所在語境而定。 mysql>SELECT?IF(1>2,2,3); ->3 mysql>SELECT I…

C語言 將整數寫入內存指定的連續字節單元中

將整數數組寫入0x40003000開始的連續10個字節內存單元中&#xff0c;注意unsigned char *指向一個字節&#xff0c;而int *指向1個字&#xff08;4個字&#xff09;&#xff0c;但是可以把字中存儲的整數放入字節單元中&#xff0c;只要不超過表示的范圍&#xff0c;注意雖然un…

mysql讀書筆記----時間函數

1.獲得當前時間&#xff1a;時間格式yyyy-MM-dd curdate();2.DAYOFWEEK(date) 3.WEEKDAY(date) 4.DAYOFMONTH(date) 5.DAYOFYEAR(date) 6.MONTH(date) 7.DAYNAME(date) 8.MONTHNAME(date) 9.QUARTER(date) 10.WEEK(date) WEEK(date,first) 11.YEAR(date) 12.HOUR(time) 13.MINU…

企業數據1

1. 企業數據 1.1. 全局 1.1.1. 貨幣 CNY Chinese Yuan Renminbi &#xffe5; 6.825020 ARS Argentine Peso $ 3.791090 BOB Bolivian Boliviano $b 7.570800 BRL Brazilian Real R$ 1.766500 CAD Canadian Dollar $ 1.037570 CLP Chilean Peso $ …

sql判斷語句

方法一&#xff1a; <if test"null ! orderType and 0 orderType"> order by amountTimes desc </if><if test"null ! orderType and 1 orderType">order by amountTimes asc </if><if test"null ! orderType and 2 …

Thinkphp 整合tcpdf

網上查了些關于tcpdf 使用教程&#xff0c;整合到TP的話&#xff0c;會有些小問題&#xff0c;由于基礎還不是很扎實&#xff0c;花了點時間終于整合OK了。下面介紹步驟&#xff1a; 環境&#xff1a; TP版本&#xff1a;TP3.2.2 tcpdf:tcpdf_6_2_3 1. 將tcpdf_6_2_3.zip解壓在…

多項目開發下的dll文件管理

閱讀目錄&#xff1a;DS01&#xff1a;為什么要對生成的dll文件進行管理&#xff1f;DS02&#xff1a;首先介紹以下兩個DOS命令DS03&#xff1a;第一種實現方法&#xff08;xcopy&#xff09;DS04&#xff1a;第二種實現方法&#xff08;attrib&#xff09;DS05&#xff1a;分享…

關于Java中的隨機數產生

對比兩種寫法&#xff1a; 第一種&#xff1a; public static void main(String args[]){Random random new Random(System.currentTimeMillis());for(int i0; i<20; i){int sindex random.nextInt(2);System.out.println(sindex);}}第二種&#xff1a; public static voi…

視圖

視圖是虛表&#xff0c;是從一個或幾個基本表&#xff08;或視圖&#xff09;中導出的表&#xff0c;在系統的數據字典中僅存放了視圖的定義&#xff0c;不存放視圖對應的數據。視圖是原始數據庫數據的一種變換&#xff0c;是查看表中數據的另外一種方式。可以將視圖看成是一個…

選擇器的并發性

4.3.4 并發性 選擇器對象是線程安全的&#xff0c;但它們包含的鍵集合不是。通過keys( )和selectKeys( )返回的鍵的集合是Selector對象內部的私有的Set對象集合的直接引用。這些集合可能在任意時間被改變。已注冊的鍵的集合是只讀的。如果您試圖修改它&#xff0c;那么您得到的…

mysql 自定義函數之判斷

DELIMITER $$CREATE DEFINERrootlocalhost FUNCTION getMin(a int,b int) RETURNS int(11)BEGINdeclare min int;if(a>b)then set min b;elseif(b>a)then set min a;else set min 0;#end if;end if;RETURN min;END 調用該函數可以如下方式 select getMin(1,2); 返回值…

C/C++的數組名

數組名相當于指向數組第一個元素的地址。數組名不是變量&#xff0c;是地址常量&#xff0c;不能為其賦值。如下&#xff1a;1&#xff09;一維數組中對于數組 a[5] {1, 2, 3, 4, 5};數組名a相當于指向第一個元素a[0]的指針。即 a 與 &a[0] 等價。2&#xff09;二維數組中…

mysql的運算法

一、算術運算符1、加 www.2cto.com mysql> select 12;-----| 12 |-----| 3 |-----2、減mysql> select 1-2;-----| 1-2 |-----| -1 |-----3、乘mysql> select 2*3;-----| 2*3 |-----| 6 |-----4、除mysql> select 2/3;--------| 2/3 |--------| 0.6667 |-…

轉-- iOS 30多個iOS常用動畫,帶詳細注釋

// // CoreAnimationEffect.h // CoreAnimationEffect // // Created by VincentXue on 13-1-19. // Copyright (c) 2013年 VincentXue. All rights reserved. //#import <Foundation/Foundation.h>/**! 導入QuartzCore.framework** Example:** Step.1** #imp…

Java中abstract與interface

抽象類&#xff08;abstract class&#xff09;的特點&#xff1a; 1.抽象類、抽象方法都必須使用abstract修飾。 2.抽象類中&#xff0c;可以有非抽象方法&#xff0c;甚至可以是沒有任何方法或變量的空類。 對于抽象類中不定義抽象方法的用意在于&#xff1a;使該類不能被創建…

按位與、或、異或等運算方法

按位與運算符&#xff08;&&#xff09; 參加運算的兩個數據&#xff0c;按二進制位進行“與”運算。 運算規則&#xff1a;0&00; 0&10; 1&00; 1&11; 即&#xff1a;兩位同時為“1”&#xff0c;結果才為“1”&#xff0c;否則為0 例如&#xff1…

JavaScript驗證

<script type"text/javascript"> /*密碼*/ function password() { var password document.getElementById("password").value; var ts document.getElementById("tsPassword"); if (password.length >…

mysql數據庫根據上傳的經緯度計算距離

select 6371.393*ACOS(COS(RADIANS(latitude))*COS(RADIANS(47.02))*COS(RADIANS(longitude)-RADIANS(114.100))SIN(RADIANS(latitude))*SIN(RADIANS(47.02))) as distancefrom location

emacs配置

; 指針顏色設置為白色(set-cursor-color "white");; 鼠標顏色設置為白色(set-mouse-color "white") ;; 從color-theme中獲取;; 網上下載color-theme.el&#xff0c;放到加載路徑(&#xff0f;usr/share/emacs/site-lisp )下;; M-x color-theme-select,鼠標…

自然連接(NATURAL JOIN)

自然連接&#xff08;NATURAL JOIN&#xff09;是一種特殊的等價連接&#xff0c;它將表中具有相同名稱的列自動進行記錄匹配。自然連接不必指定任何同等連接條件。圖9.9給出了典型的自然連接示意圖。 圖9.9 自然連接 自然連接自動判斷相同名稱的列&#xff0c;而后形成匹配。…