<h1>Results</h1>

The current program reads its run-time parameters from an input file
called <code>\step-29.prm</code> that looks like this:
@code
subsection Mesh & geometry parameters
  # Distance of the focal point of the lens to the x-axis
  set Focal distance        = 0.3

  # Number of global mesh refinement steps applied to initial coarse grid
  set Number of refinements = 5
end


subsection Physical constants
  # Wave speed
  set c     = 1.5e5

  # Frequency
  set omega = 3.0e7
end


subsection Output parameters
  # Name of the output file (without extension)
  set Output file   = solution

  # A name for the output format to be used
  set Output format = vtu
end
@endcode

As can be seen, we set
$d=0.3$, which amounts to a focus of the transducer lens
at $x=0.5$, $y=0.3$. The coarse mesh is refined 5 times,
resulting in 160x160 cells, and the output is written in vtu
format. The parameter reader understands many more parameters
pertaining in particular to the generation of output, but we
need none of these parameters here and therefore stick with
their default values.

Here's the console output of the program in debug mode:

@code
> make run
[ 33%] Building CXX object CMakeFiles/step-29.dir/step-29.cc.o
[ 66%] Linking CXX executable step-29
[ 66%] Built target step-29
[100%] Run step-29 with Debug configuration
Generating grid... done (0.675234s)
  Number of active cells:  25600
Setting up system... done (0.375661s)
  Number of degrees of freedom: 51842
Assembling system matrix... done (1.96864s)
Solving linear system... done (0.861862s)
Generating output... done (1.66913s)
[100%] Built target run
@endcode

(Of course, execution times will differ if you run the program
locally.) The fact that most of the time is spent on assembling
the system matrix and generating output is due to the many assertions
that need to be checked in debug mode. In release mode these parts
of the program run much faster whereas solving the linear system is
hardly sped up at all:

@code
> make run
[ 33%] Building CXX object CMakeFiles/step-29.dir/step-29.cc.o
[ 66%] Linking CXX executable step-29
[ 66%] Built target step-29
[100%] Run step-29 with Release configuration
Generating grid... done (0.005207s)
  Number of active cells:  25600
Setting up system... done (0.018111s)
  Number of degrees of freedom: 51842
Assembling system matrix... done (0.021501s)
Solving linear system... done (0.590303s)
Generating output... done (0.090787s)
[100%] Built target run
@endcode

The graphical output of the program looks as follows:


<table align="center" class="doxtable">
  <tr>
    <td>
      <img src="https://www.dealii.org/images/steps/developer/step-29.v.png" alt="v = Re(u)">
    </td>
    <td>
      <img src="https://www.dealii.org/images/steps/developer/step-29.w.png" alt="w = Im(u)">
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <img src="https://www.dealii.org/images/steps/developer/step-29.intensity.png" alt="|u|">
    </td>
  </tr>
</table>

The first two pictures show the real and imaginary parts of
$u$, whereas the last shows the intensity $|u|$. One can clearly
see that the intensity is focused around the focal point of the
lens (0.5, 0.3), and that the focus
is rather sharp in $x$-direction but more blurred in $y$-direction, which is a
consequence of the geometry of the focusing lens, its finite aperture,
and the wave nature of the problem.

Because colorful graphics are always fun, and to stress the focusing
effects some more, here is another set of images highlighting how well
the intensity is actually focused in $x$-direction:

<table align="center" class="doxtable">
  <tr>
    <td>
      <img src="https://www.dealii.org/images/steps/developer/step-29.surface.png" alt="|u|">
    </td>
    <td>
      <img src="https://www.dealii.org/images/steps/developer/step-29.contours.png" alt="|u|">
    </td>
  </tr>
</table>


As a final note, the structure of the program makes it easy to
determine which parts of the program scale nicely as the mesh is
refined and which parts don't. Here are the run times for 5, 6, and 7
global refinements:

@code
> make run
[ 66%] Built target step-29
[100%] Run step-29 with Release configuration
Generating grid... done (0.008767s)
  Number of active cells:  25600
Setting up system... done (0.007043s)
  Number of degrees of freedom: 51842
Assembling system matrix... done (0.020942s)
Solving linear system... done (0.585853s)
Generating output... done (0.092681s)
[100%] Built target run

> make run
[ 66%] Built target step-29
[100%] Run step-29 with Release configuration
Generating grid... done (0.027986s)
  Number of active cells:  102400
Setting up system... done (0.070022s)
  Number of degrees of freedom: 206082
Assembling system matrix... done (0.075252s)
Solving linear system... done (4.13989s)
Generating output... done (0.369556s)
[100%] Built target run

> make run
[ 66%] Built target step-29
[100%] Run step-29 with Release configuration
Generating grid... done (0.186439s)
  Number of active cells:  409600
Setting up system... done (0.272828s)
  Number of degrees of freedom: 821762
Assembling system matrix... done (0.316252s)
Solving linear system... done (33.1424s)
Generating output... done (1.36328s)
[100%] Built target run
@endcode

Each time we refine the mesh once more, so the number of cells and degrees
of freedom roughly quadruples from each step to the next. As can be seen,
generating the grid, setting up degrees of freedom, assembling the
linear system, and generating output scale pretty closely to linear,
whereas solving the linear system is an operation that requires 8
times more time each time the number of degrees of freedom is
increased by a factor of 4, i.e. it is ${\cal O}(N^{3/2})$. This can
be explained by the fact that (using optimal ordering) the
bandwidth of a finite element matrix is $B={\cal O}(N^{(dim-1)/dim})$,
and the effort to solve a banded linear system using LU decomposition
is ${\cal O}(BN)$. This also explains why the program does run in 3d
as well (after changing the dimension on the
<code>UltrasoundProblem</code> object), but scales very badly and
takes extraordinary patience before it finishes solving the linear
system on a mesh with appreciable resolution, even though all the
other parts of the program scale very nicely.



<a name="step-29-extensions"></a>
<h3>Possibilities for extensions</h3>

An obvious possible extension for this program is to run it in 3d
&mdash; after all, the world around us is three-dimensional, and
ultrasound beams propagate in three-dimensional media. You can try
this by simply changing the template parameter of the principal class
in <code>main()</code> and running it. This won't get you very far,
though: certainly not if you do 5 global refinement steps as set in
the parameter file. You'll simply run out of memory as both the mesh
(with its $(2^5)^3 \cdot 5^3=2^{15}\cdot 125 \approx 4\cdot 10^6$ cells)
and in particular the sparse direct solver take too much memory. You
can solve with 3 global refinement steps, however, if you have a bit
of time: in early 2011, the direct solve takes about half an
hour. What you'll notice, however, is that the solution is completely
wrong: the mesh size is simply not small enough to resolve the
solution's waves accurately, and you can see this in plots of the
solution. Consequently, this is one of the cases where adaptivity is
indispensable if you don't just want to throw a bigger (presumably
%parallel) machine at the problem.
