13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3d7b241e6Sjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5d7b241e6Sjeremylt // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7d7b241e6Sjeremylt 83d576824SJeremy L Thompson #include <ceed-impl.h> 949aac155SJeremy L Thompson #include <ceed.h> 102b730f8bSJeremy L Thompson #include <ceed/backend.h> 113d576824SJeremy L Thompson #include <stdbool.h> 123d576824SJeremy L Thompson #include <stdio.h> 133d576824SJeremy L Thompson #include <string.h> 14d7b241e6Sjeremylt 15dfdf5a53Sjeremylt /// @file 167a982d89SJeremy L. Thompson /// Implementation of CeedOperator interfaces 177a982d89SJeremy L. Thompson 187a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 197a982d89SJeremy L. Thompson /// CeedOperator Library Internal Functions 207a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 217a982d89SJeremy L. Thompson /// @addtogroup CeedOperatorDeveloper 227a982d89SJeremy L. Thompson /// @{ 237a982d89SJeremy L. Thompson 247a982d89SJeremy L. Thompson /** 25e15f9bd0SJeremy L Thompson @brief Check if a CeedOperator Field matches the QFunction Field 26e15f9bd0SJeremy L Thompson 27e15f9bd0SJeremy L Thompson @param[in] ceed Ceed object for error handling 28d1d35e2fSjeremylt @param[in] qf_field QFunction Field matching Operator Field 29e15f9bd0SJeremy L Thompson @param[in] r Operator Field ElemRestriction 30e15f9bd0SJeremy L Thompson @param[in] b Operator Field Basis 31e15f9bd0SJeremy L Thompson 32e15f9bd0SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 33e15f9bd0SJeremy L Thompson 34e15f9bd0SJeremy L Thompson @ref Developer 35e15f9bd0SJeremy L Thompson **/ 362b730f8bSJeremy L Thompson static int CeedOperatorCheckField(Ceed ceed, CeedQFunctionField qf_field, CeedElemRestriction r, CeedBasis b) { 37edb2538eSJeremy L Thompson CeedInt dim = 1, num_comp = 1, q_comp = 1, rstr_num_comp = 1, size = qf_field->size; 381c66c397SJeremy L Thompson CeedEvalMode eval_mode = qf_field->eval_mode; 392b730f8bSJeremy L Thompson 40e15f9bd0SJeremy L Thompson // Restriction 416574a04fSJeremy L Thompson CeedCheck((r == CEED_ELEMRESTRICTION_NONE) == (eval_mode == CEED_EVAL_WEIGHT), ceed, CEED_ERROR_INCOMPATIBLE, 426574a04fSJeremy L Thompson "CEED_ELEMRESTRICTION_NONE and CEED_EVAL_WEIGHT must be used together."); 43e15f9bd0SJeremy L Thompson if (r != CEED_ELEMRESTRICTION_NONE) { 44edb2538eSJeremy L Thompson CeedCall(CeedElemRestrictionGetNumComponents(r, &rstr_num_comp)); 45e1e9e29dSJed Brown } 46e15f9bd0SJeremy L Thompson // Basis 47356036faSJeremy L Thompson CeedCheck((b == CEED_BASIS_NONE) == (eval_mode == CEED_EVAL_NONE), ceed, CEED_ERROR_INCOMPATIBLE, 48356036faSJeremy L Thompson "CEED_BASIS_NONE and CEED_EVAL_NONE must be used together."); 49356036faSJeremy L Thompson if (b != CEED_BASIS_NONE) { 502b730f8bSJeremy L Thompson CeedCall(CeedBasisGetDimension(b, &dim)); 512b730f8bSJeremy L Thompson CeedCall(CeedBasisGetNumComponents(b, &num_comp)); 52c4e3f59bSSebastian Grimberg CeedCall(CeedBasisGetNumQuadratureComponents(b, eval_mode, &q_comp)); 53edb2538eSJeremy L Thompson CeedCheck(r == CEED_ELEMRESTRICTION_NONE || rstr_num_comp == num_comp, ceed, CEED_ERROR_DIMENSION, 546574a04fSJeremy L Thompson "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components, but Basis has %" CeedInt_FMT 556574a04fSJeremy L Thompson " components", 56edb2538eSJeremy L Thompson qf_field->field_name, qf_field->size, CeedEvalModes[qf_field->eval_mode], rstr_num_comp, num_comp); 57e15f9bd0SJeremy L Thompson } 58e15f9bd0SJeremy L Thompson // Field size 59d1d35e2fSjeremylt switch (eval_mode) { 60e15f9bd0SJeremy L Thompson case CEED_EVAL_NONE: 61edb2538eSJeremy L Thompson CeedCheck(size == rstr_num_comp, ceed, CEED_ERROR_DIMENSION, 62953dad27SJames Wright "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components", qf_field->field_name, 63edb2538eSJeremy L Thompson qf_field->size, CeedEvalModes[qf_field->eval_mode], rstr_num_comp); 64e15f9bd0SJeremy L Thompson break; 65e15f9bd0SJeremy L Thompson case CEED_EVAL_INTERP: 66c4e3f59bSSebastian Grimberg case CEED_EVAL_GRAD: 67c4e3f59bSSebastian Grimberg case CEED_EVAL_DIV: 68c4e3f59bSSebastian Grimberg case CEED_EVAL_CURL: 696574a04fSJeremy L Thompson CeedCheck(size == num_comp * q_comp, ceed, CEED_ERROR_DIMENSION, 706574a04fSJeremy L Thompson "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction/Basis has %" CeedInt_FMT " components", qf_field->field_name, 716574a04fSJeremy L Thompson qf_field->size, CeedEvalModes[qf_field->eval_mode], num_comp * q_comp); 72e15f9bd0SJeremy L Thompson break; 73e15f9bd0SJeremy L Thompson case CEED_EVAL_WEIGHT: 74d1d35e2fSjeremylt // No additional checks required 75e15f9bd0SJeremy L Thompson break; 76e15f9bd0SJeremy L Thompson } 77e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 787a982d89SJeremy L. Thompson } 797a982d89SJeremy L. Thompson 807a982d89SJeremy L. Thompson /** 817a982d89SJeremy L. Thompson @brief View a field of a CeedOperator 827a982d89SJeremy L. Thompson 837a982d89SJeremy L. Thompson @param[in] field Operator field to view 84d1d35e2fSjeremylt @param[in] qf_field QFunction field (carries field name) 85d1d35e2fSjeremylt @param[in] field_number Number of field being viewed 864c4400c7SValeria Barra @param[in] sub true indicates sub-operator, which increases indentation; false for top-level operator 87d1d35e2fSjeremylt @param[in] input true for an input field; false for output field 887a982d89SJeremy L. Thompson @param[in] stream Stream to view to, e.g., stdout 897a982d89SJeremy L. Thompson 907a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 917a982d89SJeremy L. Thompson 927a982d89SJeremy L. Thompson @ref Utility 937a982d89SJeremy L. Thompson **/ 942b730f8bSJeremy L Thompson static int CeedOperatorFieldView(CeedOperatorField field, CeedQFunctionField qf_field, CeedInt field_number, bool sub, bool input, FILE *stream) { 957a982d89SJeremy L. Thompson const char *pre = sub ? " " : ""; 96d1d35e2fSjeremylt const char *in_out = input ? "Input" : "Output"; 977a982d89SJeremy L. Thompson 982b730f8bSJeremy L Thompson fprintf(stream, 992b730f8bSJeremy L Thompson "%s %s field %" CeedInt_FMT 1002b730f8bSJeremy L Thompson ":\n" 1017a982d89SJeremy L. Thompson "%s Name: \"%s\"\n", 102d1d35e2fSjeremylt pre, in_out, field_number, pre, qf_field->field_name); 103990fdeb6SJeremy L Thompson fprintf(stream, "%s Size: %" CeedInt_FMT "\n", pre, qf_field->size); 1042b730f8bSJeremy L Thompson fprintf(stream, "%s EvalMode: %s\n", pre, CeedEvalModes[qf_field->eval_mode]); 105356036faSJeremy L Thompson if (field->basis == CEED_BASIS_NONE) fprintf(stream, "%s No basis\n", pre); 1062b730f8bSJeremy L Thompson if (field->vec == CEED_VECTOR_ACTIVE) fprintf(stream, "%s Active vector\n", pre); 1072b730f8bSJeremy L Thompson else if (field->vec == CEED_VECTOR_NONE) fprintf(stream, "%s No vector\n", pre); 108e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 1097a982d89SJeremy L. Thompson } 1107a982d89SJeremy L. Thompson 1117a982d89SJeremy L. Thompson /** 1127a982d89SJeremy L. Thompson @brief View a single CeedOperator 1137a982d89SJeremy L. Thompson 1147a982d89SJeremy L. Thompson @param[in] op CeedOperator to view 1157a982d89SJeremy L. Thompson @param[in] sub Boolean flag for sub-operator 1167a982d89SJeremy L. Thompson @param[in] stream Stream to write; typically stdout/stderr or a file 1177a982d89SJeremy L. Thompson 1187a982d89SJeremy L. Thompson @return Error code: 0 - success, otherwise - failure 1197a982d89SJeremy L. Thompson 1207a982d89SJeremy L. Thompson @ref Utility 1217a982d89SJeremy L. Thompson **/ 1227a982d89SJeremy L. Thompson int CeedOperatorSingleView(CeedOperator op, bool sub, FILE *stream) { 1237a982d89SJeremy L. Thompson const char *pre = sub ? " " : ""; 1241c66c397SJeremy L Thompson CeedInt num_elem, num_qpts, total_fields = 0; 1257a982d89SJeremy L. Thompson 1262b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetNumElements(op, &num_elem)); 1272b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts)); 1282b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetNumArgs(op, &total_fields)); 1291c66c397SJeremy L Thompson 1302b730f8bSJeremy L Thompson fprintf(stream, "%s %" CeedInt_FMT " elements with %" CeedInt_FMT " quadrature points each\n", pre, num_elem, num_qpts); 1312b730f8bSJeremy L Thompson fprintf(stream, "%s %" CeedInt_FMT " field%s\n", pre, total_fields, total_fields > 1 ? "s" : ""); 1322b730f8bSJeremy L Thompson fprintf(stream, "%s %" CeedInt_FMT " input field%s:\n", pre, op->qf->num_input_fields, op->qf->num_input_fields > 1 ? "s" : ""); 133d1d35e2fSjeremylt for (CeedInt i = 0; i < op->qf->num_input_fields; i++) { 1342b730f8bSJeremy L Thompson CeedCall(CeedOperatorFieldView(op->input_fields[i], op->qf->input_fields[i], i, sub, 1, stream)); 1357a982d89SJeremy L. Thompson } 1362b730f8bSJeremy L Thompson fprintf(stream, "%s %" CeedInt_FMT " output field%s:\n", pre, op->qf->num_output_fields, op->qf->num_output_fields > 1 ? "s" : ""); 137d1d35e2fSjeremylt for (CeedInt i = 0; i < op->qf->num_output_fields; i++) { 1382b730f8bSJeremy L Thompson CeedCall(CeedOperatorFieldView(op->output_fields[i], op->qf->output_fields[i], i, sub, 0, stream)); 1397a982d89SJeremy L. Thompson } 140e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 1417a982d89SJeremy L. Thompson } 1427a982d89SJeremy L. Thompson 143d99fa3c5SJeremy L Thompson /** 1440f60e0a8SJeremy L Thompson @brief Find the active vector basis for a non-composite CeedOperator 145eaf62fffSJeremy L Thompson 146eaf62fffSJeremy L Thompson @param[in] op CeedOperator to find active basis for 1470f60e0a8SJeremy L Thompson @param[out] active_basis Basis for active input vector or NULL for composite operator 148eaf62fffSJeremy L Thompson 149eaf62fffSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 150eaf62fffSJeremy L Thompson 151eaf62fffSJeremy L Thompson @ref Developer 152eaf62fffSJeremy L Thompson **/ 153eaf62fffSJeremy L Thompson int CeedOperatorGetActiveBasis(CeedOperator op, CeedBasis *active_basis) { 154506b1a0cSSebastian Grimberg CeedCall(CeedOperatorGetActiveBases(op, active_basis, NULL)); 155506b1a0cSSebastian Grimberg return CEED_ERROR_SUCCESS; 156506b1a0cSSebastian Grimberg } 157506b1a0cSSebastian Grimberg 158506b1a0cSSebastian Grimberg /** 159506b1a0cSSebastian Grimberg @brief Find the active input and output vector bases for a non-composite CeedOperator 160506b1a0cSSebastian Grimberg 161506b1a0cSSebastian Grimberg @param[in] op CeedOperator to find active bases for 162506b1a0cSSebastian Grimberg @param[out] active_input_basis Basis for active input vector or NULL for composite operator 163506b1a0cSSebastian Grimberg @param[out] active_output_basis Basis for active output vector or NULL for composite operator 164506b1a0cSSebastian Grimberg 165506b1a0cSSebastian Grimberg @return An error code: 0 - success, otherwise - failure 166506b1a0cSSebastian Grimberg 167506b1a0cSSebastian Grimberg @ref Developer 168506b1a0cSSebastian Grimberg **/ 169506b1a0cSSebastian Grimberg int CeedOperatorGetActiveBases(CeedOperator op, CeedBasis *active_input_basis, CeedBasis *active_output_basis) { 1706aaed0edSJeremy L Thompson Ceed ceed; 1711c66c397SJeremy L Thompson 1726aaed0edSJeremy L Thompson CeedCall(CeedOperatorGetCeed(op, &ceed)); 173506b1a0cSSebastian Grimberg if (active_input_basis) { 174506b1a0cSSebastian Grimberg *active_input_basis = NULL; 175506b1a0cSSebastian Grimberg if (!op->is_composite) { 1762b730f8bSJeremy L Thompson for (CeedInt i = 0; i < op->qf->num_input_fields; i++) { 177eaf62fffSJeremy L Thompson if (op->input_fields[i]->vec == CEED_VECTOR_ACTIVE) { 178506b1a0cSSebastian Grimberg CeedCheck(!*active_input_basis || *active_input_basis == op->input_fields[i]->basis, ceed, CEED_ERROR_MINOR, 179506b1a0cSSebastian Grimberg "Multiple active input CeedBases found"); 180506b1a0cSSebastian Grimberg *active_input_basis = op->input_fields[i]->basis; 181eaf62fffSJeremy L Thompson } 1822b730f8bSJeremy L Thompson } 183506b1a0cSSebastian Grimberg CeedCheck(*active_input_basis, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedBasis found"); 184506b1a0cSSebastian Grimberg } 185506b1a0cSSebastian Grimberg } 186506b1a0cSSebastian Grimberg if (active_output_basis) { 187506b1a0cSSebastian Grimberg *active_output_basis = NULL; 188506b1a0cSSebastian Grimberg if (!op->is_composite) { 189506b1a0cSSebastian Grimberg for (CeedInt i = 0; i < op->qf->num_output_fields; i++) { 190506b1a0cSSebastian Grimberg if (op->output_fields[i]->vec == CEED_VECTOR_ACTIVE) { 191506b1a0cSSebastian Grimberg CeedCheck(!*active_output_basis || *active_output_basis == op->output_fields[i]->basis, ceed, CEED_ERROR_MINOR, 192506b1a0cSSebastian Grimberg "Multiple active output CeedBases found"); 193506b1a0cSSebastian Grimberg *active_output_basis = op->output_fields[i]->basis; 194506b1a0cSSebastian Grimberg } 195506b1a0cSSebastian Grimberg } 196506b1a0cSSebastian Grimberg CeedCheck(*active_output_basis, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedBasis found"); 197506b1a0cSSebastian Grimberg } 198506b1a0cSSebastian Grimberg } 199eaf62fffSJeremy L Thompson return CEED_ERROR_SUCCESS; 200eaf62fffSJeremy L Thompson } 201eaf62fffSJeremy L Thompson 202eaf62fffSJeremy L Thompson /** 2030f60e0a8SJeremy L Thompson @brief Find the active vector ElemRestriction for a non-composite CeedOperator 204e2f04181SAndrew T. Barker 205506b1a0cSSebastian Grimberg @param[in] op CeedOperator to find active ElemRestriction for 2060f60e0a8SJeremy L Thompson @param[out] active_rstr ElemRestriction for active input vector or NULL for composite operator 207e2f04181SAndrew T. Barker 208e2f04181SAndrew T. Barker @return An error code: 0 - success, otherwise - failure 209e2f04181SAndrew T. Barker 210e2f04181SAndrew T. Barker @ref Utility 211e2f04181SAndrew T. Barker **/ 2122b730f8bSJeremy L Thompson int CeedOperatorGetActiveElemRestriction(CeedOperator op, CeedElemRestriction *active_rstr) { 213506b1a0cSSebastian Grimberg CeedCall(CeedOperatorGetActiveElemRestrictions(op, active_rstr, NULL)); 214506b1a0cSSebastian Grimberg return CEED_ERROR_SUCCESS; 215506b1a0cSSebastian Grimberg } 216506b1a0cSSebastian Grimberg 217506b1a0cSSebastian Grimberg /** 218506b1a0cSSebastian Grimberg @brief Find the active input and output vector ElemRestrictions for a non-composite CeedOperator 219506b1a0cSSebastian Grimberg 220506b1a0cSSebastian Grimberg @param[in] op CeedOperator to find active ElemRestrictions for 221506b1a0cSSebastian Grimberg @param[out] active_input_rstr ElemRestriction for active input vector or NULL for composite operator 222506b1a0cSSebastian Grimberg @param[out] active_output_rstr ElemRestriction for active output vector or NULL for composite operator 223506b1a0cSSebastian Grimberg 224506b1a0cSSebastian Grimberg @return An error code: 0 - success, otherwise - failure 225506b1a0cSSebastian Grimberg 226506b1a0cSSebastian Grimberg @ref Utility 227506b1a0cSSebastian Grimberg **/ 228506b1a0cSSebastian Grimberg int CeedOperatorGetActiveElemRestrictions(CeedOperator op, CeedElemRestriction *active_input_rstr, CeedElemRestriction *active_output_rstr) { 2296aaed0edSJeremy L Thompson Ceed ceed; 2301c66c397SJeremy L Thompson 2316aaed0edSJeremy L Thompson CeedCall(CeedOperatorGetCeed(op, &ceed)); 232506b1a0cSSebastian Grimberg if (active_input_rstr) { 233506b1a0cSSebastian Grimberg *active_input_rstr = NULL; 234506b1a0cSSebastian Grimberg if (!op->is_composite) { 2352b730f8bSJeremy L Thompson for (CeedInt i = 0; i < op->qf->num_input_fields; i++) { 236d1d35e2fSjeremylt if (op->input_fields[i]->vec == CEED_VECTOR_ACTIVE) { 237506b1a0cSSebastian Grimberg CeedCheck(!*active_input_rstr || *active_input_rstr == op->input_fields[i]->elem_rstr, ceed, CEED_ERROR_MINOR, 238506b1a0cSSebastian Grimberg "Multiple active input CeedElemRestrictions found"); 239506b1a0cSSebastian Grimberg *active_input_rstr = op->input_fields[i]->elem_rstr; 240e2f04181SAndrew T. Barker } 2412b730f8bSJeremy L Thompson } 242506b1a0cSSebastian Grimberg CeedCheck(*active_input_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedElemRestriction found"); 243506b1a0cSSebastian Grimberg } 244506b1a0cSSebastian Grimberg } 245506b1a0cSSebastian Grimberg if (active_output_rstr) { 246506b1a0cSSebastian Grimberg *active_output_rstr = NULL; 247506b1a0cSSebastian Grimberg if (!op->is_composite) { 248506b1a0cSSebastian Grimberg for (CeedInt i = 0; i < op->qf->num_output_fields; i++) { 249506b1a0cSSebastian Grimberg if (op->output_fields[i]->vec == CEED_VECTOR_ACTIVE) { 250506b1a0cSSebastian Grimberg CeedCheck(!*active_output_rstr || *active_output_rstr == op->output_fields[i]->elem_rstr, ceed, CEED_ERROR_MINOR, 251506b1a0cSSebastian Grimberg "Multiple active output CeedElemRestrictions found"); 252506b1a0cSSebastian Grimberg *active_output_rstr = op->output_fields[i]->elem_rstr; 253506b1a0cSSebastian Grimberg } 254506b1a0cSSebastian Grimberg } 255506b1a0cSSebastian Grimberg CeedCheck(*active_output_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedElemRestriction found"); 256506b1a0cSSebastian Grimberg } 257506b1a0cSSebastian Grimberg } 258e2f04181SAndrew T. Barker return CEED_ERROR_SUCCESS; 259e2f04181SAndrew T. Barker } 260e2f04181SAndrew T. Barker 261d8dd9a91SJeremy L Thompson /** 2622788fa27SJeremy L Thompson @brief Set QFunctionContext field values of the specified type. 2634385fb7fSSebastian Grimberg 264ea61e9acSJeremy L Thompson For composite operators, the value is set in all sub-operator QFunctionContexts that have a matching `field_name`. 2659fd66db6SSebastian Grimberg A non-zero error code is returned for single operators that do not have a matching field of the same type or composite operators that do not have 2669fd66db6SSebastian Grimberg any field of a matching type. 267d8dd9a91SJeremy L Thompson 268ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 269ea61e9acSJeremy L Thompson @param[in] field_label Label of field to set 270ea61e9acSJeremy L Thompson @param[in] field_type Type of field to set 2712788fa27SJeremy L Thompson @param[in] values Values to set 272d8dd9a91SJeremy L Thompson 273d8dd9a91SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 274d8dd9a91SJeremy L Thompson 275d8dd9a91SJeremy L Thompson @ref User 276d8dd9a91SJeremy L Thompson **/ 2772788fa27SJeremy L Thompson static int CeedOperatorContextSetGeneric(CeedOperator op, CeedContextFieldLabel field_label, CeedContextFieldType field_type, void *values) { 2781c66c397SJeremy L Thompson bool is_composite = false; 2791c66c397SJeremy L Thompson 2806574a04fSJeremy L Thompson CeedCheck(field_label, op->ceed, CEED_ERROR_UNSUPPORTED, "Invalid field label"); 2813668ca4bSJeremy L Thompson 2825ac9af79SJeremy L Thompson // Check if field_label and op correspond 2835ac9af79SJeremy L Thompson if (field_label->from_op) { 2845ac9af79SJeremy L Thompson CeedInt index = -1; 2855ac9af79SJeremy L Thompson 2865ac9af79SJeremy L Thompson for (CeedInt i = 0; i < op->num_context_labels; i++) { 2875ac9af79SJeremy L Thompson if (op->context_labels[i] == field_label) index = i; 2885ac9af79SJeremy L Thompson } 2896574a04fSJeremy L Thompson CeedCheck(index != -1, op->ceed, CEED_ERROR_UNSUPPORTED, "ContextFieldLabel does not correspond to the operator"); 2905ac9af79SJeremy L Thompson } 2915ac9af79SJeremy L Thompson 2922b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 293d8dd9a91SJeremy L Thompson if (is_composite) { 294d8dd9a91SJeremy L Thompson CeedInt num_sub; 295d8dd9a91SJeremy L Thompson CeedOperator *sub_operators; 296d8dd9a91SJeremy L Thompson 297c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_sub)); 298c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 2996574a04fSJeremy L Thompson CeedCheck(num_sub == field_label->num_sub_labels, op->ceed, CEED_ERROR_UNSUPPORTED, 3006574a04fSJeremy L Thompson "Composite operator modified after ContextFieldLabel created"); 301d8dd9a91SJeremy L Thompson 302d8dd9a91SJeremy L Thompson for (CeedInt i = 0; i < num_sub; i++) { 303d8dd9a91SJeremy L Thompson // Try every sub-operator, ok if some sub-operators do not have field 3043668ca4bSJeremy L Thompson if (field_label->sub_labels[i] && sub_operators[i]->qf->ctx) { 3052788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextSetGeneric(sub_operators[i]->qf->ctx, field_label->sub_labels[i], field_type, values)); 306d8dd9a91SJeremy L Thompson } 307d8dd9a91SJeremy L Thompson } 308d8dd9a91SJeremy L Thompson } else { 3096574a04fSJeremy L Thompson CeedCheck(op->qf->ctx, op->ceed, CEED_ERROR_UNSUPPORTED, "QFunction does not have context data"); 3102788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextSetGeneric(op->qf->ctx, field_label, field_type, values)); 3112788fa27SJeremy L Thompson } 3126d95ab46SJeremy L Thompson CeedCall(CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(op, true)); 3132788fa27SJeremy L Thompson return CEED_ERROR_SUCCESS; 3142788fa27SJeremy L Thompson } 3152788fa27SJeremy L Thompson 3162788fa27SJeremy L Thompson /** 3172788fa27SJeremy L Thompson @brief Get QFunctionContext field values of the specified type, read-only. 3184385fb7fSSebastian Grimberg 3192788fa27SJeremy L Thompson For composite operators, the values retrieved are for the first sub-operator QFunctionContext that have a matching `field_name`. 3209fd66db6SSebastian Grimberg A non-zero error code is returned for single operators that do not have a matching field of the same type or composite operators that do not have 3219fd66db6SSebastian Grimberg any field of a matching type. 3222788fa27SJeremy L Thompson 3232788fa27SJeremy L Thompson @param[in,out] op CeedOperator 3242788fa27SJeremy L Thompson @param[in] field_label Label of field to set 3252788fa27SJeremy L Thompson @param[in] field_type Type of field to set 326c5d0f995SJed Brown @param[out] num_values Number of values of type `field_type` in array `values` 327c5d0f995SJed Brown @param[out] values Values in the label 3282788fa27SJeremy L Thompson 3292788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 3302788fa27SJeremy L Thompson 3312788fa27SJeremy L Thompson @ref User 3322788fa27SJeremy L Thompson **/ 3332788fa27SJeremy L Thompson static int CeedOperatorContextGetGenericRead(CeedOperator op, CeedContextFieldLabel field_label, CeedContextFieldType field_type, size_t *num_values, 3342788fa27SJeremy L Thompson void *values) { 3351c66c397SJeremy L Thompson bool is_composite = false; 3361c66c397SJeremy L Thompson 3376574a04fSJeremy L Thompson CeedCheck(field_label, op->ceed, CEED_ERROR_UNSUPPORTED, "Invalid field label"); 3382788fa27SJeremy L Thompson 3392788fa27SJeremy L Thompson *(void **)values = NULL; 3402788fa27SJeremy L Thompson *num_values = 0; 3412788fa27SJeremy L Thompson 3425ac9af79SJeremy L Thompson // Check if field_label and op correspond 3435ac9af79SJeremy L Thompson if (field_label->from_op) { 3445ac9af79SJeremy L Thompson CeedInt index = -1; 3455ac9af79SJeremy L Thompson 3465ac9af79SJeremy L Thompson for (CeedInt i = 0; i < op->num_context_labels; i++) { 3475ac9af79SJeremy L Thompson if (op->context_labels[i] == field_label) index = i; 3485ac9af79SJeremy L Thompson } 3496574a04fSJeremy L Thompson CeedCheck(index != -1, op->ceed, CEED_ERROR_UNSUPPORTED, "ContextFieldLabel does not correspond to the operator"); 3505ac9af79SJeremy L Thompson } 3515ac9af79SJeremy L Thompson 3522788fa27SJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 3532788fa27SJeremy L Thompson if (is_composite) { 3542788fa27SJeremy L Thompson CeedInt num_sub; 3552788fa27SJeremy L Thompson CeedOperator *sub_operators; 3562788fa27SJeremy L Thompson 3572788fa27SJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_sub)); 3582788fa27SJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 3596574a04fSJeremy L Thompson CeedCheck(num_sub == field_label->num_sub_labels, op->ceed, CEED_ERROR_UNSUPPORTED, 3606574a04fSJeremy L Thompson "Composite operator modified after ContextFieldLabel created"); 3612788fa27SJeremy L Thompson 3622788fa27SJeremy L Thompson for (CeedInt i = 0; i < num_sub; i++) { 3632788fa27SJeremy L Thompson // Try every sub-operator, ok if some sub-operators do not have field 3642788fa27SJeremy L Thompson if (field_label->sub_labels[i] && sub_operators[i]->qf->ctx) { 3652788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextGetGenericRead(sub_operators[i]->qf->ctx, field_label->sub_labels[i], field_type, num_values, values)); 3662788fa27SJeremy L Thompson return CEED_ERROR_SUCCESS; 3672788fa27SJeremy L Thompson } 3682788fa27SJeremy L Thompson } 3692788fa27SJeremy L Thompson } else { 3706574a04fSJeremy L Thompson CeedCheck(op->qf->ctx, op->ceed, CEED_ERROR_UNSUPPORTED, "QFunction does not have context data"); 3712788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextGetGenericRead(op->qf->ctx, field_label, field_type, num_values, values)); 3722788fa27SJeremy L Thompson } 3732788fa27SJeremy L Thompson return CEED_ERROR_SUCCESS; 3742788fa27SJeremy L Thompson } 3752788fa27SJeremy L Thompson 3762788fa27SJeremy L Thompson /** 3772788fa27SJeremy L Thompson @brief Restore QFunctionContext field values of the specified type, read-only. 3784385fb7fSSebastian Grimberg 3792788fa27SJeremy L Thompson For composite operators, the values restored are for the first sub-operator QFunctionContext that have a matching `field_name`. 3809fd66db6SSebastian Grimberg A non-zero error code is returned for single operators that do not have a matching field of the same type or composite operators that do not have 3819fd66db6SSebastian Grimberg any field of a matching type. 3822788fa27SJeremy L Thompson 3832788fa27SJeremy L Thompson @param[in,out] op CeedOperator 3842788fa27SJeremy L Thompson @param[in] field_label Label of field to set 3852788fa27SJeremy L Thompson @param[in] field_type Type of field to set 386c5d0f995SJed Brown @param[in] values Values array to restore 3872788fa27SJeremy L Thompson 3882788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 3892788fa27SJeremy L Thompson 3902788fa27SJeremy L Thompson @ref User 3912788fa27SJeremy L Thompson **/ 3922788fa27SJeremy L Thompson static int CeedOperatorContextRestoreGenericRead(CeedOperator op, CeedContextFieldLabel field_label, CeedContextFieldType field_type, void *values) { 3931c66c397SJeremy L Thompson bool is_composite = false; 3941c66c397SJeremy L Thompson 3956574a04fSJeremy L Thompson CeedCheck(field_label, op->ceed, CEED_ERROR_UNSUPPORTED, "Invalid field label"); 3962788fa27SJeremy L Thompson 3975ac9af79SJeremy L Thompson // Check if field_label and op correspond 3985ac9af79SJeremy L Thompson if (field_label->from_op) { 3995ac9af79SJeremy L Thompson CeedInt index = -1; 4005ac9af79SJeremy L Thompson 4015ac9af79SJeremy L Thompson for (CeedInt i = 0; i < op->num_context_labels; i++) { 4025ac9af79SJeremy L Thompson if (op->context_labels[i] == field_label) index = i; 4035ac9af79SJeremy L Thompson } 4046574a04fSJeremy L Thompson CeedCheck(index != -1, op->ceed, CEED_ERROR_UNSUPPORTED, "ContextFieldLabel does not correspond to the operator"); 4055ac9af79SJeremy L Thompson } 4065ac9af79SJeremy L Thompson 4072788fa27SJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 4082788fa27SJeremy L Thompson if (is_composite) { 4092788fa27SJeremy L Thompson CeedInt num_sub; 4102788fa27SJeremy L Thompson CeedOperator *sub_operators; 4112788fa27SJeremy L Thompson 4122788fa27SJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_sub)); 4132788fa27SJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 4146574a04fSJeremy L Thompson CeedCheck(num_sub == field_label->num_sub_labels, op->ceed, CEED_ERROR_UNSUPPORTED, 4156574a04fSJeremy L Thompson "Composite operator modified after ContextFieldLabel created"); 4162788fa27SJeremy L Thompson 4172788fa27SJeremy L Thompson for (CeedInt i = 0; i < num_sub; i++) { 4182788fa27SJeremy L Thompson // Try every sub-operator, ok if some sub-operators do not have field 4192788fa27SJeremy L Thompson if (field_label->sub_labels[i] && sub_operators[i]->qf->ctx) { 4202788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextRestoreGenericRead(sub_operators[i]->qf->ctx, field_label->sub_labels[i], field_type, values)); 4212788fa27SJeremy L Thompson return CEED_ERROR_SUCCESS; 4222788fa27SJeremy L Thompson } 4232788fa27SJeremy L Thompson } 4242788fa27SJeremy L Thompson } else { 4256574a04fSJeremy L Thompson CeedCheck(op->qf->ctx, op->ceed, CEED_ERROR_UNSUPPORTED, "QFunction does not have context data"); 4262788fa27SJeremy L Thompson CeedCall(CeedQFunctionContextRestoreGenericRead(op->qf->ctx, field_label, field_type, values)); 427d8dd9a91SJeremy L Thompson } 428d8dd9a91SJeremy L Thompson return CEED_ERROR_SUCCESS; 429d8dd9a91SJeremy L Thompson } 430d8dd9a91SJeremy L Thompson 4317a982d89SJeremy L. Thompson /// @} 4327a982d89SJeremy L. Thompson 4337a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 4347a982d89SJeremy L. Thompson /// CeedOperator Backend API 4357a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 4367a982d89SJeremy L. Thompson /// @addtogroup CeedOperatorBackend 4377a982d89SJeremy L. Thompson /// @{ 4387a982d89SJeremy L. Thompson 4397a982d89SJeremy L. Thompson /** 4407a982d89SJeremy L. Thompson @brief Get the number of arguments associated with a CeedOperator 4417a982d89SJeremy L. Thompson 442ea61e9acSJeremy L Thompson @param[in] op CeedOperator 443d1d35e2fSjeremylt @param[out] num_args Variable to store vector number of arguments 4447a982d89SJeremy L. Thompson 4457a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 4467a982d89SJeremy L. Thompson 4477a982d89SJeremy L. Thompson @ref Backend 4487a982d89SJeremy L. Thompson **/ 449d1d35e2fSjeremylt int CeedOperatorGetNumArgs(CeedOperator op, CeedInt *num_args) { 4506574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_MINOR, "Not defined for composite operators"); 451d1d35e2fSjeremylt *num_args = op->num_fields; 452e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 4537a982d89SJeremy L. Thompson } 4547a982d89SJeremy L. Thompson 4557a982d89SJeremy L. Thompson /** 4567a982d89SJeremy L. Thompson @brief Get the setup status of a CeedOperator 4577a982d89SJeremy L. Thompson 458ea61e9acSJeremy L Thompson @param[in] op CeedOperator 459d1d35e2fSjeremylt @param[out] is_setup_done Variable to store setup status 4607a982d89SJeremy L. Thompson 4617a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 4627a982d89SJeremy L. Thompson 4637a982d89SJeremy L. Thompson @ref Backend 4647a982d89SJeremy L. Thompson **/ 465d1d35e2fSjeremylt int CeedOperatorIsSetupDone(CeedOperator op, bool *is_setup_done) { 466f04ea552SJeremy L Thompson *is_setup_done = op->is_backend_setup; 467e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 4687a982d89SJeremy L. Thompson } 4697a982d89SJeremy L. Thompson 4707a982d89SJeremy L. Thompson /** 4717a982d89SJeremy L. Thompson @brief Get the QFunction associated with a CeedOperator 4727a982d89SJeremy L. Thompson 473ea61e9acSJeremy L Thompson @param[in] op CeedOperator 4747a982d89SJeremy L. Thompson @param[out] qf Variable to store QFunction 4757a982d89SJeremy L. Thompson 4767a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 4777a982d89SJeremy L. Thompson 4787a982d89SJeremy L. Thompson @ref Backend 4797a982d89SJeremy L. Thompson **/ 4807a982d89SJeremy L. Thompson int CeedOperatorGetQFunction(CeedOperator op, CeedQFunction *qf) { 4816574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_MINOR, "Not defined for composite operator"); 4827a982d89SJeremy L. Thompson *qf = op->qf; 483e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 4847a982d89SJeremy L. Thompson } 4857a982d89SJeremy L. Thompson 4867a982d89SJeremy L. Thompson /** 487c04a41a7SJeremy L Thompson @brief Get a boolean value indicating if the CeedOperator is composite 488c04a41a7SJeremy L Thompson 489ea61e9acSJeremy L Thompson @param[in] op CeedOperator 490d1d35e2fSjeremylt @param[out] is_composite Variable to store composite status 491c04a41a7SJeremy L Thompson 492c04a41a7SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 493c04a41a7SJeremy L Thompson 494c04a41a7SJeremy L Thompson @ref Backend 495c04a41a7SJeremy L Thompson **/ 496d1d35e2fSjeremylt int CeedOperatorIsComposite(CeedOperator op, bool *is_composite) { 497f04ea552SJeremy L Thompson *is_composite = op->is_composite; 498e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 499c04a41a7SJeremy L Thompson } 500c04a41a7SJeremy L Thompson 501c04a41a7SJeremy L Thompson /** 5027a982d89SJeremy L. Thompson @brief Get the backend data of a CeedOperator 5037a982d89SJeremy L. Thompson 504ea61e9acSJeremy L Thompson @param[in] op CeedOperator 5057a982d89SJeremy L. Thompson @param[out] data Variable to store data 5067a982d89SJeremy L. Thompson 5077a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 5087a982d89SJeremy L. Thompson 5097a982d89SJeremy L. Thompson @ref Backend 5107a982d89SJeremy L. Thompson **/ 511777ff853SJeremy L Thompson int CeedOperatorGetData(CeedOperator op, void *data) { 512777ff853SJeremy L Thompson *(void **)data = op->data; 513e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 5147a982d89SJeremy L. Thompson } 5157a982d89SJeremy L. Thompson 5167a982d89SJeremy L. Thompson /** 5177a982d89SJeremy L. Thompson @brief Set the backend data of a CeedOperator 5187a982d89SJeremy L. Thompson 519ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 520ea61e9acSJeremy L Thompson @param[in] data Data to set 5217a982d89SJeremy L. Thompson 5227a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 5237a982d89SJeremy L. Thompson 5247a982d89SJeremy L. Thompson @ref Backend 5257a982d89SJeremy L. Thompson **/ 526777ff853SJeremy L Thompson int CeedOperatorSetData(CeedOperator op, void *data) { 527777ff853SJeremy L Thompson op->data = data; 528e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 5297a982d89SJeremy L. Thompson } 5307a982d89SJeremy L. Thompson 5317a982d89SJeremy L. Thompson /** 53234359f16Sjeremylt @brief Increment the reference counter for a CeedOperator 53334359f16Sjeremylt 534ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator to increment the reference counter 53534359f16Sjeremylt 53634359f16Sjeremylt @return An error code: 0 - success, otherwise - failure 53734359f16Sjeremylt 53834359f16Sjeremylt @ref Backend 53934359f16Sjeremylt **/ 5409560d06aSjeremylt int CeedOperatorReference(CeedOperator op) { 54134359f16Sjeremylt op->ref_count++; 54234359f16Sjeremylt return CEED_ERROR_SUCCESS; 54334359f16Sjeremylt } 54434359f16Sjeremylt 54534359f16Sjeremylt /** 5467a982d89SJeremy L. Thompson @brief Set the setup flag of a CeedOperator to True 5477a982d89SJeremy L. Thompson 548ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 5497a982d89SJeremy L. Thompson 5507a982d89SJeremy L. Thompson @return An error code: 0 - success, otherwise - failure 5517a982d89SJeremy L. Thompson 5527a982d89SJeremy L. Thompson @ref Backend 5537a982d89SJeremy L. Thompson **/ 5547a982d89SJeremy L. Thompson int CeedOperatorSetSetupDone(CeedOperator op) { 555f04ea552SJeremy L Thompson op->is_backend_setup = true; 556e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 5577a982d89SJeremy L. Thompson } 5587a982d89SJeremy L. Thompson 5597a982d89SJeremy L. Thompson /// @} 5607a982d89SJeremy L. Thompson 5617a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 5627a982d89SJeremy L. Thompson /// CeedOperator Public API 5637a982d89SJeremy L. Thompson /// ---------------------------------------------------------------------------- 5647a982d89SJeremy L. Thompson /// @addtogroup CeedOperatorUser 565dfdf5a53Sjeremylt /// @{ 566d7b241e6Sjeremylt 567d7b241e6Sjeremylt /** 568ea61e9acSJeremy L Thompson @brief Create a CeedOperator and associate a CeedQFunction. 5694385fb7fSSebastian Grimberg 570ea61e9acSJeremy L Thompson A CeedBasis and CeedElemRestriction can be associated with CeedQFunction fields with \ref CeedOperatorSetField. 571d7b241e6Sjeremylt 572ea61e9acSJeremy L Thompson @param[in] ceed Ceed object where the CeedOperator will be created 573ea61e9acSJeremy L Thompson @param[in] qf QFunction defining the action of the operator at quadrature points 574ea61e9acSJeremy L Thompson @param[in] dqf QFunction defining the action of the Jacobian of @a qf (or @ref CEED_QFUNCTION_NONE) 575ea61e9acSJeremy L Thompson @param[in] dqfT QFunction defining the action of the transpose of the Jacobian of @a qf (or @ref CEED_QFUNCTION_NONE) 576ea61e9acSJeremy L Thompson @param[out] op Address of the variable where the newly created CeedOperator will be stored 577b11c1e72Sjeremylt 578b11c1e72Sjeremylt @return An error code: 0 - success, otherwise - failure 579dfdf5a53Sjeremylt 5807a982d89SJeremy L. Thompson @ref User 581d7b241e6Sjeremylt */ 5822b730f8bSJeremy L Thompson int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op) { 5835fe0d4faSjeremylt if (!ceed->OperatorCreate) { 5845fe0d4faSjeremylt Ceed delegate; 5856574a04fSJeremy L Thompson 5862b730f8bSJeremy L Thompson CeedCall(CeedGetObjectDelegate(ceed, &delegate, "Operator")); 5876574a04fSJeremy L Thompson CeedCheck(delegate, ceed, CEED_ERROR_UNSUPPORTED, "Backend does not support OperatorCreate"); 5882b730f8bSJeremy L Thompson CeedCall(CeedOperatorCreate(delegate, qf, dqf, dqfT, op)); 589e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 5905fe0d4faSjeremylt } 5915fe0d4faSjeremylt 5926574a04fSJeremy L Thompson CeedCheck(qf && qf != CEED_QFUNCTION_NONE, ceed, CEED_ERROR_MINOR, "Operator must have a valid QFunction."); 593db002c03SJeremy L Thompson 5942b730f8bSJeremy L Thompson CeedCall(CeedCalloc(1, op)); 595db002c03SJeremy L Thompson CeedCall(CeedReferenceCopy(ceed, &(*op)->ceed)); 596d1d35e2fSjeremylt (*op)->ref_count = 1; 5972b104005SJeremy L Thompson (*op)->input_size = -1; 5982b104005SJeremy L Thompson (*op)->output_size = -1; 599db002c03SJeremy L Thompson CeedCall(CeedQFunctionReferenceCopy(qf, &(*op)->qf)); 600db002c03SJeremy L Thompson if (dqf && dqf != CEED_QFUNCTION_NONE) CeedCall(CeedQFunctionReferenceCopy(dqf, &(*op)->dqf)); 601db002c03SJeremy L Thompson if (dqfT && dqfT != CEED_QFUNCTION_NONE) CeedCall(CeedQFunctionReferenceCopy(dqfT, &(*op)->dqfT)); 6022b730f8bSJeremy L Thompson CeedCall(CeedQFunctionAssemblyDataCreate(ceed, &(*op)->qf_assembled)); 6032b730f8bSJeremy L Thompson CeedCall(CeedCalloc(CEED_FIELD_MAX, &(*op)->input_fields)); 6042b730f8bSJeremy L Thompson CeedCall(CeedCalloc(CEED_FIELD_MAX, &(*op)->output_fields)); 6052b730f8bSJeremy L Thompson CeedCall(ceed->OperatorCreate(*op)); 606e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 607d7b241e6Sjeremylt } 608d7b241e6Sjeremylt 609d7b241e6Sjeremylt /** 610*48acf710SJeremy L Thompson @brief Create a CeedOperator for evaluation at evaluation at arbitrary points in each element. 611*48acf710SJeremy L Thompson 612*48acf710SJeremy L Thompson A CeedBasis and CeedElemRestriction can be associated with CeedQFunction fields with \ref CeedOperatorSetField. 613*48acf710SJeremy L Thompson The locations of each point are set with \ref CeedOperatorAtPointsSetPoints. 614*48acf710SJeremy L Thompson 615*48acf710SJeremy L Thompson @param[in] ceed Ceed object where the CeedOperator will be created 616*48acf710SJeremy L Thompson @param[in] qf QFunction defining the action of the operator at quadrature points 617*48acf710SJeremy L Thompson @param[in] dqf QFunction defining the action of the Jacobian of @a qf (or @ref CEED_QFUNCTION_NONE) 618*48acf710SJeremy L Thompson @param[in] dqfT QFunction defining the action of the transpose of the Jacobian of @a qf (or @ref CEED_QFUNCTION_NONE) 619*48acf710SJeremy L Thompson @param[out] op Address of the variable where the newly created CeedOperator will be stored 620*48acf710SJeremy L Thompson 621*48acf710SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 622*48acf710SJeremy L Thompson 623*48acf710SJeremy L Thompson @ref User 624*48acf710SJeremy L Thompson */ 625*48acf710SJeremy L Thompson int CeedOperatorCreateAtPoints(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op) { 626*48acf710SJeremy L Thompson if (!ceed->OperatorCreateAtPoints) { 627*48acf710SJeremy L Thompson Ceed delegate; 628*48acf710SJeremy L Thompson 629*48acf710SJeremy L Thompson CeedCall(CeedGetObjectDelegate(ceed, &delegate, "Operator")); 630*48acf710SJeremy L Thompson CeedCheck(delegate, ceed, CEED_ERROR_UNSUPPORTED, "Backend does not support OperatorCreateAtPoints"); 631*48acf710SJeremy L Thompson CeedCall(CeedOperatorCreateAtPoints(delegate, qf, dqf, dqfT, op)); 632*48acf710SJeremy L Thompson return CEED_ERROR_SUCCESS; 633*48acf710SJeremy L Thompson } 634*48acf710SJeremy L Thompson 635*48acf710SJeremy L Thompson CeedCheck(qf && qf != CEED_QFUNCTION_NONE, ceed, CEED_ERROR_MINOR, "Operator must have a valid QFunction."); 636*48acf710SJeremy L Thompson 637*48acf710SJeremy L Thompson CeedCall(CeedCalloc(1, op)); 638*48acf710SJeremy L Thompson CeedCall(CeedReferenceCopy(ceed, &(*op)->ceed)); 639*48acf710SJeremy L Thompson (*op)->ref_count = 1; 640*48acf710SJeremy L Thompson (*op)->is_at_points = true; 641*48acf710SJeremy L Thompson (*op)->input_size = -1; 642*48acf710SJeremy L Thompson (*op)->output_size = -1; 643*48acf710SJeremy L Thompson CeedCall(CeedQFunctionReferenceCopy(qf, &(*op)->qf)); 644*48acf710SJeremy L Thompson if (dqf && dqf != CEED_QFUNCTION_NONE) CeedCall(CeedQFunctionReferenceCopy(dqf, &(*op)->dqf)); 645*48acf710SJeremy L Thompson if (dqfT && dqfT != CEED_QFUNCTION_NONE) CeedCall(CeedQFunctionReferenceCopy(dqfT, &(*op)->dqfT)); 646*48acf710SJeremy L Thompson CeedCall(CeedQFunctionAssemblyDataCreate(ceed, &(*op)->qf_assembled)); 647*48acf710SJeremy L Thompson CeedCall(CeedCalloc(CEED_FIELD_MAX, &(*op)->input_fields)); 648*48acf710SJeremy L Thompson CeedCall(CeedCalloc(CEED_FIELD_MAX, &(*op)->output_fields)); 649*48acf710SJeremy L Thompson CeedCall(ceed->OperatorCreateAtPoints(*op)); 650*48acf710SJeremy L Thompson return CEED_ERROR_SUCCESS; 651*48acf710SJeremy L Thompson } 652*48acf710SJeremy L Thompson 653*48acf710SJeremy L Thompson /** 65452d6035fSJeremy L Thompson @brief Create an operator that composes the action of several operators 65552d6035fSJeremy L Thompson 656ea61e9acSJeremy L Thompson @param[in] ceed Ceed object where the CeedOperator will be created 657ea61e9acSJeremy L Thompson @param[out] op Address of the variable where the newly created Composite CeedOperator will be stored 65852d6035fSJeremy L Thompson 65952d6035fSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 66052d6035fSJeremy L Thompson 6617a982d89SJeremy L. Thompson @ref User 66252d6035fSJeremy L Thompson */ 66352d6035fSJeremy L Thompson int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op) { 66452d6035fSJeremy L Thompson if (!ceed->CompositeOperatorCreate) { 66552d6035fSJeremy L Thompson Ceed delegate; 66652d6035fSJeremy L Thompson 6671c66c397SJeremy L Thompson CeedCall(CeedGetObjectDelegate(ceed, &delegate, "Operator")); 668250756a7Sjeremylt if (delegate) { 6692b730f8bSJeremy L Thompson CeedCall(CeedCompositeOperatorCreate(delegate, op)); 670e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 67152d6035fSJeremy L Thompson } 672250756a7Sjeremylt } 67352d6035fSJeremy L Thompson 6742b730f8bSJeremy L Thompson CeedCall(CeedCalloc(1, op)); 675db002c03SJeremy L Thompson CeedCall(CeedReferenceCopy(ceed, &(*op)->ceed)); 676996d9ab5SJed Brown (*op)->ref_count = 1; 677f04ea552SJeremy L Thompson (*op)->is_composite = true; 6782b730f8bSJeremy L Thompson CeedCall(CeedCalloc(CEED_COMPOSITE_MAX, &(*op)->sub_operators)); 6792b104005SJeremy L Thompson (*op)->input_size = -1; 6802b104005SJeremy L Thompson (*op)->output_size = -1; 681250756a7Sjeremylt 682db002c03SJeremy L Thompson if (ceed->CompositeOperatorCreate) CeedCall(ceed->CompositeOperatorCreate(*op)); 683e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 68452d6035fSJeremy L Thompson } 68552d6035fSJeremy L Thompson 68652d6035fSJeremy L Thompson /** 687ea61e9acSJeremy L Thompson @brief Copy the pointer to a CeedOperator. 6884385fb7fSSebastian Grimberg 689ea61e9acSJeremy L Thompson Both pointers should be destroyed with `CeedOperatorDestroy()`. 690512bb800SJeremy L Thompson 691512bb800SJeremy L Thompson Note: If the value of `op_copy` passed to this function is non-NULL, then it is assumed that `op_copy` is a pointer to a CeedOperator. 692512bb800SJeremy L Thompson This CeedOperator will be destroyed if `op_copy` is the only reference to this CeedOperator. 6939560d06aSjeremylt 694ea61e9acSJeremy L Thompson @param[in] op CeedOperator to copy reference to 695ea61e9acSJeremy L Thompson @param[in,out] op_copy Variable to store copied reference 6969560d06aSjeremylt 6979560d06aSjeremylt @return An error code: 0 - success, otherwise - failure 6989560d06aSjeremylt 6999560d06aSjeremylt @ref User 7009560d06aSjeremylt **/ 7019560d06aSjeremylt int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy) { 7022b730f8bSJeremy L Thompson CeedCall(CeedOperatorReference(op)); 7032b730f8bSJeremy L Thompson CeedCall(CeedOperatorDestroy(op_copy)); 7049560d06aSjeremylt *op_copy = op; 7059560d06aSjeremylt return CEED_ERROR_SUCCESS; 7069560d06aSjeremylt } 7079560d06aSjeremylt 7089560d06aSjeremylt /** 709ea61e9acSJeremy L Thompson @brief Provide a field to a CeedOperator for use by its CeedQFunction. 710d7b241e6Sjeremylt 711ea61e9acSJeremy L Thompson This function is used to specify both active and passive fields to a CeedOperator. 712ea61e9acSJeremy L Thompson For passive fields, a vector @arg v must be provided. 713ea61e9acSJeremy L Thompson Passive fields can inputs or outputs (updated in-place when operator is applied). 714d7b241e6Sjeremylt 715ea61e9acSJeremy L Thompson Active fields must be specified using this function, but their data (in a CeedVector) is passed in CeedOperatorApply(). 716ea61e9acSJeremy L Thompson There can be at most one active input CeedVector and at most one active output CeedVector passed to CeedOperatorApply(). 717d7b241e6Sjeremylt 718528a22edSJeremy L Thompson The number of quadrature points must agree across all points. 719356036faSJeremy L Thompson When using @ref CEED_BASIS_NONE, the number of quadrature points is determined by the element size of r. 720528a22edSJeremy L Thompson 721ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator on which to provide the field 722ea61e9acSJeremy L Thompson @param[in] field_name Name of the field (to be matched with the name used by CeedQFunction) 723ea61e9acSJeremy L Thompson @param[in] r CeedElemRestriction 724356036faSJeremy L Thompson @param[in] b CeedBasis in which the field resides or @ref CEED_BASIS_NONE if collocated with quadrature points 7255ac9af79SJeremy L Thompson @param[in] v CeedVector to be used by CeedOperator or @ref CEED_VECTOR_ACTIVE if field is active or @ref CEED_VECTOR_NONE 7265ac9af79SJeremy L Thompson if using @ref CEED_EVAL_WEIGHT in the QFunction 727b11c1e72Sjeremylt 728b11c1e72Sjeremylt @return An error code: 0 - success, otherwise - failure 729dfdf5a53Sjeremylt 7307a982d89SJeremy L. Thompson @ref User 731b11c1e72Sjeremylt **/ 7322b730f8bSJeremy L Thompson int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v) { 7331c66c397SJeremy L Thompson bool is_input = true; 7341c66c397SJeremy L Thompson CeedInt num_elem = 0, num_qpts = 0; 7351c66c397SJeremy L Thompson CeedQFunctionField qf_field; 7361c66c397SJeremy L Thompson CeedOperatorField *op_field; 7371c66c397SJeremy L Thompson 7386574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_INCOMPATIBLE, "Cannot add field to composite operator."); 7396574a04fSJeremy L Thompson CeedCheck(!op->is_immutable, op->ceed, CEED_ERROR_MAJOR, "Operator cannot be changed after set as immutable"); 7406574a04fSJeremy L Thompson CeedCheck(r, op->ceed, CEED_ERROR_INCOMPATIBLE, "ElemRestriction r for field \"%s\" must be non-NULL.", field_name); 7416574a04fSJeremy L Thompson CeedCheck(b, op->ceed, CEED_ERROR_INCOMPATIBLE, "Basis b for field \"%s\" must be non-NULL.", field_name); 7426574a04fSJeremy L Thompson CeedCheck(v, op->ceed, CEED_ERROR_INCOMPATIBLE, "Vector v for field \"%s\" must be non-NULL.", field_name); 74352d6035fSJeremy L Thompson 7442b730f8bSJeremy L Thompson CeedCall(CeedElemRestrictionGetNumElements(r, &num_elem)); 7456574a04fSJeremy L Thompson CeedCheck(r == CEED_ELEMRESTRICTION_NONE || !op->has_restriction || op->num_elem == num_elem, op->ceed, CEED_ERROR_DIMENSION, 7462b730f8bSJeremy L Thompson "ElemRestriction with %" CeedInt_FMT " elements incompatible with prior %" CeedInt_FMT " elements", num_elem, op->num_elem); 7472c7e7413SJeremy L Thompson { 7482c7e7413SJeremy L Thompson CeedRestrictionType rstr_type; 7492c7e7413SJeremy L Thompson 7502c7e7413SJeremy L Thompson CeedCall(CeedElemRestrictionGetType(r, &rstr_type)); 751*48acf710SJeremy L Thompson if (rstr_type == CEED_RESTRICTION_POINTS) { 752*48acf710SJeremy L Thompson CeedCheck(op->is_at_points, op->ceed, CEED_ERROR_UNSUPPORTED, "ElemRestrictionAtPoints not supported for standard operator fields"); 753*48acf710SJeremy L Thompson CeedCheck(b == CEED_BASIS_NONE, op->ceed, CEED_ERROR_UNSUPPORTED, "ElemRestrictionAtPoints must be used with CEED_BASIS_NONE"); 754*48acf710SJeremy L Thompson if (!op->first_points_rstr) { 755*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionReferenceCopy(r, &op->first_points_rstr)); 756*48acf710SJeremy L Thompson } else { 757*48acf710SJeremy L Thompson bool are_compatible; 758*48acf710SJeremy L Thompson 759*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionAtPointsAreCompatible(op->first_points_rstr, r, &are_compatible)); 760*48acf710SJeremy L Thompson CeedCheck(are_compatible, op->ceed, CEED_ERROR_INCOMPATIBLE, 761*48acf710SJeremy L Thompson "ElemRestriction must have compatible offsets with previously set ElemRestriction"); 762*48acf710SJeremy L Thompson } 763*48acf710SJeremy L Thompson } 7642c7e7413SJeremy L Thompson } 765d7b241e6Sjeremylt 766356036faSJeremy L Thompson if (b == CEED_BASIS_NONE) CeedCall(CeedElemRestrictionGetElementSize(r, &num_qpts)); 7679a18a30cSJeremy L Thompson else CeedCall(CeedBasisGetNumQuadraturePoints(b, &num_qpts)); 768528a22edSJeremy L Thompson CeedCheck(op->num_qpts == 0 || op->num_qpts == num_qpts, op->ceed, CEED_ERROR_DIMENSION, 769528a22edSJeremy L Thompson "%s must correspond to the same number of quadrature points as previously added Bases. Found %" CeedInt_FMT 770528a22edSJeremy L Thompson " quadrature points but expected %" CeedInt_FMT " quadrature points.", 771356036faSJeremy L Thompson b == CEED_BASIS_NONE ? "ElemRestriction" : "Basis", num_qpts, op->num_qpts); 772d1d35e2fSjeremylt for (CeedInt i = 0; i < op->qf->num_input_fields; i++) { 773d1d35e2fSjeremylt if (!strcmp(field_name, (*op->qf->input_fields[i]).field_name)) { 774d1d35e2fSjeremylt qf_field = op->qf->input_fields[i]; 775d1d35e2fSjeremylt op_field = &op->input_fields[i]; 776d7b241e6Sjeremylt goto found; 777d7b241e6Sjeremylt } 778d7b241e6Sjeremylt } 7792b104005SJeremy L Thompson is_input = false; 780d1d35e2fSjeremylt for (CeedInt i = 0; i < op->qf->num_output_fields; i++) { 781d1d35e2fSjeremylt if (!strcmp(field_name, (*op->qf->output_fields[i]).field_name)) { 782d1d35e2fSjeremylt qf_field = op->qf->output_fields[i]; 783d1d35e2fSjeremylt op_field = &op->output_fields[i]; 784d7b241e6Sjeremylt goto found; 785d7b241e6Sjeremylt } 786d7b241e6Sjeremylt } 787c042f62fSJeremy L Thompson // LCOV_EXCL_START 7882b730f8bSJeremy L Thompson return CeedError(op->ceed, CEED_ERROR_INCOMPLETE, "QFunction has no knowledge of field '%s'", field_name); 789c042f62fSJeremy L Thompson // LCOV_EXCL_STOP 790d7b241e6Sjeremylt found: 7912b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckField(op->ceed, qf_field, r, b)); 7922b730f8bSJeremy L Thompson CeedCall(CeedCalloc(1, op_field)); 793e15f9bd0SJeremy L Thompson 7942b104005SJeremy L Thompson if (v == CEED_VECTOR_ACTIVE) { 7952b104005SJeremy L Thompson CeedSize l_size; 7961c66c397SJeremy L Thompson 7972b730f8bSJeremy L Thompson CeedCall(CeedElemRestrictionGetLVectorSize(r, &l_size)); 7982b104005SJeremy L Thompson if (is_input) { 7992b104005SJeremy L Thompson if (op->input_size == -1) op->input_size = l_size; 8006574a04fSJeremy L Thompson CeedCheck(l_size == op->input_size, op->ceed, CEED_ERROR_INCOMPATIBLE, "LVector size %td does not match previous size %td", l_size, 8016574a04fSJeremy L Thompson op->input_size); 8022b104005SJeremy L Thompson } else { 8032b104005SJeremy L Thompson if (op->output_size == -1) op->output_size = l_size; 8046574a04fSJeremy L Thompson CeedCheck(l_size == op->output_size, op->ceed, CEED_ERROR_INCOMPATIBLE, "LVector size %td does not match previous size %td", l_size, 8056574a04fSJeremy L Thompson op->output_size); 8062b104005SJeremy L Thompson } 8072b730f8bSJeremy L Thompson } 8082b104005SJeremy L Thompson 809393ac2cdSJeremy L Thompson CeedCall(CeedVectorReferenceCopy(v, &(*op_field)->vec)); 810393ac2cdSJeremy L Thompson CeedCall(CeedElemRestrictionReferenceCopy(r, &(*op_field)->elem_rstr)); 811198eabceSJeremy L Thompson if (r != CEED_ELEMRESTRICTION_NONE && !op->has_restriction) { 812d1d35e2fSjeremylt op->num_elem = num_elem; 813d1d35e2fSjeremylt op->has_restriction = true; // Restriction set, but num_elem may be 0 814e15f9bd0SJeremy L Thompson } 815393ac2cdSJeremy L Thompson CeedCall(CeedBasisReferenceCopy(b, &(*op_field)->basis)); 816*48acf710SJeremy L Thompson if (op->num_qpts == 0 && !op->is_at_points) op->num_qpts = num_qpts; // no consistent number of qpts for OperatorAtPoints 817d1d35e2fSjeremylt op->num_fields += 1; 8182b730f8bSJeremy L Thompson CeedCall(CeedStringAllocCopy(field_name, (char **)&(*op_field)->field_name)); 819e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 820d7b241e6Sjeremylt } 821d7b241e6Sjeremylt 822d7b241e6Sjeremylt /** 823*48acf710SJeremy L Thompson @brief Get the CeedOperatorFields of a CeedOperator. 82443bbe138SJeremy L Thompson 825ea61e9acSJeremy L Thompson Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable. 826f04ea552SJeremy L Thompson 827ea61e9acSJeremy L Thompson @param[in] op CeedOperator 828f74ec584SJeremy L Thompson @param[out] num_input_fields Variable to store number of input fields 82943bbe138SJeremy L Thompson @param[out] input_fields Variable to store input_fields 830f74ec584SJeremy L Thompson @param[out] num_output_fields Variable to store number of output fields 83143bbe138SJeremy L Thompson @param[out] output_fields Variable to store output_fields 83243bbe138SJeremy L Thompson 83343bbe138SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 83443bbe138SJeremy L Thompson 835e9b533fbSJeremy L Thompson @ref Advanced 83643bbe138SJeremy L Thompson **/ 8372b730f8bSJeremy L Thompson int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields, 83843bbe138SJeremy L Thompson CeedOperatorField **output_fields) { 8396574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_MINOR, "Not defined for composite operator"); 8402b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckReady(op)); 84143bbe138SJeremy L Thompson 84243bbe138SJeremy L Thompson if (num_input_fields) *num_input_fields = op->qf->num_input_fields; 84343bbe138SJeremy L Thompson if (input_fields) *input_fields = op->input_fields; 84443bbe138SJeremy L Thompson if (num_output_fields) *num_output_fields = op->qf->num_output_fields; 84543bbe138SJeremy L Thompson if (output_fields) *output_fields = op->output_fields; 84643bbe138SJeremy L Thompson return CEED_ERROR_SUCCESS; 84743bbe138SJeremy L Thompson } 84843bbe138SJeremy L Thompson 84943bbe138SJeremy L Thompson /** 850*48acf710SJeremy L Thompson @brief Set the arbitrary points in each element for a CeedOperatorAtPoints. 851*48acf710SJeremy L Thompson 852*48acf710SJeremy L Thompson Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable. 853*48acf710SJeremy L Thompson 854*48acf710SJeremy L Thompson @param[in,out] op CeedOperatorAtPoints 855*48acf710SJeremy L Thompson @param[in] rstr_points CeedElemRestriction for the coordinates of each point by element 856*48acf710SJeremy L Thompson @param[in] point_coords CeedVector holding coordinates of each point 857*48acf710SJeremy L Thompson 858*48acf710SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 859*48acf710SJeremy L Thompson 860*48acf710SJeremy L Thompson @ref Advanced 861*48acf710SJeremy L Thompson **/ 862*48acf710SJeremy L Thompson int CeedOperatorAtPointsSetPoints(CeedOperator op, CeedElemRestriction rstr_points, CeedVector point_coords) { 863*48acf710SJeremy L Thompson CeedCheck(op->is_at_points, op->ceed, CEED_ERROR_MINOR, "Only defined for operator at points"); 864*48acf710SJeremy L Thompson CeedCheck(!op->is_immutable, op->ceed, CEED_ERROR_MAJOR, "Operator cannot be changed after set as immutable"); 865*48acf710SJeremy L Thompson 866*48acf710SJeremy L Thompson if (!op->first_points_rstr) { 867*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionReferenceCopy(rstr_points, &op->first_points_rstr)); 868*48acf710SJeremy L Thompson } else { 869*48acf710SJeremy L Thompson bool are_compatible; 870*48acf710SJeremy L Thompson 871*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionAtPointsAreCompatible(op->first_points_rstr, rstr_points, &are_compatible)); 872*48acf710SJeremy L Thompson CeedCheck(are_compatible, op->ceed, CEED_ERROR_INCOMPATIBLE, 873*48acf710SJeremy L Thompson "ElemRestriction must have compatible offsets with previously set field ElemRestrictions"); 874*48acf710SJeremy L Thompson } 875*48acf710SJeremy L Thompson 876*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionReferenceCopy(rstr_points, &op->rstr_points)); 877*48acf710SJeremy L Thompson CeedCall(CeedVectorReferenceCopy(point_coords, &op->point_coords)); 878*48acf710SJeremy L Thompson return CEED_ERROR_SUCCESS; 879*48acf710SJeremy L Thompson } 880*48acf710SJeremy L Thompson 881*48acf710SJeremy L Thompson /** 882*48acf710SJeremy L Thompson @brief Get the arbitrary points in each element for a CeedOperatorAtPoints. 883*48acf710SJeremy L Thompson 884*48acf710SJeremy L Thompson Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable. 885*48acf710SJeremy L Thompson 886*48acf710SJeremy L Thompson @param[in] op CeedOperatorAtPoints 887*48acf710SJeremy L Thompson @param[out] rstr_points Variable to hold CeedElemRestriction for the coordinates of each point by element 888*48acf710SJeremy L Thompson @param[out] point_coords Variable to hold CeedVector holding coordinates of each point 889*48acf710SJeremy L Thompson 890*48acf710SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 891*48acf710SJeremy L Thompson 892*48acf710SJeremy L Thompson @ref Advanced 893*48acf710SJeremy L Thompson **/ 894*48acf710SJeremy L Thompson int CeedOperatorAtPointsGetPoints(CeedOperator op, CeedElemRestriction *rstr_points, CeedVector *point_coords) { 895*48acf710SJeremy L Thompson CeedCheck(op->is_at_points, op->ceed, CEED_ERROR_MINOR, "Only defined for operator at points"); 896*48acf710SJeremy L Thompson CeedCall(CeedOperatorCheckReady(op)); 897*48acf710SJeremy L Thompson 898*48acf710SJeremy L Thompson if (rstr_points) CeedCall(CeedElemRestrictionReferenceCopy(op->rstr_points, rstr_points)); 899*48acf710SJeremy L Thompson if (point_coords) CeedCall(CeedVectorReferenceCopy(op->point_coords, point_coords)); 900*48acf710SJeremy L Thompson return CEED_ERROR_SUCCESS; 901*48acf710SJeremy L Thompson } 902*48acf710SJeremy L Thompson 903*48acf710SJeremy L Thompson /** 904de5900adSJames Wright @brief Get a CeedOperatorField of an CeedOperator from its name 905de5900adSJames Wright 906de5900adSJames Wright Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable. 907de5900adSJames Wright 908de5900adSJames Wright @param[in] op CeedOperator 909de5900adSJames Wright @param[in] field_name Name of desired CeedOperatorField 910de5900adSJames Wright @param[out] op_field CeedOperatorField corresponding to the name 911de5900adSJames Wright 912de5900adSJames Wright @return An error code: 0 - success, otherwise - failure 913de5900adSJames Wright 914de5900adSJames Wright @ref Advanced 915de5900adSJames Wright **/ 916de5900adSJames Wright int CeedOperatorGetFieldByName(CeedOperator op, const char *field_name, CeedOperatorField *op_field) { 9171c66c397SJeremy L Thompson char *name; 918de5900adSJames Wright CeedInt num_input_fields, num_output_fields; 919de5900adSJames Wright CeedOperatorField *input_fields, *output_fields; 920de5900adSJames Wright 9211c66c397SJeremy L Thompson CeedCall(CeedOperatorGetFields(op, &num_input_fields, &input_fields, &num_output_fields, &output_fields)); 922de5900adSJames Wright for (CeedInt i = 0; i < num_input_fields; i++) { 923de5900adSJames Wright CeedCall(CeedOperatorFieldGetName(input_fields[i], &name)); 924de5900adSJames Wright if (!strcmp(name, field_name)) { 925de5900adSJames Wright *op_field = input_fields[i]; 926de5900adSJames Wright return CEED_ERROR_SUCCESS; 927de5900adSJames Wright } 928de5900adSJames Wright } 929de5900adSJames Wright for (CeedInt i = 0; i < num_output_fields; i++) { 930de5900adSJames Wright CeedCall(CeedOperatorFieldGetName(output_fields[i], &name)); 931de5900adSJames Wright if (!strcmp(name, field_name)) { 932de5900adSJames Wright *op_field = output_fields[i]; 933de5900adSJames Wright return CEED_ERROR_SUCCESS; 934de5900adSJames Wright } 935de5900adSJames Wright } 936de5900adSJames Wright // LCOV_EXCL_START 9371c66c397SJeremy L Thompson bool has_name = op->name; 9381c66c397SJeremy L Thompson 939de5900adSJames Wright return CeedError(op->ceed, CEED_ERROR_MINOR, "The field \"%s\" not found in CeedOperator%s%s%s.\n", field_name, has_name ? " \"" : "", 940de5900adSJames Wright has_name ? op->name : "", has_name ? "\"" : ""); 941de5900adSJames Wright // LCOV_EXCL_STOP 942de5900adSJames Wright } 943de5900adSJames Wright 944de5900adSJames Wright /** 94528567f8fSJeremy L Thompson @brief Get the name of a CeedOperatorField 94628567f8fSJeremy L Thompson 947ea61e9acSJeremy L Thompson @param[in] op_field CeedOperatorField 94828567f8fSJeremy L Thompson @param[out] field_name Variable to store the field name 94928567f8fSJeremy L Thompson 95028567f8fSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 95128567f8fSJeremy L Thompson 952e9b533fbSJeremy L Thompson @ref Advanced 95328567f8fSJeremy L Thompson **/ 95428567f8fSJeremy L Thompson int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name) { 95528567f8fSJeremy L Thompson *field_name = (char *)op_field->field_name; 95628567f8fSJeremy L Thompson return CEED_ERROR_SUCCESS; 95728567f8fSJeremy L Thompson } 95828567f8fSJeremy L Thompson 95928567f8fSJeremy L Thompson /** 96043bbe138SJeremy L Thompson @brief Get the CeedElemRestriction of a CeedOperatorField 96143bbe138SJeremy L Thompson 962ea61e9acSJeremy L Thompson @param[in] op_field CeedOperatorField 96343bbe138SJeremy L Thompson @param[out] rstr Variable to store CeedElemRestriction 96443bbe138SJeremy L Thompson 96543bbe138SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 96643bbe138SJeremy L Thompson 967e9b533fbSJeremy L Thompson @ref Advanced 96843bbe138SJeremy L Thompson **/ 9692b730f8bSJeremy L Thompson int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr) { 970437c7c90SJeremy L Thompson *rstr = op_field->elem_rstr; 97143bbe138SJeremy L Thompson return CEED_ERROR_SUCCESS; 97243bbe138SJeremy L Thompson } 97343bbe138SJeremy L Thompson 97443bbe138SJeremy L Thompson /** 97543bbe138SJeremy L Thompson @brief Get the CeedBasis of a CeedOperatorField 97643bbe138SJeremy L Thompson 977ea61e9acSJeremy L Thompson @param[in] op_field CeedOperatorField 97843bbe138SJeremy L Thompson @param[out] basis Variable to store CeedBasis 97943bbe138SJeremy L Thompson 98043bbe138SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 98143bbe138SJeremy L Thompson 982e9b533fbSJeremy L Thompson @ref Advanced 98343bbe138SJeremy L Thompson **/ 98443bbe138SJeremy L Thompson int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis) { 98543bbe138SJeremy L Thompson *basis = op_field->basis; 98643bbe138SJeremy L Thompson return CEED_ERROR_SUCCESS; 98743bbe138SJeremy L Thompson } 98843bbe138SJeremy L Thompson 98943bbe138SJeremy L Thompson /** 99043bbe138SJeremy L Thompson @brief Get the CeedVector of a CeedOperatorField 99143bbe138SJeremy L Thompson 992ea61e9acSJeremy L Thompson @param[in] op_field CeedOperatorField 99343bbe138SJeremy L Thompson @param[out] vec Variable to store CeedVector 99443bbe138SJeremy L Thompson 99543bbe138SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 99643bbe138SJeremy L Thompson 997e9b533fbSJeremy L Thompson @ref Advanced 99843bbe138SJeremy L Thompson **/ 99943bbe138SJeremy L Thompson int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec) { 100043bbe138SJeremy L Thompson *vec = op_field->vec; 100143bbe138SJeremy L Thompson return CEED_ERROR_SUCCESS; 100243bbe138SJeremy L Thompson } 100343bbe138SJeremy L Thompson 100443bbe138SJeremy L Thompson /** 100552d6035fSJeremy L Thompson @brief Add a sub-operator to a composite CeedOperator 1006288c0443SJeremy L Thompson 1007ea61e9acSJeremy L Thompson @param[in,out] composite_op Composite CeedOperator 1008ea61e9acSJeremy L Thompson @param[in] sub_op Sub-operator CeedOperator 100952d6035fSJeremy L Thompson 101052d6035fSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 101152d6035fSJeremy L Thompson 10127a982d89SJeremy L. Thompson @ref User 101352d6035fSJeremy L Thompson */ 10142b730f8bSJeremy L Thompson int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op) { 10156574a04fSJeremy L Thompson CeedCheck(composite_op->is_composite, composite_op->ceed, CEED_ERROR_MINOR, "CeedOperator is not a composite operator"); 10166574a04fSJeremy L Thompson CeedCheck(composite_op->num_suboperators < CEED_COMPOSITE_MAX, composite_op->ceed, CEED_ERROR_UNSUPPORTED, "Cannot add additional sub-operators"); 10176574a04fSJeremy L Thompson CeedCheck(!composite_op->is_immutable, composite_op->ceed, CEED_ERROR_MAJOR, "Operator cannot be changed after set as immutable"); 10182b730f8bSJeremy L Thompson 10192b730f8bSJeremy L Thompson { 10202b730f8bSJeremy L Thompson CeedSize input_size, output_size; 10211c66c397SJeremy L Thompson 10222b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetActiveVectorLengths(sub_op, &input_size, &output_size)); 10232b730f8bSJeremy L Thompson if (composite_op->input_size == -1) composite_op->input_size = input_size; 10242b730f8bSJeremy L Thompson if (composite_op->output_size == -1) composite_op->output_size = output_size; 10252b730f8bSJeremy L Thompson // Note, a size of -1 means no active vector restriction set, so no incompatibility 10266574a04fSJeremy L Thompson CeedCheck((input_size == -1 || input_size == composite_op->input_size) && (output_size == -1 || output_size == composite_op->output_size), 10276574a04fSJeremy L Thompson composite_op->ceed, CEED_ERROR_MAJOR, 10282b730f8bSJeremy L Thompson "Sub-operators must have compatible dimensions; composite operator of shape (%td, %td) not compatible with sub-operator of " 10292b730f8bSJeremy L Thompson "shape (%td, %td)", 10302b730f8bSJeremy L Thompson composite_op->input_size, composite_op->output_size, input_size, output_size); 10312b730f8bSJeremy L Thompson } 10322b730f8bSJeremy L Thompson 1033d1d35e2fSjeremylt composite_op->sub_operators[composite_op->num_suboperators] = sub_op; 10342b730f8bSJeremy L Thompson CeedCall(CeedOperatorReference(sub_op)); 1035d1d35e2fSjeremylt composite_op->num_suboperators++; 1036e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 103752d6035fSJeremy L Thompson } 103852d6035fSJeremy L Thompson 103952d6035fSJeremy L Thompson /** 104075f0d5a4SJeremy L Thompson @brief Get the number of sub_operators associated with a CeedOperator 104175f0d5a4SJeremy L Thompson 104275f0d5a4SJeremy L Thompson @param[in] op CeedOperator 104375f0d5a4SJeremy L Thompson @param[out] num_suboperators Variable to store number of sub_operators 104475f0d5a4SJeremy L Thompson 104575f0d5a4SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 104675f0d5a4SJeremy L Thompson 104775f0d5a4SJeremy L Thompson @ref Backend 104875f0d5a4SJeremy L Thompson **/ 1049c6ebc35dSJeremy L Thompson int CeedCompositeOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators) { 10506574a04fSJeremy L Thompson CeedCheck(op->is_composite, op->ceed, CEED_ERROR_MINOR, "Only defined for a composite operator"); 105175f0d5a4SJeremy L Thompson *num_suboperators = op->num_suboperators; 105275f0d5a4SJeremy L Thompson return CEED_ERROR_SUCCESS; 105375f0d5a4SJeremy L Thompson } 105475f0d5a4SJeremy L Thompson 105575f0d5a4SJeremy L Thompson /** 105675f0d5a4SJeremy L Thompson @brief Get the list of sub_operators associated with a CeedOperator 105775f0d5a4SJeremy L Thompson 105875f0d5a4SJeremy L Thompson @param op CeedOperator 105975f0d5a4SJeremy L Thompson @param[out] sub_operators Variable to store list of sub_operators 106075f0d5a4SJeremy L Thompson 106175f0d5a4SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 106275f0d5a4SJeremy L Thompson 106375f0d5a4SJeremy L Thompson @ref Backend 106475f0d5a4SJeremy L Thompson **/ 1065c6ebc35dSJeremy L Thompson int CeedCompositeOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators) { 10666574a04fSJeremy L Thompson CeedCheck(op->is_composite, op->ceed, CEED_ERROR_MINOR, "Only defined for a composite operator"); 106775f0d5a4SJeremy L Thompson *sub_operators = op->sub_operators; 106875f0d5a4SJeremy L Thompson return CEED_ERROR_SUCCESS; 106975f0d5a4SJeremy L Thompson } 107075f0d5a4SJeremy L Thompson 107175f0d5a4SJeremy L Thompson /** 10724db537f9SJeremy L Thompson @brief Check if a CeedOperator is ready to be used. 10734db537f9SJeremy L Thompson 10744db537f9SJeremy L Thompson @param[in] op CeedOperator to check 10754db537f9SJeremy L Thompson 10764db537f9SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 10774db537f9SJeremy L Thompson 10784db537f9SJeremy L Thompson @ref User 10794db537f9SJeremy L Thompson **/ 10804db537f9SJeremy L Thompson int CeedOperatorCheckReady(CeedOperator op) { 10814db537f9SJeremy L Thompson Ceed ceed; 10821c66c397SJeremy L Thompson 10832b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetCeed(op, &ceed)); 10844db537f9SJeremy L Thompson 10852b730f8bSJeremy L Thompson if (op->is_interface_setup) return CEED_ERROR_SUCCESS; 10864db537f9SJeremy L Thompson 10874db537f9SJeremy L Thompson CeedQFunction qf = op->qf; 10884db537f9SJeremy L Thompson if (op->is_composite) { 108943622462SJeremy L Thompson if (!op->num_suboperators) { 109043622462SJeremy L Thompson // Empty operator setup 109143622462SJeremy L Thompson op->input_size = 0; 109243622462SJeremy L Thompson op->output_size = 0; 109343622462SJeremy L Thompson } else { 10944db537f9SJeremy L Thompson for (CeedInt i = 0; i < op->num_suboperators; i++) { 10952b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckReady(op->sub_operators[i])); 10964db537f9SJeremy L Thompson } 10972b104005SJeremy L Thompson // Sub-operators could be modified after adding to composite operator 10982b104005SJeremy L Thompson // Need to verify no lvec incompatibility from any changes 10992b104005SJeremy L Thompson CeedSize input_size, output_size; 11002b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetActiveVectorLengths(op, &input_size, &output_size)); 110143622462SJeremy L Thompson } 11024db537f9SJeremy L Thompson } else { 11036574a04fSJeremy L Thompson CeedCheck(op->num_fields > 0, ceed, CEED_ERROR_INCOMPLETE, "No operator fields set"); 11046574a04fSJeremy L Thompson CeedCheck(op->num_fields == qf->num_input_fields + qf->num_output_fields, ceed, CEED_ERROR_INCOMPLETE, "Not all operator fields set"); 11056574a04fSJeremy L Thompson CeedCheck(op->has_restriction, ceed, CEED_ERROR_INCOMPLETE, "At least one restriction required"); 1106*48acf710SJeremy L Thompson CeedCheck(op->num_qpts > 0 || op->is_at_points, ceed, CEED_ERROR_INCOMPLETE, 11076574a04fSJeremy L Thompson "At least one non-collocated basis is required or the number of quadrature points must be set"); 11082b730f8bSJeremy L Thompson } 11094db537f9SJeremy L Thompson 11104db537f9SJeremy L Thompson // Flag as immutable and ready 11114db537f9SJeremy L Thompson op->is_interface_setup = true; 11122b730f8bSJeremy L Thompson if (op->qf && op->qf != CEED_QFUNCTION_NONE) op->qf->is_immutable = true; 11132b730f8bSJeremy L Thompson if (op->dqf && op->dqf != CEED_QFUNCTION_NONE) op->dqf->is_immutable = true; 11142b730f8bSJeremy L Thompson if (op->dqfT && op->dqfT != CEED_QFUNCTION_NONE) op->dqfT->is_immutable = true; 11154db537f9SJeremy L Thompson return CEED_ERROR_SUCCESS; 11164db537f9SJeremy L Thompson } 11174db537f9SJeremy L Thompson 11184db537f9SJeremy L Thompson /** 1119c9366a6bSJeremy L Thompson @brief Get vector lengths for the active input and/or output vectors of a CeedOperator. 11204385fb7fSSebastian Grimberg 1121ea61e9acSJeremy L Thompson Note: Lengths of -1 indicate that the CeedOperator does not have an active input and/or output. 1122c9366a6bSJeremy L Thompson 1123c9366a6bSJeremy L Thompson @param[in] op CeedOperator 1124c9366a6bSJeremy L Thompson @param[out] input_size Variable to store active input vector length, or NULL 1125c9366a6bSJeremy L Thompson @param[out] output_size Variable to store active output vector length, or NULL 1126c9366a6bSJeremy L Thompson 1127c9366a6bSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1128c9366a6bSJeremy L Thompson 1129c9366a6bSJeremy L Thompson @ref User 1130c9366a6bSJeremy L Thompson **/ 11312b730f8bSJeremy L Thompson int CeedOperatorGetActiveVectorLengths(CeedOperator op, CeedSize *input_size, CeedSize *output_size) { 1132c9366a6bSJeremy L Thompson bool is_composite; 1133c9366a6bSJeremy L Thompson 11342b104005SJeremy L Thompson if (input_size) *input_size = op->input_size; 11352b104005SJeremy L Thompson if (output_size) *output_size = op->output_size; 1136c9366a6bSJeremy L Thompson 11372b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 11382b104005SJeremy L Thompson if (is_composite && (op->input_size == -1 || op->output_size == -1)) { 1139c9366a6bSJeremy L Thompson for (CeedInt i = 0; i < op->num_suboperators; i++) { 1140c9366a6bSJeremy L Thompson CeedSize sub_input_size, sub_output_size; 11411c66c397SJeremy L Thompson 11422b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetActiveVectorLengths(op->sub_operators[i], &sub_input_size, &sub_output_size)); 11432b104005SJeremy L Thompson if (op->input_size == -1) op->input_size = sub_input_size; 11442b104005SJeremy L Thompson if (op->output_size == -1) op->output_size = sub_output_size; 11452b104005SJeremy L Thompson // Note, a size of -1 means no active vector restriction set, so no incompatibility 11466574a04fSJeremy L Thompson CeedCheck((sub_input_size == -1 || sub_input_size == op->input_size) && (sub_output_size == -1 || sub_output_size == op->output_size), op->ceed, 11476574a04fSJeremy L Thompson CEED_ERROR_MAJOR, 11482b730f8bSJeremy L Thompson "Sub-operators must have compatible dimensions; composite operator of shape (%td, %td) not compatible with sub-operator of " 11492b730f8bSJeremy L Thompson "shape (%td, %td)", 11502b104005SJeremy L Thompson op->input_size, op->output_size, input_size, output_size); 1151c9366a6bSJeremy L Thompson } 11522b730f8bSJeremy L Thompson } 1153c9366a6bSJeremy L Thompson return CEED_ERROR_SUCCESS; 1154c9366a6bSJeremy L Thompson } 1155c9366a6bSJeremy L Thompson 1156c9366a6bSJeremy L Thompson /** 1157beecbf24SJeremy L Thompson @brief Set reuse of CeedQFunction data in CeedOperatorLinearAssemble* functions. 11584385fb7fSSebastian Grimberg 1159ea61e9acSJeremy L Thompson When `reuse_assembly_data = false` (default), the CeedQFunction associated with this CeedOperator is re-assembled every time a 11609fd66db6SSebastian Grimberg `CeedOperatorLinearAssemble*` function is called. 11619fd66db6SSebastian Grimberg When `reuse_assembly_data = true`, the CeedQFunction associated with this CeedOperator is reused between calls to 11629fd66db6SSebastian Grimberg `CeedOperatorSetQFunctionAssemblyDataUpdated`. 11638b919e6bSJeremy L Thompson 1164beecbf24SJeremy L Thompson @param[in] op CeedOperator 1165beecbf24SJeremy L Thompson @param[in] reuse_assembly_data Boolean flag setting assembly data reuse 11668b919e6bSJeremy L Thompson 11678b919e6bSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 11688b919e6bSJeremy L Thompson 11698b919e6bSJeremy L Thompson @ref Advanced 11708b919e6bSJeremy L Thompson **/ 11712b730f8bSJeremy L Thompson int CeedOperatorSetQFunctionAssemblyReuse(CeedOperator op, bool reuse_assembly_data) { 11728b919e6bSJeremy L Thompson bool is_composite; 11738b919e6bSJeremy L Thompson 11742b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 11758b919e6bSJeremy L Thompson if (is_composite) { 11768b919e6bSJeremy L Thompson for (CeedInt i = 0; i < op->num_suboperators; i++) { 11772b730f8bSJeremy L Thompson CeedCall(CeedOperatorSetQFunctionAssemblyReuse(op->sub_operators[i], reuse_assembly_data)); 11788b919e6bSJeremy L Thompson } 11798b919e6bSJeremy L Thompson } else { 11802b730f8bSJeremy L Thompson CeedCall(CeedQFunctionAssemblyDataSetReuse(op->qf_assembled, reuse_assembly_data)); 1181beecbf24SJeremy L Thompson } 1182beecbf24SJeremy L Thompson return CEED_ERROR_SUCCESS; 1183beecbf24SJeremy L Thompson } 1184beecbf24SJeremy L Thompson 1185beecbf24SJeremy L Thompson /** 1186beecbf24SJeremy L Thompson @brief Mark CeedQFunction data as updated and the CeedQFunction as requiring re-assembly. 1187beecbf24SJeremy L Thompson 1188beecbf24SJeremy L Thompson @param[in] op CeedOperator 11896e15d496SJeremy L Thompson @param[in] needs_data_update Boolean flag setting assembly data reuse 1190beecbf24SJeremy L Thompson 1191beecbf24SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1192beecbf24SJeremy L Thompson 1193beecbf24SJeremy L Thompson @ref Advanced 1194beecbf24SJeremy L Thompson **/ 11952b730f8bSJeremy L Thompson int CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(CeedOperator op, bool needs_data_update) { 1196beecbf24SJeremy L Thompson bool is_composite; 1197beecbf24SJeremy L Thompson 11982b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 1199beecbf24SJeremy L Thompson if (is_composite) { 1200beecbf24SJeremy L Thompson for (CeedInt i = 0; i < op->num_suboperators; i++) { 12012b730f8bSJeremy L Thompson CeedCall(CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(op->sub_operators[i], needs_data_update)); 1202beecbf24SJeremy L Thompson } 1203beecbf24SJeremy L Thompson } else { 12042b730f8bSJeremy L Thompson CeedCall(CeedQFunctionAssemblyDataSetUpdateNeeded(op->qf_assembled, needs_data_update)); 12058b919e6bSJeremy L Thompson } 12068b919e6bSJeremy L Thompson return CEED_ERROR_SUCCESS; 12078b919e6bSJeremy L Thompson } 12088b919e6bSJeremy L Thompson 12098b919e6bSJeremy L Thompson /** 1210ea6b5821SJeremy L Thompson @brief Set name of CeedOperator for CeedOperatorView output 1211ea6b5821SJeremy L Thompson 1212ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 1213ea61e9acSJeremy L Thompson @param[in] name Name to set, or NULL to remove previously set name 1214ea6b5821SJeremy L Thompson 1215ea6b5821SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1216ea6b5821SJeremy L Thompson 1217ea6b5821SJeremy L Thompson @ref User 1218ea6b5821SJeremy L Thompson **/ 1219ea6b5821SJeremy L Thompson int CeedOperatorSetName(CeedOperator op, const char *name) { 1220ea6b5821SJeremy L Thompson char *name_copy; 1221ea6b5821SJeremy L Thompson size_t name_len = name ? strlen(name) : 0; 1222ea6b5821SJeremy L Thompson 12232b730f8bSJeremy L Thompson CeedCall(CeedFree(&op->name)); 1224ea6b5821SJeremy L Thompson if (name_len > 0) { 12252b730f8bSJeremy L Thompson CeedCall(CeedCalloc(name_len + 1, &name_copy)); 1226ea6b5821SJeremy L Thompson memcpy(name_copy, name, name_len); 1227ea6b5821SJeremy L Thompson op->name = name_copy; 1228ea6b5821SJeremy L Thompson } 1229ea6b5821SJeremy L Thompson return CEED_ERROR_SUCCESS; 1230ea6b5821SJeremy L Thompson } 1231ea6b5821SJeremy L Thompson 1232ea6b5821SJeremy L Thompson /** 12337a982d89SJeremy L. Thompson @brief View a CeedOperator 12347a982d89SJeremy L. Thompson 12357a982d89SJeremy L. Thompson @param[in] op CeedOperator to view 12367a982d89SJeremy L. Thompson @param[in] stream Stream to write; typically stdout/stderr or a file 12377a982d89SJeremy L. Thompson 12387a982d89SJeremy L. Thompson @return Error code: 0 - success, otherwise - failure 12397a982d89SJeremy L. Thompson 12407a982d89SJeremy L. Thompson @ref User 12417a982d89SJeremy L. Thompson **/ 12427a982d89SJeremy L. Thompson int CeedOperatorView(CeedOperator op, FILE *stream) { 1243ea6b5821SJeremy L Thompson bool has_name = op->name; 12447a982d89SJeremy L. Thompson 1245f04ea552SJeremy L Thompson if (op->is_composite) { 12462b730f8bSJeremy L Thompson fprintf(stream, "Composite CeedOperator%s%s\n", has_name ? " - " : "", has_name ? op->name : ""); 12477a982d89SJeremy L. Thompson 1248d1d35e2fSjeremylt for (CeedInt i = 0; i < op->num_suboperators; i++) { 1249ea6b5821SJeremy L Thompson has_name = op->sub_operators[i]->name; 12502b730f8bSJeremy L Thompson fprintf(stream, " SubOperator %" CeedInt_FMT "%s%s:\n", i, has_name ? " - " : "", has_name ? op->sub_operators[i]->name : ""); 12512b730f8bSJeremy L Thompson CeedCall(CeedOperatorSingleView(op->sub_operators[i], 1, stream)); 12527a982d89SJeremy L. Thompson } 12537a982d89SJeremy L. Thompson } else { 12542b730f8bSJeremy L Thompson fprintf(stream, "CeedOperator%s%s\n", has_name ? " - " : "", has_name ? op->name : ""); 12552b730f8bSJeremy L Thompson CeedCall(CeedOperatorSingleView(op, 0, stream)); 12567a982d89SJeremy L. Thompson } 1257e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 12587a982d89SJeremy L. Thompson } 12593bd813ffSjeremylt 12603bd813ffSjeremylt /** 1261b7c9bbdaSJeremy L Thompson @brief Get the Ceed associated with a CeedOperator 1262b7c9bbdaSJeremy L Thompson 1263ea61e9acSJeremy L Thompson @param[in] op CeedOperator 1264b7c9bbdaSJeremy L Thompson @param[out] ceed Variable to store Ceed 1265b7c9bbdaSJeremy L Thompson 1266b7c9bbdaSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1267b7c9bbdaSJeremy L Thompson 1268b7c9bbdaSJeremy L Thompson @ref Advanced 1269b7c9bbdaSJeremy L Thompson **/ 1270b7c9bbdaSJeremy L Thompson int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed) { 1271b7c9bbdaSJeremy L Thompson *ceed = op->ceed; 1272b7c9bbdaSJeremy L Thompson return CEED_ERROR_SUCCESS; 1273b7c9bbdaSJeremy L Thompson } 1274b7c9bbdaSJeremy L Thompson 1275b7c9bbdaSJeremy L Thompson /** 1276b7c9bbdaSJeremy L Thompson @brief Get the number of elements associated with a CeedOperator 1277b7c9bbdaSJeremy L Thompson 1278ea61e9acSJeremy L Thompson @param[in] op CeedOperator 1279b7c9bbdaSJeremy L Thompson @param[out] num_elem Variable to store number of elements 1280b7c9bbdaSJeremy L Thompson 1281b7c9bbdaSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1282b7c9bbdaSJeremy L Thompson 1283b7c9bbdaSJeremy L Thompson @ref Advanced 1284b7c9bbdaSJeremy L Thompson **/ 1285b7c9bbdaSJeremy L Thompson int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem) { 12866574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_MINOR, "Not defined for composite operator"); 1287b7c9bbdaSJeremy L Thompson *num_elem = op->num_elem; 1288b7c9bbdaSJeremy L Thompson return CEED_ERROR_SUCCESS; 1289b7c9bbdaSJeremy L Thompson } 1290b7c9bbdaSJeremy L Thompson 1291b7c9bbdaSJeremy L Thompson /** 1292b7c9bbdaSJeremy L Thompson @brief Get the number of quadrature points associated with a CeedOperator 1293b7c9bbdaSJeremy L Thompson 1294ea61e9acSJeremy L Thompson @param[in] op CeedOperator 1295b7c9bbdaSJeremy L Thompson @param[out] num_qpts Variable to store vector number of quadrature points 1296b7c9bbdaSJeremy L Thompson 1297b7c9bbdaSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1298b7c9bbdaSJeremy L Thompson 1299b7c9bbdaSJeremy L Thompson @ref Advanced 1300b7c9bbdaSJeremy L Thompson **/ 1301b7c9bbdaSJeremy L Thompson int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts) { 13026574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_MINOR, "Not defined for composite operator"); 1303b7c9bbdaSJeremy L Thompson *num_qpts = op->num_qpts; 1304b7c9bbdaSJeremy L Thompson return CEED_ERROR_SUCCESS; 1305b7c9bbdaSJeremy L Thompson } 1306b7c9bbdaSJeremy L Thompson 1307b7c9bbdaSJeremy L Thompson /** 13086e15d496SJeremy L Thompson @brief Estimate number of FLOPs required to apply CeedOperator on the active vector 13096e15d496SJeremy L Thompson 1310ea61e9acSJeremy L Thompson @param[in] op CeedOperator to estimate FLOPs for 1311ea61e9acSJeremy L Thompson @param[out] flops Address of variable to hold FLOPs estimate 13126e15d496SJeremy L Thompson 13136e15d496SJeremy L Thompson @ref Backend 13146e15d496SJeremy L Thompson **/ 13159d36ca50SJeremy L Thompson int CeedOperatorGetFlopsEstimate(CeedOperator op, CeedSize *flops) { 13166e15d496SJeremy L Thompson bool is_composite; 13171c66c397SJeremy L Thompson 13182b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckReady(op)); 13196e15d496SJeremy L Thompson 13206e15d496SJeremy L Thompson *flops = 0; 13212b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 13226e15d496SJeremy L Thompson if (is_composite) { 13236e15d496SJeremy L Thompson CeedInt num_suboperators; 13241c66c397SJeremy L Thompson 1325c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 13266e15d496SJeremy L Thompson CeedOperator *sub_operators; 1327c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 13286e15d496SJeremy L Thompson 13296e15d496SJeremy L Thompson // FLOPs for each suboperator 13306e15d496SJeremy L Thompson for (CeedInt i = 0; i < num_suboperators; i++) { 13319d36ca50SJeremy L Thompson CeedSize suboperator_flops; 13321c66c397SJeremy L Thompson 13332b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetFlopsEstimate(sub_operators[i], &suboperator_flops)); 13346e15d496SJeremy L Thompson *flops += suboperator_flops; 13356e15d496SJeremy L Thompson } 13366e15d496SJeremy L Thompson } else { 13371c66c397SJeremy L Thompson CeedInt num_input_fields, num_output_fields, num_elem = 0; 13386e15d496SJeremy L Thompson CeedOperatorField *input_fields, *output_fields; 13391c66c397SJeremy L Thompson 13402b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetFields(op, &num_input_fields, &input_fields, &num_output_fields, &output_fields)); 13412b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetNumElements(op, &num_elem)); 13424385fb7fSSebastian Grimberg 13436e15d496SJeremy L Thompson // Input FLOPs 13446e15d496SJeremy L Thompson for (CeedInt i = 0; i < num_input_fields; i++) { 13456e15d496SJeremy L Thompson if (input_fields[i]->vec == CEED_VECTOR_ACTIVE) { 1346edb2538eSJeremy L Thompson CeedSize rstr_flops, basis_flops; 13476e15d496SJeremy L Thompson 1348edb2538eSJeremy L Thompson CeedCall(CeedElemRestrictionGetFlopsEstimate(input_fields[i]->elem_rstr, CEED_NOTRANSPOSE, &rstr_flops)); 1349edb2538eSJeremy L Thompson *flops += rstr_flops; 13502b730f8bSJeremy L Thompson CeedCall(CeedBasisGetFlopsEstimate(input_fields[i]->basis, CEED_NOTRANSPOSE, op->qf->input_fields[i]->eval_mode, &basis_flops)); 13516e15d496SJeremy L Thompson *flops += basis_flops * num_elem; 13526e15d496SJeremy L Thompson } 13536e15d496SJeremy L Thompson } 13546e15d496SJeremy L Thompson // QF FLOPs 13551c66c397SJeremy L Thompson { 13569d36ca50SJeremy L Thompson CeedInt num_qpts; 13579d36ca50SJeremy L Thompson CeedSize qf_flops; 13581c66c397SJeremy L Thompson 13592b730f8bSJeremy L Thompson CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts)); 13602b730f8bSJeremy L Thompson CeedCall(CeedQFunctionGetFlopsEstimate(op->qf, &qf_flops)); 13616e15d496SJeremy L Thompson *flops += num_elem * num_qpts * qf_flops; 13621c66c397SJeremy L Thompson } 13631c66c397SJeremy L Thompson 13646e15d496SJeremy L Thompson // Output FLOPs 13656e15d496SJeremy L Thompson for (CeedInt i = 0; i < num_output_fields; i++) { 13666e15d496SJeremy L Thompson if (output_fields[i]->vec == CEED_VECTOR_ACTIVE) { 1367edb2538eSJeremy L Thompson CeedSize rstr_flops, basis_flops; 13686e15d496SJeremy L Thompson 1369edb2538eSJeremy L Thompson CeedCall(CeedElemRestrictionGetFlopsEstimate(output_fields[i]->elem_rstr, CEED_TRANSPOSE, &rstr_flops)); 1370edb2538eSJeremy L Thompson *flops += rstr_flops; 13712b730f8bSJeremy L Thompson CeedCall(CeedBasisGetFlopsEstimate(output_fields[i]->basis, CEED_TRANSPOSE, op->qf->output_fields[i]->eval_mode, &basis_flops)); 13726e15d496SJeremy L Thompson *flops += basis_flops * num_elem; 13736e15d496SJeremy L Thompson } 13746e15d496SJeremy L Thompson } 13756e15d496SJeremy L Thompson } 13766e15d496SJeremy L Thompson return CEED_ERROR_SUCCESS; 13776e15d496SJeremy L Thompson } 13786e15d496SJeremy L Thompson 13796e15d496SJeremy L Thompson /** 13800126412dSJeremy L Thompson @brief Get CeedQFunction global context for a CeedOperator. 13819fd66db6SSebastian Grimberg 1382512bb800SJeremy L Thompson The caller is responsible for destroying `ctx` returned from this function via `CeedQFunctionContextDestroy()`. 1383512bb800SJeremy L Thompson 13849fd66db6SSebastian Grimberg Note: If the value of `ctx` passed into this function is non-NULL, then it is assumed that `ctx` is a pointer to a CeedQFunctionContext. 13859fd66db6SSebastian Grimberg This CeedQFunctionContext will be destroyed if `ctx` is the only reference to this CeedQFunctionContext. 13860126412dSJeremy L Thompson 1387859c15bbSJames Wright @param[in] op CeedOperator 13880126412dSJeremy L Thompson @param[out] ctx Variable to store CeedQFunctionContext 13890126412dSJeremy L Thompson 13900126412dSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 13910126412dSJeremy L Thompson 1392859c15bbSJames Wright @ref Advanced 13930126412dSJeremy L Thompson **/ 13940126412dSJeremy L Thompson int CeedOperatorGetContext(CeedOperator op, CeedQFunctionContext *ctx) { 13956574a04fSJeremy L Thompson CeedCheck(!op->is_composite, op->ceed, CEED_ERROR_INCOMPATIBLE, "Cannot retrieve QFunctionContext for composite operator"); 13960126412dSJeremy L Thompson if (op->qf->ctx) CeedCall(CeedQFunctionContextReferenceCopy(op->qf->ctx, ctx)); 13970126412dSJeremy L Thompson else *ctx = NULL; 13980126412dSJeremy L Thompson return CEED_ERROR_SUCCESS; 13990126412dSJeremy L Thompson } 14000126412dSJeremy L Thompson 14010126412dSJeremy L Thompson /** 1402ea61e9acSJeremy L Thompson @brief Get label for a registered QFunctionContext field, or `NULL` if no field has been registered with this `field_name`. 14033668ca4bSJeremy L Thompson 1404859c15bbSJames Wright Fields are registered via `CeedQFunctionContextRegister*()` functions (eg. `CeedQFunctionContextRegisterDouble()`). 1405859c15bbSJames Wright 14063668ca4bSJeremy L Thompson @param[in] op CeedOperator 14073668ca4bSJeremy L Thompson @param[in] field_name Name of field to retrieve label 14083668ca4bSJeremy L Thompson @param[out] field_label Variable to field label 14093668ca4bSJeremy L Thompson 14103668ca4bSJeremy L Thompson @return An error code: 0 - success, otherwise - failure 14113668ca4bSJeremy L Thompson 14123668ca4bSJeremy L Thompson @ref User 14133668ca4bSJeremy L Thompson **/ 141417b0d5c6SJeremy L Thompson int CeedOperatorGetContextFieldLabel(CeedOperator op, const char *field_name, CeedContextFieldLabel *field_label) { 14151c66c397SJeremy L Thompson bool is_composite, field_found = false; 14161c66c397SJeremy L Thompson 14172b730f8bSJeremy L Thompson CeedCall(CeedOperatorIsComposite(op, &is_composite)); 14182b730f8bSJeremy L Thompson 14193668ca4bSJeremy L Thompson if (is_composite) { 1420a98a090bSJeremy L Thompson // Composite operator 1421a98a090bSJeremy L Thompson // -- Check if composite label already created 14223668ca4bSJeremy L Thompson for (CeedInt i = 0; i < op->num_context_labels; i++) { 14233668ca4bSJeremy L Thompson if (!strcmp(op->context_labels[i]->name, field_name)) { 14243668ca4bSJeremy L Thompson *field_label = op->context_labels[i]; 14253668ca4bSJeremy L Thompson return CEED_ERROR_SUCCESS; 14263668ca4bSJeremy L Thompson } 14273668ca4bSJeremy L Thompson } 14283668ca4bSJeremy L Thompson 1429a98a090bSJeremy L Thompson // -- Create composite label if needed 14303668ca4bSJeremy L Thompson CeedInt num_sub; 14313668ca4bSJeremy L Thompson CeedOperator *sub_operators; 14323668ca4bSJeremy L Thompson CeedContextFieldLabel new_field_label; 14333668ca4bSJeremy L Thompson 14342b730f8bSJeremy L Thompson CeedCall(CeedCalloc(1, &new_field_label)); 1435c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_sub)); 1436c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 14372b730f8bSJeremy L Thompson CeedCall(CeedCalloc(num_sub, &new_field_label->sub_labels)); 14383668ca4bSJeremy L Thompson new_field_label->num_sub_labels = num_sub; 14393668ca4bSJeremy L Thompson 14403668ca4bSJeremy L Thompson for (CeedInt i = 0; i < num_sub; i++) { 14413668ca4bSJeremy L Thompson if (sub_operators[i]->qf->ctx) { 14423668ca4bSJeremy L Thompson CeedContextFieldLabel new_field_label_i; 14431c66c397SJeremy L Thompson 14442b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextGetFieldLabel(sub_operators[i]->qf->ctx, field_name, &new_field_label_i)); 14453668ca4bSJeremy L Thompson if (new_field_label_i) { 1446a98a090bSJeremy L Thompson field_found = true; 14473668ca4bSJeremy L Thompson new_field_label->sub_labels[i] = new_field_label_i; 14483668ca4bSJeremy L Thompson new_field_label->name = new_field_label_i->name; 14493668ca4bSJeremy L Thompson new_field_label->description = new_field_label_i->description; 14502b730f8bSJeremy L Thompson if (new_field_label->type && new_field_label->type != new_field_label_i->type) { 14517bfe0f0eSJeremy L Thompson // LCOV_EXCL_START 14522b730f8bSJeremy L Thompson CeedCall(CeedFree(&new_field_label)); 14532b730f8bSJeremy L Thompson return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE, "Incompatible field types on sub-operator contexts. %s != %s", 14542b730f8bSJeremy L Thompson CeedContextFieldTypes[new_field_label->type], CeedContextFieldTypes[new_field_label_i->type]); 14557bfe0f0eSJeremy L Thompson // LCOV_EXCL_STOP 14567bfe0f0eSJeremy L Thompson } else { 14577bfe0f0eSJeremy L Thompson new_field_label->type = new_field_label_i->type; 14587bfe0f0eSJeremy L Thompson } 14592b730f8bSJeremy L Thompson if (new_field_label->num_values != 0 && new_field_label->num_values != new_field_label_i->num_values) { 14607bfe0f0eSJeremy L Thompson // LCOV_EXCL_START 14612b730f8bSJeremy L Thompson CeedCall(CeedFree(&new_field_label)); 14622b730f8bSJeremy L Thompson return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE, "Incompatible field number of values on sub-operator contexts. %ld != %ld", 14637bfe0f0eSJeremy L Thompson new_field_label->num_values, new_field_label_i->num_values); 14647bfe0f0eSJeremy L Thompson // LCOV_EXCL_STOP 14657bfe0f0eSJeremy L Thompson } else { 14667bfe0f0eSJeremy L Thompson new_field_label->num_values = new_field_label_i->num_values; 14677bfe0f0eSJeremy L Thompson } 14683668ca4bSJeremy L Thompson } 14693668ca4bSJeremy L Thompson } 14703668ca4bSJeremy L Thompson } 1471a98a090bSJeremy L Thompson // -- Cleanup if field was found 1472a98a090bSJeremy L Thompson if (field_found) { 1473a98a090bSJeremy L Thompson *field_label = new_field_label; 1474a98a090bSJeremy L Thompson } else { 14753668ca4bSJeremy L Thompson // LCOV_EXCL_START 14762b730f8bSJeremy L Thompson CeedCall(CeedFree(&new_field_label->sub_labels)); 14772b730f8bSJeremy L Thompson CeedCall(CeedFree(&new_field_label)); 14783668ca4bSJeremy L Thompson *field_label = NULL; 14793668ca4bSJeremy L Thompson // LCOV_EXCL_STOP 14805ac9af79SJeremy L Thompson } 14815ac9af79SJeremy L Thompson } else { 1482a98a090bSJeremy L Thompson // Single, non-composite operator 1483a98a090bSJeremy L Thompson if (op->qf->ctx) { 14845ac9af79SJeremy L Thompson CeedCall(CeedQFunctionContextGetFieldLabel(op->qf->ctx, field_name, field_label)); 1485a98a090bSJeremy L Thompson } else { 1486a98a090bSJeremy L Thompson *field_label = NULL; 1487a98a090bSJeremy L Thompson } 14885ac9af79SJeremy L Thompson } 14895ac9af79SJeremy L Thompson 14905ac9af79SJeremy L Thompson // Set label in operator 14915ac9af79SJeremy L Thompson if (*field_label) { 14925ac9af79SJeremy L Thompson (*field_label)->from_op = true; 14935ac9af79SJeremy L Thompson 14943668ca4bSJeremy L Thompson // Move new composite label to operator 14953668ca4bSJeremy L Thompson if (op->num_context_labels == 0) { 14962b730f8bSJeremy L Thompson CeedCall(CeedCalloc(1, &op->context_labels)); 14973668ca4bSJeremy L Thompson op->max_context_labels = 1; 14983668ca4bSJeremy L Thompson } else if (op->num_context_labels == op->max_context_labels) { 14992b730f8bSJeremy L Thompson CeedCall(CeedRealloc(2 * op->num_context_labels, &op->context_labels)); 15003668ca4bSJeremy L Thompson op->max_context_labels *= 2; 15013668ca4bSJeremy L Thompson } 15025ac9af79SJeremy L Thompson op->context_labels[op->num_context_labels] = *field_label; 15033668ca4bSJeremy L Thompson op->num_context_labels++; 15043668ca4bSJeremy L Thompson } 15053668ca4bSJeremy L Thompson return CEED_ERROR_SUCCESS; 15063668ca4bSJeremy L Thompson } 15073668ca4bSJeremy L Thompson 15083668ca4bSJeremy L Thompson /** 15092788fa27SJeremy L Thompson @brief Set QFunctionContext field holding double precision values. 15104385fb7fSSebastian Grimberg 15112788fa27SJeremy L Thompson For composite operators, the values are set in all sub-operator QFunctionContexts that have a matching `field_name`. 1512d8dd9a91SJeremy L Thompson 1513ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 15142788fa27SJeremy L Thompson @param[in] field_label Label of field to set 1515ea61e9acSJeremy L Thompson @param[in] values Values to set 1516d8dd9a91SJeremy L Thompson 1517d8dd9a91SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1518d8dd9a91SJeremy L Thompson 1519d8dd9a91SJeremy L Thompson @ref User 1520d8dd9a91SJeremy L Thompson **/ 152117b0d5c6SJeremy L Thompson int CeedOperatorSetContextDouble(CeedOperator op, CeedContextFieldLabel field_label, double *values) { 15222b730f8bSJeremy L Thompson return CeedOperatorContextSetGeneric(op, field_label, CEED_CONTEXT_FIELD_DOUBLE, values); 1523d8dd9a91SJeremy L Thompson } 1524d8dd9a91SJeremy L Thompson 1525d8dd9a91SJeremy L Thompson /** 15262788fa27SJeremy L Thompson @brief Get QFunctionContext field holding double precision values, read-only. 15274385fb7fSSebastian Grimberg 15282788fa27SJeremy L Thompson For composite operators, the values correspond to the first sub-operator QFunctionContexts that has a matching `field_name`. 15292788fa27SJeremy L Thompson 15302788fa27SJeremy L Thompson @param[in] op CeedOperator 15312788fa27SJeremy L Thompson @param[in] field_label Label of field to get 15322788fa27SJeremy L Thompson @param[out] num_values Number of values in the field label 15332788fa27SJeremy L Thompson @param[out] values Pointer to context values 15342788fa27SJeremy L Thompson 15352788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 15362788fa27SJeremy L Thompson 15372788fa27SJeremy L Thompson @ref User 15382788fa27SJeremy L Thompson **/ 153917b0d5c6SJeremy L Thompson int CeedOperatorGetContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const double **values) { 15402788fa27SJeremy L Thompson return CeedOperatorContextGetGenericRead(op, field_label, CEED_CONTEXT_FIELD_DOUBLE, num_values, values); 15412788fa27SJeremy L Thompson } 15422788fa27SJeremy L Thompson 15432788fa27SJeremy L Thompson /** 15442788fa27SJeremy L Thompson @brief Restore QFunctionContext field holding double precision values, read-only. 15452788fa27SJeremy L Thompson 15462788fa27SJeremy L Thompson @param[in] op CeedOperator 15472788fa27SJeremy L Thompson @param[in] field_label Label of field to restore 15482788fa27SJeremy L Thompson @param[out] values Pointer to context values 15492788fa27SJeremy L Thompson 15502788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 15512788fa27SJeremy L Thompson 15522788fa27SJeremy L Thompson @ref User 15532788fa27SJeremy L Thompson **/ 155417b0d5c6SJeremy L Thompson int CeedOperatorRestoreContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, const double **values) { 15552788fa27SJeremy L Thompson return CeedOperatorContextRestoreGenericRead(op, field_label, CEED_CONTEXT_FIELD_DOUBLE, values); 15562788fa27SJeremy L Thompson } 15572788fa27SJeremy L Thompson 15582788fa27SJeremy L Thompson /** 15592788fa27SJeremy L Thompson @brief Set QFunctionContext field holding int32 values. 15604385fb7fSSebastian Grimberg 15612788fa27SJeremy L Thompson For composite operators, the values are set in all sub-operator QFunctionContexts that have a matching `field_name`. 1562d8dd9a91SJeremy L Thompson 1563ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator 1564ea61e9acSJeremy L Thompson @param[in] field_label Label of field to set 1565ea61e9acSJeremy L Thompson @param[in] values Values to set 1566d8dd9a91SJeremy L Thompson 1567d8dd9a91SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 1568d8dd9a91SJeremy L Thompson 1569d8dd9a91SJeremy L Thompson @ref User 1570d8dd9a91SJeremy L Thompson **/ 157123dbfd29SJeremy L Thompson int CeedOperatorSetContextInt32(CeedOperator op, CeedContextFieldLabel field_label, int32_t *values) { 15722b730f8bSJeremy L Thompson return CeedOperatorContextSetGeneric(op, field_label, CEED_CONTEXT_FIELD_INT32, values); 1573d8dd9a91SJeremy L Thompson } 1574d8dd9a91SJeremy L Thompson 1575d8dd9a91SJeremy L Thompson /** 15762788fa27SJeremy L Thompson @brief Get QFunctionContext field holding int32 values, read-only. 15774385fb7fSSebastian Grimberg 15782788fa27SJeremy L Thompson For composite operators, the values correspond to the first sub-operator QFunctionContexts that has a matching `field_name`. 15792788fa27SJeremy L Thompson 15802788fa27SJeremy L Thompson @param[in] op CeedOperator 15812788fa27SJeremy L Thompson @param[in] field_label Label of field to get 1582c5d0f995SJed Brown @param[out] num_values Number of int32 values in `values` 15832788fa27SJeremy L Thompson @param[out] values Pointer to context values 15842788fa27SJeremy L Thompson 15852788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 15862788fa27SJeremy L Thompson 15872788fa27SJeremy L Thompson @ref User 15882788fa27SJeremy L Thompson **/ 158923dbfd29SJeremy L Thompson int CeedOperatorGetContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const int32_t **values) { 15902788fa27SJeremy L Thompson return CeedOperatorContextGetGenericRead(op, field_label, CEED_CONTEXT_FIELD_INT32, num_values, values); 15912788fa27SJeremy L Thompson } 15922788fa27SJeremy L Thompson 15932788fa27SJeremy L Thompson /** 15942788fa27SJeremy L Thompson @brief Restore QFunctionContext field holding int32 values, read-only. 15952788fa27SJeremy L Thompson 15962788fa27SJeremy L Thompson @param[in] op CeedOperator 15972788fa27SJeremy L Thompson @param[in] field_label Label of field to get 15982788fa27SJeremy L Thompson @param[out] values Pointer to context values 15992788fa27SJeremy L Thompson 16002788fa27SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 16012788fa27SJeremy L Thompson 16022788fa27SJeremy L Thompson @ref User 16032788fa27SJeremy L Thompson **/ 160423dbfd29SJeremy L Thompson int CeedOperatorRestoreContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, const int32_t **values) { 16052788fa27SJeremy L Thompson return CeedOperatorContextRestoreGenericRead(op, field_label, CEED_CONTEXT_FIELD_INT32, values); 16062788fa27SJeremy L Thompson } 16072788fa27SJeremy L Thompson 16082788fa27SJeremy L Thompson /** 16095b6ec284SJeremy L Thompson @brief Set QFunctionContext field holding boolean values. 16105b6ec284SJeremy L Thompson 16115b6ec284SJeremy L Thompson For composite operators, the values are set in all sub-operator QFunctionContexts that have a matching `field_name`. 16125b6ec284SJeremy L Thompson 16135b6ec284SJeremy L Thompson @param[in,out] op CeedOperator 16145b6ec284SJeremy L Thompson @param[in] field_label Label of field to set 16155b6ec284SJeremy L Thompson @param[in] values Values to set 16165b6ec284SJeremy L Thompson 16175b6ec284SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 16185b6ec284SJeremy L Thompson 16195b6ec284SJeremy L Thompson @ref User 16205b6ec284SJeremy L Thompson **/ 16215b6ec284SJeremy L Thompson int CeedOperatorSetContextBoolean(CeedOperator op, CeedContextFieldLabel field_label, bool *values) { 16225b6ec284SJeremy L Thompson return CeedOperatorContextSetGeneric(op, field_label, CEED_CONTEXT_FIELD_BOOL, values); 16235b6ec284SJeremy L Thompson } 16245b6ec284SJeremy L Thompson 16255b6ec284SJeremy L Thompson /** 16265b6ec284SJeremy L Thompson @brief Get QFunctionContext field holding boolean values, read-only. 16275b6ec284SJeremy L Thompson 16285b6ec284SJeremy L Thompson For composite operators, the values correspond to the first sub-operator QFunctionContexts that has a matching `field_name`. 16295b6ec284SJeremy L Thompson 16305b6ec284SJeremy L Thompson @param[in] op CeedOperator 16315b6ec284SJeremy L Thompson @param[in] field_label Label of field to get 16325b6ec284SJeremy L Thompson @param[out] num_values Number of int32 values in `values` 16335b6ec284SJeremy L Thompson @param[out] values Pointer to context values 16345b6ec284SJeremy L Thompson 16355b6ec284SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 16365b6ec284SJeremy L Thompson 16375b6ec284SJeremy L Thompson @ref User 16385b6ec284SJeremy L Thompson **/ 16395b6ec284SJeremy L Thompson int CeedOperatorGetContextBooleanRead(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const bool **values) { 16405b6ec284SJeremy L Thompson return CeedOperatorContextGetGenericRead(op, field_label, CEED_CONTEXT_FIELD_BOOL, num_values, values); 16415b6ec284SJeremy L Thompson } 16425b6ec284SJeremy L Thompson 16435b6ec284SJeremy L Thompson /** 16445b6ec284SJeremy L Thompson @brief Restore QFunctionContext field holding boolean values, read-only. 16455b6ec284SJeremy L Thompson 16465b6ec284SJeremy L Thompson @param[in] op CeedOperator 16475b6ec284SJeremy L Thompson @param[in] field_label Label of field to get 16485b6ec284SJeremy L Thompson @param[out] values Pointer to context values 16495b6ec284SJeremy L Thompson 16505b6ec284SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 16515b6ec284SJeremy L Thompson 16525b6ec284SJeremy L Thompson @ref User 16535b6ec284SJeremy L Thompson **/ 16545b6ec284SJeremy L Thompson int CeedOperatorRestoreContextBooleanRead(CeedOperator op, CeedContextFieldLabel field_label, const bool **values) { 16555b6ec284SJeremy L Thompson return CeedOperatorContextRestoreGenericRead(op, field_label, CEED_CONTEXT_FIELD_BOOL, values); 16565b6ec284SJeremy L Thompson } 16575b6ec284SJeremy L Thompson 16585b6ec284SJeremy L Thompson /** 16593bd813ffSjeremylt @brief Apply CeedOperator to a vector 1660d7b241e6Sjeremylt 1661ea61e9acSJeremy L Thompson This computes the action of the operator on the specified (active) input, yielding its (active) output. 1662ea61e9acSJeremy L Thompson All inputs and outputs must be specified using CeedOperatorSetField(). 1663d7b241e6Sjeremylt 1664ea61e9acSJeremy L Thompson Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable. 1665f04ea552SJeremy L Thompson 1666ea61e9acSJeremy L Thompson @param[in] op CeedOperator to apply 1667ea61e9acSJeremy L Thompson @param[in] in CeedVector containing input state or @ref CEED_VECTOR_NONE if there are no active inputs 16685ac9af79SJeremy L Thompson @param[out] out CeedVector to store result of applying operator (must be distinct from @a in) or @ref CEED_VECTOR_NONE if there are no 16695ac9af79SJeremy L Thompson active outputs 1670ea61e9acSJeremy L Thompson @param[in] request Address of CeedRequest for non-blocking completion, else @ref CEED_REQUEST_IMMEDIATE 1671b11c1e72Sjeremylt 1672b11c1e72Sjeremylt @return An error code: 0 - success, otherwise - failure 1673dfdf5a53Sjeremylt 16747a982d89SJeremy L. Thompson @ref User 1675b11c1e72Sjeremylt **/ 16762b730f8bSJeremy L Thompson int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request) { 16772b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckReady(op)); 1678d7b241e6Sjeremylt 16793ca2b39bSJeremy L Thompson if (op->is_composite) { 1680250756a7Sjeremylt // Composite Operator 1681250756a7Sjeremylt if (op->ApplyComposite) { 16822b730f8bSJeremy L Thompson CeedCall(op->ApplyComposite(op, in, out, request)); 1683250756a7Sjeremylt } else { 1684d1d35e2fSjeremylt CeedInt num_suboperators; 1685d1d35e2fSjeremylt CeedOperator *sub_operators; 16861c66c397SJeremy L Thompson 16871c66c397SJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 1688c6ebc35dSJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 1689250756a7Sjeremylt 1690250756a7Sjeremylt // Zero all output vectors 16913ca2b39bSJeremy L Thompson if (out != CEED_VECTOR_NONE) CeedCall(CeedVectorSetValue(out, 0.0)); 1692d1d35e2fSjeremylt for (CeedInt i = 0; i < num_suboperators; i++) { 1693d1d35e2fSjeremylt for (CeedInt j = 0; j < sub_operators[i]->qf->num_output_fields; j++) { 1694d1d35e2fSjeremylt CeedVector vec = sub_operators[i]->output_fields[j]->vec; 16951c66c397SJeremy L Thompson 1696250756a7Sjeremylt if (vec != CEED_VECTOR_ACTIVE && vec != CEED_VECTOR_NONE) { 16972b730f8bSJeremy L Thompson CeedCall(CeedVectorSetValue(vec, 0.0)); 1698250756a7Sjeremylt } 1699250756a7Sjeremylt } 1700250756a7Sjeremylt } 1701250756a7Sjeremylt // Apply 1702f754c177SSebastian Grimberg for (CeedInt i = 0; i < num_suboperators; i++) { 1703f754c177SSebastian Grimberg CeedCall(CeedOperatorApplyAdd(sub_operators[i], in, out, request)); 1704cae8b89aSjeremylt } 1705cae8b89aSjeremylt } 17063ca2b39bSJeremy L Thompson } else { 17073ca2b39bSJeremy L Thompson // Standard Operator 17083ca2b39bSJeremy L Thompson if (op->Apply) { 17093ca2b39bSJeremy L Thompson CeedCall(op->Apply(op, in, out, request)); 17103ca2b39bSJeremy L Thompson } else { 17113ca2b39bSJeremy L Thompson // Zero all output vectors 17123ca2b39bSJeremy L Thompson CeedQFunction qf = op->qf; 17131c66c397SJeremy L Thompson 17143ca2b39bSJeremy L Thompson for (CeedInt i = 0; i < qf->num_output_fields; i++) { 17153ca2b39bSJeremy L Thompson CeedVector vec = op->output_fields[i]->vec; 17161c66c397SJeremy L Thompson 17173ca2b39bSJeremy L Thompson if (vec == CEED_VECTOR_ACTIVE) vec = out; 17183ca2b39bSJeremy L Thompson if (vec != CEED_VECTOR_NONE) CeedCall(CeedVectorSetValue(vec, 0.0)); 17193ca2b39bSJeremy L Thompson } 17203ca2b39bSJeremy L Thompson // Apply 17213ca2b39bSJeremy L Thompson if (op->num_elem) CeedCall(op->ApplyAdd(op, in, out, request)); 17223ca2b39bSJeremy L Thompson } 1723250756a7Sjeremylt } 1724e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 1725cae8b89aSjeremylt } 1726cae8b89aSjeremylt 1727cae8b89aSjeremylt /** 1728cae8b89aSjeremylt @brief Apply CeedOperator to a vector and add result to output vector 1729cae8b89aSjeremylt 1730ea61e9acSJeremy L Thompson This computes the action of the operator on the specified (active) input, yielding its (active) output. 1731ea61e9acSJeremy L Thompson All inputs and outputs must be specified using CeedOperatorSetField(). 1732cae8b89aSjeremylt 1733ea61e9acSJeremy L Thompson @param[in] op CeedOperator to apply 1734ea61e9acSJeremy L Thompson @param[in] in CeedVector containing input state or NULL if there are no active inputs 1735ea61e9acSJeremy L Thompson @param[out] out CeedVector to sum in result of applying operator (must be distinct from @a in) or NULL if there are no active outputs 1736ea61e9acSJeremy L Thompson @param[in] request Address of CeedRequest for non-blocking completion, else @ref CEED_REQUEST_IMMEDIATE 1737cae8b89aSjeremylt 1738cae8b89aSjeremylt @return An error code: 0 - success, otherwise - failure 1739cae8b89aSjeremylt 17407a982d89SJeremy L. Thompson @ref User 1741cae8b89aSjeremylt **/ 17422b730f8bSJeremy L Thompson int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request) { 17432b730f8bSJeremy L Thompson CeedCall(CeedOperatorCheckReady(op)); 1744cae8b89aSjeremylt 17453ca2b39bSJeremy L Thompson if (op->is_composite) { 1746250756a7Sjeremylt // Composite Operator 1747250756a7Sjeremylt if (op->ApplyAddComposite) { 17482b730f8bSJeremy L Thompson CeedCall(op->ApplyAddComposite(op, in, out, request)); 1749cae8b89aSjeremylt } else { 1750d1d35e2fSjeremylt CeedInt num_suboperators; 1751d1d35e2fSjeremylt CeedOperator *sub_operators; 1752250756a7Sjeremylt 17531c66c397SJeremy L Thompson CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 17541c66c397SJeremy L Thompson CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 1755d1d35e2fSjeremylt for (CeedInt i = 0; i < num_suboperators; i++) { 17562b730f8bSJeremy L Thompson CeedCall(CeedOperatorApplyAdd(sub_operators[i], in, out, request)); 17571d7d2407SJeremy L Thompson } 1758250756a7Sjeremylt } 17593ca2b39bSJeremy L Thompson } else if (op->num_elem) { 17603ca2b39bSJeremy L Thompson // Standard Operator 17613ca2b39bSJeremy L Thompson CeedCall(op->ApplyAdd(op, in, out, request)); 1762250756a7Sjeremylt } 1763e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 1764d7b241e6Sjeremylt } 1765d7b241e6Sjeremylt 1766d7b241e6Sjeremylt /** 1767b11c1e72Sjeremylt @brief Destroy a CeedOperator 1768d7b241e6Sjeremylt 1769ea61e9acSJeremy L Thompson @param[in,out] op CeedOperator to destroy 1770b11c1e72Sjeremylt 1771b11c1e72Sjeremylt @return An error code: 0 - success, otherwise - failure 1772dfdf5a53Sjeremylt 17737a982d89SJeremy L. Thompson @ref User 1774b11c1e72Sjeremylt **/ 1775d7b241e6Sjeremylt int CeedOperatorDestroy(CeedOperator *op) { 1776ad6481ceSJeremy L Thompson if (!*op || --(*op)->ref_count > 0) { 1777ad6481ceSJeremy L Thompson *op = NULL; 1778ad6481ceSJeremy L Thompson return CEED_ERROR_SUCCESS; 1779ad6481ceSJeremy L Thompson } 17802b730f8bSJeremy L Thompson if ((*op)->Destroy) CeedCall((*op)->Destroy(*op)); 17812b730f8bSJeremy L Thompson CeedCall(CeedDestroy(&(*op)->ceed)); 1782fe2413ffSjeremylt // Free fields 17832b730f8bSJeremy L Thompson for (CeedInt i = 0; i < (*op)->num_fields; i++) { 1784d1d35e2fSjeremylt if ((*op)->input_fields[i]) { 1785437c7c90SJeremy L Thompson if ((*op)->input_fields[i]->elem_rstr != CEED_ELEMRESTRICTION_NONE) { 1786437c7c90SJeremy L Thompson CeedCall(CeedElemRestrictionDestroy(&(*op)->input_fields[i]->elem_rstr)); 178715910d16Sjeremylt } 1788356036faSJeremy L Thompson if ((*op)->input_fields[i]->basis != CEED_BASIS_NONE) { 17892b730f8bSJeremy L Thompson CeedCall(CeedBasisDestroy(&(*op)->input_fields[i]->basis)); 179071352a93Sjeremylt } 17912b730f8bSJeremy L Thompson if ((*op)->input_fields[i]->vec != CEED_VECTOR_ACTIVE && (*op)->input_fields[i]->vec != CEED_VECTOR_NONE) { 17922b730f8bSJeremy L Thompson CeedCall(CeedVectorDestroy(&(*op)->input_fields[i]->vec)); 179371352a93Sjeremylt } 17942b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->input_fields[i]->field_name)); 17952b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->input_fields[i])); 1796fe2413ffSjeremylt } 17972b730f8bSJeremy L Thompson } 17982b730f8bSJeremy L Thompson for (CeedInt i = 0; i < (*op)->num_fields; i++) { 1799d1d35e2fSjeremylt if ((*op)->output_fields[i]) { 1800437c7c90SJeremy L Thompson CeedCall(CeedElemRestrictionDestroy(&(*op)->output_fields[i]->elem_rstr)); 1801356036faSJeremy L Thompson if ((*op)->output_fields[i]->basis != CEED_BASIS_NONE) { 18022b730f8bSJeremy L Thompson CeedCall(CeedBasisDestroy(&(*op)->output_fields[i]->basis)); 180371352a93Sjeremylt } 18042b730f8bSJeremy L Thompson if ((*op)->output_fields[i]->vec != CEED_VECTOR_ACTIVE && (*op)->output_fields[i]->vec != CEED_VECTOR_NONE) { 18052b730f8bSJeremy L Thompson CeedCall(CeedVectorDestroy(&(*op)->output_fields[i]->vec)); 180671352a93Sjeremylt } 18072b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->output_fields[i]->field_name)); 18082b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->output_fields[i])); 18092b730f8bSJeremy L Thompson } 1810fe2413ffSjeremylt } 1811*48acf710SJeremy L Thompson // AtPoints data 1812*48acf710SJeremy L Thompson CeedCall(CeedVectorDestroy(&(*op)->point_coords)); 1813*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionDestroy(&(*op)->rstr_points)); 1814*48acf710SJeremy L Thompson CeedCall(CeedElemRestrictionDestroy(&(*op)->first_points_rstr)); 1815d1d35e2fSjeremylt // Destroy sub_operators 18162b730f8bSJeremy L Thompson for (CeedInt i = 0; i < (*op)->num_suboperators; i++) { 1817d1d35e2fSjeremylt if ((*op)->sub_operators[i]) { 18182b730f8bSJeremy L Thompson CeedCall(CeedOperatorDestroy(&(*op)->sub_operators[i])); 181952d6035fSJeremy L Thompson } 18202b730f8bSJeremy L Thompson } 18212b730f8bSJeremy L Thompson CeedCall(CeedQFunctionDestroy(&(*op)->qf)); 18222b730f8bSJeremy L Thompson CeedCall(CeedQFunctionDestroy(&(*op)->dqf)); 18232b730f8bSJeremy L Thompson CeedCall(CeedQFunctionDestroy(&(*op)->dqfT)); 18243668ca4bSJeremy L Thompson // Destroy any composite labels 18255ac9af79SJeremy L Thompson if ((*op)->is_composite) { 18263668ca4bSJeremy L Thompson for (CeedInt i = 0; i < (*op)->num_context_labels; i++) { 18272b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->context_labels[i]->sub_labels)); 18282b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->context_labels[i])); 18293668ca4bSJeremy L Thompson } 18305ac9af79SJeremy L Thompson } 18312b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->context_labels)); 1832fe2413ffSjeremylt 18335107b09fSJeremy L Thompson // Destroy fallback 18342b730f8bSJeremy L Thompson CeedCall(CeedOperatorDestroy(&(*op)->op_fallback)); 18355107b09fSJeremy L Thompson 1836ed9e99e6SJeremy L Thompson // Destroy assembly data 18372b730f8bSJeremy L Thompson CeedCall(CeedQFunctionAssemblyDataDestroy(&(*op)->qf_assembled)); 18382b730f8bSJeremy L Thompson CeedCall(CeedOperatorAssemblyDataDestroy(&(*op)->op_assembled)); 183970a7ffb3SJeremy L Thompson 18402b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->input_fields)); 18412b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->output_fields)); 18422b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->sub_operators)); 18432b730f8bSJeremy L Thompson CeedCall(CeedFree(&(*op)->name)); 18442b730f8bSJeremy L Thompson CeedCall(CeedFree(op)); 1845e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 1846d7b241e6Sjeremylt } 1847d7b241e6Sjeremylt 1848d7b241e6Sjeremylt /// @} 1849