-
Notifications
You must be signed in to change notification settings - Fork 247
How to do Mapping between nonmatching meshes
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.
Compiling the MappingApplication is done by setting DMAPPING_APPLICATION=ON
in the configure
script used for the compilation of Kratos (in "cmake_build" folder)
Import the Application by using:
import KratosMultiphysics.MappingApplication as KratosMapping
The settings for a mapper are saved under mapper_settings
in a list.
The following settings are MANDATORY for a mapper:
-
mapper_type [string] Name of the mapper (Currently available options:
NearestNeighbor
andNearestElement
) - 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
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
- no output is printed
- timing information is printed
- warnings and basic output
- 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
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)
- 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.
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)
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()
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API