  Context: dynamo action in giant planets and rapidly rotating stars leads to a
broad variety of magnetic field geometries including small scale multipolar and
large scale dipole-dominated topologies. Previous dynamo models suggest that
solutions become multipolar once inertia becomes influential. Being tailored
for terrestrial planets, most of these models neglected the background density
stratification. Aims: we investigate the influence of the density
stratification on convection-driven dynamo models. Methods: three-dimensional
nonlinear simulations of rapidly rotating spherical shells are employed using
the anelastic approximation to incorporate density stratification. A systematic
parametric study for various density stratifications and Rayleigh numbers
allows to explore the dependence of the magnetic field topology on these
parameters. Results: anelastic dynamo models tend to produce a broad range of
magnetic field geometries that fall on two distinct branches with either strong
dipole-dominated or weak multipolar fields. As long as inertia is weak, both
branches can coexist but the dipolar branch vanishes once inertia becomes
influential. The dipolar branch also vanishes for stronger density
stratifications. The reason is the concentration of the convective columns in a
narrow region close to the outer boundary equator, a configuration that favors
non-axisymmetric solutions. In multipolar solutions, zonal flows can become
significant and participate in the toroidal field generation. Parker dynamo
waves may then play an important role close to onset of dynamo action leading
to a cyclic magnetic field behavior. Conclusion: Our simulations also suggest
that the fact that late M dwarfs have dipolar or multipolar magnetic fields can
be explained in two ways. They may differ either by the relative influence of
inertia or fall into the regime where both types of solutions coexist.
