Skip to main content

Post-processing tools 2023 R2

DVS Features

Last update: 17.04.2023

Description of various features of the DVS API.

Description of various features of the DVS API.

DVS Features

Description of various features of the DVS API

Dynamic Visualization Store Features


Table of Contents


Delete Item API Overview

Sometimes solvers need to rewind to a previous timestep and begin writing new data for various reasons. The delete api facilitates this allowing users to make a call to delete specific timesteps or a collection of timesteps. This call is similar to the dvs_begin_update() and dvs_end_update() calls where all ranks must make the same call for each rank in parallel. The API calls for this are dvs_delete_item() (C API), DVS::IClient::delete_item() (C++ API), and delete_item() (Python API).

Note: Currently for the delete item api call to work the number of servers needs to match how the data was originally written. So if it was written using 3 servers everything should still be running with 3 servers when calling the delete item api. If the number of servers varies you will see inconsistent results on timesteps being fully deleted out of all caches.

Example Usage:

#include <string>
#include <chrono>
#include <thread>
static void logging_function(void* user_data, const char* message)
{
fprintf(stderr, message);
}
int main(int argc, char** argv)
{
std::string server_uri = "grpc://localhost:12345/";
DVS::IServer* server = DVS::CREATE_SERVER_INSTANCE(server_uri.c_str());
if (!server) {
//Error creating server
return -1;
}
std::string cache_uri = "hdf5://localhost/D:/my/cache/location";
//Set a cache uri location if saving/caching data
server->set_option("CACHE_URI", cache_uri.c_str());
uint32_t server_number = 0; //Zero based server number
uint32_t local_ranks = 1; //Number of local ranks for this specific server
server->startup(server_number, local_ranks);
//Turn on blocking for server and client side deduplication
std::string shared_secret = ""; // Can use a shared secret to authenticate clients with server
DVS::IClient* client = DVS::CREATE_CLIENT_INSTANCE(server, client_flags, shared_secret.c_str());
if (!client) {
//Error creating client
return -2;
}
dvs_log_flags log_flags = dvs_log_flags::LOG_ALL; //Turn on all logging for debugging
client->set_logger(new DVS::Logger(nullptr, log_flags, logging_function));
std::string dataset_name = "my_dataset";
uint32_t my_rank = 0; //Zero based rank number;
uint32_t num_global_ranks = 1; //Number of global ranks across all servers
uint32_t num_chunks = 1; //Number of chunks this rank is using, 1 if not using chunking
//Initialize dataset
client->begin_init(dataset_name.c_str(), my_rank, num_global_ranks, num_chunks);
client->set_unit_system("SI");
{
//Add a part
dvs_part_info part_info;
part_info._id = 1;
part_info._name = "Part 1";
part_info._structured = 0;
part_info._chunking = 0;
part_info._metadata_num_pairs = 0;
part_info._metadata_keys = nullptr;
part_info._metadata_vals = nullptr;
client->add_part_info(&part_info, 1);
}
{
//Add a var
dvs_var_info var_info;
var_info._id = 1;
var_info._name = "Var 1";
var_info._unit = "";
var_info._unit_label = "";
var_info._metadata_num_pairs = 0;
var_info._metadata_keys = nullptr;
var_info._metadata_vals = nullptr;
client->add_var_info(&var_info, 1);
}
client->end_init();
//Delete all timesteps after 5.5 seconds
//See the DVS Cache URI section on Query Stanza's for more information on filtering.
//The delete item API only supports timestep.time objects currently.
client->delete_item(my_rank, "/timestep.time/gte/5.5");
uint32_t num_pending = 1;
uint32_t num_complete = 0;
//Wait until the server finished before shutting it down or the write operations may not complete
while (num_pending > 0) {
dvs_ret error = server->get_timestep_count(num_pending, num_complete);
if (error != DVS_NONE) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
API for solvers to use to send data to EnSight servers.
virtual void set_logger(ILogger *logger)=0
Set the logger interface to use.
virtual dvs_ret set_unit_system(const char *system)=0
Set the unit system we are using for this session (optional)
virtual dvs_ret delete_item(uint32_t update_num, uint32_t rank, const char *filter)=0
Delete an item.
virtual dvs_ret add_part_info(const dvs_part_info *part_info, uint32_t num_parts)=0
Add part information for session.
virtual dvs_ret add_var_info(const dvs_var_info *var_info, uint32_t num_vars)=0
Add variable information for session.
virtual dvs_ret end_init()=0
Finish initialization for this rank.
virtual dvs_ret begin_init(const char *dataset_name, uint32_t current_rank, uint32_t total_ranks, uint32_t num_chunks)=0
Begins initialization for this rank.
Interface class used to run a dynamic data server in a thread accepting incoming client connections.
virtual void set_option(const char *key, const char *value)=0
Set a specific option on the server, these are used during startup See See Server Options.
virtual dvs_ret startup(uint32_t server_number, uint32_t local_ranks)=0
Start the server.
virtual dvs_ret get_timestep_count(uint32_t &num_pending, uint32_t &num_complete) const =0
return the current number of pending and complete timesteps in the server
C++ Client API for using the Dynamic Visualization Store.
DVS_DLL_EXPORT void DESTROY_CLIENT_INSTANCE(DVS::IClient *destroy)
Destruction method for a client created with CREATE_CLIENT_INSTANCE.
DVS_DLL_EXPORT DVS::IClient * CREATE_CLIENT_INSTANCE(DVS::IServer *server, dvs_client_flags flags, const char *secret)
Factory method to create a dynamic data client interface instance.
C++ Server API for using Dynamic Visualization Store Server.
DVS_DLL_EXPORT IServer * CREATE_SERVER_INSTANCE(const char *uri)
Create a DVS::IServer instance for clients to connect to.
DVS_DLL_EXPORT void DESTROY_SERVER_INSTANCE(DVS::IServer *destroy)
Destroy the server instance (also shutting it down if needed)
Contains enums used in C/C++ API.
dvs_log_flags
Flags to control logging filters.
@ LOG_ALL
Log all messages.
dvs_client_flags
Flags for specific server setup.
@ DEDUP
Do not send duplicate data to server.
@ BLOCK_FOR_SERVER
Clients should block for servers to be initialized before sending data.
@ NODE
This is a field variable per each node of a part's mesh.
int32_t dvs_ret
Return value of methods, TODO.
#define DVS_NONE
No detected error has occurred.
Struct holding information for a part's definition.
char ** _metadata_vals
UTF-8 Compatible value, each array should be null terminate.
char * _name
UTF-8 Compatible name of part [null terminated], max name length visible in GUI == 79,...
uint8_t _structured
Currently Unused.
uint32_t _id
Unique identifier for part, MUST BE > 0.
uint32_t _metadata_num_pairs
Number of arrays in _metadata_keys/_metadata_vals.
char ** _metadata_keys
UTF-8 Compatible key , each array should be null terminated.
uint8_t _chunking
1 if using chunks
Struct holding information for a variable's definiton.
char * _unit_label
UTF-8 Compatible label, see: https://nexusdemo.ensight.com/docs/python/html/ENS_UNITSSchema....
char * _unit
UTF-8 Compatible unit type, see: https://nexusdemo.ensight.com/docs/python/html/ENS_UNITSSchema....
enum dvs_var_type _type
Type of variable, see dvs_var_type enum (dynamic_visualization_store_enums.h)
char ** _metadata_keys
UTF-8 Compatible key , each array should be null terminated.
uint32_t _metadata_num_pairs
Number of arrays in _metadata_keys/_metadata_vals.
uint32_t _id
Unique id for variable.
char ** _metadata_vals
UTF-8 Compatible value, each array should be null terminated.
enum dvs_var_location _location
Location of variable (case/part/element/node), see dvs_var_location enum (dynamic_visualization_store...
char * _name
UTF-8 Compatible name of variable [null terminated], max name length visible in the GUI == 49,...
int main(int argc, char **argv)
Main method of test client application.