78 lines
2.4 KiB
C
78 lines
2.4 KiB
C
#include "sph_worker_runtime_reports.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static int fail(const char *message)
|
|
{
|
|
fprintf(stderr, "%s\n", message);
|
|
return 1;
|
|
}
|
|
|
|
static void fill_options(sphlite_worker_options_t *options)
|
|
{
|
|
sphlite_worker_options_init(options);
|
|
options->solver_id = "SPH";
|
|
options->case_file = "case.inp";
|
|
options->ipc_name = "ipc";
|
|
options->log_path = "build-codex-unix/worker_runtime_report.log";
|
|
options->worker_id = "worker";
|
|
}
|
|
|
|
static void fill_ipc(sphlite_worker_ipc_t *ipc)
|
|
{
|
|
(void)sphlite_worker_ipc_init(ipc, "ipc", "cmd_block", "data_block");
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
sphlite_worker_options_t options;
|
|
sphlite_worker_ipc_t ipc;
|
|
sphlite_worker_runtime_reports_t reports;
|
|
sphlite_worker_data_exchange_t data;
|
|
sphlite_worker_particle_record_t particle;
|
|
sphlite_worker_force_record_t force;
|
|
|
|
fill_options(&options);
|
|
fill_ipc(&ipc);
|
|
sphlite_worker_runtime_reports_init(&reports, &options);
|
|
if (!reports.enabled ||
|
|
strstr(reports.log_path, "worker_runtime_report.log") == 0 ||
|
|
strstr(reports.particle_path,
|
|
"sphlite_cclite_particle_report.csv") == 0 ||
|
|
strstr(reports.force_path, "sphlite_cclite_force_report.csv") == 0) {
|
|
return fail("runtime report path initialization failed");
|
|
}
|
|
sphlite_worker_runtime_reports_prepare(&reports);
|
|
|
|
sphlite_worker_data_exchange_clear(&data);
|
|
data.particle_header.count = 1;
|
|
data.particle_header.nonfinite_count = 2;
|
|
data.force_header.count = 3;
|
|
data.force_header.total_force[0] = 4.0;
|
|
data.force_header.total_moment[1] = 5.0;
|
|
sphlite_worker_runtime_reports_log(&reports, &options, &ipc, &data,
|
|
SPHLITE_WORKER_COMMAND_IMPORT_LOADS, 6, 7,
|
|
SPHLITE_WORKER_STATE_DONE, 0, SPHLITE_WORKER_ERROR_OK, "ok");
|
|
|
|
sphlite_worker_particle_record_clear(&particle);
|
|
particle.particle_id_ext = 10;
|
|
particle.export_index = 1;
|
|
particle.internal_index = 2;
|
|
particle.phase = 1;
|
|
particle.status = 0;
|
|
particle.material_id = 3;
|
|
particle.section_id = 4;
|
|
sphlite_worker_runtime_reports_particle(&reports, 6, 1, &particle);
|
|
|
|
sphlite_worker_force_record_clear(&force);
|
|
force.particle_id_ext = 10;
|
|
force.export_index = 1;
|
|
force.internal_index = 2;
|
|
force.source_id = 3;
|
|
force.pair_id = 4;
|
|
force.contact_state = SPHLITE_WORKER_CONTACT_ACTIVE;
|
|
sphlite_worker_runtime_reports_force(&reports, 6, 1, &force);
|
|
return 0;
|
|
}
|