ceed-operator.c (28567f8f11ac5e58fa39329798911e806cc70c57) ceed-operator.c (f04ea552c0bc984e9734ef5cac4fa0e4550ba0f1)
1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3// reserved. See files LICENSE and NOTICE for details.
4//
5// This file is part of CEED, a collection of benchmarks, miniapps, software
6// libraries and APIs for efficient high-order finite element and spectral
7// element discretizations for exascale applications. For more information and
8// source code availability see http://github.com/ceed.

--- 132 unchanged lines hidden (view full) ---

141
142 @ref Developer
143**/
144int CeedOperatorCheckReady(CeedOperator op) {
145 int ierr;
146 Ceed ceed;
147 ierr = CeedOperatorGetCeed(op, &ceed); CeedChk(ierr);
148
1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3// reserved. See files LICENSE and NOTICE for details.
4//
5// This file is part of CEED, a collection of benchmarks, miniapps, software
6// libraries and APIs for efficient high-order finite element and spectral
7// element discretizations for exascale applications. For more information and
8// source code availability see http://github.com/ceed.

--- 132 unchanged lines hidden (view full) ---

141
142 @ref Developer
143**/
144int CeedOperatorCheckReady(CeedOperator op) {
145 int ierr;
146 Ceed ceed;
147 ierr = CeedOperatorGetCeed(op, &ceed); CeedChk(ierr);
148
149 if (op->interface_setup)
149 if (op->is_interface_setup)
150 return CEED_ERROR_SUCCESS;
151
152 CeedQFunction qf = op->qf;
150 return CEED_ERROR_SUCCESS;
151
152 CeedQFunction qf = op->qf;
153 if (op->composite) {
153 if (op->is_composite) {
154 if (!op->num_suboperators)
155 // LCOV_EXCL_START
156 return CeedError(ceed, CEED_ERROR_INCOMPLETE, "No sub_operators set");
157 // LCOV_EXCL_STOP
158 } else {
159 if (op->num_fields == 0)
160 // LCOV_EXCL_START
161 return CeedError(ceed, CEED_ERROR_INCOMPLETE, "No operator fields set");

--- 11 unchanged lines hidden (view full) ---

173 // LCOV_EXCL_START
174 return CeedError(ceed, CEED_ERROR_INCOMPLETE,
175 "At least one non-collocated basis is required "
176 "or the number of quadrature points must be set");
177 // LCOV_EXCL_STOP
178 }
179
180 // Flag as immutable and ready
154 if (!op->num_suboperators)
155 // LCOV_EXCL_START
156 return CeedError(ceed, CEED_ERROR_INCOMPLETE, "No sub_operators set");
157 // LCOV_EXCL_STOP
158 } else {
159 if (op->num_fields == 0)
160 // LCOV_EXCL_START
161 return CeedError(ceed, CEED_ERROR_INCOMPLETE, "No operator fields set");

--- 11 unchanged lines hidden (view full) ---

173 // LCOV_EXCL_START
174 return CeedError(ceed, CEED_ERROR_INCOMPLETE,
175 "At least one non-collocated basis is required "
176 "or the number of quadrature points must be set");
177 // LCOV_EXCL_STOP
178 }
179
180 // Flag as immutable and ready
181 op->interface_setup = true;
181 op->is_interface_setup = true;
182 if (op->qf && op->qf != CEED_QFUNCTION_NONE)
183 // LCOV_EXCL_START
182 if (op->qf && op->qf != CEED_QFUNCTION_NONE)
183 // LCOV_EXCL_START
184 op->qf->operators_set++;
184 op->qf->is_immutable = true;
185 // LCOV_EXCL_STOP
186 if (op->dqf && op->dqf != CEED_QFUNCTION_NONE)
187 // LCOV_EXCL_START
185 // LCOV_EXCL_STOP
186 if (op->dqf && op->dqf != CEED_QFUNCTION_NONE)
187 // LCOV_EXCL_START
188 op->dqf->operators_set++;
188 op->dqf->is_immutable = true;
189 // LCOV_EXCL_STOP
190 if (op->dqfT && op->dqfT != CEED_QFUNCTION_NONE)
191 // LCOV_EXCL_START
189 // LCOV_EXCL_STOP
190 if (op->dqfT && op->dqfT != CEED_QFUNCTION_NONE)
191 // LCOV_EXCL_START
192 op->dqfT->operators_set++;
192 op->dqfT->is_immutable = true;
193 // LCOV_EXCL_STOP
194 return CEED_ERROR_SUCCESS;
195}
196
197/**
198 @brief View a field of a CeedOperator
199
200 @param[in] field Operator field to view

--- 157 unchanged lines hidden (view full) ---

358 @param[out] num_elem Variable to store number of elements
359
360 @return An error code: 0 - success, otherwise - failure
361
362 @ref Backend
363**/
364
365int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem) {
193 // LCOV_EXCL_STOP
194 return CEED_ERROR_SUCCESS;
195}
196
197/**
198 @brief View a field of a CeedOperator
199
200 @param[in] field Operator field to view

--- 157 unchanged lines hidden (view full) ---

358 @param[out] num_elem Variable to store number of elements
359
360 @return An error code: 0 - success, otherwise - failure
361
362 @ref Backend
363**/
364
365int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem) {
366 if (op->composite)
366 if (op->is_composite)
367 // LCOV_EXCL_START
368 return CeedError(op->ceed, CEED_ERROR_MINOR,
369 "Not defined for composite operator");
370 // LCOV_EXCL_STOP
371
372 *num_elem = op->num_elem;
373 return CEED_ERROR_SUCCESS;
374}

