Complete V5 acceptance milestone

This commit is contained in:
shenw
2026-06-26 12:54:40 +08:00
parent 26639d8dc2
commit a01a4fda24
105 changed files with 8694 additions and 8922 deletions
+18 -27
View File
@@ -51,9 +51,7 @@ int main(void)
int linsol_preconditioner = -1;
int linsol_iteration = -1;
int linsol_status = -999;
int linsol_backend = -1;
int linsol_available = -1;
int linsol_capabilities = -1;
int linsol_matrix_class = -1;
int shell_sample_count = -1;
int shell_last_element = -1;
int node_ids[1] = {2};
@@ -100,6 +98,8 @@ int main(void)
double conv_contact_gap = -1.0;
double conv_combined_norm = -1.0;
double linsol_residual = -1.0;
double linsol_initial_residual = -1.0;
double linsol_relative_residual = -1.0;
double shell_drilling_factor = -1.0;
double shell_s3_shear_factor = -1.0;
double shell_s3_shear_min_scale = -1.0;
@@ -137,30 +137,15 @@ int main(void)
if (linsol_method != 1 || linsol_preconditioner != 1 ||
linsol_iteration != 0 || linsol_residual != 0.0 ||
linsol_status != 0) return 47;
ierr = femlite_get_linear_solver_external_info(&linsol_backend,
&linsol_available,
&linsol_capabilities);
if (ierr != 0) return check_ierr(ierr, 4701);
if (linsol_backend != FEMLITE_LS_EXT_BACKEND_REF_DIRECT) return 4702;
if (linsol_available != 1) return 4703;
if ((linsol_capabilities & FEMLITE_LS_EXT_CAP_DIRECT) == 0 ||
(linsol_capabilities & FEMLITE_LS_EXT_CAP_GENERAL) == 0 ||
(linsol_capabilities & FEMLITE_LS_EXT_CAP_SPD) == 0 ||
(linsol_capabilities & FEMLITE_LS_EXT_CAP_INDEFINITE) == 0) {
return 47031;
}
ierr = femlite_set_linear_solver_external_backend(
FEMLITE_LS_EXT_BACKEND_SUPERLU);
if (ierr != 0) return check_ierr(ierr, 4704);
ierr = femlite_get_linear_solver_external_info(&linsol_backend,
&linsol_available,
&linsol_capabilities);
if (ierr != 0) return check_ierr(ierr, 4705);
if (linsol_backend != FEMLITE_LS_EXT_BACKEND_SUPERLU) return 4706;
if (linsol_available != 0 || linsol_capabilities != 0) return 4707;
ierr = femlite_set_linear_solver_external_backend(
FEMLITE_LS_EXT_BACKEND_REF_DIRECT);
if (ierr != 0) return check_ierr(ierr, 4708);
ierr = femlite_get_linear_solver_diagnostics(&linsol_matrix_class,
&linsol_initial_residual,
&linsol_residual,
&linsol_relative_residual,
&linsol_status);
if (ierr != 0) return check_ierr(ierr, 471);
if (linsol_matrix_class != FEMLITE_CSR_CLASS_GENERAL ||
linsol_initial_residual != 0.0 || linsol_residual != 0.0 ||
linsol_relative_residual != 0.0 || linsol_status != 0) return 472;
ierr = femlite_set_linear_solver(2, 0);
if (ierr != 0) return check_ierr(ierr, 48);
ierr = femlite_get_linear_solver_settings(&linsol_method,
@@ -173,6 +158,12 @@ int main(void)
&linsol_preconditioner);
if (ierr != 0) return check_ierr(ierr, 502);
if (linsol_method != 3 || linsol_preconditioner != 1) return 503;
ierr = femlite_set_linear_solver(100, 1);
if (ierr == 0) return 504;
ierr = femlite_get_linear_solver_settings(&linsol_method,
&linsol_preconditioner);
if (ierr != 0) return check_ierr(ierr, 505);
if (linsol_method != 3 || linsol_preconditioner != 1) return 506;
ierr = femlite_set_linear_solver(1, 1);
if (ierr != 0) return check_ierr(ierr, 51);
-199
View File
@@ -1,199 +0,0 @@
#include "femlite_c_api.h"
#include <math.h>
#include <stdio.h>
static int check_ierr(int ierr, int code)
{
int err_code = 0;
char message[256];
if (ierr == 0) {
return 0;
}
(void)femlite_get_last_error(&err_code, message, (int)sizeof(message));
fprintf(stderr, "test_external_diag_c_api failed at %d: ierr=%d code=%d %s\n",
code, ierr, err_code, message);
return code;
}
static int check_close(double actual, double expected, int code)
{
double scale = fmax(1.0, fabs(expected));
if (fabs(actual - expected) > 1.0e-12 * scale) {
fprintf(stderr,
"test_external_diag_c_api mismatch at %d: %.17g vs %.17g\n",
code, actual, expected);
return code;
}
return 0;
}
static int read_diag(int *valid,
int *nrow,
int *ncol,
int *nnz,
int *class_id,
int *sym_pat,
int *sym_val,
int *status,
double *matrix_norm,
double *rhs_norm,
double *initial_resid,
double *initial_rel)
{
return femlite_get_linear_solver_external_diag(
valid, nrow, ncol, nnz, class_id, sym_pat, sym_val, status,
matrix_norm, rhs_norm, initial_resid, initial_rel);
}
static int check_default_diag(void)
{
int ierr = 0;
int valid = -1;
int nrow = -1;
int ncol = -1;
int nnz = -1;
int class_id = -1;
int sym_pat = -1;
int sym_val = -1;
int status = -99;
double matrix_norm = -1.0;
double rhs_norm = -1.0;
double initial_resid = -1.0;
double initial_rel = -1.0;
int failed = 0;
ierr = read_diag(&valid, &nrow, &ncol, &nnz, &class_id, &sym_pat,
&sym_val, &status, &matrix_norm, &rhs_norm,
&initial_resid, &initial_rel);
if (ierr != 0) return check_ierr(ierr, 10);
if (valid != 0) return 11;
if (nrow != 0 || ncol != 0 || nnz != 0) return 12;
if (class_id != FEMLITE_CSR_CLASS_GENERAL) return 13;
if (sym_pat != 0 || sym_val != 0) return 14;
if (status != 0) return 15;
failed = check_close(matrix_norm, 0.0, 16);
if (failed != 0) return failed;
failed = check_close(rhs_norm, 0.0, 17);
if (failed != 0) return failed;
failed = check_close(initial_resid, 0.0, 18);
if (failed != 0) return failed;
return check_close(initial_rel, 0.0, 19);
}
static int check_backend_config(void)
{
int ierr = 0;
int backend = -1;
int available = -1;
int capabilities = -1;
int prepared = -1;
int command_ran = -1;
int command_exit = -1;
int finish_status = -1;
double residual = -1.0;
double relative = -1.0;
double backward = -1.0;
ierr = femlite_set_linear_solver_external_backend(
FEMLITE_LS_EXT_BACKEND_SUPERLU);
if (ierr != 0) return check_ierr(ierr, 30);
ierr = femlite_get_linear_solver_external_info(&backend, &available,
&capabilities);
if (ierr != 0) return check_ierr(ierr, 31);
if (backend != FEMLITE_LS_EXT_BACKEND_SUPERLU) return 32;
if (available != 0 || capabilities != 0) return 33;
ierr = femlite_configure_linear_solver_external_file(
"capi_ext_file", "", 0, 1, 0, 1);
if (ierr != 0) return check_ierr(ierr, 35);
ierr = femlite_set_linear_solver_external_backend(
FEMLITE_LS_EXT_BACKEND_FILE);
if (ierr != 0) return check_ierr(ierr, 36);
ierr = femlite_get_linear_solver_external_info(&backend, &available,
&capabilities);
if (ierr != 0) return check_ierr(ierr, 37);
if (backend != FEMLITE_LS_EXT_BACKEND_FILE) return 38;
if (available != 1) return 39;
if ((capabilities & FEMLITE_LS_EXT_CAP_DIRECT) == 0 ||
(capabilities & FEMLITE_LS_EXT_CAP_GENERAL) == 0) {
return 40;
}
ierr = femlite_get_linear_solver_external_file_diag(
&prepared, &command_ran, &command_exit, &finish_status,
&residual, &relative, &backward);
if (ierr != 0) return check_ierr(ierr, 41);
if (prepared != 0 || command_ran != 0 || command_exit != 0) return 42;
ierr = femlite_set_linear_solver_external_backend(
FEMLITE_LS_EXT_BACKEND_NONE);
if (ierr != 0) return check_ierr(ierr, 34);
return 0;
}
static int check_null_guards(void)
{
int valid = 0;
int nrow = 0;
int ncol = 0;
int nnz = 0;
int class_id = 0;
int sym_pat = 0;
int sym_val = 0;
int status = 0;
double matrix_norm = 0.0;
double rhs_norm = 0.0;
double initial_resid = 0.0;
double initial_rel = 0.0;
char path[128];
int ierr = 0;
ierr = read_diag(NULL, &nrow, &ncol, &nnz, &class_id, &sym_pat,
&sym_val, &status, &matrix_norm, &rhs_norm,
&initial_resid, &initial_rel);
if (ierr != -1) return 50;
ierr = read_diag(&valid, &nrow, &ncol, &nnz, &class_id, &sym_pat,
&sym_val, &status, NULL, &rhs_norm, &initial_resid,
&initial_rel);
if (ierr != -1) return 51;
if (femlite_configure_linear_solver_external_file(
NULL, "", 0, 1, 0, 1) != -1) return 52;
if (femlite_get_linear_solver_external_file_diag(
NULL, &status, &status, &status, &matrix_norm, &rhs_norm,
&initial_resid) != -1) return 53;
if (femlite_get_linear_solver_external_file_paths(
NULL, (int)sizeof(path), path, (int)sizeof(path),
path, (int)sizeof(path), path, (int)sizeof(path),
path, (int)sizeof(path), path, (int)sizeof(path)) != -1) {
return 54;
}
if (femlite_get_linear_solver_external_file_paths(
path, 0, path, (int)sizeof(path), path, (int)sizeof(path),
path, (int)sizeof(path), path, (int)sizeof(path),
path, (int)sizeof(path)) != -1) {
return 55;
}
return 0;
}
int main(void)
{
int ierr = 0;
int failed = 0;
ierr = femlite_initialize();
if (ierr != 0) return check_ierr(ierr, 1);
failed = check_default_diag();
if (failed != 0) return failed;
failed = check_backend_config();
if (failed != 0) return failed;
failed = check_null_guards();
if (failed != 0) return failed;
ierr = femlite_finalize();
if (ierr != 0) return check_ierr(ierr, 2);
return 0;
}