This commit is contained in:
@@ -18,6 +18,24 @@ static int check_ierr(int ierr, int code)
|
||||
return code;
|
||||
}
|
||||
|
||||
static int file_contains(const char *path, const char *needle)
|
||||
{
|
||||
FILE *fp = fopen(path, "r");
|
||||
char line[512];
|
||||
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
while (fgets(line, (int)sizeof(line), fp) != NULL) {
|
||||
if (strstr(line, needle) != NULL) {
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ierr = 0;
|
||||
@@ -61,6 +79,15 @@ int main(void)
|
||||
int shell_sample_count = -1;
|
||||
int shell_last_element = -1;
|
||||
int node_ids[1] = {2};
|
||||
int source_ids[1] = {42};
|
||||
int load_mode[1] = {1};
|
||||
int valid_flags[1] = {1};
|
||||
int bad_node_ids[1] = {9999};
|
||||
int coupling_accepted = -1;
|
||||
int coupling_rejected_nonfinite = -1;
|
||||
int coupling_rejected_unknown = -1;
|
||||
int coupling_rejected_capacity = -1;
|
||||
int source_accepted = -1;
|
||||
int elem_nodes[4];
|
||||
int facet_id[8];
|
||||
int elem_id[8];
|
||||
@@ -72,6 +99,11 @@ int main(void)
|
||||
double normal[3 * 8];
|
||||
double area[8];
|
||||
double force[3] = {5.0, 1.0, -2.0};
|
||||
double bad_force[3] = {NAN, 0.0, 0.0};
|
||||
double coupling_force[3] = {0.0, 0.0, 0.0};
|
||||
double coupling_moment[3] = {0.0, 0.0, 0.0};
|
||||
double source_force[3] = {0.0, 0.0, 0.0};
|
||||
double source_moment[3] = {0.0, 0.0, 0.0};
|
||||
double disp[3] = {0.0, 0.0, 0.0};
|
||||
double vel[3] = {0.0, 0.0, 0.0};
|
||||
double acc[3] = {0.0, 0.0, 0.0};
|
||||
@@ -130,7 +162,7 @@ int main(void)
|
||||
|
||||
ierr = femlite_get_version(&major, &minor, &patch);
|
||||
if (ierr != 0) return check_ierr(ierr, 2);
|
||||
if (major != 0 || minor != 6 || patch != 3) return 3;
|
||||
if (major != 0 || minor != 6 || patch != 4) return 3;
|
||||
|
||||
ierr = femlite_read_inp("examples/c3d4_one_element.inp");
|
||||
if (ierr != 0) return check_ierr(ierr, 4);
|
||||
@@ -401,16 +433,123 @@ int main(void)
|
||||
if (ierr != 0) return check_ierr(ierr, 11);
|
||||
if (nfacet != 4 || max_face_nodes != 3) return 12;
|
||||
|
||||
ierr = femlite_get_coupling_surface_count(&nfacet, &max_face_nodes);
|
||||
if (ierr != 0) return check_ierr(ierr, 1301);
|
||||
if (nfacet != 4 || max_face_nodes != 3) return 1302;
|
||||
|
||||
ierr = femlite_get_boundary_facets(8, 8, facet_id, elem_id, face_id,
|
||||
facet_nnode, facet_conn, x, vnod,
|
||||
normal, area);
|
||||
if (ierr != 0) return check_ierr(ierr, 13);
|
||||
if (facet_id[0] != 1 || elem_id[0] != 1 || facet_nnode[0] != 3) return 14;
|
||||
|
||||
ierr = femlite_clear_sph_forces();
|
||||
ierr = femlite_get_coupling_surface_facets(8, 8, facet_id, elem_id,
|
||||
face_id, facet_nnode,
|
||||
facet_conn, x, vnod, normal,
|
||||
area);
|
||||
if (ierr != 0) return check_ierr(ierr, 1303);
|
||||
if (facet_id[0] != 1 || elem_id[0] != 1 || facet_nnode[0] != 3) return 1304;
|
||||
|
||||
ierr = femlite_clear_coupling_loads();
|
||||
if (ierr != 0) return check_ierr(ierr, 15);
|
||||
ierr = femlite_apply_sph_nodal_forces(1, node_ids, force);
|
||||
ierr = femlite_apply_coupling_nodal_forces(0, node_ids, force, source_ids,
|
||||
load_mode, valid_flags);
|
||||
if (ierr != 0) return check_ierr(ierr, 1313);
|
||||
ierr = femlite_get_coupling_load_diagnostics(
|
||||
coupling_force, coupling_moment, &coupling_accepted,
|
||||
&coupling_rejected_nonfinite, &coupling_rejected_unknown,
|
||||
&coupling_rejected_capacity);
|
||||
if (ierr != 0) return check_ierr(ierr, 1314);
|
||||
if (coupling_accepted != 0 || coupling_rejected_nonfinite != 0 ||
|
||||
coupling_rejected_unknown != 0 || coupling_rejected_capacity != 0) {
|
||||
return 1315;
|
||||
}
|
||||
ierr = femlite_apply_coupling_nodal_forces(1, node_ids, force, source_ids,
|
||||
load_mode, valid_flags);
|
||||
if (ierr != 0) return check_ierr(ierr, 16);
|
||||
ierr = femlite_get_coupling_load_diagnostics(
|
||||
coupling_force, coupling_moment, &coupling_accepted,
|
||||
&coupling_rejected_nonfinite, &coupling_rejected_unknown,
|
||||
&coupling_rejected_capacity);
|
||||
if (ierr != 0) return check_ierr(ierr, 1305);
|
||||
if (coupling_accepted != 1 || coupling_rejected_nonfinite != 0 ||
|
||||
coupling_rejected_unknown != 0 || coupling_rejected_capacity != 0) {
|
||||
return 1306;
|
||||
}
|
||||
if (fabs(coupling_force[0] - 5.0) > 1.0e-16 ||
|
||||
fabs(coupling_force[1] - 1.0) > 1.0e-16 ||
|
||||
fabs(coupling_force[2] + 2.0) > 1.0e-16) return 1307;
|
||||
if (fabs(coupling_moment[0]) > 1.0e-16 ||
|
||||
fabs(coupling_moment[1] - 2.0) > 1.0e-16 ||
|
||||
fabs(coupling_moment[2] - 1.0) > 1.0e-16) return 1308;
|
||||
ierr = femlite_get_coupling_source_load_diagnostics(
|
||||
42, source_force, source_moment, &source_accepted);
|
||||
if (ierr != 0) return check_ierr(ierr, 1320);
|
||||
if (source_accepted != 1) return 1321;
|
||||
if (fabs(source_force[0] - 5.0) > 1.0e-16 ||
|
||||
fabs(source_force[1] - 1.0) > 1.0e-16 ||
|
||||
fabs(source_force[2] + 2.0) > 1.0e-16) return 1322;
|
||||
if (fabs(source_moment[0]) > 1.0e-16 ||
|
||||
fabs(source_moment[1] - 2.0) > 1.0e-16 ||
|
||||
fabs(source_moment[2] - 1.0) > 1.0e-16) return 1323;
|
||||
ierr = femlite_get_coupling_source_load_diagnostics(
|
||||
7, source_force, source_moment, &source_accepted);
|
||||
if (ierr != 0) return check_ierr(ierr, 1324);
|
||||
if (source_accepted != 0 ||
|
||||
fabs(source_force[0]) > 1.0e-16 ||
|
||||
fabs(source_force[1]) > 1.0e-16 ||
|
||||
fabs(source_force[2]) > 1.0e-16) return 1325;
|
||||
ierr = femlite_write_coupling_reports(
|
||||
"build-wsl-debug/c_api_coupling_load_report.csv",
|
||||
"build-wsl-debug/c_api_coupling_surface_report.csv");
|
||||
if (ierr != 0) return check_ierr(ierr, 1326);
|
||||
if (!file_contains("build-wsl-debug/c_api_coupling_load_report.csv",
|
||||
"index,node_id,source_id,load_mode,fx,fy,fz,mx,my,mz")) {
|
||||
return 1327;
|
||||
}
|
||||
if (!file_contains("build-wsl-debug/c_api_coupling_load_report.csv",
|
||||
"1,2,42,1")) {
|
||||
return 1328;
|
||||
}
|
||||
if (!file_contains("build-wsl-debug/c_api_coupling_surface_report.csv",
|
||||
"source_id,count,fx,fy,fz,mx,my,mz")) {
|
||||
return 1329;
|
||||
}
|
||||
if (!file_contains("build-wsl-debug/c_api_coupling_surface_report.csv",
|
||||
"42,1")) {
|
||||
return 1330;
|
||||
}
|
||||
ierr = femlite_clear_coupling_loads();
|
||||
if (ierr != 0) return check_ierr(ierr, 1331);
|
||||
ierr = femlite_get_coupling_load_diagnostics(
|
||||
coupling_force, coupling_moment, &coupling_accepted,
|
||||
&coupling_rejected_nonfinite, &coupling_rejected_unknown,
|
||||
&coupling_rejected_capacity);
|
||||
if (ierr != 0) return check_ierr(ierr, 1332);
|
||||
if (coupling_accepted != 0 || coupling_rejected_nonfinite != 0 ||
|
||||
coupling_rejected_unknown != 0 || coupling_rejected_capacity != 0) {
|
||||
return 1333;
|
||||
}
|
||||
ierr = femlite_apply_coupling_nodal_forces(1, node_ids, force, source_ids,
|
||||
load_mode, valid_flags);
|
||||
if (ierr != 0) return check_ierr(ierr, 1334);
|
||||
ierr = femlite_apply_coupling_nodal_forces(1, node_ids, bad_force,
|
||||
source_ids, load_mode,
|
||||
valid_flags);
|
||||
if (ierr == 0) return 1309;
|
||||
ierr = femlite_apply_coupling_nodal_forces(1, bad_node_ids, force,
|
||||
source_ids, load_mode,
|
||||
valid_flags);
|
||||
if (ierr == 0) return 1310;
|
||||
ierr = femlite_get_coupling_load_diagnostics(
|
||||
coupling_force, coupling_moment, &coupling_accepted,
|
||||
&coupling_rejected_nonfinite, &coupling_rejected_unknown,
|
||||
&coupling_rejected_capacity);
|
||||
if (ierr != 0) return check_ierr(ierr, 1311);
|
||||
if (coupling_accepted != 1 || coupling_rejected_nonfinite != 1 ||
|
||||
coupling_rejected_unknown != 1 || coupling_rejected_capacity != 0) {
|
||||
return 1312;
|
||||
}
|
||||
ierr = femlite_advance_explicit(1.0e-8);
|
||||
if (ierr != 0) return check_ierr(ierr, 17);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user