686 lines
20 KiB
C++
686 lines
20 KiB
C++
#ifndef SPHLITE_HPP
|
|
#define SPHLITE_HPP
|
|
|
|
#include "sphlite_c_api.h"
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace sphlite {
|
|
|
|
enum Phase {
|
|
PhaseWater = SPHLITE_PHASE_WATER,
|
|
PhaseGas = SPHLITE_PHASE_GAS,
|
|
PhaseExplosive = SPHLITE_PHASE_EXPLOSIVE,
|
|
PhaseSolid = SPHLITE_PHASE_SOLID,
|
|
PhaseShell = SPHLITE_PHASE_SHELL,
|
|
PhaseBoundary = SPHLITE_PHASE_BOUNDARY,
|
|
PhaseCoupling = SPHLITE_PHASE_COUPLING,
|
|
PhaseSolidFailed = SPHLITE_PHASE_SOLID_FAILED,
|
|
PhaseShellFailed = SPHLITE_PHASE_SHELL_FAILED
|
|
};
|
|
|
|
enum Status {
|
|
StatusActive = SPHLITE_STATUS_ACTIVE,
|
|
StatusInactive = SPHLITE_STATUS_INACTIVE,
|
|
StatusFailed = SPHLITE_STATUS_FAILED,
|
|
StatusReserved = SPHLITE_STATUS_RESERVED
|
|
};
|
|
|
|
struct Version {
|
|
int major;
|
|
int minor;
|
|
int patch;
|
|
};
|
|
|
|
struct ParticleState {
|
|
std::vector<int> particle_id_ext;
|
|
std::vector<int> phase;
|
|
std::vector<int> status;
|
|
std::vector<int> material_id;
|
|
std::vector<int> section_id;
|
|
std::vector<double> x;
|
|
std::vector<double> v;
|
|
std::vector<double> a;
|
|
std::vector<double> rho;
|
|
std::vector<double> pressure;
|
|
std::vector<double> internal_energy;
|
|
std::vector<double> temperature;
|
|
std::vector<double> h;
|
|
};
|
|
|
|
struct WaterSummary {
|
|
double mass;
|
|
double momentum[3];
|
|
double max_pressure;
|
|
double min_density;
|
|
double max_density;
|
|
};
|
|
|
|
struct WaterDtLimits {
|
|
double cfl;
|
|
double acceleration;
|
|
double viscous;
|
|
};
|
|
|
|
struct GasSummary {
|
|
double volume;
|
|
double center[3];
|
|
double mean_pressure;
|
|
double max_pressure;
|
|
};
|
|
|
|
struct GasBubbleMetrics {
|
|
double equivalent_radius;
|
|
double radius_rate;
|
|
double center[3];
|
|
};
|
|
|
|
struct GasDtLimits {
|
|
double cfl;
|
|
double acceleration;
|
|
double dtcrit;
|
|
};
|
|
|
|
struct GasExtendedSummary {
|
|
double mass;
|
|
double momentum[3];
|
|
double density_range[2];
|
|
double dt_limits[3];
|
|
};
|
|
|
|
struct GasSourceSummary {
|
|
double mass_source;
|
|
double momentum_source[3];
|
|
double energy_source;
|
|
};
|
|
|
|
struct ExplosiveSummary {
|
|
int particle_count;
|
|
int reacted_count;
|
|
double lambda_range[3];
|
|
double released_totals[5];
|
|
double detonation_time_range[2];
|
|
};
|
|
|
|
struct ExplosiveReleaseBalance {
|
|
double mass_values[4];
|
|
double energy_values[2];
|
|
double momentum_values[3];
|
|
};
|
|
|
|
struct SolidSummary {
|
|
int active_count;
|
|
int failed_count;
|
|
double mass;
|
|
double momentum[3];
|
|
double kinetic_energy;
|
|
double internal_energy;
|
|
double max_von_mises;
|
|
double plastic_strain_range[2];
|
|
double damage_range[2];
|
|
double softening_range[2];
|
|
double dt_limits[3];
|
|
};
|
|
|
|
struct SolidParticleState {
|
|
std::vector<double> values;
|
|
std::vector<int> failure_status;
|
|
std::vector<int> reference_neighbor_count;
|
|
std::vector<int> reference_degenerate;
|
|
std::vector<int> correction_status;
|
|
};
|
|
|
|
struct SolidDiagnostics {
|
|
double max_strain_rate;
|
|
double max_acceleration;
|
|
double internal_force_residual;
|
|
};
|
|
|
|
struct SolidReferenceQuality {
|
|
int reference_neighbor_min;
|
|
double correction_det_min;
|
|
int correction_status;
|
|
};
|
|
|
|
struct CouplingRegionInfo {
|
|
std::string name;
|
|
int region_type;
|
|
int export_mode;
|
|
int import_mode;
|
|
int load_mode;
|
|
int distribution_mode;
|
|
int contact_state_mode;
|
|
int enabled;
|
|
int particle_count;
|
|
int facet_count;
|
|
};
|
|
|
|
struct CouplingParticleExport {
|
|
std::vector<int> ext_ids;
|
|
std::vector<int> internal_indices;
|
|
std::vector<int> phases;
|
|
std::vector<int> statuses;
|
|
std::vector<int> materials;
|
|
std::vector<int> sections;
|
|
std::vector<double> scalar_values;
|
|
std::vector<double> vector_values;
|
|
};
|
|
|
|
struct CouplingFacetExport {
|
|
std::vector<int> facet_ids;
|
|
std::vector<int> particle_ids;
|
|
std::vector<int> materials;
|
|
std::vector<int> sections;
|
|
std::vector<double> vector_values;
|
|
std::vector<double> area_values;
|
|
};
|
|
|
|
struct CouplingDiagnostics {
|
|
std::vector<double> values;
|
|
std::vector<int> counts;
|
|
};
|
|
|
|
struct CouplingLoadBalance {
|
|
double input_force[3];
|
|
double distributed_force[3];
|
|
double force_error;
|
|
double input_moment[3];
|
|
double distributed_moment[3];
|
|
double moment_error;
|
|
};
|
|
|
|
struct CouplingContactDiagnostics {
|
|
std::vector<int> counts;
|
|
std::vector<double> values;
|
|
};
|
|
|
|
class Error : public std::runtime_error {
|
|
public:
|
|
explicit Error(const std::string &message) : std::runtime_error(message) {}
|
|
};
|
|
|
|
inline std::string last_error_message()
|
|
{
|
|
int code = 0;
|
|
char message[256];
|
|
if (sphlite_get_last_error(&code, message, static_cast<int>(sizeof(message))) != 0) {
|
|
return "SPHLite C API parameter error";
|
|
}
|
|
return std::string(message);
|
|
}
|
|
|
|
inline void check(int ierr)
|
|
{
|
|
if (ierr != 0) {
|
|
throw Error(last_error_message());
|
|
}
|
|
}
|
|
|
|
inline void initialize()
|
|
{
|
|
check(sphlite_initialize());
|
|
}
|
|
|
|
inline void finalize()
|
|
{
|
|
check(sphlite_finalize());
|
|
}
|
|
|
|
inline Version version()
|
|
{
|
|
Version result = {0, 0, 0};
|
|
check(sphlite_get_version(&result.major, &result.minor, &result.patch));
|
|
return result;
|
|
}
|
|
|
|
inline void read_inp(const std::string &filename)
|
|
{
|
|
check(sphlite_read_inp(filename.c_str()));
|
|
}
|
|
|
|
inline void build_model()
|
|
{
|
|
check(sphlite_build_model());
|
|
}
|
|
|
|
inline int particle_count()
|
|
{
|
|
int count = 0;
|
|
check(sphlite_get_particle_count(&count));
|
|
return count;
|
|
}
|
|
|
|
inline void run_explicit()
|
|
{
|
|
check(sphlite_run_explicit());
|
|
}
|
|
|
|
inline ParticleState particle_state()
|
|
{
|
|
int count = particle_count();
|
|
ParticleState state;
|
|
state.particle_id_ext.resize(count);
|
|
state.phase.resize(count);
|
|
state.status.resize(count);
|
|
state.material_id.resize(count);
|
|
state.section_id.resize(count);
|
|
state.x.resize(3 * count);
|
|
state.v.resize(3 * count);
|
|
state.a.resize(3 * count);
|
|
state.rho.resize(count);
|
|
state.pressure.resize(count);
|
|
state.internal_energy.resize(count);
|
|
state.temperature.resize(count);
|
|
state.h.resize(count);
|
|
int actual = 0;
|
|
check(sphlite_get_particle_state(count, state.particle_id_ext.data(),
|
|
state.phase.data(), state.status.data(), state.material_id.data(),
|
|
state.section_id.data(), state.x.data(), state.v.data(), state.a.data(),
|
|
state.rho.data(), state.pressure.data(), state.internal_energy.data(),
|
|
state.temperature.data(), state.h.data(), &actual));
|
|
return state;
|
|
}
|
|
|
|
inline WaterSummary water_summary()
|
|
{
|
|
WaterSummary summary = {0.0, {0.0, 0.0, 0.0}, 0.0, 0.0, 0.0};
|
|
check(sphlite_get_water_summary(&summary.mass, summary.momentum,
|
|
&summary.max_pressure, &summary.min_density, &summary.max_density));
|
|
return summary;
|
|
}
|
|
|
|
inline WaterDtLimits water_dt_limits()
|
|
{
|
|
WaterDtLimits limits = {0.0, 0.0, 0.0};
|
|
check(sphlite_get_water_dt_limits(
|
|
&limits.cfl, &limits.acceleration, &limits.viscous));
|
|
return limits;
|
|
}
|
|
|
|
inline GasSummary gas_summary()
|
|
{
|
|
GasSummary summary = {0.0, {0.0, 0.0, 0.0}, 0.0, 0.0};
|
|
check(sphlite_get_gas_summary(&summary.volume, summary.center,
|
|
&summary.mean_pressure, &summary.max_pressure));
|
|
return summary;
|
|
}
|
|
|
|
inline GasBubbleMetrics gas_bubble_metrics()
|
|
{
|
|
GasBubbleMetrics metrics = {0.0, 0.0, {0.0, 0.0, 0.0}};
|
|
check(sphlite_get_gas_bubble_metrics(&metrics.equivalent_radius,
|
|
&metrics.radius_rate, metrics.center));
|
|
return metrics;
|
|
}
|
|
|
|
inline GasDtLimits gas_dt_limits()
|
|
{
|
|
GasDtLimits limits = {0.0, 0.0, 0.0};
|
|
check(sphlite_get_gas_dt_limits(&limits.cfl, &limits.acceleration,
|
|
&limits.dtcrit));
|
|
return limits;
|
|
}
|
|
|
|
inline GasExtendedSummary gas_extended_summary()
|
|
{
|
|
GasExtendedSummary summary = {
|
|
0.0, {0.0, 0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0, 0.0}};
|
|
check(sphlite_get_gas_extended_summary(&summary.mass, summary.momentum,
|
|
summary.density_range, summary.dt_limits));
|
|
return summary;
|
|
}
|
|
|
|
inline GasSourceSummary gas_source_summary()
|
|
{
|
|
GasSourceSummary summary = {0.0, {0.0, 0.0, 0.0}, 0.0};
|
|
check(sphlite_get_gas_source_summary(&summary.mass_source,
|
|
summary.momentum_source, &summary.energy_source));
|
|
return summary;
|
|
}
|
|
|
|
inline void set_ignition_point(double x, double y, double z, double time)
|
|
{
|
|
check(sphlite_set_ignition_point(x, y, z, time));
|
|
}
|
|
|
|
inline ExplosiveSummary explosive_summary()
|
|
{
|
|
ExplosiveSummary summary = {
|
|
0, 0, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0}};
|
|
check(sphlite_get_explosive_summary(&summary.particle_count,
|
|
&summary.reacted_count, summary.lambda_range, summary.released_totals,
|
|
summary.detonation_time_range));
|
|
return summary;
|
|
}
|
|
|
|
inline ExplosiveReleaseBalance explosive_release_balance()
|
|
{
|
|
ExplosiveReleaseBalance balance = {
|
|
{0.0, 0.0, 0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0, 0.0}};
|
|
check(sphlite_get_explosive_release_balance(balance.mass_values,
|
|
balance.energy_values, balance.momentum_values));
|
|
return balance;
|
|
}
|
|
|
|
inline SolidSummary solid_summary()
|
|
{
|
|
SolidSummary summary = {
|
|
0, 0, 0.0, {0.0, 0.0, 0.0}, 0.0, 0.0, 0.0,
|
|
{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0, 0.0}};
|
|
double values[SPHLITE_SOLID_SUMMARY_VALUE_COUNT] = {0.0};
|
|
check(sphlite_get_solid_summary(&summary.active_count,
|
|
&summary.failed_count, values, SPHLITE_SOLID_SUMMARY_VALUE_COUNT));
|
|
summary.mass = values[0];
|
|
summary.momentum[0] = values[1];
|
|
summary.momentum[1] = values[2];
|
|
summary.momentum[2] = values[3];
|
|
summary.kinetic_energy = values[4];
|
|
summary.internal_energy = values[5];
|
|
summary.max_von_mises = values[6];
|
|
summary.plastic_strain_range[0] = values[7];
|
|
summary.plastic_strain_range[1] = values[8];
|
|
summary.damage_range[0] = values[9];
|
|
summary.damage_range[1] = values[10];
|
|
summary.softening_range[0] = values[11];
|
|
summary.softening_range[1] = values[12];
|
|
summary.dt_limits[0] = values[13];
|
|
summary.dt_limits[1] = values[14];
|
|
summary.dt_limits[2] = values[15];
|
|
return summary;
|
|
}
|
|
|
|
inline SolidParticleState solid_particle_state()
|
|
{
|
|
int count = particle_count();
|
|
SolidParticleState state;
|
|
state.values.resize(SPHLITE_SOLID_PARTICLE_VALUE_COUNT * count);
|
|
state.failure_status.resize(count);
|
|
state.reference_neighbor_count.resize(count);
|
|
state.reference_degenerate.resize(count);
|
|
state.correction_status.resize(count);
|
|
int actual = 0;
|
|
check(sphlite_get_solid_particle_state(count, state.values.data(),
|
|
static_cast<int>(state.values.size()), state.failure_status.data(),
|
|
state.reference_neighbor_count.data(), state.reference_degenerate.data(),
|
|
state.correction_status.data(), &actual));
|
|
return state;
|
|
}
|
|
|
|
inline SolidDiagnostics solid_diagnostics()
|
|
{
|
|
double values[SPHLITE_SOLID_DIAGNOSTIC_VALUE_COUNT] = {0.0, 0.0, 0.0};
|
|
check(sphlite_get_solid_diagnostics(
|
|
values, SPHLITE_SOLID_DIAGNOSTIC_VALUE_COUNT));
|
|
SolidDiagnostics diagnostics = {values[0], values[1], values[2]};
|
|
return diagnostics;
|
|
}
|
|
|
|
inline SolidReferenceQuality solid_reference_quality()
|
|
{
|
|
int reference_neighbor_min = 0;
|
|
int correction_status = 0;
|
|
double values[SPHLITE_SOLID_REFERENCE_VALUE_COUNT] = {0.0};
|
|
check(sphlite_get_solid_reference_quality(&reference_neighbor_min,
|
|
&correction_status, values, SPHLITE_SOLID_REFERENCE_VALUE_COUNT));
|
|
SolidReferenceQuality quality = {
|
|
reference_neighbor_min, values[0], correction_status};
|
|
return quality;
|
|
}
|
|
|
|
inline void set_output_directory(const std::string &path)
|
|
{
|
|
check(sphlite_set_output_directory(path.c_str()));
|
|
}
|
|
|
|
inline void write_output(int step, double time)
|
|
{
|
|
check(sphlite_write_output(step, time));
|
|
}
|
|
|
|
inline void write_restart(const std::string &filename)
|
|
{
|
|
check(sphlite_write_restart(filename.c_str()));
|
|
}
|
|
|
|
inline void read_restart(const std::string &filename)
|
|
{
|
|
check(sphlite_read_restart(filename.c_str()));
|
|
}
|
|
|
|
inline int coupling_region_count()
|
|
{
|
|
int count = 0;
|
|
check(sphlite_coupling_get_region_count(&count));
|
|
return count;
|
|
}
|
|
|
|
inline CouplingRegionInfo coupling_region_info(int region_index)
|
|
{
|
|
char name[128];
|
|
CouplingRegionInfo info = {"", 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
check(sphlite_coupling_get_region_info(region_index, name,
|
|
static_cast<int>(sizeof(name)), &info.region_type, &info.export_mode,
|
|
&info.import_mode, &info.enabled, &info.particle_count,
|
|
&info.facet_count));
|
|
check(sphlite_coupling_get_region_modes(region_index, &info.load_mode,
|
|
&info.distribution_mode, &info.contact_state_mode));
|
|
info.name = std::string(name);
|
|
return info;
|
|
}
|
|
|
|
inline CouplingParticleExport coupling_export_particles(int region_index)
|
|
{
|
|
CouplingRegionInfo info = coupling_region_info(region_index);
|
|
int capacity = info.particle_count > 0 ? info.particle_count : 1;
|
|
CouplingParticleExport result;
|
|
result.ext_ids.resize(capacity);
|
|
result.internal_indices.resize(capacity);
|
|
result.phases.resize(capacity);
|
|
result.statuses.resize(capacity);
|
|
result.materials.resize(capacity);
|
|
result.sections.resize(capacity);
|
|
result.scalar_values.resize(SPHLITE_COUPLING_PARTICLE_SCALAR_COUNT * capacity);
|
|
result.vector_values.resize(3 * SPHLITE_COUPLING_PARTICLE_VECTOR_COUNT * capacity);
|
|
int count = 0;
|
|
check(sphlite_coupling_export_particles(region_index, capacity, &count,
|
|
result.ext_ids.data(), result.internal_indices.data(),
|
|
result.phases.data(), result.statuses.data(), result.materials.data(),
|
|
result.sections.data(), result.scalar_values.data(),
|
|
result.vector_values.data()));
|
|
result.ext_ids.resize(count);
|
|
result.internal_indices.resize(count);
|
|
result.phases.resize(count);
|
|
result.statuses.resize(count);
|
|
result.materials.resize(count);
|
|
result.sections.resize(count);
|
|
result.scalar_values.resize(SPHLITE_COUPLING_PARTICLE_SCALAR_COUNT * count);
|
|
result.vector_values.resize(3 * SPHLITE_COUPLING_PARTICLE_VECTOR_COUNT * count);
|
|
return result;
|
|
}
|
|
|
|
inline CouplingFacetExport coupling_export_facets(int region_index)
|
|
{
|
|
CouplingRegionInfo info = coupling_region_info(region_index);
|
|
int capacity = info.facet_count > 0 ? info.facet_count : 1;
|
|
CouplingFacetExport result;
|
|
result.facet_ids.resize(capacity);
|
|
result.particle_ids.resize(capacity);
|
|
result.materials.resize(capacity);
|
|
result.sections.resize(capacity);
|
|
result.vector_values.resize(3 * SPHLITE_COUPLING_FACET_VECTOR_COUNT * capacity);
|
|
result.area_values.resize(capacity);
|
|
int count = 0;
|
|
check(sphlite_coupling_export_facets(region_index, capacity, &count,
|
|
result.facet_ids.data(), result.particle_ids.data(),
|
|
result.materials.data(), result.sections.data(),
|
|
result.vector_values.data(), result.area_values.data()));
|
|
result.facet_ids.resize(count);
|
|
result.particle_ids.resize(count);
|
|
result.materials.resize(count);
|
|
result.sections.resize(count);
|
|
result.vector_values.resize(3 * SPHLITE_COUPLING_FACET_VECTOR_COUNT * count);
|
|
result.area_values.resize(count);
|
|
return result;
|
|
}
|
|
|
|
inline void coupling_apply_particle_forces(int region_index,
|
|
const std::vector<int> &export_indices,
|
|
const std::vector<double> &forces)
|
|
{
|
|
if (forces.size() != 3 * export_indices.size()) {
|
|
throw Error("coupling force vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_particle_forces(region_index,
|
|
static_cast<int>(export_indices.size()), export_indices.data(),
|
|
forces.data()));
|
|
}
|
|
|
|
inline void coupling_apply_facet_loads(int region_index,
|
|
const std::vector<int> &facet_ids,
|
|
const std::vector<double> &loads)
|
|
{
|
|
if (loads.size() != 3 * facet_ids.size()) {
|
|
throw Error("coupling facet load vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_facet_loads(region_index,
|
|
static_cast<int>(facet_ids.size()), facet_ids.data(), loads.data()));
|
|
}
|
|
|
|
inline void coupling_apply_facet_pressures(int region_index,
|
|
const std::vector<int> &facet_ids,
|
|
const std::vector<double> &pressures,
|
|
int distribution_mode,
|
|
int coupling_step)
|
|
{
|
|
if (pressures.size() != facet_ids.size()) {
|
|
throw Error("coupling pressure vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_facet_pressures(region_index,
|
|
static_cast<int>(facet_ids.size()), facet_ids.data(), pressures.data(),
|
|
distribution_mode, coupling_step));
|
|
}
|
|
|
|
inline void coupling_apply_facet_tractions(int region_index,
|
|
const std::vector<int> &facet_ids,
|
|
const std::vector<double> &tractions,
|
|
int distribution_mode,
|
|
int coupling_step)
|
|
{
|
|
if (tractions.size() != 3 * facet_ids.size()) {
|
|
throw Error("coupling traction vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_facet_tractions(region_index,
|
|
static_cast<int>(facet_ids.size()), facet_ids.data(), tractions.data(),
|
|
distribution_mode, coupling_step));
|
|
}
|
|
|
|
inline void coupling_apply_facet_resultants(int region_index,
|
|
const std::vector<int> &facet_ids,
|
|
const std::vector<double> &resultants,
|
|
int distribution_mode,
|
|
int coupling_step)
|
|
{
|
|
if (resultants.size() != 3 * facet_ids.size()) {
|
|
throw Error("coupling resultant vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_facet_resultants(region_index,
|
|
static_cast<int>(facet_ids.size()), facet_ids.data(), resultants.data(),
|
|
distribution_mode, coupling_step));
|
|
}
|
|
|
|
inline void coupling_apply_contact_state(int region_index,
|
|
const std::vector<int> &facet_ids,
|
|
const std::vector<double> &normals,
|
|
const std::vector<double> &gaps,
|
|
const std::vector<double> &penetrations,
|
|
const std::vector<double> &pressures,
|
|
int coupling_step)
|
|
{
|
|
std::size_t count = facet_ids.size();
|
|
if (normals.size() != 3 * count || gaps.size() != count ||
|
|
penetrations.size() != count || pressures.size() != count) {
|
|
throw Error("coupling contact state vector size mismatch");
|
|
}
|
|
check(sphlite_coupling_apply_contact_state(region_index,
|
|
static_cast<int>(count), facet_ids.data(), normals.data(), gaps.data(),
|
|
penetrations.data(), pressures.data(), coupling_step));
|
|
}
|
|
|
|
inline void coupling_apply_motion_boundary(int region_index,
|
|
int export_index,
|
|
int target_kind,
|
|
int mode,
|
|
const double target[3])
|
|
{
|
|
check(sphlite_coupling_apply_motion_boundary(region_index, export_index,
|
|
target_kind, mode, target));
|
|
}
|
|
|
|
inline void coupling_clear_imports()
|
|
{
|
|
check(sphlite_coupling_clear_imports());
|
|
}
|
|
|
|
inline CouplingLoadBalance coupling_load_balance()
|
|
{
|
|
CouplingLoadBalance balance = {};
|
|
check(sphlite_coupling_get_load_balance(balance.input_force,
|
|
balance.distributed_force, &balance.force_error, balance.input_moment,
|
|
balance.distributed_moment, &balance.moment_error));
|
|
return balance;
|
|
}
|
|
|
|
inline CouplingContactDiagnostics coupling_contact_diagnostics()
|
|
{
|
|
CouplingContactDiagnostics diagnostics;
|
|
diagnostics.counts.resize(SPHLITE_COUPLING_CONTACT_DIAGNOSTIC_COUNT_COUNT);
|
|
diagnostics.values.resize(SPHLITE_COUPLING_CONTACT_DIAGNOSTIC_VALUE_COUNT);
|
|
check(sphlite_coupling_get_contact_diagnostics(diagnostics.counts.data(),
|
|
static_cast<int>(diagnostics.counts.size()), diagnostics.values.data(),
|
|
static_cast<int>(diagnostics.values.size())));
|
|
return diagnostics;
|
|
}
|
|
|
|
inline CouplingDiagnostics coupling_diagnostics()
|
|
{
|
|
CouplingDiagnostics diagnostics;
|
|
diagnostics.values.resize(SPHLITE_COUPLING_DIAGNOSTIC_VALUE_COUNT);
|
|
diagnostics.counts.resize(SPHLITE_COUPLING_DIAGNOSTIC_COUNT_COUNT);
|
|
check(sphlite_coupling_get_diagnostics(diagnostics.values.data(),
|
|
static_cast<int>(diagnostics.values.size()), diagnostics.counts.data(),
|
|
static_cast<int>(diagnostics.counts.size())));
|
|
return diagnostics;
|
|
}
|
|
|
|
class Session {
|
|
public:
|
|
Session() : active_(true) { initialize(); }
|
|
|
|
~Session()
|
|
{
|
|
if (active_) {
|
|
sphlite_finalize();
|
|
}
|
|
}
|
|
|
|
Session(const Session &) = delete;
|
|
Session &operator=(const Session &) = delete;
|
|
|
|
void close()
|
|
{
|
|
if (active_) {
|
|
finalize();
|
|
active_ = false;
|
|
}
|
|
}
|
|
|
|
private:
|
|
bool active_;
|
|
};
|
|
|
|
} // namespace sphlite
|
|
|
|
#endif
|