Data API

The data API is responsible for transferring field data between the client and the SIMULIA Co-Simulation Services.

This page discusses:

You access a field by specifying the interface region, collection, and field type that defines the field.

The field values are specified in a memory buffer in the order in which the members (nodes or elements) are defined within a collection. The memory required to store the field depends on the number of members in the collection, the multiplicity, and the data type.

The algebraic type specifies whether the field is a scalar, vector, or tensor field.

The algebraic type, along with the spatial dimension, defines a field’s multiplicity. The multiplicity is the number of field values stored per member.

All vector and tensor fields are transferred in the global Cartesian coordinate system. The client is responsible for providing the proper transformation to and from the global Cartesian coordinate system.

There are two data transactions:

  • transferring field data from the SIMULIA Co-Simulation Services to the client; and
  • transferring field data from the client to the SIMULIA Co-Simulation Services.

Transferring Field Data from the Co-Simulation Services to the Client

Use the SMACseGetField function to retrieve an incoming field from the SIMULIA Co-Simulation Services. The SMACseGetField function takes the following arguments:

iFieldName
Field type of the incoming field.
iRegionName
Region name that the field spans.
iCollectionName
Node or element collection name depending on whether it is a nodal- or element-based field.

If the collection name is not specified for nodal fields, the field data for all nodes on the region is provided.

iNMembers
Number of members in iMembers. This argument is reserved for future use.
iMembers
Member list. This argument is reserved for future use.
iTimeStamp
Time the field is to be retrieved. Field values are interpolated between the previous coupling step and the target time.

The time should be between the previous target time and the current target time.

oAppBuffer
Address of the client’s memory buffer into which to copy field data.
iMaxSizeInBytes
Memory buffer size in bytes.
oMissingMembers
Byte array indicating missing members.

iFieldName, iRegionName, and iCollectionName identify the subset of the field.

The client must allocate a memory buffer for oAppBuffer, such that the SIMULIA Co-Simulation Services can copy the field data to the client’s memory. The maximum size parameter, iMaxSizeInBytes, ensures that the SIMULIA Co-Simulation Services does not overwrite your memory. The required memory is the product of the number of members in the collection, the multiplicity of the field type, and the data type size. For example, assume you have a nodal 3D vector field using double precision. If there are 20 nodes in the collection, the buffer size needs to be 20 members × 3 values per member × 8 bytes for double precision.

Missing members are nodes or elements for which the mapper neighborhood search failed; therefore, field data cannot be mapped at these locations. Missing member treatment is intended for a small number of failures. Depending on the field type, there are various ways of providing a localized treatment. For example, when mapping displacements, you can choose to interpolate values from neighboring nodes; when mapping fluxes, you can assign a zero value at a local spot without sacrificing global conservation across the interface.

There are several methods of treating missing members:

  • If oMissingMembers is NULL and the Co-Simulation Configuration file does not specify how to treat missing members, an error is issued and the simulation is ended.
  • If oMissingMembers is NULL and the Co-Simulation Configuration file specifies how to treat missing members, the appropriate treatment is applied. For more information, see Mapping Specification.
  • If an oMissingMembers vector is provided, its entries are set to one to indicate the member is missing members. In this case, a warning is issued and the client is responsible for providing a field value for the missing member.

Example

The following example illustrates the SMACseGetField function:

                                           :
         unsigned int buffSizeInBytes = nInterfaceDof*sizeof(double);
         SMACseGetField( "force", "Mesh B", "", mesh_B.getNumNodes(), mesh_B.labels(), t+dT, f_b, buffSizeInBytes, NULL);
                                            :

Transferring Field Data from the Client to the Co-Simulation Services

The SIMULIA Co-Simulation Services calls the client's putFieldFunction to copy field data from the client's memory to the SIMULIA Co-Simulation Services memory buffer. putFieldFunction is a call-back function; it is a function that you need to write to copy your application’s field data to the SIMULIA Co-Simulation Services memory.

Both putFieldFunction and userData are registered when you establish a connection with the SIMULIA Co-Simulation Services (see Establishing Connections). The userData variable is an opaque pointer to an application’s data object. You can define userData to provide access to your client's data without having to use global variables.

putFieldFunction is called by the SIMULIA Co-Simulation Services for each outgoing field on a collection basis. putFieldFunction needs to fill the SIMULIA Co-Simulation Services memory buffer with the field values in the order in which the members are defined in the collection.

Example

The following example illustrates the putFieldFunction function:

void myPutField(const char* fieldType, const char* meshName, const char* collectionName, 
                const unsigned int nMembers, int* members, void* targetBuffer, void * userData)
{
    double* target = (double *) targetBuffer;
    if (strcasecmp(fieldType,"pressure") == 0) {
      for (unsigned int i1 = 0; i1 < nMembers; i1++) target[i1] =  ….   
           // copy pressure from application memory space
           // you can use userData to get access to the application’s pressures
           
    } if (strcasecmp(fieldType,"temperature") == 0) {
      for (unsigned int i1 = 0; i1 < nMembers; i1++) target[i1] =  ….   
           // copy temperature from application memory space
           // you can use userData to get access to the application’s pressures
    }
}