Openfoam for Computational Fluid Dynamics
Total Page:16
File Type:pdf, Size:1020Kb
OpenFOAM for Computational Fluid Dynamics Goong Chen, Qingang Xiong, Philip J. Morris, Eric G. Paterson, Alexey Sergeev, and Yi-Ching Wang Introduction difficult or expensive to measure or to test exper- There is a revolution going on, impacting and imentally. What is more, numerical computation transforming how computational mechanics and can simulate supernova explosions and galaxy for- the associated design and optimization are done: mations, which cannot be produced in earthbound the emergence, availability, and large-scale use of laboratories. It has been recognized for at least OpenFOAM [1]. It belongs to the contemporary thirty years that computational science constitutes open-source trend not unlike the roles played a third and independent branch of science on equal by the Linux operating system or the Internet footing with theoretical and experimental sciences. encyclopedia Wikipedia. OpenFOAM is free and is Cutting across disciplines at the center of compu- used by thousands of people worldwide in both tational science is computational fluid dynamics academic and industrial settings. The acronym (CFD), which makes up the core of OpenFOAM and is the focus of this article. OpenFOAM stands for Open Source Field Operation In the early days of CFD research and develop- and Manipulation. ment, computer programs (“codes”) were primarily Computational mathematics and mechanics pro- developed in universities and national laboratories. vide fundamental methods and tools for simulating Many of these efforts had lifetimes of ten to twenty physical processes. Numerical computation can years and involved numerous Ph.D. students and offer important insights and data that are either postdoctoral associates. Fueled by intense Ph.D.- level research, those early codes provided the basis Goong Chen is professor of mathematics at Texas A&M of modern CFD knowledge. However, this model University (TAMU) and Texas A&M University at Qatar of development had several flaws. The constant (TAMUQ). His email address is [email protected]. turnover of personnel in academic research groups Qingang Xiong is postdoctoral researcher of mechanical created serious continuity problems, especially if engineering at Iowa State University. His email address is the faculty advisor or group leader was not manag- [email protected]. ing the code architecture. Another challenge was Philip J. Morris is Boeing/A.D. Welliver Professor of Aerospace that Ph.D. students and postdocs in engineering Engineering at The Pennsylvania State University. His email address is [email protected]. and mathematics were often self-taught program- mers, which meant that most of the codes were Eric G. Paterson is Rolls Royce Commonwealth Professor of Marine Propulsion and department head of Aerospace and suboptimal programs. Those student-written re- Ocean Engineering at Virginia Tech. His email address is search codes often became notorious as “spaghetti [email protected]. code”, which was hard to extend to new physics or Alexey Sergeev is postdoctoral fellow of mathematics at new parallel high-performance computing architec- TAMU and TAMUQ. His email address is asergeev@ tures without extraordinary effort. Finally, because asergeev.com. such a significant amount of time and financial Yi-Ching Wang is a Ph.D. student in the mathematics depart- resources had been invested in the development, ment of TAMU. Her email address is [email protected]. those codes were usually proprietary and rarely edu. made available to the public except to those in the DOI: http://dx.doi.org/10.1090/noti1095 extended academic family of the leader. 354 Notices of the AMS Volume 61, Number 4 If the researcher is not a CFD code developer, work at the Numerical Methods Group at Universit¨at then most of the time the only alternative is to Heidelberg, Germany, and today it is a global open- buy and use commercial CFD software packages. source project maintained primarily at Texas A&M There are now many such CFD packages (see, University, Clemson University, and Universit¨at e.g., those listed in [2], though this list is not Heidelberg and has dozens of contributors and exhaustive). License fees for commercial software several hundred users scattered around the world. typically range from US$10,000 to US$50,000 per The Stanford University Unstructured (SU2) [7] year depending on the “added extras”, the number suite is an open-source collection of C++-based of users, whether multiple licenses are required software tools for performing partial differential for parallel computation, and the commercial equation (PDE) analysis and solving PDE con- or academic nature of the license. This is not strained optimization problems. The toolset is inexpensive. For a faculty member who doesn’t designed with computational fluid dynamics and have a research grant or is retired, the cost is aerodynamic shape optimization in mind, but is generally prohibitive. extensible to treat arbitrary sets of governing As long as the Internet has existed, there has equations such as potential flow, electrodynamics, been free and open-source software available chemically reacting flows, and many others. SU2 is to download and share. However, over the past under active development in the Aerospace Design decade, the level of sophistication and quality Lab (ADL) of the Department of Aeronautics and of open-source software has significantly grown, Astronautics at Stanford University and is released largely aided by the move to object-oriented pro- under an open-source license. gramming and online version-control repositories M´efisto [8], 3D finite element software for (e.g., SourceForge [3], GitHub [4]). As in the early numerical solutions of a set of boundary value days, much of this software finds its roots in problems, has been posted by Prof. Alain Perronnet academia and national laboratories. of the Laboratoire Jacques-Louis Lions at the OpenFOAM was born in the strong British Universit´e Pierre et Marie Curie in Paris, France, tradition of fluid dynamics research, specifically who is a long-time collaborator with the first author at The Imperial College, London, which has been of this article. a center of CFD research since the 1960s. The Another open-source software package for CFD original development of OpenFOAM was begun or PDEs includes MFIX (Multiphase Flows with by Prof. David Gosman and Dr. Radd Issa, with Interface eXchanges), developed by the National principal developers Henry Weller and Dr. Hrvoje Energy Technology Laboratory (NETL) of the De- Jasak. It was based on the finite volume method partment of Energy [9], suitable for hydrodynamics, (FVM) [5], an idea to use C++ and object-oriented heat transfer, and chemical reactions in fluid-solid programming to develop a syntactical model of systems. It is based on the finite volume method equation mimicking (see Box 2) and scalar-vector- and written in Fortran. tensor operations. A large number of Ph.D. students Still more open-source finite element softwares and their theses have contributed to the project. such as FEniCS, FreeFem++, etc., can be found in Weller and Jasak founded the company Nabla Ltd., [37]. Nevertheless, most of their primary emphases but it was not successful in marketing its product, are not built for the purpose of CFD. FOAM (the predecessor of OpenFOAM), and folded The revenue and survival strategy of the com- in 2004. Weller founded OpenCFD Ltd. in 2004 pany OpenCFD Ltd. (which has been absorbed into and released the GNU general public license of ESI Group), is a “Redhat model” [10] providing OpenFOAM software. OpenFOAM constitutes a support, training, and consulting services. While C++ CFD toolbox for customized numerical solvers OpenFOAM is open-source, the development model (over sixty of them) that can perform simulations is a “cathedral” style [11] where code contributions of basic CFD, combustion, turbulence modeling, from researchers are not accepted back into the electromagnetics, heat transfer, multiphase flow, main distribution due to strict control of the code stress analysis, and even financial mathematics base. For researchers who want to distribute their modeled by the Black-Scholes equation. In August developments and find other online documentation, 2011, OpenCFD was acquired by Silicon Graphics there are a community-oriented discussion forum International (SGI). In September 2012, SGI sold [12], a wiki [13], and an international summer OpenCFD Ltd to the ESI Group. workshop [14]. While OpenFOAM may be the first and most Now, with the open-source libraries in Open- widely adopted open-source computational me- FOAM, one does not have to spend one’s whole chanics software, there indeed are other examples. career writing CFD codes or be forced to buy com- A few are briefly mentioned here. They include mercial softwares. Many other users of OpenFOAM deal.ii [6], a finite-element Differential Equations have developed relevant libraries and solvers that Analysis Library, which originally emerged from are either posted online or may be requested for April 2014 Notices of the AMS 355 Solve // define field scalar u and f ( volVectorField u, f; fvm::ddt(rho,U) // construct the Laplacian equation and solve it + fvm::div(U,U) solve - fvm::laplacian(mu,U) ( == fvm::laplacian(u) == f - fvc::grad(p) ); + f ); Box 1. OpenFOAM code for the potential Box 2. OpenFOAM code for the N-S equation (3). equation (1). Here, as well as in Box 1, equation mimicking is quite obvious. Note that the specifications fvm and fvc are selected by the user from the free. The number of OpenFOAM users has been fvSchemes dictionary in the system dictionary; cf. steadily increasing. It is now estimated to be of Chart 1. Here fvm::laplacian means an implicit finite volume discretization for the Laplacian <case> operator, and similarly for fvm::div for the divergence operator. On the other hand, system fvc::grad means an explicit finite volume (control parameter: ∆ t, ∆ x, maximum controlDict Courant number, etc) discretization for the gradient operator. The (discretization schemes for , 2, , parentheses ( , ) means a product of the fvSchemes ∇ ∇ ∇× interpolation, etc.) enclosed quantities, including tensor products.