Lines Matching +full:- +full:- +full:check

1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4 // SPDX-License-Identifier: BSD-2-Clause
8 #include <ceed-impl.h>
19 /// ----------------------------------------------------------------------------
21 /// ----------------------------------------------------------------------------
30 @param[out] field_index Index of field, or `-1` if field is not registered
32 @return An error code: 0 - success, otherwise - failure
37 *field_index = -1; in CeedQFunctionContextGetFieldIndex()
38 for (CeedInt i = 0; i < ctx->num_fields; i++) { in CeedQFunctionContextGetFieldIndex()
39 if (!strcmp(ctx->field_labels[i]->name, field_name)) *field_index = i; in CeedQFunctionContextGetFieldIndex()
54 @return An error code: 0 - success, otherwise - failure
61 CeedInt field_index = -1; in CeedQFunctionContextRegisterGeneric()
63 // Check for duplicate in CeedQFunctionContextRegisterGeneric()
65 CeedCheck(field_index == -1, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, in CeedQFunctionContextRegisterGeneric()
69 if (ctx->num_fields == 0) { in CeedQFunctionContextRegisterGeneric()
70 CeedCall(CeedCalloc(1, &ctx->field_labels)); in CeedQFunctionContextRegisterGeneric()
71 ctx->max_fields = 1; in CeedQFunctionContextRegisterGeneric()
72 } else if (ctx->num_fields == ctx->max_fields) { in CeedQFunctionContextRegisterGeneric()
73 CeedCall(CeedRealloc(2 * ctx->max_fields, &ctx->field_labels)); in CeedQFunctionContextRegisterGeneric()
74 ctx->max_fields *= 2; in CeedQFunctionContextRegisterGeneric()
76 CeedCall(CeedCalloc(1, &ctx->field_labels[ctx->num_fields])); in CeedQFunctionContextRegisterGeneric()
92 CeedCall(CeedStringAllocCopy(field_name, (char **)&ctx->field_labels[ctx->num_fields]->name)); in CeedQFunctionContextRegisterGeneric()
93 …CeedCall(CeedStringAllocCopy(field_description, (char **)&ctx->field_labels[ctx->num_fields]->desc… in CeedQFunctionContextRegisterGeneric()
94 ctx->field_labels[ctx->num_fields]->type = field_type; in CeedQFunctionContextRegisterGeneric()
95 ctx->field_labels[ctx->num_fields]->offset = field_offset; in CeedQFunctionContextRegisterGeneric()
96 ctx->field_labels[ctx->num_fields]->size = field_size * num_values; in CeedQFunctionContextRegisterGeneric()
97 ctx->field_labels[ctx->num_fields]->num_values = num_values; in CeedQFunctionContextRegisterGeneric()
98 ctx->num_fields++; in CeedQFunctionContextRegisterGeneric()
107 @return An error code: 0 - success, otherwise - failure
112 if (ctx->DataDestroy) { in CeedQFunctionContextDestroyData()
113 CeedCall(ctx->DataDestroy(ctx)); in CeedQFunctionContextDestroyData()
136 @return An error code: 0 - success, otherwise - failure
150 @return An error code: 0 - success, otherwise - failure
161 /// ----------------------------------------------------------------------------
163 /// ----------------------------------------------------------------------------
173 @return An error code: 0 - success, otherwise - failure
194 @brief Check for valid data in a `CeedQFunctionContext`
196 @param[in] ctx `CeedQFunctionContext` to check validity
199 @return An error code: 0 - success, otherwise - failure
204 CeedCheck(ctx->HasValidData, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, in CeedQFunctionContextHasValidData()
206 CeedCall(ctx->HasValidData(ctx, has_valid_data)); in CeedQFunctionContextHasValidData()
211 @brief Check for borrowed data of a specific @ref CeedMemType in a `CeedQFunctionContext`
213 @param[in] ctx `CeedQFunctionContext` to check
214 @param[in] mem_type Memory type to check
217 @return An error code: 0 - success, otherwise - failure
222 CeedCheck(ctx->HasBorrowedDataOfType, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, in CeedQFunctionContextHasBorrowedDataOfType()
224 CeedCall(ctx->HasBorrowedDataOfType(ctx, mem_type, has_borrowed_data_of_type)); in CeedQFunctionContextHasBorrowedDataOfType()
234 @return An error code: 0 - success, otherwise - failure
239 *state = ctx->state; in CeedQFunctionContextGetState()
249 @return An error code: 0 - success, otherwise - failure
254 *(void **)data = ctx->data; in CeedQFunctionContextGetBackendData()
264 @return An error code: 0 - success, otherwise - failure
269 ctx->data = data; in CeedQFunctionContextSetBackendData()
280 @return An error code: 0 - success, otherwise - failure
289 if (field_index != -1) { in CeedQFunctionContextGetFieldLabel()
290 *field_label = ctx->field_labels[field_index]; in CeedQFunctionContextGetFieldLabel()
305 @return An error code: 0 - success, otherwise - failure
313 // Check field type in CeedQFunctionContextSetGeneric()
314 …CeedCheck(field_label->type == field_type, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPO… in CeedQFunctionContextSetGeneric()
315 …QFunctionContext field with name \"%s\" registered as %s, not registered as %s", field_label->name, in CeedQFunctionContextSetGeneric()
316 CeedContextFieldTypes[field_label->type], CeedContextFieldTypes[field_type]); in CeedQFunctionContextSetGeneric()
319 is_different = memcmp(&data[field_label->offset], values, field_label->size); in CeedQFunctionContextSetGeneric()
323 memcpy(&data[field_label->offset], values, field_label->size); in CeedQFunctionContextSetGeneric()
330 @brief Get `CeedQFunctionContext` field data, read-only
338 @return An error code: 0 - success, otherwise - failure
346 // Check field type in CeedQFunctionContextGetGenericRead()
347 …CeedCheck(field_label->type == field_type, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPO… in CeedQFunctionContextGetGenericRead()
348 …QFunctionContext field with name \"%s\" registered as %s, not registered as %s", field_label->name, in CeedQFunctionContextGetGenericRead()
349 CeedContextFieldTypes[field_label->type], CeedContextFieldTypes[field_type]); in CeedQFunctionContextGetGenericRead()
352 *(void **)values = &data[field_label->offset]; in CeedQFunctionContextGetGenericRead()
355 *num_values = field_label->size / sizeof(int); in CeedQFunctionContextGetGenericRead()
358 *num_values = field_label->size / sizeof(double); in CeedQFunctionContextGetGenericRead()
361 *num_values = field_label->size / sizeof(bool); in CeedQFunctionContextGetGenericRead()
368 @brief Restore `CeedQFunctionContext` field data, read-only
375 @return An error code: 0 - success, otherwise - failure
381 // Check field type in CeedQFunctionContextRestoreGenericRead()
382 …CeedCheck(field_label->type == field_type, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPO… in CeedQFunctionContextRestoreGenericRead()
383 …QFunctionContext field with name \"%s\" registered as %s, not registered as %s", field_label->name, in CeedQFunctionContextRestoreGenericRead()
384 CeedContextFieldTypes[field_label->type], CeedContextFieldTypes[field_type]); in CeedQFunctionContextRestoreGenericRead()
397 @return An error code: 0 - success, otherwise - failure
408 @brief Get `CeedQFunctionContext` field holding double precision values, read-only
415 @return An error code: 0 - success, otherwise - failure
426 @brief Restore `CeedQFunctionContext` field holding double precision values, read-only
432 @return An error code: 0 - success, otherwise - failure
449 @return An error code: 0 - success, otherwise - failure
460 @brief Get `CeedQFunctionContext` field holding `int32` values, read-only
467 @return An error code: 0 - success, otherwise - failure
478 @brief Restore `CeedQFunctionContext` field holding `int32` values, read-only
484 @return An error code: 0 - success, otherwise - failure
501 @return An error code: 0 - success, otherwise - failure
512 @brief Get `CeedQFunctionContext` field holding boolean values, read-only
519 @return An error code: 0 - success, otherwise - failure
530 @brief Restore `CeedQFunctionContext` field holding boolean values, read-only
536 @return An error code: 0 - success, otherwise - failure
553 @return An error code: 0 - success, otherwise - failure
558 if (f_mem_type) *f_mem_type = ctx->data_destroy_mem_type; in CeedQFunctionContextGetDataDestroy()
559 if (f) *f = ctx->data_destroy_function; in CeedQFunctionContextGetDataDestroy()
568 @return An error code: 0 - success, otherwise - failure
579 /// ----------------------------------------------------------------------------
581 /// ----------------------------------------------------------------------------
591 @return An error code: 0 - success, otherwise - failure
596 if (!ceed->QFunctionContextCreate) { in CeedQFunctionContextCreate()
607 …ctCreate(ceed, CeedQFunctionContextView_Object, CeedQFunctionContextDestroy_Object, &(*ctx)->obj)); in CeedQFunctionContextCreate()
608 CeedCall(ceed->QFunctionContextCreate(*ctx)); in CeedQFunctionContextCreate()
617 …Note: If the value of `*ctx_copy` passed to this function is non-`NULL`, then it is assumed that `…
623 @return An error code: 0 - success, otherwise - failure
646 @return An error code: 0 - success, otherwise - failure
651 …CeedCheck(ctx->SetData, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, "Backend does… in CeedQFunctionContextSetData()
652 CeedCheck(ctx->state % 2 == 0, CeedQFunctionContextReturnCeed(ctx), 1, in CeedQFunctionContextSetData()
656 ctx->ctx_size = size; in CeedQFunctionContextSetData()
657 CeedCall(ctx->SetData(ctx, mem_type, copy_mode, data)); in CeedQFunctionContextSetData()
658 ctx->state += 2; in CeedQFunctionContextSetData()
672 @return An error code: 0 - success, otherwise - failure
683 …CeedCheck(ctx->TakeData, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, "Backend doe… in CeedQFunctionContextTakeData()
684 CeedCheck(ctx->state % 2 == 0, CeedQFunctionContextReturnCeed(ctx), 1, in CeedQFunctionContextTakeData()
691 CeedCall(ctx->TakeData(ctx, mem_type, &temp_data)); in CeedQFunctionContextTakeData()
709 @return An error code: 0 - success, otherwise - failure
716 …CeedCheck(ctx->GetData, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, "Backend does… in CeedQFunctionContextGetData()
717 CeedCheck(ctx->state % 2 == 0, CeedQFunctionContextReturnCeed(ctx), 1, in CeedQFunctionContextGetData()
719 CeedCheck(ctx->num_readers == 0, CeedQFunctionContextReturnCeed(ctx), 1, in CeedQFunctionContextGetData()
725 CeedCall(ctx->GetData(ctx, mem_type, data)); in CeedQFunctionContextGetData()
726 ctx->state++; in CeedQFunctionContextGetData()
743 @return An error code: 0 - success, otherwise - failure
750 CeedCheck(ctx->GetDataRead, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_UNSUPPORTED, in CeedQFunctionContextGetDataRead()
752 CeedCheck(ctx->state % 2 == 0, CeedQFunctionContextReturnCeed(ctx), 1, in CeedQFunctionContextGetDataRead()
758 CeedCall(ctx->GetDataRead(ctx, mem_type, data)); in CeedQFunctionContextGetDataRead()
759 ctx->num_readers++; in CeedQFunctionContextGetDataRead()
769 @return An error code: 0 - success, otherwise - failure
774 …CeedCheck(ctx->state % 2 == 1, CeedQFunctionContextReturnCeed(ctx), 1, "Cannot restore CeedQFuncti… in CeedQFunctionContextRestoreData()
776 if (ctx->RestoreData) CeedCall(ctx->RestoreData(ctx)); in CeedQFunctionContextRestoreData()
778 ctx->state++; in CeedQFunctionContextRestoreData()
788 @return An error code: 0 - success, otherwise - failure
793 …CeedCheck(ctx->num_readers > 0, CeedQFunctionContextReturnCeed(ctx), 1, "Cannot restore CeedQFunct… in CeedQFunctionContextRestoreDataRead()
795 ctx->num_readers--; in CeedQFunctionContextRestoreDataRead()
796 if (ctx->num_readers == 0 && ctx->RestoreDataRead) CeedCall(ctx->RestoreDataRead(ctx)); in CeedQFunctionContextRestoreDataRead()
810 @return An error code: 0 - success, otherwise - failure
828 @return An error code: 0 - success, otherwise - failure
846 @return An error code: 0 - success, otherwise - failure
862 @return An error code: 0 - success, otherwise - failure
867 *field_labels = ctx->field_labels; in CeedQFunctionContextGetAllFieldLabels()
868 *num_fields = ctx->num_fields; in CeedQFunctionContextGetAllFieldLabels()
882 @return An error code: 0 - success, otherwise - failure
888 if (field_name) *field_name = label->name; in CeedContextFieldLabelGetDescription()
889 if (field_offset) *field_offset = label->offset; in CeedContextFieldLabelGetDescription()
890 if (num_values) *num_values = label->num_values; in CeedContextFieldLabelGetDescription()
891 if (field_description) *field_description = label->description; in CeedContextFieldLabelGetDescription()
892 if (field_type) *field_type = label->type; in CeedContextFieldLabelGetDescription()
902 @return An error code: 0 - success, otherwise - failure
907 *ctx_size = ctx->ctx_size; in CeedQFunctionContextGetContextSize()
917 @return Error code: 0 - success, otherwise - failure
932 @return Error code: 0 - success, otherwise - failure
947 @return An error code: 0 - success, otherwise - failure
963 fprintf(stream, "%s Context Data Size: %zu\n", tabs, ctx->ctx_size); in CeedQFunctionContextView()
964 for (CeedInt i = 0; i < ctx->num_fields; i++) { in CeedQFunctionContextView()
965 …eled %s field: %s\n", tabs, CeedContextFieldTypes[ctx->field_labels[i]->type], ctx->field_labels[i… in CeedQFunctionContextView()
978 @return An error code: 0 - success, otherwise - failure
984 ctx->data_destroy_mem_type = f_mem_type; in CeedQFunctionContextSetDataDestroy()
985 ctx->data_destroy_function = f; in CeedQFunctionContextSetDataDestroy()
994 @return An error code: 0 - success, otherwise - failure
1003 …CeedCheck(((*ctx)->state % 2) == 0, CeedQFunctionContextReturnCeed(*ctx), 1, "Cannot destroy CeedQ… in CeedQFunctionContextDestroy()
1006 if ((*ctx)->Destroy) CeedCall((*ctx)->Destroy(*ctx)); in CeedQFunctionContextDestroy()
1007 for (CeedInt i = 0; i < (*ctx)->num_fields; i++) { in CeedQFunctionContextDestroy()
1008 CeedCall(CeedFree(&(*ctx)->field_labels[i]->name)); in CeedQFunctionContextDestroy()
1009 CeedCall(CeedFree(&(*ctx)->field_labels[i]->description)); in CeedQFunctionContextDestroy()
1010 CeedCall(CeedFree(&(*ctx)->field_labels[i])); in CeedQFunctionContextDestroy()
1012 CeedCall(CeedFree(&(*ctx)->field_labels)); in CeedQFunctionContextDestroy()
1013 CeedCall(CeedObjectDestroy_Private(&(*ctx)->obj)); in CeedQFunctionContextDestroy()