We develop and analyze an algorithmic framework and library of parallel automatically differentiable data-types written in the C++ programming language. In addition to representing variables and discretized expressions on a simulation grid, the data-types hide algorithms employed behind the scenes capable of automatically computing the sparse analytical Jacobian. Using the library, reservoir simulators can be developed rapidly by simply writing the residual equations, and without any hand differentiation, loops, or any other low-level constructs. The key challenge addressed is a technical development to enable this to run fast. Faster than if any of several existing automatic differentiation packages were used, faster than any purely Object Oriented implementation, and at least as fast as if a development team implemented hand-optimized residuals, analytical derivatives, and Jacobian assembly routines. This is achieved by extending a generic programming technique specific to the C++ programming language known as Expression Templates. The extension enables its application to handle nested abstract types including sparse vector composites. Consequently, the library implementation can handle the complexity of any reservoir simulation model with optimal use of microprocessor hard-ware. We demonstrate the ease of use of the library by presenting an efficient and rapidly developed fully-implicit simulator. Performance analysis is performed with varying grid size and is bench-marked with structured implemen-tations. The tests are run with widely used compilers on standard microprocessors.
展开▼