Importing a Remote Client's Mesh

A client can bypass the SIMULIA Co-Simulation Services mapper and provide its own mapping services.

This page discusses:

In some cases, the client might prefer to perform its own field mapping and to bypass the SIMULIA Co-Simulation Services mapper. Typical cases include:

  • a client using non-standard element types that the SIMULIA Co-Simulation Services mapper does not support; or
  • particle and Lattice Boltzmann applications where the mapping is best performed by the solver because these methods use specialized mapping algorithms. In addition, the amount of data transfer is reduced.

The header file, SMACseApiMesh.h, defines additional services to import a remote mesh. The services to import a remote mesh are serial; you should call them from the main compute process, whether using serial or parallel mode.

Creating a Local Mesh to Represent the Remote Mesh

Use the SMACseCreateMesh function to create a local mesh object (see Creating a Mesh Object). This mesh object is used to hold the remote mesh; do not assign any node or element collection to it. The mesh name used by the client importing the remote mesh can be different from the remote mesh name; the association between the meshes is done through the Co-Simulation Configuration file. You must set the <mapOn> element to “NOMAP” on the <connection> element (see <connection> Element).

Use the SMACseRegisterMesh function to register the mesh object (see Registering the Mesh Object). Then, define the incoming and outgoing fields (see Creating a Field Type).

Once you register the interface model (see Registering the Interface Model), you can retrieve the remote mesh's node and element topology.

Example

The following example illustrates how to create a local mesh to represent a remote mesh and how to assign incoming and outgoing fields to the local mesh:

   // Create local mesh object

   SMACseMesh* mesh = SMACseCreateMesh("myMeshName");
   
   // Do NOT define any element and node collections 
   
   // Register Mesh
   SMACseRegisterMesh( mesh );
                  
   // You can now define fields on the mesh
   SMACseCreateFieldDefinition( "displacement",    SMACseFieldPos_atNode,          
                                SMACseFieldAlgType_Vector3d, SMACseFieldDataType_Double );
   SMACseCreateFieldDefinition( "force",           SMACseFieldPos_atNode,          
                                SMACseFieldAlgType_Vector3d, SMACseFieldDataType_Double );
   
    // Register Incoming and Outgoing Fields
    SMACseRegisterOutgoingField( "force",           "myMeshName");
    SMACseRegisterIncomingField( "displacement",    "myMeshName");

    // Register the interface model
    SMACseRegisterInterface();

Accessing the Remote Mesh Definition

The header file, SMACseApiMesh.h, defines additional services to retrieve and access the topology information of the remote mesh.

Retrieving the Remote Mesh

After you register the interface model, use the SMACseGetRemoteMesh function to retrieve the remote mesh's topology. The SMACseGetRemoteMesh function takes the following arguments:

iLocalMeshName
Local mesh name representing the remote mesh.
oNNodes
Number of nodes on the remote mesh.
oNElemCollections
Number of element collections on the remote mesh.
oNDim
Dimensionality of the remote mesh. Set to:
  • SMACseDim_2d for a 2D mesh
  • SMACseDim_3d for a 3D mesh
  • SMACseDim_Axi for an axisymmetric mesh
The SMACseGetRemoteMesh function returns a mesh handle to retrieve the topology information.

Unpacking the Remote Mesh Node Collection

Use the SMACseGetNodeCollection function to retrieve the node collection. The remote mesh can have only a single node collection. The SMACseGetNodeCollection function takes the following arguments:

iMeshHd
Mesh handle.
oLabels
Vector containing the node labels.
oCoordinates
Vector containing the nodal coordinates.

The vector size for oLabels and oCoordinates is based on the oNNodes and oNDim provided by SMACseGetRemoteMesh. Nodal field data is transferred in the order in which the nodes are defined in the node collection.

Unpacking the Remote Mesh Element Collections

Use the SMACseQueryElemCollection and SMACseGetElemCollection functions to retrieve the element collection information.

The SMACseQueryElemCollection function takes the following arguments:

iMeshHd
Mesh handle.
iCollection
Collection index.

The collection index is 0-based (that is, the first collection has an index equal to 0).

oNElems
Number of elements in the collection.
oNodesPerElem
Number of nodes per element.
The SMACseQueryElemCollection function returns a character string identifying the element topology.

The SMACseGetElemCollection function takes the following arguments:

iMeshHd
Mesh handle.
iCollection
Collection index.

The collection index is 0-based (that is, the first collection has an index equal to 0).

oLabels
Vector to node labels.
oConnectivity
Element connectivity.

Element field data is stored the order in which the elements are defined in the collection.

Example

The following example illustrates how to extract the topology information of a remote mesh:

   unisgned int nNodes = 0;
   unsigned int nElemCollections = 0;
   unsigned int dimension = 0;
   SMACseMesh* mesh = SMACseGetRemoteMesh( "myMeshName", nNodes, nElemCollections, dimension); 
   
   // Process the node labels and coordinates
   unsigned int* nodeLabels = (unsigned int *) malloc(nNodes*sizeof(int));
   double* coords = (double *) malloc(nNodes*dimension*sizeof(double)); 
   SMACseGetNodeCollection (mesh,nodeLabels,coords);
   
   // loop over all element collection
   for (unsigned int jCollection = 0; jCollection <nElemCollections; ++jCollection) {
       
       unsigned int nElems = 0;
       unsigned int nNodesPerElem = 0;
       const char* topology = SMACseQueryElemCollection( mesh, jCollection, &nElems, &nNodesPerElem );
       
       if (strcmp(topology,"SMACseSurfTopo_Tri3") == 0) {
            unsigend int* Tri3Labels = (unsigned int *) malloc(nElems*sizeof(int));
            unsigned int* Tri3Connectivity = (unsigned int *) malloc(nElems*nNodesPerElem*sizeof(int));
            SMACseGetElemCollection ( mesh, jCollection, myDb->Tri3Labels, myDb->Tri3Connectivity );
       } else if (strcmp(topology,"SMACseSurfTopo_Tri6") == 0) {
                             :              
       }    
   } // for element collections