.. _adaptivetopology-example:

#################
Adaptive Topology
#################

.. image:: ../../../images/vtfx/adaptivetopology_example.png
    :height: 250px
    :align: center

This example shows how to write a model where the topology changes between time steps (model is remeshed). 

The example writes out a very simple model which consists of one triangle in the first time step, which is then changed 
("remeshed") into two triangles in the second time step. The example also includes a scalar result (with per element 
mapping) for the two time steps.

To setup an adaptive topology model, you first write out all the unique element blocks and node blocks. You then specify 
the sequence of the element blocks in the :class:`cee::vtfx::GeometryBlock`. Use the 
:func:`addElementBlockForState() <cee::ctf::GeometryBlock::addElementBlockForState>` method to specify a given element 
block for a given state.

Please note that you either have to provide geometry setup for all time steps or one geometry setup for each step in 
your analysis. However, if you have a changing topology on only some time steps, you can reuse the element and node 
blocks by referring to them from several time steps.

.. literalinclude:: ../../../../../../EnvisionDesktop/Examples/VTFx/VTFxAdaptiveTopology/VTFxAdaptiveTopology.cpp
    :language: cpp
    :lines: 53-316