Abstract
In this work, we develop an extension of the Curiously Recurring Template Pattern (CRTP), which allows us to organize three related concepts in a class hierarchy. Generalizations, specializations and special procedures are the concepts that we use to define and implement several tools. We call these tools general template units because they are well-defined building blocks (units) for numerically solving partial differential equations (PDEs), are based on the use of templates of the C++ language, and can be applied in the solution of different kinds of problems. We focus on the solution of PDEs using the Finite Volume Method (FVM) in box-shaped domains. The three concepts just mentioned are intensively used to generate optimized codes for each case study. The convenience of our approach is highlighted in the numerical solutions of the examples of application, including laminar thermal convection, turbulent thermal convection, as well as a two-phase flow model in porous media, all of them in one, two, and three dimensions. The mathematical models of these examples were obtained using the axiomatic formulation, which provides generality, simplicity, and clarity to tackle any continuum mechanics application. The ideas explained in this work are quite simple but powerful in solving fluid dynamics problems, in which the conservativeness of the FVM is an important feature. The techniques developed in this work allow us to swap easily between numerical schemes for computing the coefficients obtained by applying the FVM.
- A. Al-Huthali and A. Datta-Gupta. 2004. Streamline simulation of counter-current imbibition in naturally fractured reservoirs. Journal of Petroleum Science and Engineering 43, 271--300.Google ScholarCross Ref
- M. Allen, I. Herrera, and G. Pinder. 1998. Numerical Modelling in Science and Engineering. John Wiley & Sons, New York, NY.Google Scholar
- M. H. Austern. 1999. Generic Programming and the STL: Using and Extending the C++ Standard Template Library. Addison-Wesley, New York, NY. Google ScholarDigital Library
- S. Balay, J. Brown, K. Buschelman, W. D. Gropp, D. Kaushik, M. G. Knepley, L. C. McInnes, B. F. Smith, and H. Zhang. 2011. PETSc Web page. Retrieved July 16, 2016 from http://www.mcs.anl.gov/petsc.Google Scholar
- W. Bangerth, R. Hartmann, and G. Kanschat. 2007. deal.II-- A general--purpose object--oriented finite element library. ACM Transactions on Mathematical Software 33, 4. Google ScholarDigital Library
- J. J. Barton and L. R. Nackman. 1994. Scientifc and Engineering C++. Addison--Wesley, New York, NY.Google Scholar
- R. Bastiaans, C. Rindt, F. Nieuwstadt, and A. van Steenhoven. 2000. Direct and large--eddy simulation of the transitional of two-- and three--dimensional plane plumes in a confined enclosure. International Journal of Heat and Mass Transfer 43, 2375--2393.Google ScholarCross Ref
- E. Bertolazzi and G. Manzini. 2002. Algorithm: P2MESH: Generic object-oriented interface between 2-D unstructured meshes and FEM/FVM-based PDE solvers. ACM Transactions on Mathematical Software 28, 1, 101--131. Google ScholarDigital Library
- D. L. Brown, W. D. Henshaw, and D. J. Quinlan. 1997. Overture: An object oriented framework for solving partial differential equations. In Lecture Notes in Computer Science. Vol. 1343. Springer, Berlin. Retrieved July 16, 2016 from https://computation.llnl.gov/casc/Overture/. Google ScholarDigital Library
- S. Buckley and M. Leverett. 1942. Mechanism of fluid displacement in sands. Transactions of the AIME 146, 107--116.Google ScholarCross Ref
- P. Castillo, R. Rieben, and D. White. 2005. FEMSTER: An object-oriented class library of high-order discrete differential forms. ACM Transactions on Mathematical Software 31, 4, 425--457. http://www.swmath.org/software/275. Google ScholarDigital Library
- Z. Chen, G. Huan, and Y. Ma. 2006. Computational Methods for Multiphase Flows in Porous Media. SIAM, Philadelphia, PA. Google ScholarDigital Library
- J. O. Coplien. 1995. Curiously recurring template patterns. C++ Report, 24--27. Google ScholarDigital Library
- A. Corey. 1954. The interrelation between gas and oil relative permeabilities. Producers Monthly 19, 1, 3841.Google Scholar
- CUSP. Library of generic parallel algorithms for sparse matrix and graph computations. Retrieved July 16, 2016 from http://code.google.com/p/cusp-library/.Google Scholar
- E. David. 1993. Modélisation des écoulements compressibles et hypersoniques: une approche instantionnaire. Ph.D. dissertation. National Polytechnic Institute, Grenoble, France.Google Scholar
- L. de la Cruz. TUNAM: Template units for numerical applications and modeling. Retrieved July 16, 2016 from http://code.google.com/p/tunam/.Google Scholar
- L. M. de la Cruz. 2005. Parallel computing of balance equations in turbulent flow. Ph.D. dissertation. IIMAS, UNAM, Mexico. In Spanish. Retrieved July 16, 2016 from http://bc.unam.mx/index-alterno.html.Google Scholar
- Eigen. C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. Retrieved July 16, 2016 from http://eigen.tuxfamily.org/.Google Scholar
- FLENS. Flexible library for efficient numerical solutions. Retrieved July 16, 2016 from http://flens.sourceforge.net/.Google Scholar
- M. Hatakeyama, M. Watanabe, and T. Suzuki. 1998. Object-oriented fluid flow simulation system. Computers & Fluids 27, 5--6, 581--597.Google ScholarCross Ref
- T. Hayase, J. A. C. Humphrey, and R. Greif. 1992. A consistently formulated QUICK scheme for fast and stable convergence using finite-volume iterative calculation procedures. Journal of Computational Physics 98, 1, 108--118. Google ScholarDigital Library
- I. Herrera and G. S. Herrera. 2011. Unified formulation of enhanced oil-recovery methods. Geofisica Internacional 50, 1.Google Scholar
- I. Herrera and G. Pinder. 2012. Mathematical Modeling in Science and Engineering: An Axiomatic Approach. John Wiley & Sons, New York, NY.Google Scholar
- P. S. Kholsa and S. G. Rubin. 1974. A diagonal dominant second-order accurate implicit scheme. Computers and Fluids 2, 207--209.Google ScholarCross Ref
- B. S. Kirk, J. W. Peterson, R. H. Stogner, and G. F. Carey. 2006. libMesh: A C++ Library for Parallel Adaptive Mesh Refinement/Coarsening Simulations. Engineering with Computers 22, 3--4, 237--254. http://dx.doi.org/10.1007/s00366-006-0049-3. Google ScholarCross Ref
- D. B. Kirk and W. W. Hwu. 2010. Programming Massively Parallel Processors: A Hands-on Approach. Morgan Kaufmann, Burlington, MA. Google ScholarDigital Library
- D. Kuzmin, R. Löhner, and S. Turek. 2012. Flux--Corrected Transport: Principles, Algorithms and Applications. 2nd ed. Scientific Computation. Springer, New York, NY.Google Scholar
- S. Lamine and M. G. Edwards. 2010. Higher order multidimensional upwind convection schemes for flow in porous media on structured and unstructured quadrilateral grids. SIAM Journal on Scientific Computing 32, 3, 1119--1139.Google ScholarDigital Library
- H. P. Langtangen and O. Munthe. 2001. Solving systems of partial differential equations using object-oriented programming techniques with coupled heat and fluid flow as example. ACM Transactions on Mathematical Software 27, 1, 1--26. Google ScholarDigital Library
- B. P. Leonard. 1979. A stable and accurate convective modelling procedure based on quadratic upstream interpolation. Comp. Meth. in App. Mech. and Engineering 19, 59--98. Google ScholarDigital Library
- M. Lesieur and O. Métais. 1996. New trends in large-eddy simulations of turbulence. Annual Review of Fluid Mechanics 28, 45--82.Google ScholarCross Ref
- R. J. Leveque. 2002. Finite Volume Methods for Hyperbolic Problems. Cambridge University Press, New York, NY.Google Scholar
- A. Lipchin and R. A. Brown. 1999. Comparison of three turbulence models for simulation of melt convection in Czochralski crystal growth of silicon. Journal of Crystal Growth 205, 1--2, 71--91.Google ScholarCross Ref
- J.-L. Liu, I.-J. Lin, M.-Z. Shih, R.-C. Chen, and M.-C. Hsieh. 1996. Object-oriented programming of adaptive finite element and finite volume methods. Applied Numerical Mathematics 21, 4, 439--467. Google ScholarDigital Library
- A. Logg and G. N. Wells. 2010. DOLFIN: Automated finite element computing. ACM Transactions on Mathematical Software 37, 2. http://fenicsproject.org/. Google ScholarDigital Library
- MTL4. Matrix template library 4. Retrieved July 16, 2016 from http://www.simunova.com/de/mtl4.Google Scholar
- N. Myers. 1995. Traits: A new and useful template technique. C++ Report.Google Scholar
- J. Nie, D. Hopkins, Y. Chen, and H. Hsieh. 2010. Development of an object-oriented finite element program with adaptive mesh refinement for multi-physics applications. Advances in Engineering Software 41, 4, 569--579. Google ScholarDigital Library
- NIST. FiPy: A finite volume PDE solver using Python. Retrieved July 16, 2016 from http://www.ctcms.nist.gov/fipy/.Google Scholar
- S. Norris. 2000. A parallel Navier--Stokes solver for natural convection and free surface flow. Ph.D. dissertation. Department of Mechanical Engineering, University of Sydney, Sydney, Australia.Google Scholar
- S. V. Patankar. 1980. Numerical Heat Transfer and Fluid Flow. McGraw--Hill, New York, NY.Google Scholar
- L. Pesch, A. Bell, H. Sollie, V. R. Ambati, O. Bokhove, and J. J. V. D. Vegt. 2007. hpGEM -- A software framework for discontinuous Galerkin finite element methods. ACM Transactions on Mathematical Software 33, 4. http://www.hpgem.org. Google ScholarDigital Library
- Seldon. C++ library for linear algebra. Retrieved July 16, 2016 from http://seldon.sourceforge.net/.Google Scholar
- Y. Tian and T. Karayiannis. 2000a. Low turbulence natural convection in an air filled square cavity, Part I: The thermal and fluid flow fields. International Journal of Heat and Mass Transfer 43, 849--866.Google ScholarCross Ref
- Y. Tian and T. Karayiannis. 2000b. Low turbulence natural convection in an air filled square cavity, Part II: The thermal and fluid flow fields. International Journal of Heat and Mass Transfer 43, 867--884.Google ScholarCross Ref
- uBlas. Basic linear algebra library. Retrieved July 16, 2016 from http://www.boost.org/.Google Scholar
- J. P. Van Doormaal and G. D Raithby. 1984. Enhancements of the simple method for predicting incompressible fluid flows. Numerical Heat Transfer 7, 147--163.Google ScholarCross Ref
- D. Vandevoorde and N. M. Josuttis. 2003. C++ Templates. Addison-Wesley, New York, NY. Google ScholarDigital Library
- T. Veldhuizen. Blitz++: Object-oriented library for scientific computing. Retrieved July 16, 2016 from http://sourceforge.net/projects/blitz/.Google Scholar
- T. L. Veldhuizen. 1995a. Expression templates. C++ Report 7, 5, 26--31. Reprinted in C++ Gems, ed. Stanley Lippman.Google Scholar
- T. L. Veldhuizen. 1995b. Using C++ template metaprograms. C++ Report 7, 4, 36--43. Reprinted in C++ Gems, ed. Stanley Lippman.Google Scholar
- T. L. Veldhuizen. 1998. Arrays in Blitz++. In Lecture Notes in Computer Science. Vol. 1505. Springer, Berlin. Google ScholarDigital Library
- H. K. Versteeg and W. Malalasekera. 1995. An introduction to computation of fluid dynamics. The finite volume method. Longman Scientific and Technical, Harlow, UK.Google Scholar
- H. Weller, G. Tabor, H. Jasak, and C. Fureby. 1998. A tensorial approach to CFD using object orientated techniques. Computers in Physics 12, 6, 620--631. Google ScholarDigital Library
- J. Xaman, G. Alvarez, L. Lira, and C. Estrada. 2005. Numerical study of heat transfer by laminar and turbulent natural convection in tall cavities of facade elements. Energy and Buildings 37, 7, 787--794.Google ScholarCross Ref
Index Terms
- General Template Units for the Finite Volume Method in Box-Shaped Domains
Recommendations
A numerical method for three-dimensional gas-liquid flow computations
A numerical method for multiphase flow computations based on a finite-difference formulation with a fixed grid is described. The method combines ideas from front tracking and the Ghost Fluid Method, with a numerical technique for velocity extrapolation ...
Computation of three-dimensional multiphase flow dynamics by Fully-Coupled Immersed Flow (FCIF) solver
This work presents a Fully-Coupled Immersed Flow (FCIF) solver for the three-dimensional simulation of fluidfluid interaction by coupling two distinct flow solvers using an Immersed Boundary (IB) method. The FCIF solver captures dynamic interactions ...
A level-set continuum method for two-phase flows with insoluble surfactant
A level-set continuum surface force method is presented to compute two-phase flows with insoluble surfactant. Our method recasts the Navier-Stokes equations for a two-phase flow with insoluble surfactant as ''one-fluid'' formulation. Interfacial ...
Comments