--- 5 unchanged lines hidden (view full) ---

380 @param[out] num_qpts Variable to store vector number of quadrature points
381
382 @return An error code: 0 - success, otherwise - failure
383
384 @ref Backend
385**/
386
387int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts) {
367 // LCOV_EXCL_START
368 return CeedError(op->ceed, CEED_ERROR_MINOR,
369 "Not defined for composite operator");
370 // LCOV_EXCL_STOP
371
372 *num_elem = op->num_elem;
373 return CEED_ERROR_SUCCESS;
374}

--- 5 unchanged lines hidden (view full) ---

380 @param[out] num_qpts Variable to store vector number of quadrature points
381
382 @return An error code: 0 - success, otherwise - failure
383
384 @ref Backend
385**/
386
387int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts) {
388 if (op->composite)
388 if (op->is_composite)
389 // LCOV_EXCL_START
390 return CeedError(op->ceed, CEED_ERROR_MINOR,
391 "Not defined for composite operator");
392 // LCOV_EXCL_STOP
393
394 *num_qpts = op->num_qpts;
395 return CEED_ERROR_SUCCESS;
396}

--- 5 unchanged lines hidden (view full) ---

402 @param[out] num_args Variable to store vector number of arguments
403
404 @return An error code: 0 - success, otherwise - failure
405
406 @ref Backend
407**/
408
409int CeedOperatorGetNumArgs(CeedOperator op, CeedInt *num_args) {
389 // LCOV_EXCL_START
390 return CeedError(op->ceed, CEED_ERROR_MINOR,
391 "Not defined for composite operator");
392 // LCOV_EXCL_STOP
393
394 *num_qpts = op->num_qpts;
395 return CEED_ERROR_SUCCESS;
396}

--- 5 unchanged lines hidden (view full) ---

402 @param[out] num_args Variable to store vector number of arguments
403
404 @return An error code: 0 - success, otherwise - failure
405
406 @ref Backend
407**/
408
409int CeedOperatorGetNumArgs(CeedOperator op, CeedInt *num_args) {
410 if (op->composite)
410 if (op->is_composite)
411 // LCOV_EXCL_START
412 return CeedError(op->ceed, CEED_ERROR_MINOR,
413 "Not defined for composite operators");
414 // LCOV_EXCL_STOP
415
416 *num_args = op->num_fields;
417 return CEED_ERROR_SUCCESS;
418}

--- 5 unchanged lines hidden (view full) ---

424 @param[out] is_setup_done Variable to store setup status
425
426 @return An error code: 0 - success, otherwise - failure
427
428 @ref Backend
429**/
430
431int CeedOperatorIsSetupDone(CeedOperator op, bool *is_setup_done) {
411 // LCOV_EXCL_START
412 return CeedError(op->ceed, CEED_ERROR_MINOR,
413 "Not defined for composite operators");
414 // LCOV_EXCL_STOP
415
416 *num_args = op->num_fields;
417 return CEED_ERROR_SUCCESS;
418}

--- 5 unchanged lines hidden (view full) ---

