Skip to content

Commit

Permalink
err - add more data to CeedCheck messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylt committed Jul 12, 2024
1 parent 371292c commit 9367c6e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
11 changes: 9 additions & 2 deletions interface/ceed-basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ static int CeedBasisCreateProjectionMatrices(CeedBasis basis_from, CeedBasis bas
// Check for compatible quadrature spaces
CeedCall(CeedBasisGetNumQuadraturePoints(basis_to, &Q_to));
CeedCall(CeedBasisGetNumQuadraturePoints(basis_from, &Q_from));
CeedCheck(Q_to == Q_from, ceed, CEED_ERROR_DIMENSION, "Bases must have compatible quadrature spaces");
CeedCheck(Q_to == Q_from, ceed, CEED_ERROR_DIMENSION,
"Bases must have compatible quadrature spaces."
" 'basis_from has %" CeedInt_FMT " points and 'basis_to' has %" CeedInt_FMT,
Q_from, Q_to);
Q = Q_to;

// Check for matching tensor or non-tensor
Expand All @@ -225,9 +228,13 @@ static int CeedBasisCreateProjectionMatrices(CeedBasis basis_from, CeedBasis bas

// Check for matching FE space
CeedFESpace fe_space_to, fe_space_from;

CeedCall(CeedBasisGetFESpace(basis_to, &fe_space_to));
CeedCall(CeedBasisGetFESpace(basis_from, &fe_space_from));
CeedCheck(fe_space_to == fe_space_from, ceed, CEED_ERROR_MINOR, "Bases must both be the same FE space type");
CeedCheck(fe_space_to == fe_space_from, ceed, CEED_ERROR_MINOR,
"Bases must both be the same FE space type."
" 'basis_from' is a %s and 'basis_to' is a %s",
CeedFESpaces[fe_space_from], CeedFESpaces[fe_space_to]);

// Get source matrices
CeedInt dim, q_comp = 1;
Expand Down
5 changes: 4 additions & 1 deletion interface/ceed-elemrestriction.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,10 @@ int CeedElemRestrictionSetAtPointsEVectorSize(CeedElemRestriction rstr, CeedSize
CeedCall(CeedElemRestrictionGetCeed(rstr, &ceed));
CeedCall(CeedElemRestrictionGetType(rstr, &rstr_type));
CeedCheck(rstr_type == CEED_RESTRICTION_POINTS, ceed, CEED_ERROR_INCOMPATIBLE, "Can only compute offset for a points CeedElemRestriction");
CeedCheck(e_size >= rstr->e_size, ceed, CEED_ERROR_INCOMPATIBLE, "Can only increase the size of the E-vector for the CeedElemRestriction");
CeedCheck(e_size >= rstr->e_size, ceed, CEED_ERROR_INCOMPATIBLE,
"Can only increase the size of the E-vector for the CeedElemRestriction."
" Current size: %" CeedSize_FMT " New size: %" CeedSize_FMT,
rstr->e_size, e_size);
rstr->e_size = e_size;
return CEED_ERROR_SUCCESS;
}
Expand Down
27 changes: 20 additions & 7 deletions interface/ceed-preconditioning.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ static int CeedSingleOperatorAssembleSymbolic(CeedOperator op, CeedInt offset, C
if (elem_rstr_in != elem_rstr_out) {
CeedCall(CeedElemRestrictionGetNumElements(elem_rstr_out, &num_elem_out));
CeedCheck(num_elem_in == num_elem_out, ceed, CEED_ERROR_UNSUPPORTED,
"Active input and output operator restrictions must have the same number of elements");
"Active input and output operator restrictions must have the same number of elements."
" Input has %" CeedInt_FMT " elements; output has %" CeedInt_FMT "elements.",
num_elem_in, num_elem_out);
CeedCall(CeedElemRestrictionGetElementSize(elem_rstr_out, &elem_size_out));
CeedCall(CeedElemRestrictionGetNumComponents(elem_rstr_out, &num_comp_out));
CeedCall(CeedElemRestrictionGetELayout(elem_rstr_out, layout_er_out));
Expand Down Expand Up @@ -602,7 +604,7 @@ static int CeedSingleOperatorAssemble(CeedOperator op, CeedInt offset, CeedVecto
CeedCall(CeedOperatorAssemblyDataGetEvalModes(data, &num_active_bases_in, &num_eval_modes_in, &eval_modes_in, NULL, &num_active_bases_out,
&num_eval_modes_out, &eval_modes_out, NULL, NULL));

CeedCheck(num_active_bases_in == num_active_bases_out && num_active_bases_in == 1, ceed, CEED_ERROR_UNSUPPORTED,
CeedCheck(num_active_bases_in == 1 && num_active_bases_out == 1, ceed, CEED_ERROR_UNSUPPORTED,
"Cannot assemble operator with multiple active bases");
CeedCheck(num_eval_modes_in[0] > 0 && num_eval_modes_out[0] > 0, ceed, CEED_ERROR_UNSUPPORTED, "Cannot assemble operator without inputs/outputs");

Expand All @@ -629,13 +631,17 @@ static int CeedSingleOperatorAssemble(CeedOperator op, CeedInt offset, CeedVecto
if (elem_rstr_in != elem_rstr_out) {
CeedCall(CeedElemRestrictionGetNumElements(elem_rstr_out, &num_elem_out));
CeedCheck(num_elem_in == num_elem_out, ceed, CEED_ERROR_UNSUPPORTED,
"Active input and output operator restrictions must have the same number of elements");
"Active input and output operator restrictions must have the same number of elements."
" Input has %" CeedInt_FMT " elements; output has %" CeedInt_FMT "elements.",
num_elem_in, num_elem_out);
CeedCall(CeedElemRestrictionGetElementSize(elem_rstr_out, &elem_size_out));
CeedCall(CeedElemRestrictionGetNumComponents(elem_rstr_out, &num_comp_out));
if (basis_out == CEED_BASIS_NONE) num_qpts_out = elem_size_out;
else CeedCall(CeedBasisGetNumQuadraturePoints(basis_out, &num_qpts_out));
CeedCheck(num_qpts_in == num_qpts_out, ceed, CEED_ERROR_UNSUPPORTED,
"Active input and output bases must have the same number of quadrature points");
"Active input and output bases must have the same number of quadrature points."
" Input has %" CeedInt_FMT " points; output has %" CeedInt_FMT "points.",
num_qpts_in, num_qpts_out);

CeedCall(CeedElemRestrictionGetType(elem_rstr_out, &elem_rstr_type_out));
if (elem_rstr_type_out == CEED_RESTRICTION_ORIENTED) {
Expand Down Expand Up @@ -802,7 +808,9 @@ static int CeedSingleOperatorAssemblyCountEntries(CeedOperator op, CeedSize *num
if (rstr_in != rstr_out) {
CeedCall(CeedElemRestrictionGetNumElements(rstr_out, &num_elem_out));
CeedCheck(num_elem_in == num_elem_out, ceed, CEED_ERROR_UNSUPPORTED,
"Active input and output operator restrictions must have the same number of elements");
"Active input and output operator restrictions must have the same number of elements."
" Input has %" CeedInt_FMT " elements; output has %" CeedInt_FMT "elements.",
num_elem_in, num_elem_out);
CeedCall(CeedElemRestrictionGetElementSize(rstr_out, &elem_size_out));
CeedCall(CeedElemRestrictionGetNumComponents(rstr_out, &num_comp_out));
} else {
Expand Down Expand Up @@ -2123,7 +2131,9 @@ int CeedOperatorLinearAssemblePointBlockDiagonalSymbolic(CeedOperator op, CeedSi
"Active element restrictions must have the same component stride: %d vs %d", comp_stride, comp_stride_sub);
CeedCall(CeedElemRestrictionGetNumComponents(active_elem_rstrs[i], &num_active_components_sub));
CeedCheck(num_active_components == num_active_components_sub, ceed, CEED_ERROR_INCOMPATIBLE,
"All suboperators must have the same number of output components");
"All suboperators must have the same number of output components."
" Previous: %" CeedInt_FMT " Current: %" CeedInt_FMT,
num_active_components, num_active_components_sub);
}
}
}
Expand Down Expand Up @@ -2571,7 +2581,10 @@ int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_
CeedCall(CeedOperatorGetActiveBasis(op_fine, &basis_fine));
CeedCall(CeedBasisGetNumQuadraturePoints(basis_fine, &Q_f));
CeedCall(CeedBasisGetNumQuadraturePoints(basis_coarse, &Q_c));
CeedCheck(Q_f == Q_c, ceed, CEED_ERROR_DIMENSION, "Bases must have compatible quadrature spaces");
CeedCheck(Q_f == Q_c, ceed, CEED_ERROR_DIMENSION,
"Bases must have compatible quadrature spaces."
" Fine grid: %" CeedInt_FMT " points, Coarse grid: %" CeedInt_FMT " points",
Q_f, Q_c);

// Create coarse to fine basis, if required
if (op_prolong || op_restrict) {
Expand Down
8 changes: 6 additions & 2 deletions interface/ceed-qfunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,14 @@ int CeedQFunctionAddInput(CeedQFunction qf, const char *field_name, CeedInt size
CeedCheck(!is_immutable, ceed, CEED_ERROR_MAJOR, "QFunction cannot be changed after set as immutable");
CeedCheck(eval_mode != CEED_EVAL_WEIGHT || size == 1, ceed, CEED_ERROR_DIMENSION, "CEED_EVAL_WEIGHT should have size 1");
for (CeedInt i = 0; i < qf->num_input_fields; i++) {
CeedCheck(strcmp(field_name, qf->input_fields[i]->field_name), ceed, CEED_ERROR_MINOR, "CeedQFunction field names must be unique");
CeedCheck(strcmp(field_name, qf->input_fields[i]->field_name), ceed, CEED_ERROR_MINOR,
"CeedQFunction field names must be unique. Duplicate name: %s",
field_name);
}
for (CeedInt i = 0; i < qf->num_output_fields; i++) {
CeedCheck(strcmp(field_name, qf->output_fields[i]->field_name), ceed, CEED_ERROR_MINOR, "CeedQFunction field names must be unique");
CeedCheck(strcmp(field_name, qf->output_fields[i]->field_name), ceed, CEED_ERROR_MINOR,
"CeedQFunction field names must be unique. Duplicate name: %s",
field_name);
}
CeedCall(CeedQFunctionFieldSet(&qf->input_fields[qf->num_input_fields], field_name, size, eval_mode));
qf->num_input_fields++;
Expand Down
15 changes: 12 additions & 3 deletions interface/ceed-vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,10 @@ int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x) {
CeedCall(CeedVectorGetCeed(y, &ceed));
CeedCall(CeedVectorGetLength(y, &length_y));
CeedCall(CeedVectorGetLength(x, &length_x));
CeedCheck(length_x == length_y, ceed, CEED_ERROR_UNSUPPORTED, "Cannot add vector of different lengths");
CeedCheck(length_x == length_y, ceed, CEED_ERROR_UNSUPPORTED,
"Cannot add vector of different lengths."
" x length: %" CeedSize_FMT " y length: %" CeedSize_FMT,
length_x, length_y);
CeedCheck(x != y, ceed, CEED_ERROR_UNSUPPORTED, "Cannot use same vector for x and y in CeedVectorAXPY");

CeedCall(CeedVectorHasValidArray(x, &has_valid_array_x));
Expand Down Expand Up @@ -795,7 +798,10 @@ int CeedVectorAXPBY(CeedVector y, CeedScalar alpha, CeedScalar beta, CeedVector

CeedCall(CeedVectorGetLength(y, &length_y));
CeedCall(CeedVectorGetLength(x, &length_x));
CeedCheck(length_x == length_y, ceed, CEED_ERROR_UNSUPPORTED, "Cannot add vector of different lengths");
CeedCheck(length_x == length_y, ceed, CEED_ERROR_UNSUPPORTED,
"Cannot add vector of different lengths."
" x length: %" CeedSize_FMT " y length: %" CeedSize_FMT,
length_x, length_y);
CeedCheck(x != y, ceed, CEED_ERROR_UNSUPPORTED, "Cannot use same vector for x and y in CeedVectorAXPBY");

CeedCall(CeedVectorHasValidArray(x, &has_valid_array_x));
Expand Down Expand Up @@ -856,7 +862,10 @@ int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y) {
CeedCall(CeedVectorGetLength(w, &length_w));
CeedCall(CeedVectorGetLength(x, &length_x));
CeedCall(CeedVectorGetLength(y, &length_y));
CeedCheck(length_w == length_x && length_w == length_y, ceed, CEED_ERROR_UNSUPPORTED, "Cannot multiply vectors of different lengths");
CeedCheck(length_w == length_x && length_w == length_y, ceed, CEED_ERROR_UNSUPPORTED,
"Cannot multiply vectors of different lengths."
" x length: %" CeedSize_FMT " y length: %" CeedSize_FMT,
length_x, length_y);

CeedCall(CeedGetParent(w->ceed, &ceed_parent_w));
CeedCall(CeedGetParent(x->ceed, &ceed_parent_x));
Expand Down

0 comments on commit 9367c6e

Please sign in to comment.