GRIT
ConfigFile()
Parameters()
Engine2D()
Simplex0()
Simplex1()
Simplex2()
Utility functions

To make GRIT accessible for those who are more comfortable writing Python code, we provide the following interface which contains the necessary classes and functions to recreate the existing C++ demos. The GRIT source code also includes Python versions of a subset of the C++ demos, these can be found in the 'GRIT/GRIT/bin' folder.

Classes and member functions

ConfigFile()

load(file_name,trow_on_errors=true)
exist()
clear()
get_value(name)
get_value(name,default_value)
get_value(operation_name,label_value,parameter_name)
get_value(operation_name,label_value,parameter_name,default_value)

example:

import pygrit as GRIT
...
cfg_filename = '../bin/my_cfg_file.cfg'
settings = GRIT.ConfigFile()
settings.load(cfg_filename)
settings.get_value('txt_filename', 'example.txt')
settings.get_value('steps', '100')

Parameters()

set_upper_threshold_attribute(name, value)
set_lower_threshold_attribute(name, value)

example:

import pygrit as GRIT
...
cfg_filename = '../bin/tutorial_contact.cfg'
settings = GRIT.ConfigFile()
settings.load(cfg_filename)
parameters = GRIT.make_parameters_from_config_file(settings)
parameters.set_lower_threshold_attribute('refinement', refinement_attribute_name)
parameters.set_lower_threshold_attribute('interface_refinement', refinement_attribute_name)
parameters.set_upper_threshold_attribute('coarsening', coarsening_attribute_name)
parameters.set_upper_threshold_attribute('interface_coarsening', coarsening_attribute_name)

Engine2D()

update(parameters)
create_attribute(name, dimension)
get_all_simplices()
in_phase(label, simplex0)
in_phase(label, simplex1)
in_phase(label, simplex2)
is_dimension(label, simplex0)
is_dimension(label, simplex1)
is_dimension(label, simplex2)
filter(simplex_set, module_name, condition_name, info)

example:

import pygrit as GRIT
...
cfg_filename = '../bin/tutorial_vortex_in_a_box.cfg'
settings = GRIT.ConfigFile()
settings.load(cfg_filename)
parameters = GRIT.make_parameters_from_config_file(settings)
engine = GRIT.Engine2D()
engine.update(parameters)
refinement_attribute_name = 'my_refinement_values'
engine.create_attribute(refinement_attribute_name, 1)
all = engine.get_all_simplices()
...
class Info:
  label1 = north_object_label
  label2 = south_object_label
def is_contact_surface(engine, simplex, info):
  if engine.is_dimension(1,simplex) or engine.is_dimension(0,simplex):
   return engine.in_phase(info.label1,simplex) and engine.in_phase(info.label2,simplex)
contact = engine.filter(all,__name__,'is_contact_surface',Info())

Simplex0()


Simplex1()


Simplex2()


Utility functions

get_data_file_path(file_name)
generate_filename(prefix, frame, extension)
make_parameters_from_config_file(config_file)
init_engine_with_mesh_file(file_name, parameters, engine)
svg_draw(file_name, engine, parameters, attribute_name_x='current', attribute_name_y='current')
make_phase(engine, label)
make_phase(engine, simplexset)
get_sub_range(engine, phase, name, values, vertex_attribute)
get_sub_range(engine, phase, name, values, edge_attribute)
get_sub_range(engine, phase, name, values, face_attribute)
get_sub_range_current(engine, phase, x, y)
get_sub_range_target(engine, phase, x, y)
set_sub_range(engine, phase, name, values, vertex_attribute)
set_sub_range(engine, phase, name, values, edge_attribute)
set_sub_range(engine, phase, name, values, face_attribute)
set_sub_range_current()
set_sub_range_target(engine, phase, x, y, using_partial_data=false)
clear_attribute(engine, name, value, vertex_attribute)
clear_attribute(engine, name, value, edge_attribute)
clear_attribute(engine, name, value, face_attribute)