424 @param[out] is_setup_done Variable to store setup status
425
426 @return An error code: 0 - success, otherwise - failure
427
428 @ref Backend
429**/
430
431int CeedOperatorIsSetupDone(CeedOperator op, bool *is_setup_done) {
432 *is_setup_done = op->backend_setup;
432 *is_setup_done = op->is_backend_setup;
433 return CEED_ERROR_SUCCESS;
434}
435
436/**
437 @brief Get the QFunction associated with a CeedOperator
438
439 @param op CeedOperator
440 @param[out] qf Variable to store QFunction
441
442 @return An error code: 0 - success, otherwise - failure
443
444 @ref Backend
445**/
446
447int CeedOperatorGetQFunction(CeedOperator op, CeedQFunction *qf) {
433 return CEED_ERROR_SUCCESS;
434}
435
436/**
437 @brief Get the QFunction associated with a CeedOperator
438
439 @param op CeedOperator
440 @param[out] qf Variable to store QFunction
441
442 @return An error code: 0 - success, otherwise - failure
443
444 @ref Backend
445**/
446
447int CeedOperatorGetQFunction(CeedOperator op, CeedQFunction *qf) {
448 if (op->composite)
448 if (op->is_composite)
449 // LCOV_EXCL_START
450 return CeedError(op->ceed, CEED_ERROR_MINOR,
451 "Not defined for composite operator");
452 // LCOV_EXCL_STOP
453
454 *qf = op->qf;
455 return CEED_ERROR_SUCCESS;
456}

--- 5 unchanged lines hidden (view full) ---

462 @param[out] is_composite Variable to store composite status
463
464 @return An error code: 0 - success, otherwise - failure
465
466 @ref Backend
467**/
468
469int CeedOperatorIsComposite(CeedOperator op, bool *is_composite) {
449 // LCOV_EXCL_START
450 return CeedError(op->ceed, CEED_ERROR_MINOR,
451 "Not defined for composite operator");
452 // LCOV_EXCL_STOP
453
454 *qf = op->qf;
455 return CEED_ERROR_SUCCESS;
456}

--- 5 unchanged lines hidden (view full) ---

462 @param[out] is_composite Variable to store composite status
463
464 @return An error code: 0 - success, otherwise - failure
465
466 @ref Backend
467**/
468
469int CeedOperatorIsComposite(CeedOperator op, bool *is_composite) {
470 *is_composite = op->composite;
470 *is_composite = op->is_composite;
471 return CEED_ERROR_SUCCESS;
472}
473
474/**
475 @brief Get the number of sub_operators associated with a CeedOperator
476
477 @param op CeedOperator
478 @param[out] num_suboperators Variable to store number of sub_operators
479
480 @return An error code: 0 - success, otherwise - failure
481
482 @ref Backend
483**/
484
485int CeedOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators) {
471 return CEED_ERROR_SUCCESS;
472}
473
474/**
475 @brief Get the number of sub_operators associated with a CeedOperator
476
477 @param op CeedOperator
478 @param[out] num_suboperators Variable to store number of sub_operators
479
480 @return An error code: 0 - success, otherwise - failure
481
482 @ref Backend
483**/
484
485int CeedOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators) {
486 if (!op->composite)
486 if (!op->is_composite)
487 // LCOV_EXCL_START
488 return CeedError(op->ceed, CEED_ERROR_MINOR, "Not a composite operator");
489 // LCOV_EXCL_STOP
490
491 *num_suboperators = op->num_suboperators;
492 return CEED_ERROR_SUCCESS;
493}
494

--- 4 unchanged lines hidden (view full) ---

499 @param[out] sub_operators Variable to store list of sub_operators
500
501 @return An error code: 0 - success, otherwise - failure
502
503 @ref Backend
504**/
505
506int CeedOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators) {
487 // LCOV_EXCL_START
488 return CeedError(op->ceed, CEED_ERROR_MINOR, "Not a composite operator");
489 // LCOV_EXCL_STOP
490
491 *num_suboperators = op->num_suboperators;
492 return CEED_ERROR_SUCCESS;
493}
494

--- 4 unchanged lines hidden (view full) ---

499 @param[out] sub_operators Variable to store list of sub_operators
500
501 @return An error code: 0 - success, otherwise - failure
502
503 @ref Backend
504**/
505
506int CeedOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators) {
507 if (!op->composite)
507 if (!op->is_composite)
508 // LCOV_EXCL_START
509 return CeedError(op->ceed, CEED_ERROR_MINOR, "Not a composite operator");
510 // LCOV_EXCL_STOP
511
512 *sub_operators = op->sub_operators;
513 return CEED_ERROR_SUCCESS;
514}
515

--- 49 unchanged lines hidden (view full) ---

