MmProcess
The GeMA Mesh Mapping Process Plugin
Mesh mapping processes

Transfering data between two meshes

mm.meshMapping(meshId, bucketIndexObject, nodeDataIds, gaussDataIds, dstGauss, mappingOptions, translationMap)
Description: Transfers data from a source mesh to a destination mesh. The process deals with source/destination data on nodes and/or gauss points.
Parameters: meshId A string with the destination mesh id.
bucketIndexObject A bucket index object with the source mesh references stored in.
nodeDataIds A string with the id (or a lua table with various ids) of the source node data to be mapped on the destination mesh. Can be nil if parameter gaussDataIds is not.
gaussDataIds A string with the id (or a lua table with various ids) of the source gauss data to be mapped on the destination mesh. Can be nil if parameter nodeDataIds is not.
dstGauss A lua table of booleans which size is equal to the sum of sizes of parameter nodeDataIds and gaussDataIds tables. If boolean is false, it means that the corresponding value will be mapped on the nodes of the destination mesh. If boolean is true, the corresponding value will be mapped on the gauss points of the destination mesh.
mappingOptions An optional lua table with a set of flags defining options for the mesh mapping.
translationMap An optional lua table needed when the destination attributes, in the destination mesh, have different ids than the source ones. The given table should be indexed by the names of the source mesh ids, having as values de the names of the corresponding attribute ids on the destination mesh. If the x and y attributes from the source mesh should be mapped onto the a and b attributes of the destination mesh, this table should be equal to {x = "a", y = "b"}
Returns: Nothing.

In the code fragment below we want to map 'ux', 'uy' and 'p' data values from a source mesh. The two first values 'ux' and 'uy' are node values and will be transferred on gauss points of the destination mesh. The third value 'p' is a gauss value and will be transferred on nodes of the destination mesh. Before processing the mapping the first step is to create a bucket index of the elements of the source mesh. The bucket index object is the accelerating structure responsible to speed up the mapping process as explained here.

Important Note: it is the responsibility of the user to previously prepare the destination mesh to receive data. Depending on where the data will be stored (on nodes or on gauss points) the user may create the appropriate data values on the destination mesh.

local bucketIndex = mm.buildBucketIndex('srcMesh', 'cell') -- Bucket index of elements (required) of the source mesh
local dstGauss = {true, true, false} -- Where to transfer the data on destination mesh
-- Create data values in destination mesh to receive source data in accord with the dstGauss table
local dstMesh = modelData:mesh('dstMesh')
dstMesh:addGaussAttributeSet(ValueInfo('gauss attribute', {id = 'ux'}))
dstMesh:addGaussAttributeSet(ValueInfo('gauss attribute', {id = 'uy'}))
dstMesh:addNodeValueSet(ValueInfo('node attribute', {id = 'p'}))
local options = {
noDataMode = true, -- Will activate the `noData` mode
noDataValue = -999.9, -- Will set the `noData` value to -999.9
noDataEps = 0.0001, -- Will set the tolerency value to 0.0001
state = 0, -- Only last state will be mapped
interpType = 'idw', -- IDW interpolation will be used (cf. GeMA interpolator section)
interpParam = 2.0, -- IDW parameter (inverse distance squared in this case)
activeOnly = true, -- Only gauss points of active elements of the destination mesh will receive data
info = true, -- Will print informations during the mesh mapping
}
mm.meshMapping('dstMesh', bucketIndex, {'ux', 'uy'}, 'p', dstGauss, options)