<HTML>
<CENTER><A HREF = "https://sparta.github.io">SPARTA WWW Site</A> - <A HREF = "Manual.html">SPARTA Documentation</A> - <A HREF = "Section_commands.html#comm">SPARTA Commands</A> 
</CENTER>






<HR>

<H3>fix adapt command 
</H3>
<H3>fix adapt/kk command 
</H3>
<P><B>Syntax:</B>
</P>
<PRE>fix ID adapt Nfreq args ... 
</PRE>
<UL><LI>ID is documented in <A HREF = "fix.html">fix</A> command
<LI>adapt = style name of this fix command
<LI>Nfreq = perform grid adaptation every this many steps
<LI>args = all remaining args are identical to those defined for the <A HREF = "adapt_grid.html">adapt_grid</A> command 
</UL>
<P><B>Examples:</B>
</P>
<PRE>fix 1 adapt 1000 all refine particle 10 50
fix 1 adapt 1000 all coarsen particle 10 50
fix 1 adapt 500 subset refine coarsen particle 10 50
fix 1 adapt 10000 all refine surf 0.15 iterate 1 dir 1 0 0 
fix 10 adapt 1000 all refine coarsen value c_1[1] 5.0 10.0 iterate 2 
</PRE>
<P><B>Description:</B>
</P>
<P>This command performs on-the-fly adapatation of grid cells as a
simulation runs, either by refinement or coarsening or both.  Grid
adaptation can also be performed before or between simulations by
using the <A HREF = "adapt_grid.html">adapt_grid</A> command.
</P>
<P>Refinement means splitting one child cell into multiple new child
cells; the original child cell becomes a parent cell.  Coarsening
means combining all the child cells of a parent cell, so that the
child cells are deleted and the parent cell becomes a single new child
cell.  See <A HREF = "Section_howto.html#howto_8">Section howto 4.8</A> for a
description of the hierarchical grid used by SPARTA and a defintion of
child and parent cells.
</P>
<P>Grid adaptation can be useful for adjusting the grid cell sizes to the
current particle density distribution, or mean-free-path of particles,
or to other simulation attributes such as the presence of surface
elements.  A well-adapted grid can improve accuracy of the simulation
and/or reduce a simulation's computational cost.
</P>
<P>Adaptation is performed by this command once every <I>Nfreq</I> timesteps.
</P>
<P>All of the command arguments which appear after <I>Nfreq</I>, which
determine how adapation is done for both refinement and coarsening,
are exactly the same as for the <A HREF = "adapt_grid.html">adapt_grid</A> command.
</P>
<P>This includes a group-ID parameter which can be used to limit
adaptation to a subset of current grid cells.  See the
<A HREF = "adapt_grid.html">adapt_grid</A> command doc page for details.
</P>
<P>The one exception is that the <I>iterate</I> keyword cannot be used with
the fix adapt command.  Only a single iteration of the action1 and
action2 parameters (described on the <A HREF = "adapt_grid.html">adapt_grid</A> doc
page) can be performed each time grid adaptation is performed.
</P>
<P>Note that if you want the grid partitioning (and their particles) to
be rebalanced across processors after grid adaptation, you can use the
<A HREF = "fix_balance.html">fix_balance</A> command.  If you set the <I>Nfreq</I>
setting for this command and the <A HREF = "fix_balance.html">fix_balance</A>
command to the same value, then both operations will occur on the same
timesteps.  However, the fix balance command needs to appear in the
input script after the fix adapt command, if you want balancing to
occur after adaptation (whether the Nfreq values are the same or not).
</P>
<HR>

<P><B>Restart, output info:</B>
</P>
<P>No information about this fix is written to <A HREF = "restart.html">binary restart
files</A>.
</P>
<P>This fix computes a global scalar which is a flag for whether any grid
cells were adapted on the last timestep it was invoked.  The value of
the flag is 1 if any cells were refined or coarsened, else it is 0.
</P>
<P>This fix also computes a global vector of length 2.  The first value
is the number of cells which were refined.  The second is the number
which were coarsened.  Both on the last timestep the fix was invoked.
</P>
<HR>

<P>Styles with a <I>kk</I> suffix are functionally the same as the
corresponding style without the suffix.  They have been optimized to
run faster, depending on your available hardware, as discussed in the
<A HREF = "Section_accelerate.html">Accelerating SPARTA</A> section of the manual.
The accelerated styles take the same arguments and should produce the
same results, except for different random number, round-off and
precision issues.
</P>
<P>These accelerated styles are part of the KOKKOS package. They are only
enabled if SPARTA was built with that package.  See the <A HREF = "Section_start.html#start_3">Making
SPARTA</A> section for more info.
</P>
<P>You can specify the accelerated styles explicitly in your input script
by including their suffix, or you can use the <A HREF = "Section_start.html#start_7">-suffix command-line
switch</A> when you invoke SPARTA, or you can
use the <A HREF = "suffix.html">suffix</A> command in your input script.
</P>
<P>See the <A HREF = "Section_accelerate.html">Accelerating SPARTA</A> section of the
manual for more instructions on how to use the accelerated styles
effectively.
</P>
<HR>

<P><B>Restrictions:</B>
</P>
<P>Currently, if there are custom attributes defined for grid cells, grid
adaptation does not set new values for new grid cells created when
either refinement or coarsening takes place.  The new cells will have
zero values for their attributes.  This is because there is no simple
way to determine how new attribute values should be computed.  This
may be changed in the future.
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "adapt_grid.html">adapt_grid</A>, <A HREF = "fix_balance.html">fix balance</A>
</P>
<P><B>Default:</B> none
</P>
</HTML>