565 @param op CeedOperator
566
567 @return An error code: 0 - success, otherwise - failure
568
569 @ref Backend
570**/
571
572int CeedOperatorSetSetupDone(CeedOperator op) {
508 // LCOV_EXCL_START
509 return CeedError(op->ceed, CEED_ERROR_MINOR, "Not a composite operator");
510 // LCOV_EXCL_STOP
511
512 *sub_operators = op->sub_operators;
513 return CEED_ERROR_SUCCESS;
514}
515

--- 49 unchanged lines hidden (view full) ---

565 @param op CeedOperator
566
567 @return An error code: 0 - success, otherwise - failure
568
569 @ref Backend
570**/
571
572int CeedOperatorSetSetupDone(CeedOperator op) {
573 op->backend_setup = true;
573 op->is_backend_setup = true;
574 return CEED_ERROR_SUCCESS;
575}
576
577/// @}
578
579/// ----------------------------------------------------------------------------
580/// CeedOperator Public API
581/// ----------------------------------------------------------------------------

--- 83 unchanged lines hidden (view full) ---

665 ierr = CeedCompositeOperatorCreate(delegate, op); CeedChk(ierr);
666 return CEED_ERROR_SUCCESS;
667 }
668 }
669
670 ierr = CeedCalloc(1, op); CeedChk(ierr);
671 (*op)->ceed = ceed;
672 ierr = CeedReference(ceed); CeedChk(ierr);
574 return CEED_ERROR_SUCCESS;
575}
576
577/// @}
578
579/// ----------------------------------------------------------------------------
580/// CeedOperator Public API
581/// ----------------------------------------------------------------------------

--- 83 unchanged lines hidden (view full) ---

665 ierr = CeedCompositeOperatorCreate(delegate, op); CeedChk(ierr);
666 return CEED_ERROR_SUCCESS;
667 }
668 }
669
670 ierr = CeedCalloc(1, op); CeedChk(ierr);
671 (*op)->ceed = ceed;
672 ierr = CeedReference(ceed); CeedChk(ierr);
673 (*op)->composite = true;
673 (*op)->is_composite = true;
674 ierr = CeedCalloc(16, &(*op)->sub_operators); CeedChk(ierr);
675
676 if (ceed->CompositeOperatorCreate) {
677 ierr = ceed->CompositeOperatorCreate(*op); CeedChk(ierr);
678 }
679 return CEED_ERROR_SUCCESS;
680}
681

--- 44 unchanged lines hidden (view full) ---

726
727 @return An error code: 0 - success, otherwise - failure
728
729 @ref User
730**/
731int CeedOperatorSetField(CeedOperator op, const char *field_name,
732 CeedElemRestriction r, CeedBasis b, CeedVector v) {
733 int ierr;
674 ierr = CeedCalloc(16, &(*op)->sub_operators); CeedChk(ierr);
675
676 if (ceed->CompositeOperatorCreate) {
677 ierr = ceed->CompositeOperatorCreate(*op); CeedChk(ierr);
678 }
679 return CEED_ERROR_SUCCESS;
680}
681

--- 44 unchanged lines hidden (view full) ---

726
727 @return An error code: 0 - success, otherwise - failure
728
729 @ref User
730**/
731int CeedOperatorSetField(CeedOperator op, const char *field_name,
732 CeedElemRestriction r, CeedBasis b, CeedVector v) {
733 int ierr;
734 if (op->composite)
734 if (op->is_composite)
735 // LCOV_EXCL_START
736 return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE,
737 "Cannot add field to composite operator.");
738 // LCOV_EXCL_STOP
735 // LCOV_EXCL_START
736 return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE,
737 "Cannot add field to composite operator.");
738 // LCOV_EXCL_STOP
739 if (op->is_immutable)
740 // LCOV_EXCL_START
741 return CeedError(op->ceed, CEED_ERROR_MAJOR,
742 "Operator cannot be changed after set as immutable");
743 // LCOV_EXCL_STOP
739 if (!r)
740 // LCOV_EXCL_START
741 return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE,
742 "ElemRestriction r for field \"%s\" must be non-NULL.",
743 field_name);
744 // LCOV_EXCL_STOP
745 if (!b)
746 // LCOV_EXCL_START

--- 81 unchanged lines hidden (view full) ---

