83 lines
2.5 KiB
C++
83 lines
2.5 KiB
C++
#include "sphlite.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
int main()
|
|
{
|
|
if (SPHLITE_COUPLING_EXPORT_BOTH != 3 ||
|
|
SPHLITE_COUPLING_IMPORT_FORCE != 1) {
|
|
return 1;
|
|
}
|
|
|
|
sphlite::Session session;
|
|
std::string input =
|
|
std::string(SPHLITE_TEST_DATA_DIR) + "/coupling_shell_region_080.inp";
|
|
sphlite::read_inp(input);
|
|
sphlite::build_model();
|
|
|
|
if (sphlite::coupling_region_count() != 2) {
|
|
return 1;
|
|
}
|
|
sphlite::CouplingRegionInfo info = sphlite::coupling_region_info(2);
|
|
if (info.name != "SHELL_BOTH" ||
|
|
info.export_mode != SPHLITE_COUPLING_EXPORT_BOTH ||
|
|
info.import_mode != SPHLITE_COUPLING_IMPORT_FORCE ||
|
|
info.particle_count != 3 || info.facet_count != 3) {
|
|
return 1;
|
|
}
|
|
try {
|
|
(void)sphlite::coupling_region_info(99);
|
|
return 1;
|
|
} catch (const sphlite::Error &) {
|
|
}
|
|
|
|
sphlite::CouplingParticleExport particles = sphlite::coupling_export_particles(2);
|
|
if (particles.ext_ids.size() != 3 || particles.ext_ids[0] != 1 ||
|
|
particles.scalar_values.size() != 3 * SPHLITE_COUPLING_PARTICLE_SCALAR_COUNT ||
|
|
particles.vector_values.size() != 9 * SPHLITE_COUPLING_PARTICLE_VECTOR_COUNT) {
|
|
return 1;
|
|
}
|
|
sphlite::CouplingFacetExport facets = sphlite::coupling_export_facets(1);
|
|
if (facets.facet_ids.size() != 3 || facets.facet_ids[0] != 1 ||
|
|
facets.area_values[0] <= 0.0) {
|
|
return 1;
|
|
}
|
|
|
|
std::vector<int> indices(1, 1);
|
|
std::vector<double> forces;
|
|
forces.push_back(2.0);
|
|
forces.push_back(0.0);
|
|
forces.push_back(0.0);
|
|
sphlite::coupling_apply_particle_forces(2, indices, forces);
|
|
std::vector<int> facet_ids(1, 1);
|
|
std::vector<double> loads;
|
|
loads.push_back(0.0);
|
|
loads.push_back(3.0);
|
|
loads.push_back(0.0);
|
|
sphlite::coupling_apply_facet_loads(1, facet_ids, loads);
|
|
double target[3] = {0.0, 0.0, 1.0};
|
|
sphlite::coupling_apply_motion_boundary(2, 2,
|
|
SPHLITE_COUPLING_MOTION_VELOCITY, SPHLITE_COUPLING_MOTION_DIRECT,
|
|
target);
|
|
sphlite::CouplingDiagnostics diagnostics = sphlite::coupling_diagnostics();
|
|
if (diagnostics.values.size() != SPHLITE_COUPLING_DIAGNOSTIC_VALUE_COUNT ||
|
|
diagnostics.counts.size() != SPHLITE_COUPLING_DIAGNOSTIC_COUNT_COUNT ||
|
|
diagnostics.counts[3] != 2) {
|
|
return 1;
|
|
}
|
|
try {
|
|
std::vector<double> bad_forces(2, 0.0);
|
|
sphlite::coupling_apply_particle_forces(2, indices, bad_forces);
|
|
return 1;
|
|
} catch (const sphlite::Error &) {
|
|
}
|
|
sphlite::coupling_clear_imports();
|
|
diagnostics = sphlite::coupling_diagnostics();
|
|
if (diagnostics.counts[0] < 1) {
|
|
return 1;
|
|
}
|
|
session.close();
|
|
return 0;
|
|
}
|