ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:19.17KB ,
资源ID:5531825      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5531825.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(OpenFOAM编程格式要求.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

OpenFOAM编程格式要求.docx

1、OpenFOAM编程格式要求OpenFOAM Code Style GuideGeneral 80 character lines max The normal indentation is 4 spaces per logical level. Use spaces for indentation, not tab characters. Avoid trailing whitespace. The body of control statements (eg,if,else,while, etc). is always delineated with brace brackets. A p

2、ossible exception can be made in conjunction withbreakorcontinueas part of a control structure. The body ofcasestatements is usually delineated with brace brackets. A fall-throughcaseshould be commented as such. stream outputo is always four characters after the start of the stream, so that thesymbo

3、ls align, i.e.Info.os.fsoWarningIn(className:functionName()WarningmessagenotWarningIn(className:functionName()Warningmessage no unnecessary class section headers, i.e. remove/*PrivateMemberFunctions*/Check/Edit/Writeif they contain nothing, even if planned for future use class titles are centred/*-*

4、ClassexampleClassDeclaration*-*/not/*-*ClassexampleClassDeclaration*-*/The.HFiles header file spacingo Leave two empty lines between sections (as per functions in the.Cfile etc) use/- Commentcomments in header file to add descriptions to class data and functions do be included in the Doxygen documen

5、tation:o text on the line starting with/-becomes the Doxygen brief description;o text on subsequent lines becomes the Doxygen detailed descriptione.g./-Afunctionwhichreturnsathing/Thisisadetaileddescriptionofthefunction/whichprocessesstuffandreturnsotherstuff/dependingonthings.thingfunction(stuff1,s

6、tuff2);o list entries start with-or-#for numbered lists but cannot start on the line immediately below the brief description so/-ComparetriFaces/Returns:/-0:different/-+1:identical/-1:sameface,butdifferentorientationstaticinlineintcompare(consttriFace&,consttriFace&);or/-ComparetriFacesreturning0,+1

7、or-1/-0:different/-+1:identical/-1:sameface,butdifferentorientationstaticinlineintcompare(consttriFace&,consttriFace&);not/-ComparetriFacesreturning0,+1or-1/-0:different/-+1:identical/-1:sameface,butdifferentorientationstaticinlineintcompare(consttriFace&,consttriFace&);o list can be nested for exam

8、ple/-Searchforemname/inthefollowinghierarchy:/-#personalsettings:/-/.OpenFOAM/forversion-specificfiles/-/.OpenFOAM/forversion-independentfiles/-#site-widesettings:/-$WM_PROJECT_INST_DIR/site/forversion-specificfiles/-$WM_PROJECT_INST_DIR/site/forversion-independentfiles/-#shippedsettings:/-$WM_PROJE

9、CT_DIR/etc/returnthefullpathnameorfileName()ifthenamecannotbefound/OptionallyabortifthefilecannotbefoundfileNamefindEtcFile(constfileName&,boolmandatory=false);o for more details see the Doxygen documentation. destructoro If adding a comment to the destructor - use/-and code as a normal function:/-D

10、estructorclassName(); inline functionso Use inline functions where appropriate in a separateclassNameI.Hfile. Avoid cluttering the header file with function bodies.The.CFiles Do not open/close namespaces in a.Cfileo Fully scope the function name, i.e.Foam:returnTypeFoam:className:functionName()notna

11、mespaceFoam.returnTypeclassName:functionName().EXCEPTIONWhen there are multiple levels of namespace, they may be used in the.Cfile, i.e.namespaceFoamnamespacecompressiblenamespaceRASModels./EndnamespaceRASModels/Endnamespacecompressible/EndnamespaceFoam Use two empty lines between functionsCoding Pr

12、actice passing data as arguments or return values.o Pass bool, label and scalar as copy, anything larger by reference. consto Use everywhere it is applicable. variable initialisation usingconstclassName&variableName=otherClass.data();notconstclassName&variableName(otherClass.data(); virtual function

13、so If a class is virtual, make all derived classes virtual.Conditional Statementsif(condition)code;ORif(longcondition)code;not(no space betweenifand(used)if(condition)code;forandwhileLoopsfor(i=0;imaxI;i+)code;ORfor(i=0;imaxI;i+)code;notthis (no space betweenforand(used)for(i=0;imaxI;i+)code;Note th

14、at when indexing through iterators, it is often slightly more efficient to use the pre-increment form. Eg,+iterinstead ofiter+forAll,forAllIter,forAllConstIter, etc. loopslikeforloops, butforAll(notforAll(Using theforAllIterandforAllConstItermacros is generally advantageous - less typing, easier to

15、find later. However, since they are macros, they will fail if the iterated object contains any commas.The following will FAIL!:forAllIter(HashTablelabelPair,edge,Hash,foo,iter)These convenience macros are also generally avoided in other container classes and OpenFOAM primitive classes.Splitting Over

16、 Multiple LinesSplitting return type and function name split initially after the function return type and left align do not putconstonto its own line - use a split to keep it with the function name and arguments.constFoam:longReturnTypeName&Foam:longClassName:longFunctionNameconstnotconstFoam:longRe

17、turnTypeName&Foam:longClassName:longFunctionNameconstnorconstFoam:longReturnTypeName&Foam:longClassName:longFunctionNameconstnorconstFoam:longReturnTypeName&Foam:longClassName:longFunctionNameconst if it needs to be split again, split at the function name (leaving behind the preceding scoping =:=s),

18、 and again, left align, i.e.constFoam:longReturnTypeName&Foam:veryveryveryverylongClassName:veryveryveryverylongFunctionNameconstSplitting long lines at an “=”Indent after splitvariableName=longClassName.longFunctionName(longArgument);OR (where necessary)variableName=longClassName.longFunctionName(l

19、ongArgument1,longArgument2);notvariableName=longClassName.longFunctionName(longArgument);norvariableName=longClassName.longFunctionName(longArgument1,longArgument2);Maths and Logic operator spacinga+b,a-ba*b,a/ba&b,aba=b,a!=bab,a=b,a=ba|b,a&b splitting formulae over several linesSplit and indent as

20、per “splitting long lines at an =” with the operator on the lower line. Align operator so that first variable, function or bracket on the next line is 4 spaces indented i.e.variableName=a*(a+b)*exp(c/d)*(k+t);This is sometimes more legible when surrounded by extra parentheses:variableName=(a*(a+b)*e

21、xp(c/d)*(k+t); splitting logical tests over several linesoutdent the operator so that the next variable to test is aligned with the four space indentation, i.e.if(a=true&b=c)General For readability in the comment blocks, certain tags are used that are translated by pre-filtering the file before send

22、ing it to Doxygen. The tags start in column 1, the contents follow on the next lines and indented by 4 spaces. The filter removes the leading 4 spaces from the following lines until the next tag that starts in column 1. The Class and Description tags are the most important ones. The first paragraph

23、following the Description will be used for the brief description, the remaining paragraphs become the detailed description.For example,ClassFoam:myClassDescriptionAclassforspecifyingthedocumentationstyle.Theclassisimplementedasasetofrecommendationsthatmaysometimesbeuseful. The class name must be qua

24、lified by its namespace, otherwise Doxygen will think you are documenting some other class. If you dont have anything to say about the class (at the moment), use the namespace-qualified class name for the description. This aids with finding these under-documented classes later.ClassFoam:myUnderDocum

25、entedClassDescriptionFoam:myUnderDocumentedClass Use Class and Namespace tags in the header files. The Description block then applies to documenting the class. Use InClass and InNamespace in the source files. The Description block then applies to documenting the file itself.InClassFoam:myClassDescri

26、ptionImplementsthereadandwritingoffiles.Doxygen Special CommandsDoxygen has a large number of special commands with a =prefix.Since the filtering removes the leading spaces within the blocks, the Doxygencommmands can be inserted within the block without problems.InClassFoam:myClassDescriptionImplementsthereadandwritingoffiles.Anexampleinputfile:verbatimpatchNametypemyPatchType;refValue1

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1