828 memcpy(tmp, field_name, len+1);
829 (*op_field)->field_name = tmp;
830 return CEED_ERROR_SUCCESS;
831}
832
833/**
834 @brief Get the CeedOperatorFields of a CeedOperator
835
744 if (!r)
745 // LCOV_EXCL_START
746 return CeedError(op->ceed, CEED_ERROR_INCOMPATIBLE,
747 "ElemRestriction r for field \"%s\" must be non-NULL.",
748 field_name);
749 // LCOV_EXCL_STOP
750 if (!b)
751 // LCOV_EXCL_START

--- 81 unchanged lines hidden (view full) ---

833 memcpy(tmp, field_name, len+1);
834 (*op_field)->field_name = tmp;
835 return CEED_ERROR_SUCCESS;
836}
837
838/**
839 @brief Get the CeedOperatorFields of a CeedOperator
840
841 Note: Calling this function asserts that setup is complete
842 and sets the CeedOperator as immutable.
843
836 @param op CeedOperator
837 @param[out] input_fields Variable to store input_fields
838 @param[out] output_fields Variable to store output_fields
839
840 @return An error code: 0 - success, otherwise - failure
841
842 @ref Backend
843**/
844int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields,
845 CeedOperatorField **input_fields,
846 CeedInt *num_output_fields,
847 CeedOperatorField **output_fields) {
844 @param op CeedOperator
845 @param[out] input_fields Variable to store input_fields
846 @param[out] output_fields Variable to store output_fields
847
848 @return An error code: 0 - success, otherwise - failure
849
850 @ref Backend
851**/
852int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields,
853 CeedOperatorField **input_fields,
854 CeedInt *num_output_fields,
855 CeedOperatorField **output_fields) {
848 if (op->composite)
856 int ierr;
857
858 if (op->is_composite)
849 // LCOV_EXCL_START
850 return CeedError(op->ceed, CEED_ERROR_MINOR,
851 "Not defined for composite operator");
852 // LCOV_EXCL_STOP
859 // LCOV_EXCL_START
860 return CeedError(op->ceed, CEED_ERROR_MINOR,
861 "Not defined for composite operator");
862 // LCOV_EXCL_STOP
863 ierr = CeedOperatorCheckReady(op); CeedChk(ierr);
853
854 if (num_input_fields) *num_input_fields = op->qf->num_input_fields;
855 if (input_fields) *input_fields = op->input_fields;
856 if (num_output_fields) *num_output_fields = op->qf->num_output_fields;
857 if (output_fields) *output_fields = op->output_fields;
858 return CEED_ERROR_SUCCESS;
859}
860

--- 67 unchanged lines hidden (view full) ---

928 @return An error code: 0 - success, otherwise - failure
929
930 @ref User
931 */
932int CeedCompositeOperatorAddSub(CeedOperator composite_op,
933 CeedOperator sub_op) {
934 int ierr;
935
864
865 if (num_input_fields) *num_input_fields = op->qf->num_input_fields;
866 if (input_fields) *input_fields = op->input_fields;
867 if (num_output_fields) *num_output_fields = op->qf->num_output_fields;
868 if (output_fields) *output_fields = op->output_fields;
869 return CEED_ERROR_SUCCESS;
870}
871

--- 67 unchanged lines hidden (view full) ---

