<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Method for High-resolution Resulting Data of Unstable Oil Displacement Simulation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Timokhin Petr</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mikhaylyuk Mikhail</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Moscow</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Russia</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Federal State Institution «Scientific Research Institute for System Analysis of the Russian Academy of Sciences»</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>In the paper the task of real-time synthesis of quality images of resulting data obtained in simulation of unstable oil displacement from porous media is considered. A new, GPU-based method to construct and visualize on UltraHD screens a polygonal model of the isosurface of the saturation of displacing liquid was proposed. The method is based on distributing and parallelizing of «marching cubes» threads between GPU cores by means of programmable tessellation. As initial graphic primitives, quadrangular parametric patches are used, the processing of which on the GPU is high-performance and has low video memory overhead. The proposed method was implemented in visualization software and successfully tested. The proposed solution can be used in researches in oil and gas industry as well as in virtual environment systems, virtual laboratories, scientific and educational applications, etc.</p>
      </abstract>
      <kwd-group>
        <kwd>visualization</kwd>
        <kwd>real-time</kwd>
        <kwd>oil displacement</kwd>
        <kwd>isosurface</kwd>
        <kwd>marching cubes</kwd>
        <kwd>GPU</kwd>
        <kwd>tessellation</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>With the increasing complexity of hydrocarbon extraction, a
high priority is acquired by digital technologies aimed at raising
oil recovery
oil-bearing
cubes», MC) [4,5]. The former approach allows to obtain
highquality images of isosurface, however, the rate of image
synthesis significantly falls on UltraHD screens, which opposes
the isosurface to be rendered in real-time. In the latter approach,
the quality of synthesized images is determined by the detail of
the render grid: the higher it is, the less angularity the isosurface
model is subjected to. This is clearly visible in
UltraHD.</p>
      <p>Therefore, to obtain high-quality images in real-time, effective
methods to construct polygonal isosurface model on detailed
render grid using distributed computing [1] and calculation
parallelization on multi-core GPU, are needed.</p>
      <p>The paper proposes a new, distributed method which
performs computations of «marching cubes» in parallel
GPUthreads generated by means of programmable tessellation of
quadrangular graphic primitives [2]. The solution proposed is
implemented using C++, GLSL languages and OpenGL library.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Constructing a polygonal model of the isosurface</title>
      <p>Consider the task of visualization of a polygonal model of
the surface of some constant value  ∗ of the saturation field of
the displacing fluid. This field is defined by a render grid R of
size</p>
      <p>×  ×  cells. Each of 8 vertices of the cell corresponds
to a certain value S of the saturation of the displacing fluid. We
will construct polygons only in those cells (cubes) of the grid R,
for all 8 vertices of which is not met the same condition:  &lt;  ∗
or  ≥  ∗. In other words, only the cells, that do not lie
completely inside or outside the isosurface, will be affected.</p>
      <p>Consider some   , , cell. Let us number the vertices of this
cell from 0 to 7, and the edges – from 0 to 11. We mark every
vertex of the cell, for which  &lt;  ∗, with a bit value equal to 1,
otherwise – 0. Denote by K the configuration of 8 written one
after another bits. To every K value (from 0 to 255) a set of
triangles (polygons), which will be a part of the polygonal
model of the isosurface (containing in the render grid cell), is
uniquely corresponded. Every such set includes from 0 to 5
triangles. The vertices of the triangle lie on the edges of the cell,
so that one edge contains no more than one vertex. The set of
triangles is given by a sequence of 16 indices: 3 edge indices
per triangle and one index (-1) of the end of the sequence. All
the 256 sequences form a table T of sets of triangles (see [4]).
For the vertex specified by some edge index e in table T the
coordinates P are calculated as follows
 =   +  ∗− ( ) (  −   ),
 ( )− ( )
(1)
where A, B are vertices of eth edge of the cell,   ,   are their
coordinates, and  ( ),  ( ) are values of saturation of
displacing liquid at vertices A and B.</p>
      <p>Let us denote by   , , a GPU-thread constructing a part of
the polygonal model of the isosurface in the   , , th cell
(hereinafter referred to as «marching cubes» thread). Then, the
entire polygonal model of the isosurface can be constructed by
creating and performing the «marching cubes» threads for all
the cells of the render grid.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Tessellation based «marching cubes»</title>
      <p>In this paper, it is proposed to create «marching cubes»
threads by means of programmable tessellation (subdividing) of
patch-quads –
quadrangular parametric
graphic
primitives
(hereinafter referred to as patches). Having programmed the
graphics pipeline of the GPU in a certain way, one patch can be
subdivided into a regular grid of size up to 
× 
vertices. Here

=  
+ 1 and</p>
      <p>is the maximum tessellation level – the
largest number of segments, the patch side can be subdivided
into (at least 64 in OpenGL 4.0). According to the pipeline
architecture each vertex is processed in a separate graphic
thread which we program to construct the corresponding part of
the polygonal isosurface model. The main advantage of the
approach proposed is that the vertices (threads) are generated
mp
patches
n
D
fictive vertices</p>
      <p>(threads)
