| ceed-operator.c (9beba3585d181bdcf4b16bccd6526a6077e1482e) | ceed-operator.c (8a297abd0abffb6af7c8cbd4ffcd5e5f554c8ef0) |
|---|---|
| 1// Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <ceed-impl.h> --- 104 unchanged lines hidden (view full) --- 113 ":\n" 114 "%s Name: \"%s\"\n", 115 pre, in_out, field_number, pre, field_name); 116 fprintf(stream, "%s Size: %" CeedInt_FMT "\n", pre, size); 117 fprintf(stream, "%s EvalMode: %s\n", pre, CeedEvalModes[eval_mode]); 118 if (basis == CEED_BASIS_NONE) fprintf(stream, "%s No basis\n", pre); 119 if (vec == CEED_VECTOR_ACTIVE) fprintf(stream, "%s Active vector\n", pre); 120 else if (vec == CEED_VECTOR_NONE) fprintf(stream, "%s No vector\n", pre); | 1// Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <ceed-impl.h> --- 104 unchanged lines hidden (view full) --- 113 ":\n" 114 "%s Name: \"%s\"\n", 115 pre, in_out, field_number, pre, field_name); 116 fprintf(stream, "%s Size: %" CeedInt_FMT "\n", pre, size); 117 fprintf(stream, "%s EvalMode: %s\n", pre, CeedEvalModes[eval_mode]); 118 if (basis == CEED_BASIS_NONE) fprintf(stream, "%s No basis\n", pre); 119 if (vec == CEED_VECTOR_ACTIVE) fprintf(stream, "%s Active vector\n", pre); 120 else if (vec == CEED_VECTOR_NONE) fprintf(stream, "%s No vector\n", pre); |
| 121 122 CeedCall(CeedVectorDestroy(&vec)); 123 CeedCall(CeedBasisDestroy(&basis)); | |
| 124 return CEED_ERROR_SUCCESS; 125} 126 127/** 128 @brief View a single `CeedOperator` 129 130 @param[in] op `CeedOperator` to view 131 @param[in] sub Boolean flag for sub-operator --- 26 unchanged lines hidden (view full) --- 158 fprintf(stream, "%s %" CeedInt_FMT " output field%s:\n", pre, num_output_fields, num_output_fields > 1 ? "s" : ""); 159 for (CeedInt i = 0; i < num_output_fields; i++) { 160 CeedCall(CeedOperatorFieldView(op_output_fields[i], qf_output_fields[i], i, sub, 0, stream)); 161 } 162 return CEED_ERROR_SUCCESS; 163} 164 165/** | 121 return CEED_ERROR_SUCCESS; 122} 123 124/** 125 @brief View a single `CeedOperator` 126 127 @param[in] op `CeedOperator` to view 128 @param[in] sub Boolean flag for sub-operator --- 26 unchanged lines hidden (view full) --- 155 fprintf(stream, "%s %" CeedInt_FMT " output field%s:\n", pre, num_output_fields, num_output_fields > 1 ? "s" : ""); 156 for (CeedInt i = 0; i < num_output_fields; i++) { 157 CeedCall(CeedOperatorFieldView(op_output_fields[i], qf_output_fields[i], i, sub, 0, stream)); 158 } 159 return CEED_ERROR_SUCCESS; 160} 161 162/** |
| 166 @brief Find the active input vector `CeedBasis` for a non-composite `CeedOperator`. | 163 @brief Find the active input vector `CeedBasis` for a non-composite `CeedOperator` |
| 167 | 164 |
| 168 Note: Caller is responsible for destroying the `active_basis` with @ref CeedBasisDestroy(). 169 | |
| 170 @param[in] op `CeedOperator` to find active `CeedBasis` for 171 @param[out] active_basis `CeedBasis` for active input vector or `NULL` for composite operator 172 173 @return An error code: 0 - success, otherwise - failure 174 175 @ref Developer 176**/ 177int CeedOperatorGetActiveBasis(CeedOperator op, CeedBasis *active_basis) { 178 CeedCall(CeedOperatorGetActiveBases(op, active_basis, NULL)); 179 return CEED_ERROR_SUCCESS; 180} 181 182/** | 165 @param[in] op `CeedOperator` to find active `CeedBasis` for 166 @param[out] active_basis `CeedBasis` for active input vector or `NULL` for composite operator 167 168 @return An error code: 0 - success, otherwise - failure 169 170 @ref Developer 171**/ 172int CeedOperatorGetActiveBasis(CeedOperator op, CeedBasis *active_basis) { 173 CeedCall(CeedOperatorGetActiveBases(op, active_basis, NULL)); 174 return CEED_ERROR_SUCCESS; 175} 176 177/** |
| 183 @brief Find the active input and output vector `CeedBasis` for a non-composite `CeedOperator`. | 178 @brief Find the active input and output vector `CeedBasis` for a non-composite `CeedOperator` |
| 184 | 179 |
| 185 Note: Caller is responsible for destroying the bases with @ref CeedBasisDestroy(). 186 | |
| 187 @param[in] op `CeedOperator` to find active `CeedBasis` for 188 @param[out] active_input_basis `CeedBasis` for active input vector or `NULL` for composite operator 189 @param[out] active_output_basis `CeedBasis` for active output vector or `NULL` for composite operator 190 191 @return An error code: 0 - success, otherwise - failure 192 193 @ref Developer 194**/ --- 14 unchanged lines hidden (view full) --- 209 CeedVector vec; 210 211 CeedCall(CeedOperatorFieldGetVector(op_input_fields[i], &vec)); 212 if (vec == CEED_VECTOR_ACTIVE) { 213 CeedBasis basis; 214 215 CeedCall(CeedOperatorFieldGetBasis(op_input_fields[i], &basis)); 216 CeedCheck(!*active_input_basis || *active_input_basis == basis, ceed, CEED_ERROR_MINOR, "Multiple active input CeedBases found"); | 180 @param[in] op `CeedOperator` to find active `CeedBasis` for 181 @param[out] active_input_basis `CeedBasis` for active input vector or `NULL` for composite operator 182 @param[out] active_output_basis `CeedBasis` for active output vector or `NULL` for composite operator 183 184 @return An error code: 0 - success, otherwise - failure 185 186 @ref Developer 187**/ --- 14 unchanged lines hidden (view full) --- 202 CeedVector vec; 203 204 CeedCall(CeedOperatorFieldGetVector(op_input_fields[i], &vec)); 205 if (vec == CEED_VECTOR_ACTIVE) { 206 CeedBasis basis; 207 208 CeedCall(CeedOperatorFieldGetBasis(op_input_fields[i], &basis)); 209 CeedCheck(!*active_input_basis || *active_input_basis == basis, ceed, CEED_ERROR_MINOR, "Multiple active input CeedBases found"); |
| 217 if (!*active_input_basis) CeedCall(CeedBasisReferenceCopy(basis, active_input_basis)); 218 CeedCall(CeedBasisDestroy(&basis)); | 210 *active_input_basis = basis; |
| 219 } | 211 } |
| 220 CeedCall(CeedVectorDestroy(&vec)); | |
| 221 } 222 CeedCheck(*active_input_basis, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedBasis found"); 223 } 224 } 225 if (active_output_basis) { 226 *active_output_basis = NULL; 227 if (!is_composite) { 228 for (CeedInt i = 0; i < num_output_fields; i++) { 229 CeedVector vec; 230 231 CeedCall(CeedOperatorFieldGetVector(op_output_fields[i], &vec)); 232 if (vec == CEED_VECTOR_ACTIVE) { 233 CeedBasis basis; 234 235 CeedCall(CeedOperatorFieldGetBasis(op_output_fields[i], &basis)); 236 CeedCheck(!*active_output_basis || *active_output_basis == basis, ceed, CEED_ERROR_MINOR, "Multiple active output CeedBases found"); | 212 } 213 CeedCheck(*active_input_basis, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedBasis found"); 214 } 215 } 216 if (active_output_basis) { 217 *active_output_basis = NULL; 218 if (!is_composite) { 219 for (CeedInt i = 0; i < num_output_fields; i++) { 220 CeedVector vec; 221 222 CeedCall(CeedOperatorFieldGetVector(op_output_fields[i], &vec)); 223 if (vec == CEED_VECTOR_ACTIVE) { 224 CeedBasis basis; 225 226 CeedCall(CeedOperatorFieldGetBasis(op_output_fields[i], &basis)); 227 CeedCheck(!*active_output_basis || *active_output_basis == basis, ceed, CEED_ERROR_MINOR, "Multiple active output CeedBases found"); |
| 237 if (!*active_output_basis) CeedCall(CeedBasisReferenceCopy(basis, active_output_basis)); 238 CeedCall(CeedBasisDestroy(&basis)); | 228 *active_output_basis = basis; |
| 239 } | 229 } |
| 240 CeedCall(CeedVectorDestroy(&vec)); | |
| 241 } 242 CeedCheck(*active_output_basis, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedBasis found"); 243 } 244 } 245 return CEED_ERROR_SUCCESS; 246} 247 248/** | 230 } 231 CeedCheck(*active_output_basis, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedBasis found"); 232 } 233 } 234 return CEED_ERROR_SUCCESS; 235} 236 237/** |
| 249 @brief Find the active vector `CeedElemRestriction` for a non-composite `CeedOperator`. | 238 @brief Find the active vector `CeedElemRestriction` for a non-composite `CeedOperator` |
| 250 | 239 |
| 251 Note: Caller is responsible for destroying the `active_rstr` with @ref CeedElemRestrictionDestroy(). 252 | |
| 253 @param[in] op `CeedOperator` to find active `CeedElemRestriction` for 254 @param[out] active_rstr `CeedElemRestriction` for active input vector or NULL for composite operator 255 256 @return An error code: 0 - success, otherwise - failure 257 258 @ref Utility 259**/ 260int CeedOperatorGetActiveElemRestriction(CeedOperator op, CeedElemRestriction *active_rstr) { 261 CeedCall(CeedOperatorGetActiveElemRestrictions(op, active_rstr, NULL)); 262 return CEED_ERROR_SUCCESS; 263} 264 265/** | 240 @param[in] op `CeedOperator` to find active `CeedElemRestriction` for 241 @param[out] active_rstr `CeedElemRestriction` for active input vector or NULL for composite operator 242 243 @return An error code: 0 - success, otherwise - failure 244 245 @ref Utility 246**/ 247int CeedOperatorGetActiveElemRestriction(CeedOperator op, CeedElemRestriction *active_rstr) { 248 CeedCall(CeedOperatorGetActiveElemRestrictions(op, active_rstr, NULL)); 249 return CEED_ERROR_SUCCESS; 250} 251 252/** |
| 266 @brief Find the active input and output vector `CeedElemRestriction` for a non-composite `CeedOperator`. | 253 @brief Find the active input and output vector `CeedElemRestriction` for a non-composite `CeedOperator` |
| 267 | 254 |
| 268 Note: Caller is responsible for destroying the restrictions with @ref CeedElemRestrictionDestroy(). 269 | |
| 270 @param[in] op `CeedOperator` to find active `CeedElemRestriction` for 271 @param[out] active_input_rstr `CeedElemRestriction` for active input vector or NULL for composite operator 272 @param[out] active_output_rstr `CeedElemRestriction` for active output vector or NULL for composite operator 273 274 @return An error code: 0 - success, otherwise - failure 275 276 @ref Utility 277**/ --- 14 unchanged lines hidden (view full) --- 292 CeedVector vec; 293 294 CeedCall(CeedOperatorFieldGetVector(op_input_fields[i], &vec)); 295 if (vec == CEED_VECTOR_ACTIVE) { 296 CeedElemRestriction rstr; 297 298 CeedCall(CeedOperatorFieldGetElemRestriction(op_input_fields[i], &rstr)); 299 CeedCheck(!*active_input_rstr || *active_input_rstr == rstr, ceed, CEED_ERROR_MINOR, "Multiple active input CeedElemRestrictions found"); | 255 @param[in] op `CeedOperator` to find active `CeedElemRestriction` for 256 @param[out] active_input_rstr `CeedElemRestriction` for active input vector or NULL for composite operator 257 @param[out] active_output_rstr `CeedElemRestriction` for active output vector or NULL for composite operator 258 259 @return An error code: 0 - success, otherwise - failure 260 261 @ref Utility 262**/ --- 14 unchanged lines hidden (view full) --- 277 CeedVector vec; 278 279 CeedCall(CeedOperatorFieldGetVector(op_input_fields[i], &vec)); 280 if (vec == CEED_VECTOR_ACTIVE) { 281 CeedElemRestriction rstr; 282 283 CeedCall(CeedOperatorFieldGetElemRestriction(op_input_fields[i], &rstr)); 284 CeedCheck(!*active_input_rstr || *active_input_rstr == rstr, ceed, CEED_ERROR_MINOR, "Multiple active input CeedElemRestrictions found"); |
| 300 if (!*active_input_rstr) CeedCall(CeedElemRestrictionReferenceCopy(rstr, active_input_rstr)); 301 CeedCall(CeedElemRestrictionDestroy(&rstr)); | 285 *active_input_rstr = rstr; |
| 302 } | 286 } |
| 303 CeedCall(CeedVectorDestroy(&vec)); | |
| 304 } 305 CeedCheck(*active_input_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedElemRestriction found"); 306 } 307 } 308 if (active_output_rstr) { 309 *active_output_rstr = NULL; 310 if (!is_composite) { 311 for (CeedInt i = 0; i < num_output_fields; i++) { 312 CeedVector vec; 313 314 CeedCall(CeedOperatorFieldGetVector(op_output_fields[i], &vec)); 315 if (vec == CEED_VECTOR_ACTIVE) { 316 CeedElemRestriction rstr; 317 318 CeedCall(CeedOperatorFieldGetElemRestriction(op_output_fields[i], &rstr)); 319 CeedCheck(!*active_output_rstr || *active_output_rstr == rstr, ceed, CEED_ERROR_MINOR, "Multiple active output CeedElemRestrictions found"); | 287 } 288 CeedCheck(*active_input_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active input CeedElemRestriction found"); 289 } 290 } 291 if (active_output_rstr) { 292 *active_output_rstr = NULL; 293 if (!is_composite) { 294 for (CeedInt i = 0; i < num_output_fields; i++) { 295 CeedVector vec; 296 297 CeedCall(CeedOperatorFieldGetVector(op_output_fields[i], &vec)); 298 if (vec == CEED_VECTOR_ACTIVE) { 299 CeedElemRestriction rstr; 300 301 CeedCall(CeedOperatorFieldGetElemRestriction(op_output_fields[i], &rstr)); 302 CeedCheck(!*active_output_rstr || *active_output_rstr == rstr, ceed, CEED_ERROR_MINOR, "Multiple active output CeedElemRestrictions found"); |
| 320 if (!*active_output_rstr) CeedCall(CeedElemRestrictionReferenceCopy(rstr, active_output_rstr)); 321 CeedCall(CeedElemRestrictionDestroy(&rstr)); | 303 *active_output_rstr = rstr; |
| 322 } | 304 } |
| 323 CeedCall(CeedVectorDestroy(&vec)); | |
| 324 } 325 CeedCheck(*active_output_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedElemRestriction found"); 326 } 327 } 328 return CEED_ERROR_SUCCESS; 329} 330 331/** --- 245 unchanged lines hidden (view full) --- 577 bool is_tensor; 578 CeedBasis basis; 579 580 CeedCall(CeedOperatorFieldGetBasis(input_fields[i], &basis)); 581 if (basis != CEED_BASIS_NONE) { 582 CeedCall(CeedBasisIsTensor(basis, &is_tensor)); 583 *has_tensor_bases &= is_tensor; 584 } | 305 } 306 CeedCheck(*active_output_rstr, ceed, CEED_ERROR_INCOMPLETE, "No active output CeedElemRestriction found"); 307 } 308 } 309 return CEED_ERROR_SUCCESS; 310} 311 312/** --- 245 unchanged lines hidden (view full) --- 558 bool is_tensor; 559 CeedBasis basis; 560 561 CeedCall(CeedOperatorFieldGetBasis(input_fields[i], &basis)); 562 if (basis != CEED_BASIS_NONE) { 563 CeedCall(CeedBasisIsTensor(basis, &is_tensor)); 564 *has_tensor_bases &= is_tensor; 565 } |
| 585 CeedCall(CeedBasisDestroy(&basis)); | |
| 586 } 587 for (CeedInt i = 0; i < num_outputs; i++) { 588 bool is_tensor; 589 CeedBasis basis; 590 591 CeedCall(CeedOperatorFieldGetBasis(output_fields[i], &basis)); 592 if (basis != CEED_BASIS_NONE) { 593 CeedCall(CeedBasisIsTensor(basis, &is_tensor)); 594 *has_tensor_bases &= is_tensor; 595 } | 566 } 567 for (CeedInt i = 0; i < num_outputs; i++) { 568 bool is_tensor; 569 CeedBasis basis; 570 571 CeedCall(CeedOperatorFieldGetBasis(output_fields[i], &basis)); 572 if (basis != CEED_BASIS_NONE) { 573 CeedCall(CeedBasisIsTensor(basis, &is_tensor)); 574 *has_tensor_bases &= is_tensor; 575 } |
| 596 CeedCall(CeedBasisDestroy(&basis)); | |
| 597 } 598 return CEED_ERROR_SUCCESS; 599} 600 601/** 602 @brief Get a boolean value indicating if the `CeedOperator` is immutable 603 604 @param[in] op `CeedOperator` --- 549 unchanged lines hidden (view full) --- 1154 @ref Advanced 1155**/ 1156int CeedOperatorFieldGetName(CeedOperatorField op_field, const char **field_name) { 1157 *field_name = op_field->field_name; 1158 return CEED_ERROR_SUCCESS; 1159} 1160 1161/** | 576 } 577 return CEED_ERROR_SUCCESS; 578} 579 580/** 581 @brief Get a boolean value indicating if the `CeedOperator` is immutable 582 583 @param[in] op `CeedOperator` --- 549 unchanged lines hidden (view full) --- 1133 @ref Advanced 1134**/ 1135int CeedOperatorFieldGetName(CeedOperatorField op_field, const char **field_name) { 1136 *field_name = op_field->field_name; 1137 return CEED_ERROR_SUCCESS; 1138} 1139 1140/** |
| 1162 @brief Get the `CeedElemRestriction` of a `CeedOperator` Field. | 1141 @brief Get the `CeedElemRestriction` of a `CeedOperator` Field |
| 1163 | 1142 |
| 1164 Note: Caller is responsible for destroying the `rstr` with @ref CeedElemRestrictionDestroy(). 1165 | |
| 1166 @param[in] op_field `CeedOperator` Field 1167 @param[out] rstr Variable to store `CeedElemRestriction` 1168 1169 @return An error code: 0 - success, otherwise - failure 1170 1171 @ref Advanced 1172**/ 1173int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr) { | 1143 @param[in] op_field `CeedOperator` Field 1144 @param[out] rstr Variable to store `CeedElemRestriction` 1145 1146 @return An error code: 0 - success, otherwise - failure 1147 1148 @ref Advanced 1149**/ 1150int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr) { |
| 1174 *rstr = NULL; 1175 CeedCall(CeedElemRestrictionReferenceCopy(op_field->elem_rstr, rstr)); | 1151 *rstr = op_field->elem_rstr; |
| 1176 return CEED_ERROR_SUCCESS; 1177} 1178 1179/** | 1152 return CEED_ERROR_SUCCESS; 1153} 1154 1155/** |
| 1180 @brief Get the `CeedBasis` of a `CeedOperator` Field. | 1156 @brief Get the `CeedBasis` of a `CeedOperator` Field |
| 1181 | 1157 |
| 1182 Note: Caller is responsible for destroying the `basis` with @ref CeedBasisDestroy(). 1183 | |
| 1184 @param[in] op_field `CeedOperator` Field 1185 @param[out] basis Variable to store `CeedBasis` 1186 1187 @return An error code: 0 - success, otherwise - failure 1188 1189 @ref Advanced 1190**/ 1191int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis) { | 1158 @param[in] op_field `CeedOperator` Field 1159 @param[out] basis Variable to store `CeedBasis` 1160 1161 @return An error code: 0 - success, otherwise - failure 1162 1163 @ref Advanced 1164**/ 1165int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis) { |
| 1192 *basis = NULL; 1193 CeedCall(CeedBasisReferenceCopy(op_field->basis, basis)); | 1166 *basis = op_field->basis; |
| 1194 return CEED_ERROR_SUCCESS; 1195} 1196 1197/** | 1167 return CEED_ERROR_SUCCESS; 1168} 1169 1170/** |
| 1198 @brief Get the `CeedVector` of a `CeedOperator` Field. | 1171 @brief Get the `CeedVector` of a `CeedOperator` Field |
| 1199 | 1172 |
| 1200 Note: Caller is responsible for destroying the `vec` with @ref CeedVectorDestroy(). 1201 | |
| 1202 @param[in] op_field `CeedOperator` Field 1203 @param[out] vec Variable to store `CeedVector` 1204 1205 @return An error code: 0 - success, otherwise - failure 1206 1207 @ref Advanced 1208**/ 1209int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec) { | 1173 @param[in] op_field `CeedOperator` Field 1174 @param[out] vec Variable to store `CeedVector` 1175 1176 @return An error code: 0 - success, otherwise - failure 1177 1178 @ref Advanced 1179**/ 1180int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec) { |
| 1210 *vec = NULL; 1211 CeedCall(CeedVectorReferenceCopy(op_field->vec, vec)); | 1181 *vec = op_field->vec; |
| 1212 return CEED_ERROR_SUCCESS; 1213} 1214 1215/** 1216 @brief Get the data of a `CeedOperator` Field. 1217 | 1182 return CEED_ERROR_SUCCESS; 1183} 1184 1185/** 1186 @brief Get the data of a `CeedOperator` Field. 1187 |
| 1218 Any arguments set as `NULL` are ignored.. | 1188 Any arguments set as `NULL` are ignored. |
| 1219 | 1189 |
| 1220 Note: Caller is responsible for destroying the `rstr`, `basis`, and `vec`. 1221 | |
| 1222 @param[in] op_field `CeedOperator` Field 1223 @param[out] field_name Variable to store the field name 1224 @param[out] rstr Variable to store `CeedElemRestriction` 1225 @param[out] basis Variable to store `CeedBasis` 1226 @param[out] vec Variable to store `CeedVector` 1227 1228 @return An error code: 0 - success, otherwise - failure 1229 --- 82 unchanged lines hidden (view full) --- 1312 1313 CeedCall(CeedOperatorIsComposite(op, &is_composite)); 1314 CeedCheck(is_composite, CeedOperatorReturnCeed(op), CEED_ERROR_MINOR, "Only defined for a composite operator"); 1315 *sub_operators = op->sub_operators; 1316 return CEED_ERROR_SUCCESS; 1317} 1318 1319/** | 1190 @param[in] op_field `CeedOperator` Field 1191 @param[out] field_name Variable to store the field name 1192 @param[out] rstr Variable to store `CeedElemRestriction` 1193 @param[out] basis Variable to store `CeedBasis` 1194 @param[out] vec Variable to store `CeedVector` 1195 1196 @return An error code: 0 - success, otherwise - failure 1197 --- 82 unchanged lines hidden (view full) --- 1280 1281 CeedCall(CeedOperatorIsComposite(op, &is_composite)); 1282 CeedCheck(is_composite, CeedOperatorReturnCeed(op), CEED_ERROR_MINOR, "Only defined for a composite operator"); 1283 *sub_operators = op->sub_operators; 1284 return CEED_ERROR_SUCCESS; 1285} 1286 1287/** |
| 1288 @brief Get a sub `CeedOperator` of a composite `CeedOperator` from its name. 1289 1290 `sub_op` is set to `NULL` if the sub operator is not found. 1291 1292 Note: Calling this function asserts that setup is complete and sets the `CeedOperator` as immutable. 1293 1294 @param[in] op Composite `CeedOperator` 1295 @param[in] op_name Name of desired sub `CeedOperator` 1296 @param[out] sub_op Sub `CeedOperator` corresponding to the name 1297 1298 @return An error code: 0 - success, otherwise - failure 1299 1300 @ref Advanced 1301**/ 1302int CeedCompositeOperatorGetSubByName(CeedOperator op, const char *op_name, CeedOperator *sub_op) { 1303 bool is_composite; 1304 CeedInt num_sub_ops; 1305 CeedOperator *sub_ops; 1306 1307 CeedCall(CeedOperatorIsComposite(op, &is_composite)); 1308 CeedCheck(is_composite, CeedOperatorReturnCeed(op), CEED_ERROR_MINOR, "Only defined for a composite operator"); 1309 *sub_op = NULL; 1310 CeedCall(CeedCompositeOperatorGetNumSub(op, &num_sub_ops)); 1311 CeedCall(CeedCompositeOperatorGetSubList(op, &sub_ops)); 1312 for (CeedInt i = 0; i < num_sub_ops; i++) { 1313 if (sub_ops[i]->name && !strcmp(op_name, sub_ops[i]->name)) { 1314 *sub_op = sub_ops[i]; 1315 return CEED_ERROR_SUCCESS; 1316 } 1317 } 1318 return CEED_ERROR_SUCCESS; 1319} 1320 1321/** |
|
| 1320 @brief Check if a `CeedOperator` is ready to be used. 1321 1322 @param[in] op `CeedOperator` to check 1323 1324 @return An error code: 0 - success, otherwise - failure 1325 1326 @ref User 1327**/ --- 351 unchanged lines hidden (view full) --- 1679 if (vec == CEED_VECTOR_ACTIVE) { 1680 CeedEvalMode eval_mode; 1681 CeedSize rstr_flops, basis_flops; 1682 CeedElemRestriction rstr; 1683 CeedBasis basis; 1684 1685 CeedCall(CeedOperatorFieldGetElemRestriction(op_input_fields[i], &rstr)); 1686 CeedCall(CeedElemRestrictionGetFlopsEstimate(rstr, CEED_NOTRANSPOSE, &rstr_flops)); | 1322 @brief Check if a `CeedOperator` is ready to be used. 1323 1324 @param[in] op `CeedOperator` to check 1325 1326 @return An error code: 0 - success, otherwise - failure 1327 1328 @ref User 1329**/ --- 351 unchanged lines hidden (view full) --- 1681 if (vec == CEED_VECTOR_ACTIVE) { 1682 CeedEvalMode eval_mode; 1683 CeedSize rstr_flops, basis_flops; 1684 CeedElemRestriction rstr; 1685 CeedBasis basis; 1686 1687 CeedCall(CeedOperatorFieldGetElemRestriction(op_input_fields[i], &rstr)); 1688 CeedCall(CeedElemRestrictionGetFlopsEstimate(rstr, CEED_NOTRANSPOSE, &rstr_flops)); |
| 1687 CeedCall(CeedElemRestrictionDestroy(&rstr)); | |
| 1688 *flops += rstr_flops; 1689 CeedCall(CeedOperatorFieldGetBasis(op_input_fields[i], &basis)); 1690 CeedCall(CeedQFunctionFieldGetEvalMode(qf_input_fields[i], &eval_mode)); 1691 CeedCall(CeedBasisGetFlopsEstimate(basis, CEED_NOTRANSPOSE, eval_mode, &basis_flops)); | 1689 *flops += rstr_flops; 1690 CeedCall(CeedOperatorFieldGetBasis(op_input_fields[i], &basis)); 1691 CeedCall(CeedQFunctionFieldGetEvalMode(qf_input_fields[i], &eval_mode)); 1692 CeedCall(CeedBasisGetFlopsEstimate(basis, CEED_NOTRANSPOSE, eval_mode, &basis_flops)); |
| 1692 CeedCall(CeedBasisDestroy(&basis)); | |
| 1693 *flops += basis_flops * num_elem; 1694 } | 1693 *flops += basis_flops * num_elem; 1694 } |
| 1695 CeedCall(CeedVectorDestroy(&vec)); | |
| 1696 } 1697 // QF FLOPs 1698 { 1699 CeedInt num_qpts; 1700 CeedSize qf_flops; 1701 CeedQFunction qf; 1702 1703 CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts)); --- 12 unchanged lines hidden (view full) --- 1716 if (vec == CEED_VECTOR_ACTIVE) { 1717 CeedEvalMode eval_mode; 1718 CeedSize rstr_flops, basis_flops; 1719 CeedElemRestriction rstr; 1720 CeedBasis basis; 1721 1722 CeedCall(CeedOperatorFieldGetElemRestriction(op_output_fields[i], &rstr)); 1723 CeedCall(CeedElemRestrictionGetFlopsEstimate(rstr, CEED_TRANSPOSE, &rstr_flops)); | 1695 } 1696 // QF FLOPs 1697 { 1698 CeedInt num_qpts; 1699 CeedSize qf_flops; 1700 CeedQFunction qf; 1701 1702 CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts)); --- 12 unchanged lines hidden (view full) --- 1715 if (vec == CEED_VECTOR_ACTIVE) { 1716 CeedEvalMode eval_mode; 1717 CeedSize rstr_flops, basis_flops; 1718 CeedElemRestriction rstr; 1719 CeedBasis basis; 1720 1721 CeedCall(CeedOperatorFieldGetElemRestriction(op_output_fields[i], &rstr)); 1722 CeedCall(CeedElemRestrictionGetFlopsEstimate(rstr, CEED_TRANSPOSE, &rstr_flops)); |
| 1724 CeedCall(CeedElemRestrictionDestroy(&rstr)); | |
| 1725 *flops += rstr_flops; 1726 CeedCall(CeedOperatorFieldGetBasis(op_output_fields[i], &basis)); 1727 CeedCall(CeedQFunctionFieldGetEvalMode(qf_output_fields[i], &eval_mode)); 1728 CeedCall(CeedBasisGetFlopsEstimate(basis, CEED_TRANSPOSE, eval_mode, &basis_flops)); | 1723 *flops += rstr_flops; 1724 CeedCall(CeedOperatorFieldGetBasis(op_output_fields[i], &basis)); 1725 CeedCall(CeedQFunctionFieldGetEvalMode(qf_output_fields[i], &eval_mode)); 1726 CeedCall(CeedBasisGetFlopsEstimate(basis, CEED_TRANSPOSE, eval_mode, &basis_flops)); |
| 1729 CeedCall(CeedBasisDestroy(&basis)); | |
| 1730 *flops += basis_flops * num_elem; 1731 } | 1727 *flops += basis_flops * num_elem; 1728 } |
| 1732 CeedCall(CeedVectorDestroy(&vec)); | |
| 1733 } 1734 } 1735 return CEED_ERROR_SUCCESS; 1736} 1737 1738/** 1739 @brief Get `CeedQFunction` global context for a `CeedOperator`. 1740 --- 328 unchanged lines hidden (view full) --- 2069 CeedCall(CeedOperatorGetFields(sub_operators[i], NULL, NULL, &num_output_fields, &output_fields)); 2070 for (CeedInt j = 0; j < num_output_fields; j++) { 2071 CeedVector vec; 2072 2073 CeedCall(CeedOperatorFieldGetVector(output_fields[j], &vec)); 2074 if (vec != CEED_VECTOR_ACTIVE && vec != CEED_VECTOR_NONE) { 2075 CeedCall(CeedVectorSetValue(vec, 0.0)); 2076 } | 1729 } 1730 } 1731 return CEED_ERROR_SUCCESS; 1732} 1733 1734/** 1735 @brief Get `CeedQFunction` global context for a `CeedOperator`. 1736 --- 328 unchanged lines hidden (view full) --- 2065 CeedCall(CeedOperatorGetFields(sub_operators[i], NULL, NULL, &num_output_fields, &output_fields)); 2066 for (CeedInt j = 0; j < num_output_fields; j++) { 2067 CeedVector vec; 2068 2069 CeedCall(CeedOperatorFieldGetVector(output_fields[j], &vec)); 2070 if (vec != CEED_VECTOR_ACTIVE && vec != CEED_VECTOR_NONE) { 2071 CeedCall(CeedVectorSetValue(vec, 0.0)); 2072 } |
| 2077 CeedCall(CeedVectorDestroy(&vec)); | |
| 2078 } 2079 } 2080 // Apply 2081 for (CeedInt i = 0; i < num_suboperators; i++) { 2082 CeedCall(CeedOperatorApplyAdd(sub_operators[i], in, out, request)); 2083 } 2084 } 2085 } else { 2086 // Standard Operator 2087 if (op->Apply) { 2088 CeedCall(op->Apply(op, in, out, request)); 2089 } else { 2090 CeedInt num_output_fields; 2091 CeedOperatorField *output_fields; 2092 2093 CeedCall(CeedOperatorGetFields(op, NULL, NULL, &num_output_fields, &output_fields)); 2094 // Zero all output vectors 2095 for (CeedInt i = 0; i < num_output_fields; i++) { | 2073 } 2074 } 2075 // Apply 2076 for (CeedInt i = 0; i < num_suboperators; i++) { 2077 CeedCall(CeedOperatorApplyAdd(sub_operators[i], in, out, request)); 2078 } 2079 } 2080 } else { 2081 // Standard Operator 2082 if (op->Apply) { 2083 CeedCall(op->Apply(op, in, out, request)); 2084 } else { 2085 CeedInt num_output_fields; 2086 CeedOperatorField *output_fields; 2087 2088 CeedCall(CeedOperatorGetFields(op, NULL, NULL, &num_output_fields, &output_fields)); 2089 // Zero all output vectors 2090 for (CeedInt i = 0; i < num_output_fields; i++) { |
| 2096 bool is_active; | |
| 2097 CeedVector vec; 2098 2099 CeedCall(CeedOperatorFieldGetVector(output_fields[i], &vec)); | 2091 CeedVector vec; 2092 2093 CeedCall(CeedOperatorFieldGetVector(output_fields[i], &vec)); |
| 2100 is_active = vec == CEED_VECTOR_ACTIVE; 2101 if (is_active) vec = out; | 2094 if (vec == CEED_VECTOR_ACTIVE) vec = out; |
| 2102 if (vec != CEED_VECTOR_NONE) CeedCall(CeedVectorSetValue(vec, 0.0)); | 2095 if (vec != CEED_VECTOR_NONE) CeedCall(CeedVectorSetValue(vec, 0.0)); |
| 2103 if (!is_active) CeedCall(CeedVectorDestroy(&vec)); | |
| 2104 } 2105 // Apply 2106 if (op->num_elem > 0) CeedCall(op->ApplyAdd(op, in, out, request)); 2107 } 2108 } 2109 return CEED_ERROR_SUCCESS; 2110} 2111 --- 155 unchanged lines hidden --- | 2096 } 2097 // Apply 2098 if (op->num_elem > 0) CeedCall(op->ApplyAdd(op, in, out, request)); 2099 } 2100 } 2101 return CEED_ERROR_SUCCESS; 2102} 2103 --- 155 unchanged lines hidden --- |