# Tékigô

## What it does ?

Our mesh-adaptation helper **Tékigô** is a wrapper to -hopefully- ease static mesh adaptations.

The difference from usual approaches is that

Tékigôcan rescale and mix several adaptation criteria before giving it to the mesh adaptation. In particular Global number of nodes and minimal mesh size area prioricontrolled.

Basically, this is a python interface to a mesh adaptation implementation, looking like this:

```
def custom_criteria(tkg_sol)
mesh = tkg_sol.load_current_mesh()
x_coor = mesh['/Coordinates/x']
y_coor = mesh['/Coordinates/y']
radius = np.hypot(x_coor-0.1, y_coor-0.1)
# create a radius centerend at (0.1, 0.1)
mask = np.where(radius < 0.01, 1.0, 0.0)
# create a mask.
# showing one 1cm close to point (0.1, 0.1)
# and zero elsewhere.
criteria = dict() # This dict store all the criterias to use
criteria['zonal_simple'] = mask
def main():
"""Example of usage """
tekigo_sol = TekigoSolution(
mesh='-MESH_PATH-', # Initial mesh
solution='-SOLAVG_PATH-', # Initial avg solution
out_dir='./Results', # Results of adaptation
overwrite_dir=True, # allow to overwrite previous result.
only_sol_vars=[], # solut. fields used for this adaption
only_msh_vars=[ # mesh fields used for this adaptation
'/Coordinates/x'
'/Coordinates/y'])
refine(
tekigo_sol,
custom_criteria,
dry_run=True, # If True, compute metric and exit, no adaption.
iteration_max=8, # maximum number of iteration
nnode_max=120000, # maximum numberof nodes
min_edge=0.7e-3, # minimum edge allowed (m)
l2_crit=0.005, # stop refinement iterations if mesh converges
coarsen=False # Forbid coarsening, only refinement allowed.
)
```

To get the idea, read the first tutorial Cooking with tekigo, beginner level. Indeed **Tékigô** is a kitchen to cook your custom metrics.

## Example

**Tékigô** can specify the target node-number after the adaptation and can mix up multiple variable fields as criteria of adaptation. **Fig.1** shows adaptations by **Tékigô** on different criteria (*i.e.* different variable fileds). The temperature and the absolute velocity field in the left were used as criteria of adaptation. The figures on the right are some example of adaptation based on those criteria. Low temperature and high absolute velocity zones are refined. The initial node-number was 34,684, the target node-number was 100,000 nodes for all those adaptations.

* Fig.1 Example of adaptation on a temperature and an absolute velocity field; V-T field is a mix of temperature and velocity field *

Tékigôdoes static adaptations : the simulations done during the first meshesmust be considered as garbage. The only simulations to be considered must be done on the same, last mesh. Tékigô does not do dynamic adaptation, where the mesh moves with a computation, becausehic sunt leones.

## Mesh adaptation tool underneath

Up to doday (Aug. 2020) , **Tékigô** relies on meshes created by MMG library, interpolations are done with the software HIP. The process is **sequential**.

In the future, the metrics could be provided to other parallel pipelines, such as the Yales2/MMG flow. Be aware that in all mesh adaptators, there are three steps:

- mesh generation
- interpolation on new mesh
- partitionning (if parallel)

…and each of the step could be done by a different software.

## Glossary

The algorithm of **Tékigô** will be explained, but only after several definitions. To figure it out, the idea of *metric* field should be explained beforehand.

### Metric :

*Metric* is the final quantity controling the future mesh *with respect to the current mesh*. It is , for ANY location -each node-, **the ratio btw the cell edge of the current mesh and the cell edge of the future mesh.**

- A metric of 0.5 means the future edge will be two times smaller
and the future cell volume, in 3D, will be 8 times smaller.
**Low value < 1 means stronger refinement** - A metric of 2 means the future edge will be 2 times bigger.
- A metric of 1 means NO ADAPTATION.

**Fig.2** is an example of *metric*. Here *metric* is set to near 1.0 around the upper and lower inlets to less refine the mesh, and it is set to around 0.7 to refine more in the rest of the field. *Metric* can be definded based on a single variable as well as multiple variables to mix up as shown in **Fig.1**.

* Fig.2 Metric on the temperature field of Fig.1 *

### Criterion :

A field used to **Flag** a zone for mesh refinement/coarsening.
Criterias are Used-defined fields known at each node of the mesh.

- Criterion = 0 : NO ADAPTATION
- Criterion = 1 : MAXIMUM REFINEMENT
- Criterion = -1 : MAXIMUM COARSENING

**Criterias are normalized btw -1 and 1 to allow blendings.**

### Ensuring the target node-number

Specifying *metric* implicitly set the node-number in advance of the adaptation. To enable to specify explicitly the target node-number, **Tékigô** has an outer iterative process as shown in **Fig.3**. It estimates the node-number based on the *metric* at first. If it’s far from the target, *metric* will be modified so that the node-number gets closer to the target. When the estimated number is enough close to the target, **Tékigô** finally runs an adaptation.

* Fig.3 inner iterative process process on the metric in Tékigô *

The process described in Fig.3 doesn’t always give a mesh of the targeted node-number or a mesh refined as specified by *metric* field. Now if we call it “inner loop”, we have another one called “outer loop” in **Tékigô** as shown in Fig.4. This loop allows to get closer to the target node-number gradually with the iterative way. In each loop, **Tékigô** checks criteria such as L2-norm and max iteration number if it continues the refinement by the outer loop or not. *L2-norm* in this process basically means how similar/different to/from a mesh is when compared to its specified *metric* field.

* Fig.4 Outer Iterative adaptation system in Tékigô *