| ceed-preconditioning.c (915834c9f1e582e3fdfc87db6b4fa4e010d293bb) | ceed-preconditioning.c (a34b87f3093c7ebf2340d51111ccb8fb4cdeaebd) |
|---|---|
| 1// Copyright (c) 2017-2025, 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> --- 2437 unchanged lines hidden (view full) --- 2446 Note: Calling this function asserts that setup is complete and sets the `CeedOperator` as immutable. 2447 2448 @param[in] op `CeedOperator` to assemble 2449 @param[out] values Values to assemble into matrix 2450 2451 @ref User 2452**/ 2453int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values) { | 1// Copyright (c) 2017-2025, 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> --- 2437 unchanged lines hidden (view full) --- 2446 Note: Calling this function asserts that setup is complete and sets the `CeedOperator` as immutable. 2447 2448 @param[in] op `CeedOperator` to assemble 2449 @param[out] values Values to assemble into matrix 2450 2451 @ref User 2452**/ 2453int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values) { |
| 2454 bool is_composite, has_linear_assemble_single; | 2454 bool is_composite; |
| 2455 CeedInt num_suboperators, offset = 0; 2456 CeedSize single_entries = 0; 2457 CeedOperator *sub_operators; 2458 2459 CeedCall(CeedOperatorCheckReady(op)); 2460 CeedCall(CeedOperatorIsComposite(op, &is_composite)); 2461 2462 // Early exit for empty operator 2463 if (!is_composite) { 2464 CeedInt num_elem = 0; 2465 2466 CeedCall(CeedOperatorGetNumElements(op, &num_elem)); 2467 if (num_elem == 0) return CEED_ERROR_SUCCESS; | 2455 CeedInt num_suboperators, offset = 0; 2456 CeedSize single_entries = 0; 2457 CeedOperator *sub_operators; 2458 2459 CeedCall(CeedOperatorCheckReady(op)); 2460 CeedCall(CeedOperatorIsComposite(op, &is_composite)); 2461 2462 // Early exit for empty operator 2463 if (!is_composite) { 2464 CeedInt num_elem = 0; 2465 2466 CeedCall(CeedOperatorGetNumElements(op, &num_elem)); 2467 if (num_elem == 0) return CEED_ERROR_SUCCESS; |
| 2468 has_linear_assemble_single = op->LinearAssembleSingle != NULL; 2469 } else { 2470 CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 2471 CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 2472 has_linear_assemble_single = true; 2473 for (CeedInt i = 0; i < num_suboperators; i++) { 2474 has_linear_assemble_single = has_linear_assemble_single && sub_operators[i]->LinearAssembleSingle != NULL; 2475 } | |
| 2476 } 2477 2478 if (op->LinearAssemble) { 2479 // Backend version 2480 CeedCall(op->LinearAssemble(op, values)); 2481 return CEED_ERROR_SUCCESS; | 2468 } 2469 2470 if (op->LinearAssemble) { 2471 // Backend version 2472 CeedCall(op->LinearAssemble(op, values)); 2473 return CEED_ERROR_SUCCESS; |
| 2482 } else if (has_linear_assemble_single) { | 2474 } else if (is_composite) { |
| 2483 // Default to summing contributions of suboperators 2484 CeedCall(CeedVectorSetValue(values, 0.0)); | 2475 // Default to summing contributions of suboperators 2476 CeedCall(CeedVectorSetValue(values, 0.0)); |
| 2485 if (is_composite && num_suboperators > 0 && sub_operators[0]) { 2486 CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 2487 CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 2488 for (CeedInt k = 0; k < num_suboperators; k++) { 2489 CeedCall(CeedSingleOperatorAssemble(sub_operators[k], offset, values)); 2490 CeedCall(CeedSingleOperatorAssemblyCountEntries(sub_operators[k], &single_entries)); 2491 offset += single_entries; 2492 } 2493 } else { 2494 CeedCall(CeedSingleOperatorAssemble(op, offset, values)); | 2477 CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 2478 CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 2479 for (CeedInt k = 0; k < num_suboperators; k++) { 2480 CeedCall(CeedSingleOperatorAssemble(sub_operators[k], offset, values)); 2481 CeedCall(CeedSingleOperatorAssemblyCountEntries(sub_operators[k], &single_entries)); 2482 offset += single_entries; |
| 2495 } 2496 return CEED_ERROR_SUCCESS; | 2483 } 2484 return CEED_ERROR_SUCCESS; |
| 2485 } else if (op->LinearAssembleSingle) { 2486 CeedCall(CeedVectorSetValue(values, 0.0)); 2487 CeedCall(CeedSingleOperatorAssemble(op, offset, values)); 2488 return CEED_ERROR_SUCCESS; |
|
| 2497 } else { 2498 // Operator fallback 2499 CeedOperator op_fallback; 2500 2501 CeedCall(CeedOperatorGetFallback(op, &op_fallback)); 2502 if (op_fallback) { 2503 CeedCall(CeedOperatorLinearAssemble(op_fallback, values)); 2504 return CEED_ERROR_SUCCESS; 2505 } 2506 } 2507 | 2489 } else { 2490 // Operator fallback 2491 CeedOperator op_fallback; 2492 2493 CeedCall(CeedOperatorGetFallback(op, &op_fallback)); 2494 if (op_fallback) { 2495 CeedCall(CeedOperatorLinearAssemble(op_fallback, values)); 2496 return CEED_ERROR_SUCCESS; 2497 } 2498 } 2499 |
| 2508 // Default interface implementation | 2500 // Default to interface version if non-composite and no fallback |
| 2509 CeedCall(CeedVectorSetValue(values, 0.0)); | 2501 CeedCall(CeedVectorSetValue(values, 0.0)); |
| 2510 if (is_composite) { 2511 CeedCall(CeedCompositeOperatorGetNumSub(op, &num_suboperators)); 2512 CeedCall(CeedCompositeOperatorGetSubList(op, &sub_operators)); 2513 for (CeedInt k = 0; k < num_suboperators; k++) { 2514 CeedCall(CeedSingleOperatorAssemble(sub_operators[k], offset, values)); 2515 CeedCall(CeedSingleOperatorAssemblyCountEntries(sub_operators[k], &single_entries)); 2516 offset += single_entries; 2517 } 2518 } else { 2519 CeedCall(CeedSingleOperatorAssemble(op, offset, values)); 2520 } | 2502 CeedCall(CeedSingleOperatorAssemble(op, offset, values)); |
| 2521 return CEED_ERROR_SUCCESS; 2522} 2523 2524/** 2525 @brief Get the multiplicity of nodes across sub-operators in a composite `CeedOperator`. 2526 2527 Note: Calling this function asserts that setup is complete and sets the `CeedOperator` as immutable. 2528 --- 480 unchanged lines hidden --- | 2503 return CEED_ERROR_SUCCESS; 2504} 2505 2506/** 2507 @brief Get the multiplicity of nodes across sub-operators in a composite `CeedOperator`. 2508 2509 Note: Calling this function asserts that setup is complete and sets the `CeedOperator` as immutable. 2510 --- 480 unchanged lines hidden --- |