关键词不能为空

当前您在: 主页 > 英语 >

CFX用户手册-User Fortran

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-01 21:46
tags:

-

2021年2月1日发(作者:gest)


User Fortran


Introduction



The chapter discusses:



?



?



?



?



?



?



?



?



?



User CEL Functions and Routines



User Junction Box Routines



Shared Libraries



User Parameters



Utility Routines for User Functions



ANSYS CFX Memory Management System (MMS)



User CEL Examples



User Junction Box Examples



Using CFX-4 Routines in ANSYS CFX



To


allow


you


to


add


additional


features


and


physical


models


to


ANSYS


CFX,


you


can


write


your


own


subroutines


in


Fortran


and


have


the


ANSYS


CFX- Solver


call these routines through a source code interface. You may also wish


to implement customized physical models which would never be available


in ANSYS CFX due to confidentiality considerations.


ANSYS


CFX


supports


user


subroutines


written


in


Fortran


77


or


Fortran


90.


A list of supported compilers for each platform is available. Using


Fortran


77 whenever possible is recommended.


Two different kinds of user routines are available in ANSYS CFX:


CFX

< br>可以利用两种不同的方式应用用户子程序



?



User defined CEL (CFX Expression Language) functions can be used


within a CEL expression, following the standard CEL rules.


For


details, see User CEL Functions and Routines.




用户定义


CEL



User defined CEL


)函数可以在


CEL


表达式中使 用



?



Junction box routines can be used at several places in the ANSYS


CFX-Solver


to


execute


user


code.


For


details,


see


User


Junction


Box


Routines.



Junction box routines


可以在


ANSYS CFX- Solver


中执行用户代码



The following tasks can be accomplished with user subroutines in ANSYS


CFX:


通过 用户程序可以在


CFX


中完成以下内容:



?



?



?



?



?



?



Input of user data (e.g., data required for profile boundary


conditions or externally generated sources).


User- specified boundary conditions (e.g., profile boundary


conditions).


User- specified


initial


conditions


(e.g.,


externally


generated


flow


fields,


random


distribution


or


disturbance


of


existing


solutions).


User-specified source terms (e.g., externally generated body


forces or general additional source terms used to implement new


physical models).


Junction


box


routines


called


every


timestep


which


acts


as


a


general


interface between the ANSYS CFX-Solver and other software (e.g.,


structure mechanic codes). Junction boxes also offer an interface


for advanced monitoring and solution output.


User


particle


routines


are


used


to


specify


sources


of


momentum,


heat


and


mass


transfer,


and


can


also


be


used


to


specify


injection


regions


for


particles.


The


structure


of


particle


user


routines


is


the


same.


An example of this functionality is available.


For details, see Structure of User CEL Functions.



For details, see Particle User Sources.



For details, see User Defined.



Note that ANSYS CFX includes features such as advanced monitoring of


solution


variables


or


global


values


and


extended


CEL


functionality,


which


may reduce your need for user subroutines.


To


use


junction


box


routines,


you


will


need


to


be


familiar


with


the


ANSYS


CFX MMS (Memory Management System) to set up and pass around user data


for


access


in


any


subroutine.


For


details,


see


ANSYS


CFX


Memory


Management


System (MMS).



Shared libraries allow subroutines to be re-used without recompilation


for


successive


ANSYS


CFX-Solver


runs


or


even


for


different


applications.


The location of a shared library is specified in ANSYS CFX-Pre. During


execution of the ANSYS CFX- Solver, the user subroutines are loaded from


the specified shared libraries.


For details, see Shared Libraries.







User CEL Functions and Routines


User CEL functions allow


you to create


your own


functions in addition to


the predefined CEL functions (e.g., sin, cos, step, etc.). You can then


use these functions in any expression where a CEL function can be used.


A


user


CEL


function


passes


an


argument


list


to


a


subroutine


that


you


have


written, and then uses the returned values from the subroutine to set


values for the quantity of interest. The figure below demonstrates the


concept.




All


variables


that


are


available


for


use


in


standard


CEL


expressions


are


also


available


for


use


in


User


CEL


Expressions.


A


list


of


these


variables


is available.


For details, see Variables Available for use in CEL


Expressions.



Details on creating user CEL functions in ANSYS CFX-Pre and defining


quantities via an expression with an argument list are available.


For details, see User Routine Details View.



?



For details, see


User Functions


.



?



Details on creating shared libraries and compiling subroutines are


available.


For details, see Shared Libraries.



Examples


of


using


user