qp
which is the running number  ∈ [0,       − 1] of passing
patch, and is performed as follows
 =  −   −   ,
where 
  = ⌊ ⌋,</p>
      <p>=     and 
 = ⌊
 −   ⌋,</p>
      <p>=    .</p>
      <p>Tessellation evaluation shader (TE). This shader performs
processing of every vertex, obtained as a result of patch
tessellation, in a parallel thread, and sets the correspondence of
the
vertex (thread) to a render grid
cell.</p>
      <p>The latter is
implemented by adding to the vertex the attributes (  ,   ,   ) –
indices of the row, column and slice of the corresponding cell in
render grid, which are calculated as follows

 =   +  ,</p>
      <p>=   +  ,  =   ,
where  and  are indices of the row and column of the vertex in
2D grid of vertices derived after tessellation the patch:
 = ⌊ ℎ +  ⌋,  = ⌊   +  ⌋,
where ( ,  ) ∈ [0,1] are normalized real coordinates of the
vertex in 2D grid, provided by TE-shader, and  is a small
constant which compensates machine error of real numbers
representation.</p>
      <p>Geometry shader. This shader processes every (  ,   ,   )th
vertex, which results either in replacing the vertex
by a
constructed part of the polygonal model of the isosurface, or in
discarding the vertex</p>
      <p>without any geometry creation. The
processing starts with calculating of the number K of predefined
set of triangles (see Section 2):</p>
      <p>= ∑7=0 (2 ( (  ) &lt;  ∗)),
where p is running number of a vertex in the (  ,   ,   ) ℎ cell
of render grid, and  (  ) is the value of saturation of displacing
liquid at vertex   of the cell. If 
= 0 or 
= 255 (the cell
completely lies inside or outside the isosurface), then any
triangles are not created in the cell (geometry shader simply
exits). Otherwise, according to the table  (see Section 2), the
set of triangles, corresponding to  , is determined. Positions of
vertices of these triangles are calculated using Eq. (1), and then
triangles are emitted (see [2] for more detail). Note, that before
starting the visualization, the saturation field of the displacing
fluid is loaded into video memory as floating-point 3D-texture,
and the table  – as an integer 2D-texture.</p>
      <p>The triangles
produced
by the
geometry shader are
rasterized (fixed function of the pipeline), resulting into pixels
(fragments) forming the image of the isosurface model. Pixel
colors are calculated in parallel, independently of each other by
means of developed fragment shader based on the Phong
illumination model [2] with directional light source. Figure 2
shows general scheme of the
main visualization pipeline,
representing the whole workflow from simulated data till screen
image.</p>
      <sec id="sec-3-1">
        <title>Scalar field values (3D texture)</title>
      </sec>
      <sec id="sec-3-2">
        <title>Index table of MCtriangles (2D texture)</title>
      </sec>
      <sec id="sec-3-3">
        <title>Patches</title>
      </sec>
      <sec id="sec-3-4">
        <title>MC-threads</title>
        <p>tessellation shaders
geometry shader</p>
      </sec>
      <sec id="sec-3-5">
        <title>Polygonal isosurface model</title>
      </sec>
      <sec id="sec-3-6">
        <title>Isosurface image</title>
        <p>fragment shader</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Results</title>
      <p>Based on the method proposed, a software to visualize
results of simulation of unstable oil displacement from porous
media was created. Using the developed solution, a research of
about 70 steps of simulation of displacing oil by water on a
calculation grid of 1003 points was carried out. Figure 3 shows
the change of the isosurface of water saturation, corresponding
to the moment of breakthrough of displacement front. On the
figure one can see the characteristic tongues of the displacing
liquid (called «fingers»). The polygonal model of the isosurface
was constructed and visualized at screen resolution of
3840x2160 pixels using GeForce GTX 1080 Ti graphics card,
the average visualization rate was about 100 frames per second.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusions</title>
      <p>The paper proposes a new, distributed method to construct
and visualize on the GPU a polygonal model of the isosurface,
which provides real-time synthesis of quality images of the
isosurface on UltraHD screens. The proposed solution is based
on creation and execution of «marching cubes» threads on the
GPU using the developed set of tessellation, geometry and
fragment shaders. The novelty of the work consists in
distribution and parallelization of the «marching cubes» threads
between GPU cores by means of programmable tessellation of
quadrangular parametric graphic primitives – patches. Their
processing is high-performance due to hardware support at the
GPU architecture level and has low video memory overhead.</p>
      <p>The proposed method was implemented in visualization
software, and it was tested on data obtained in simulation of
unstable oil displacement by water. Approbation of the software
has confirmed that the methods and algorithms created meet the
requirements for visualization of the results of simulation of
unstable oil displacement. The developed solution can be used
in researches in oil&amp;gas industry, as well to build virtual
environment systems, virtual laboratories, scientific
visualization systems, etc.</p>
    </sec>
    <sec id="sec-6">
      <title>6. Acknowledgements</title>
    </sec>
    <sec id="sec-7">
      <title>7. References</title>
    </sec>
  </body>
  <back>
    <ref-list />
  </back>
</article>