Dilate field

../../../../_images/thumbnail4.png

Description

The dilate operation propagates the maximum nodal value of a cell to all other nodes of that cell.

Parameters

  • base: Base

    The input base

  • variables: list(str)

    The list of variables to dilate

  • passes: int, default = 1

    The number of times the dilate operation is applied to the base

  • memory_mode: bool, default = False

    If True, the modifications are done directly on the input base to limit memory usage. If False, a new base is created.

Preconditions

  • The variables to dilate must be located in node.

  • The base must be unstructured.

Postconditions

  • If memory_mode = False, the input base remains unchanged and the output base has the same structure as the input base.

  • If memory_mode = True, the input base is modified in-place and the returned base is the same object as the input base.

Usage

import antares
treatment = antares.Treatment('dilatefield')
treatment['base'] = base
treatment['variables'] = ['var1', 'var2']
treatment['passes'] = 2
dilated_base = treatment.execute()

or

import antares
dilated_base = antares.treatment.DilateField(
              base = base,
              variables = ['var1', 'var2'],
              passes = 2,)

Example

The following example shows the effect of the dilate field for 1 pass and 2 passes.

import os
import antares

# Prepare output folder
output_folder = os.path.join("OUTPUT", "TreatmentDilate")
os.makedirs(output_folder, exist_ok=True)

# Read example base
base = antares.io.Read(
    filename='../data/AMR/amr_example.h5',
    format='hdf_antares',)


# Apply dilate field treatment
dilated_base_1_pass = antares.treatment.DilateField(
    base=base,
    variables=['metric'],
    passes=1,
    )

dilated_base_2_passes = antares.treatment.DilateField(
    base=base,
    variables=['metric'],
    passes=2,
    )



# Dump base
antares.io.Dump(
    base=dilated_base_1_pass,
    filename='dilated_base_1_pass',
    folder=output_folder,
    format='hdf_antares',)

antares.io.Dump(
    base=dilated_base_2_passes,
    filename='dilated_base_2_passes',
    folder=output_folder,
    format='hdf_antares',)
../../../../_images/input1.png

Dilated field after 1 pass

../../../../_images/dilate_1_pass.png

Dilated field after 2 passes

../../../../_images/dilate_2_passes.png