CEL


functions


are


available.


For


details,


see


User


CEL Examples.



Structure of User CEL Functions


A User Fortran file


may contain


several


user routines


that can be called


from the ANSYS CFX-Solver, as well as any secondary routines that are


called only from other routines in this file.


In addition to any comments and declarations that you may wish to add,


the basic structure of a user CEL function is:


#include


dllexport()








SUBROUTINE (








& NLOC, NRET, NARG, RET, ARGS, CRESLT, CZ,DZ,IZ,LZ,RZ )


C








INTEGER NLOC,NARG,NRET








CHARACTER CRESLT*(*)








REAL ARGS(NLOC,NARG), RET(NLOC,NRET)


C








INTEGER IZ(*)








CHARACTER CZ(*)*(1)








DOUBLE PRECISION DZ(*)








LOGICAL LZ(*)








REAL RZ(*)


C








.... executable statements








END


The dllexport() macro is used to ensure that a calling name is known


externally on those platforms that require it for successful runtime


linking.


The


macro


is


defined


in


an


include


file


so


#include



should be the first line of the Fortran file.


One dllexport() should be specified for every routine that the ANSYS


CFX-Solver can call in the Fortran file.


Each


dllexport()


must


precede


the


SUBROUTINE


statement


that


it


refers


to


and must start in column 1. The argument of the dllexport macro should


be


the


name


of


the


subroutine


in


lower


case


and


should


not


contain


spaces.


User


CEL


functions


have


a


fixed


argument


list


which


contains


the


following


data fields:


?



?



?



?



?



?



NLOC:


Number


of


locations


in


space


over


which


the


calculations


have


to be performed.


NARG: Number of arguments passed to the function.


ARGS(1:NLOC,1:NARG): Arguments passed to the function (at each


point in space).


NRET: Number of return variables. This is always 1 in ANSYS CFX,


but is included to allow future extensions.


RET(1:NLOC,1:NRET): Return variables (at each point in space).


CZ(*), DZ(*), IZ(*), LZ(*), RZ(*): CHARACTER, DOUBLE PRECISION,


INTEGER, LOGICAL and REAL stacks.


The length (NLOC) of the arguments (ARGS) and the return value (RET) of


user CEL functions is determined by the locale for which the routine is


called. For example, for a boundary


element group, NLOC is the number of


faces in the group, and for vertices, NLOC is the number of vertices in


the current zone.


Note


that,


in


general,


your


user


CEL


function


will


be


called


several


times


during each iteration and the value of NLOC will be different for each


call.


This


is


because


the


ANSYS


CFX- Solver


will


split


the


specified


region


(e.g., a boundary condition region) into a number of smaller ‘pieces'


and


call


your


function


for


each


piece.


Your


user


subroutine


should


be


coded


to deal with this.


The stacks are required if the information specified on the right side


of the CEL expression (e.g., B*C and D in A


=


UR(B*C,


D)) is not


sufficient to calculate A. It might be necessary to pick up additional


data


(e.g.,


user


input


data,


data


at


other


locales,


gradients, etc).


For


details, see Utility Routines for User Functions.


This data is accessed


from


the


ANSYS


CFX


Memory


Management


System


and


requires


the


global


stacks.


Therefore,


the


global


stacks


are


added


to


the


argument


list.


For


details,


see ANSYS CFX Memory Management System (MMS).



A template user CEL function Fortran file named ucf_template.F can be


found in /examples/.


Note that all strings used in User Fortran are case sensitive.











User CEL Function Units


On


entry


into


a


user


CEL


function


routine,


the


arguments


are


automatically


converted into the units


specified


in the


Argument List


list in the


User


Function


Editor


(labelled


Argument


List


in


the


definition


for


the


function


in the CCL file LIBRARY section).


On exit, the results are automatically converted from the


Result Units



into the solution units used by the ANSYS CFX-Solver.


This ability to choose the working units for the routine with automatic


conversion may be useful for creating interfaces between the ANSYS


CFX-Solver and third-party data or applications.
































User CEL Example 1: User Defined Momentum Source


Problem Setup


A common application of user CEL functions is the specification of user


defined source terms. In the following example, a constant source term


for the y-component of the momentum equation has to be applied on two


rectangular boxes characterized by their extension in the x and y


coordinate direction.



Creating the User CEL Function


Additional information on creating user CEL functions in ANSYS CFX-Pre


is available.


For details, see


User Functions


.



First,


you


should


first


create


a


user


routine


with


the


following


settings:


?



?



