Steps to Perform Mapping
Last update: 10.07.2023
Steps to Perform Mapping
This section describes the mapping workflow. It also provides simple APIs implementation examples, so it can be used to familiarize with the basic participant library API concepts. The details of the mapping algorithms can be found in the System Coupling User's Guide.
The steps involved in setting up and executing mapping of data are shown in Figure 1 and described in more details below.
Figure 1: Sequence of steps to execute mapping
The steps are described in more detail below. A couple of code examples for each target language is provided at the end of this section.
Step 1: Start
Start by initializing the participant library in standalone mode.
If using C++ or Python languages, this step involves instantiating the SystemCoupling
class (there can only be a single instance of this class at a time).
If using C or Fortran languages, in most cases nothing needs to be done for this step. The only exception is when a) running in parallel using one of the supported MPI versions and b) implementing the APIs on a subset of all parallel processes. In this case, start by calling syscStartStandaloneParallel
function in C or syscStartStandaloneF
function in Fortran and by passing the desired MPI communicator into those functions. See Execution in a Parallel Environment for more details.
Step 2: Set Up Mapping
Create and register variables, regions, and coupling interfaces.
Step 3: Register Heavyweight Data Access
In this step, the callback functions to access the participant's mesh and solution data must be registered. See Access to Heavyweight Data for more details.
Step 4: Update Inputs
During this step, mapping will be performed, and inputs (target values) will be brought up-to-date. The latest output (source) values on the source side of the interface will be used to fill the inputs.
Inputs update can be performed multiple times. If the source values change, this will be reflected in the target values.
Mapping examples
Sample code is provided, demonstrating the use of the participant library APIs to perform mapping.
For information on how to compile the code in these examples, see Compiling, Linking, and Executing Applications That Use the Participant Library.
Surface mapping example
In this example, the solution data is mapped between two surface regions. The mesh in each region consists of a single (unit square) quadrilateral element. The variable to be transferred from source to target is a scalar defined on elements. The variable is set to be extensive, although the choice of whether the variable is extensive or intensive is insignificant here, since the meshes are conformal.
The value on the source element is set to 33.3
. Since the meshes are identical on source and target, the expected result of mapping is that the target value also becomes 33.3
.
Figure 2 illustrates the problem setup.
Figure 2: Simple surface mapping example
C++
C
Fortran
Python
Volume Mapping Example
In this example, the solution data is mapped between two volume regions. The mesh in each region consists of a single (unit cube) hexahedral element. The variable to be transferred from source to target is a scalar defined on nodes. The variable is set to be intensive.
The values on the source element are set to 33.3
. Since the meshes are identical on source and target, the expected result of mapping is that the target values also become 33.3
.
Figure 3 illustrates the problem setup.
Figure 3: Simple volume mapping example