Prepare SPHLite 0.2.0 development baseline
This commit is contained in:
@@ -17,24 +17,44 @@ int main(void)
|
||||
int minor = 0;
|
||||
int patch = 0;
|
||||
int count = 0;
|
||||
int warnings = 0;
|
||||
int step = 0;
|
||||
int ids[4];
|
||||
int phase[4];
|
||||
int status[4];
|
||||
int material_id[4];
|
||||
int section_id[4];
|
||||
double x[12];
|
||||
double v[12];
|
||||
double a[12];
|
||||
double rho[4];
|
||||
double pressure[4];
|
||||
double internal_energy[4];
|
||||
double temperature[4];
|
||||
double h[4];
|
||||
double time = 0.0;
|
||||
|
||||
if (SPHLITE_PHASE_SOLID != 4 || SPHLITE_STATUS_ACTIVE != 0) {
|
||||
return fail("C constants are not locked");
|
||||
}
|
||||
if (sphlite_get_particle_count(NULL) != -1) {
|
||||
return fail("null particle count pointer did not return -1");
|
||||
}
|
||||
if (sphlite_get_last_error(NULL, path, (int)sizeof(path)) != -1) {
|
||||
return fail("null last-error code pointer did not return -1");
|
||||
}
|
||||
if (sphlite_set_output_interval(0) != -1) {
|
||||
return fail("non-positive output interval did not return -1");
|
||||
}
|
||||
|
||||
ierr = sphlite_initialize();
|
||||
if (ierr != 0) return fail("initialize failed");
|
||||
|
||||
ierr = sphlite_get_version(&major, &minor, &patch);
|
||||
if (ierr != 0) return fail("get_version failed");
|
||||
if (major != 0 || minor != 1 || patch != 0) return fail("unexpected version");
|
||||
if (major != 0 || minor != 1 || patch != 1) return fail("unexpected version");
|
||||
|
||||
snprintf(path, sizeof(path), "%s/minimal_particles.inp", SPHLITE_TEST_DATA_DIR);
|
||||
snprintf(path, sizeof(path), "%s/minimal_particles_011.inp", SPHLITE_TEST_DATA_DIR);
|
||||
ierr = sphlite_read_inp(path);
|
||||
if (ierr != 0) return fail("read_inp failed");
|
||||
|
||||
@@ -43,12 +63,43 @@ int main(void)
|
||||
|
||||
ierr = sphlite_get_particle_count(&count);
|
||||
if (ierr != 0 || count != 4) return fail("particle count mismatch");
|
||||
ierr = sphlite_get_input_warning_count(&warnings);
|
||||
if (ierr != 0 || warnings != 0) return fail("warning count mismatch");
|
||||
|
||||
if (sphlite_get_particle_state(1, ids, phase, status, material_id, section_id,
|
||||
x, v, a, rho, pressure, internal_energy, temperature, h, &count) == 0) {
|
||||
return fail("small particle-state buffer did not fail");
|
||||
}
|
||||
|
||||
ierr = sphlite_get_particle_state(4, ids, phase, status, material_id, section_id,
|
||||
x, v, a, rho, pressure, internal_energy, temperature, h, &count);
|
||||
if (ierr != 0 || count != 4) return fail("particle state query failed");
|
||||
if (ids[0] != 1 || phase[0] != SPHLITE_PHASE_SOLID ||
|
||||
status[0] != SPHLITE_STATUS_ACTIVE) {
|
||||
return fail("particle state content mismatch");
|
||||
}
|
||||
|
||||
if (sphlite_get_particle_state(4, NULL, phase, status, material_id, section_id,
|
||||
x, v, a, rho, pressure, internal_energy, temperature, h, &count) != -1) {
|
||||
return fail("null particle-state array did not return -1");
|
||||
}
|
||||
|
||||
ierr = sphlite_advance_explicit(1.0e-6);
|
||||
if (ierr != 0) return fail("advance explicit failed");
|
||||
ierr = sphlite_get_current_time(&time, &step);
|
||||
if (ierr != 0 || step != 1 || time <= 0.0) return fail("time query failed");
|
||||
|
||||
ierr = sphlite_set_output_directory(SPHLITE_TEST_WORK_DIR);
|
||||
if (ierr != 0) return fail("set output directory failed");
|
||||
ierr = sphlite_write_output(step, time);
|
||||
if (ierr != 0) return fail("write output failed");
|
||||
|
||||
snprintf(path, sizeof(path), "%s/restart_c_api.tmp", SPHLITE_TEST_WORK_DIR);
|
||||
ierr = sphlite_write_restart(path);
|
||||
if (ierr != 0) return fail("write restart failed");
|
||||
ierr = sphlite_read_restart(path);
|
||||
if (ierr != 0) return fail("read restart failed");
|
||||
|
||||
ierr = sphlite_finalize();
|
||||
if (ierr != 0) return fail("finalize failed");
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "sphlite.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
int main()
|
||||
{
|
||||
if (sphlite::PhaseSolid != SPHLITE_PHASE_SOLID ||
|
||||
sphlite::StatusActive != SPHLITE_STATUS_ACTIVE) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sphlite::Session session;
|
||||
sphlite::Version version = sphlite::version();
|
||||
if (version.major != 0 || version.minor != 1 || version.patch != 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string input = std::string(SPHLITE_TEST_DATA_DIR) + "/minimal_particles_011.inp";
|
||||
sphlite::read_inp(input);
|
||||
sphlite::build_model();
|
||||
if (sphlite::particle_count() != 4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sphlite::ParticleState state = sphlite::particle_state();
|
||||
if (state.particle_id_ext.size() != 4 || state.phase[0] != sphlite::PhaseSolid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
session.close();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user