939 @return An error code: 0 - success, otherwise - failure
940
941 @ref User
942 */
943int CeedCompositeOperatorAddSub(CeedOperator composite_op,
944 CeedOperator sub_op) {
945 int ierr;
946
936 if (!composite_op->composite)
947 if (!composite_op->is_composite)
937 // LCOV_EXCL_START
938 return CeedError(composite_op->ceed, CEED_ERROR_MINOR,
939 "CeedOperator is not a composite operator");
940 // LCOV_EXCL_STOP
941
942 if (composite_op->num_suboperators == CEED_COMPOSITE_MAX)
943 // LCOV_EXCL_START
944 return CeedError(composite_op->ceed, CEED_ERROR_UNSUPPORTED,
945 "Cannot add additional sub_operators");
946 // LCOV_EXCL_STOP
948 // LCOV_EXCL_START
949 return CeedError(composite_op->ceed, CEED_ERROR_MINOR,
950 "CeedOperator is not a composite operator");
951 // LCOV_EXCL_STOP
952
953 if (composite_op->num_suboperators == CEED_COMPOSITE_MAX)
954 // LCOV_EXCL_START
955 return CeedError(composite_op->ceed, CEED_ERROR_UNSUPPORTED,
956 "Cannot add additional sub_operators");
957 // LCOV_EXCL_STOP
958 if (composite_op->is_immutable)
959 // LCOV_EXCL_START
960 return CeedError(composite_op->ceed, CEED_ERROR_MAJOR,
961 "Operator cannot be changed after set as immutable");
962 // LCOV_EXCL_STOP
947
948 composite_op->sub_operators[composite_op->num_suboperators] = sub_op;
949 ierr = CeedOperatorReference(sub_op); CeedChk(ierr);
950 composite_op->num_suboperators++;
951 return CEED_ERROR_SUCCESS;
952}
953
954/**

--- 6 unchanged lines hidden (view full) ---

961 @param num_qpts Number of quadrature points to set
962
963 @return An error code: 0 - success, otherwise - failure
964
965 @ref Backend
966**/
967
968int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts) {
963
964 composite_op->sub_operators[composite_op->num_suboperators] = sub_op;
965 ierr = CeedOperatorReference(sub_op); CeedChk(ierr);
966 composite_op->num_suboperators++;
967 return CEED_ERROR_SUCCESS;
968}
969
970/**

--- 6 unchanged lines hidden (view full) ---

977 @param num_qpts Number of quadrature points to set
978
979 @return An error code: 0 - success, otherwise - failure
980
981 @ref Backend
982**/
983
984int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts) {
969 if (op->composite)
985 if (op->is_composite)
970 // LCOV_EXCL_START
971 return CeedError(op->ceed, CEED_ERROR_MINOR,
972 "Not defined for composite operator");
973 // LCOV_EXCL_STOP
974 if (op->num_qpts)
975 // LCOV_EXCL_START
976 return CeedError(op->ceed, CEED_ERROR_MINOR,
977 "Number of quadrature points already defined");
978 // LCOV_EXCL_STOP
986 // LCOV_EXCL_START
987 return CeedError(op->ceed, CEED_ERROR_MINOR,
988 "Not defined for composite operator");
989 // LCOV_EXCL_STOP
990 if (op->num_qpts)
991 // LCOV_EXCL_START
992 return CeedError(op->ceed, CEED_ERROR_MINOR,
993 "Number of quadrature points already defined");
994 // LCOV_EXCL_STOP
995 if (op->is_immutable)
996 // LCOV_EXCL_START
997 return CeedError(op->ceed, CEED_ERROR_MAJOR,
998 "Operator cannot be changed after set as immutable");
999 // LCOV_EXCL_STOP
979
980 op->num_qpts = num_qpts;
981 return CEED_ERROR_SUCCESS;
982}
983
984/**
985 @brief View a CeedOperator
986
987 @param[in] op CeedOperator to view
988 @param[in] stream Stream to write; typically stdout/stderr or a file
989
990 @return Error code: 0 - success, otherwise - failure
991
992 @ref User
993**/
994int CeedOperatorView(CeedOperator op, FILE *stream) {
995 int ierr;
996
1000
1001 op->num_qpts = num_qpts;
1002 return CEED_ERROR_SUCCESS;
1003}
1004
1005/**
1006 @brief View a CeedOperator
1007
1008 @param[in] op CeedOperator to view
1009 @param[in] stream Stream to write; typically stdout/stderr or a file
1010
1011 @return Error code: 0 - success, otherwise - failure
1012
1013 @ref User
1014**/
1015int CeedOperatorView(CeedOperator op, FILE *stream) {
1016 int ierr;
1017
997 if (op->composite) {
1018 if (op->is_composite) {
998 fprintf(stream, "Composite CeedOperator\n");
999
1000 for (CeedInt i=0; i<op->num_suboperators; i++) {
1001 fprintf(stream, " SubOperator [%d]:\n", i);
1002 ierr = CeedOperatorSingleView(op->sub_operators[i], 1, stream);
1003 CeedChk(ierr);
1004 }
1005 } else {

--- 5 unchanged lines hidden (view full) ---

1011
1012/**
1013 @brief Apply CeedOperator to a vector
1014
1015 This computes the action of the operator on the specified (active) input,
1016 yielding its (active) output. All inputs and outputs must be specified using
1017 CeedOperatorSetField().
1018
1019 fprintf(stream, "Composite CeedOperator\n");
1020
1021 for (CeedInt i=0; i<op->num_suboperators; i++) {
1022 fprintf(stream, " SubOperator [%d]:\n", i);
1023 ierr = CeedOperatorSingleView(op->sub_operators[i], 1, stream);
1024 CeedChk(ierr);
1025 }
1026 } else {

--- 5 unchanged lines hidden (view full) ---

1032
1033/**
1034 @brief Apply CeedOperator to a vector
1035
1036 This computes the action of the operator on the specified (active) input,
1037 yielding its (active) output. All inputs and outputs must be specified using
1038 CeedOperatorSetField().
1039
1040 Note: Calling this function asserts that setup is complete
1041 and sets the CeedOperator as immutable.
1042
1019 @param op CeedOperator to apply
1020 @param[in] in CeedVector containing input state or @ref CEED_VECTOR_NONE if
1021 there are no active inputs
1022 @param[out] out CeedVector to store result of applying operator (must be
1023 distinct from @a in) or @ref CEED_VECTOR_NONE if there are no
1024 active outputs
1025 @param request Address of CeedRequest for non-blocking completion, else
1026 @ref CEED_REQUEST_IMMEDIATE

--- 20 unchanged lines hidden (view full) ---

1047 vec = out;
1048 if (vec != CEED_VECTOR_NONE) {
1049 ierr = CeedVectorSetValue(vec, 0.0); CeedChk(ierr);
1050 }
1051 }
1052 // Apply
1053 ierr = op->ApplyAdd(op, in, out, request); CeedChk(ierr);
1054 }
1043 @param op CeedOperator to apply
1044 @param[in] in CeedVector containing input state or @ref CEED_VECTOR_NONE if
1045 there are no active inputs
1046 @param[out] out CeedVector to store result of applying operator (must be
1047 distinct from @a in) or @ref CEED_VECTOR_NONE if there are no
1048 active outputs
1049 @param request Address of CeedRequest for non-blocking completion, else
1050 @ref CEED_REQUEST_IMMEDIATE

--- 20 unchanged lines hidden (view full) ---

1071 vec = out;
1072 if (vec != CEED_VECTOR_NONE) {
1073 ierr = CeedVectorSetValue(vec, 0.0); CeedChk(ierr);
1074 }
1075 }
1076 // Apply
1077 ierr = op->ApplyAdd(op, in, out, request); CeedChk(ierr);
1078 }
1055 } else if (op->composite) {
1079 } else if (op->is_composite) {
1056 // Composite Operator
1057 if (op->ApplyComposite) {
1058 ierr = op->ApplyComposite(op, in, out, request); CeedChk(ierr);
1059 } else {
1060 CeedInt num_suboperators;
1061 ierr = CeedOperatorGetNumSub(op, &num_suboperators); CeedChk(ierr);
1062 CeedOperator *sub_operators;
1063 ierr = CeedOperatorGetSubList(op, &sub_operators); CeedChk(ierr);

--- 42 unchanged lines hidden (view full) ---

1106int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out,
1107 CeedRequest *request) {
1108 int ierr;
1109 ierr = CeedOperatorCheckReady(op); CeedChk(ierr);
1110
1111 if (op->num_elem) {
1112 // Standard Operator
1113 ierr = op->ApplyAdd(op, in, out, request); CeedChk(ierr);
1080 // Composite Operator
1081 if (op->ApplyComposite) {
1082 ierr = op->ApplyComposite(op, in, out, request); CeedChk(ierr);
1083 } else {
1084 CeedInt num_suboperators;
1085 ierr = CeedOperatorGetNumSub(op, &num_suboperators); CeedChk(ierr);
1086 CeedOperator *sub_operators;
1087 ierr = CeedOperatorGetSubList(op, &sub_operators); CeedChk(ierr);

--- 42 unchanged lines hidden (view full) ---

1130int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out,
1131 CeedRequest *request) {
1132 int ierr;
1133 ierr = CeedOperatorCheckReady(op); CeedChk(ierr);
1134
1135 if (op->num_elem) {
1136 // Standard Operator
1137 ierr = op->ApplyAdd(op, in, out, request); CeedChk(ierr);
1114 } else if (op->composite) {
1138 } else if (op->is_composite) {
1115 // Composite Operator
1116 if (op->ApplyAddComposite) {
1117 ierr = op->ApplyAddComposite(op, in, out, request); CeedChk(ierr);
1118 } else {
1119 CeedInt num_suboperators;
1120 ierr = CeedOperatorGetNumSub(op, &num_suboperators); CeedChk(ierr);
1121 CeedOperator *sub_operators;
1122 ierr = CeedOperatorGetSubList(op, &sub_operators); CeedChk(ierr);

--- 55 unchanged lines hidden (view full) ---

1178 ierr = CeedFree(&(*op)->output_fields[i]->field_name); CeedChk(ierr);
1179 ierr = CeedFree(&(*op)->output_fields[i]); CeedChk(ierr);
1180 }
1181 // Destroy sub_operators
1182 for (int i=0; i<(*op)->num_suboperators; i++)
1183 if ((*op)->sub_operators[i]) {
1184 ierr = CeedOperatorDestroy(&(*op)->sub_operators[i]); CeedChk(ierr);
1185 }
1139 // Composite Operator
1140 if (op->ApplyAddComposite) {
1141 ierr = op->ApplyAddComposite(op, in, out, request); CeedChk(ierr);
1142 } else {
1143 CeedInt num_suboperators;
1144 ierr = CeedOperatorGetNumSub(op, &num_suboperators); CeedChk(ierr);
1145 CeedOperator *sub_operators;
1146 ierr = CeedOperatorGetSubList(op, &sub_operators); CeedChk(ierr);

--- 55 unchanged lines hidden (view full) ---

1202 ierr = CeedFree(&(*op)->output_fields[i]->field_name); CeedChk(ierr);
1203 ierr = CeedFree(&(*op)->output_fields[i]); CeedChk(ierr);
1204 }
1205 // Destroy sub_operators
1206 for (int i=0; i<(*op)->num_suboperators; i++)
1207 if ((*op)->sub_operators[i]) {
1208 ierr = CeedOperatorDestroy(&(*op)->sub_operators[i]); CeedChk(ierr);
1209 }
1186 if ((*op)->qf)
1187 // LCOV_EXCL_START
1188 (*op)->qf->operators_set--;
1189 // LCOV_EXCL_STOP
1190 ierr = CeedQFunctionDestroy(&(*op)->qf); CeedChk(ierr);
1210 ierr = CeedQFunctionDestroy(&(*op)->qf); CeedChk(ierr);
1191 if ((*op)->dqf && (*op)->dqf != CEED_QFUNCTION_NONE)
1192 // LCOV_EXCL_START
1193 (*op)->dqf->operators_set--;
1194 // LCOV_EXCL_STOP
1195 ierr = CeedQFunctionDestroy(&(*op)->dqf); CeedChk(ierr);
1211 ierr = CeedQFunctionDestroy(&(*op)->dqf); CeedChk(ierr);
1196 if ((*op)->dqfT && (*op)->dqfT != CEED_QFUNCTION_NONE)
1197 // LCOV_EXCL_START
1198 (*op)->dqfT->operators_set--;
1199 // LCOV_EXCL_STOP
1200 ierr = CeedQFunctionDestroy(&(*op)->dqfT); CeedChk(ierr);
1201
1202 // Destroy fallback
1203 if ((*op)->op_fallback) {
1204 ierr = (*op)->qf_fallback->Destroy((*op)->qf_fallback); CeedChk(ierr);
1205 ierr = CeedFree(&(*op)->qf_fallback); CeedChk(ierr);
1206 ierr = (*op)->op_fallback->Destroy((*op)->op_fallback); CeedChk(ierr);
1207 ierr = CeedFree(&(*op)->op_fallback); CeedChk(ierr);
1208 }
1209
1210 ierr = CeedFree(&(*op)->input_fields); CeedChk(ierr);
1211 ierr = CeedFree(&(*op)->output_fields); CeedChk(ierr);
1212 ierr = CeedFree(&(*op)->sub_operators); CeedChk(ierr);
1213 ierr = CeedFree(op); CeedChk(ierr);
1214 return CEED_ERROR_SUCCESS;
1215}
1216
1217/// @}
1212 ierr = CeedQFunctionDestroy(&(*op)->dqfT); CeedChk(ierr);
1213
1214 // Destroy fallback
1215 if ((*op)->op_fallback) {
1216 ierr = (*op)->qf_fallback->Destroy((*op)->qf_fallback); CeedChk(ierr);
1217 ierr = CeedFree(&(*op)->qf_fallback); CeedChk(ierr);
1218 ierr = (*op)->op_fallback->Destroy((*op)->op_fallback); CeedChk(ierr);
1219 ierr = CeedFree(&(*op)->op_fallback); CeedChk(ierr);
1220 }
1221
1222 ierr = CeedFree(&(*op)->input_fields); CeedChk(ierr);
1223 ierr = CeedFree(&(*op)->output_fields); CeedChk(ierr);
1224 ierr = CeedFree(&(*op)->sub_operators); CeedChk(ierr);
1225 ierr = CeedFree(op); CeedChk(ierr);
1226 return CEED_ERROR_SUCCESS;
1227}
1228
1229/// @}