?



?



?



Routine Name: UserSourceRoutine


Option: User CEL Function


Calling Name: user_source


Library Name: MomentumSource1


Library Path: /home/cfxuser/shared_libraries


Next, you should create a User Function with the following settings:


?



?



?



?



?



Function Name: UserSource


Option: User Function


User Routine Name:


Argument List: [m], [m]


Result Units: [kg m^-2 s^-2]


In this example, the compiled code for the user subroutine


MomentumSource1.F


is


stored


in


the


shared


library



(the prefix and suffix may vary depending on your platform), which can


be found under the /home/cfxuser/shared_libraries/


directory. If there is


a problem linking


the shared library


to the ANSYS


CFX-Solver, you


can


check that


it


has been


created, but you will usually


not need to know about this library.


The new user CEL function can now be used to set the momentum source


components within the subdomain as follows:


Momentum x-comp: 0.0


?



Momentum y-comp: UserSource(X,Y)


?



Momentum z-comp: 0.0


?



These values are set on the Subdomain Sources form.


For details, see


Sources Tab.



User Fortran Routine


Source


terms


for


the


momentum


equations


can


be


specified


in


CEL


for


a


given


subdomain. Since the user CEL routine defined the extent of the source,


the source subdomain can be defined


to cover


the entire flow


domain. The


subroutine was developed from the template routine ucf_template.F


available in /examples/. Note that some commented sections of


the routine have not been included here. The routine MomentumSource1.F


has the following form:


#include


dllexport(user_source)








SUBROUTINE USER_SOURCE (







&


NLOC,NRET,NARG ,RET,ARGS,CRESLT,CZ,DZ,IZ,LZ,RZ)


C


C .....


C


C ------------------------------


C Argument list


C ------------------------------


C








INTEGER NLOC, NRET, NARG








CHARACTER CRESLT*(*)








REAL RET(1:NLOC,1:NRET), ARGS(1:NLOC,1:NARG)


C








INTEGER IZ(*)








CHARACTER CZ(*)*(1)








DOUBLE PRECISION DZ(*)








LOGICAL LZ(*)








REAL RZ(*)


C


C .....


C


C ------------------------------


C Executable statements


C ------------------------------


C


C-------------------------------------------- -------------


C SOURCE = RET(1:NLOC,1)


C X = ARGS(1:NLOC,1)


C Y = ARGS(1:NLOC,2)


C----------------------- ----------------------------------


C


C---- Low level user routine








CALL USER_SOURCE_SUB (NLOC,RET(1,1),ARGS(1,1),ARGS(1,2))


C








CRESLT = 'GOOD'








END








SUBROUTINE USER_SOURCE_SUB (NLOC,SOURCE,X,Y)


C


C .....


C


C ------------------------------


C Local Variables


C ------------------------------








INTEGER NLOC, ILOC








REAL SOURCE(NLOC), X(NLOC), Y(NLOC)


C------- --------------------------------------------------


C - 0.5 SOURCE = 1000.0


C - 3.5 SOURCE = -1000.0


C----- -------------------------------------------------- --


C ---------------------------


C Executable Statements


C ---------------------------








DO ILOC=1,NLOC











SOURCE(ILOC) = 0.0











IF


(X(ILOC).GE.0.5 .AND. X(ILOC).LE.1.5 .AND.







&





Y(ILOC).GE.1.25 .AND. Y(ILOC).LE.1.75) THEN














SOURCE(ILOC) = 1000.0











ELSE


IF


(X(ILOC).GE.3.5 .AND.


X(ILOC).LE.4.5 .AND.







&






Y(ILOC).GE.1.25 .AND. Y(ILOC).LE.1.75) THEN














SOURCE(ILOC) = -1000.0











END IF








END DO


C








END







































User CEL Example 2: Using Gradients for an Additional Variable


Source


For


some


applications,


the


source


terms


for


the


transport


equations


might


depend


on


local


gradients.


Gradients


are


currently


not


supported


directly


within CEL. However, gradients of most variables can still be accessed


in


CEL


expressions


through


the


use


of


user


CEL


functions.


This


is


achieved


by


calling


the


utility


USER_GETVAR


with


the


‘Gradient'


operator


attached


to the variable name.


The


following


example


shows


the


use


of


a


source


term


depending


on


gradients


of one additional variable,


the transport equation of another additional variable,


.


, in

-


-


-


-


-


-


-


-



本文更新与2021-02-01 21:46,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/595314.html

CFX用户手册-User Fortran的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文