Skip to content

How to do Mapping between nonmatching meshes

Philipp Bucher edited this page May 16, 2017 · 17 revisions

This guide explains how to use the MappingApplication for exchanging Variable Data on an interface of nonmatching grids. The data is exchanged between an origin and a destination SubModelPart. These SubModelParts can, but don't have to, be in separate ModelParts. The Application works in serial as well as fully MPI-parallel. The usage does not change if executed in parallel.

In order to use the Application, the following steps have to be performed:

And example is provided at the end of this page.

Compiling

Compiling the MappingApplication is done by setting DMAPPING_APPLICATION=ON in the configure script used for the compilation of Kratos (in "cmake_build" folder)

Settings in the JSON file

The settings for a mapper are saved under mapper_settings in a list.

Basic Usage

The following settings are MANDATORY for a mapper:

  • mapper_type [string] Name of the mapper (Currently available options: NearestNeighbor and NearestElement)
  • interface_submodel_part_origin [string] Name of the interface submodelpart in the origin modelpart
  • interface_submodel_part_destination [string] Name of the interface submodelpart in the destination modelpart

Extended functionalities

These settings are for advanced users. It is recommended to not interfere with the search parameters.

  • echo_level [integer] specifies how much information the mapper prints
  1. no output is printed
  2. timing information is printed
  3. warnings and basic output
  4. very detailed output
  • search_radius [double] (default: automatic computation) search radius for the neighbor search
  • search_iterations [double] (default: 3) number of search iterations for the neighbor search, usually not needed
  • approximation_tolerance [double] needed for element-based mapper if the the projection fails

The default values are saved in the m_default_settings in the MapperFactory

Importing

Import the Application by using:

import KratosMultiphysics.MappingApplication as KratosMapping

Initializing the mapper

The mapper takes the full model parts of origin and destination as well as some parameters from a JSON file as input.

mapper = KratosMapping.MapperFactory(model_part_origin, 
				     model_part_destination, 
				     project_parameters_mapper_1)

Using the mapping functions

Basic Usage

  • Map (variable_origin, variable_destination, options): This function maps from the origin side of the interface to the destination side of the interface
  • InverseMap (variable_origin, variable_destination, options): This function maps from the destination side of the interface to the origin side of the interface
  • UpdateInterface (search radius): This function updates the interface in case of relative motion (e.g. sliding), it recomputes the neighboring pairs.

Extended functionalities

Besides the basic functionality of the mapper, extended functionalities are implemented to increase the usability.

Extended functionalities are provided through the usage of specific flags. These flags are the Flags-Objects implemented by Kratos and require a certain usage which is explained in this section.

Currently the following flags are implemented, for the respective functions:

  • Map/InverseMap ADD_VALUES: Instead of overwriting the nodal values with the mapped values, the mapped values are added to the existing ones (useful if for example several loads act on the interface, not only the mapped loads)
  • Map/InverseMap SWAP_SIGN: The sign of the mapped values is swapped

The flags have to be used with referring to their namespace: KratosMapping.MapperFactory.FLAGNAME

Alternatively they can also be addressed with the name of their mapper: i.e. mapper.SWAP_SIGN

Moreover their names can be redefined in python: i.e. add_values = KratosMapping.MapperFactory.ADD_VALUES

If several flags are to be used, then they have to be separated by a vertical bar ("|") i.e. (ADD_VALUES | SWAP_SIGN)

Example

JSON file

{
"mapper_settings": [
		{
		"mapper_type": "NearestNeighbor",
		"interface_submodel_part_origin": "Interface_Fluid",
		"interface_submodel_part_destination": "Interface_Structure"
		},
		{
		"mapper_type": "NearestElement",
		"interface_submodel_part_origin": "SubModelPart_Interface_1",
		"interface_submodel_part_destination": "SubModelPart_Interface_2",
		"search_radius" : 1.34,
		"search_iterations" : 10,
		"approximation_tolerance" : 1.77,
		"echo_level" : 3
		}
	]
}

Usage in MainKratos.py

import KratosMultiphysics.MappingApplication as KratosMapping

nearest_neighbor_mapper = KratosMapping.MapperFactory(
					main_modelpart_1,
					main_modelpart_2,
					["mapper_settings"][0])
													  
nearest_element_mapper = KratosMapping.MapperFactory(
					main_modelpart_3,
					main_modelpart_4,
					["mapper_settings"][1])
					
nearest_neighbor_mapper.Map(PRESSURE, PRESSURE)

nearest_element_mapper.InverseMap(VELOCITY, VELOCITY, KratosMapping.MapperFactory.ADD_VALUES)

swap_sign = KratosMapping.MapperFactory.SWAP_SIGN

nearest_element_mapper.Map(REACTION, POINT_LOAD, nearest_element_mapper.ADD_VALUES | swap_sign)

nearest_neighbor_mapper.UpdateInterface()

Project information

Getting Started

Tutorials

Developers

Kratos structure

Conventions

Solvers

Debugging, profiling and testing

HOW TOs

Utilities

Kratos API

Kratos Structural Mechanics API

Clone this wiki locally