| setup-libceed.c (a171b6ef1192a8f5f3031330339aaab2ded4c8fb) | setup-libceed.c (4d00b080eb3f95d2e04e55c0ff369c5c847bb288) |
|---|---|
| 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/// @file --- 70 unchanged lines hidden (view full) --- 79 80 PetscCall(PetscFree(data)); 81 82 PetscFunctionReturn(PETSC_SUCCESS); 83}; 84 85// Utility function to create local CEED restriction from DMPlex 86PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr) { | 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/// @file --- 70 unchanged lines hidden (view full) --- 79 80 PetscCall(PetscFree(data)); 81 82 PetscFunctionReturn(PETSC_SUCCESS); 83}; 84 85// Utility function to create local CEED restriction from DMPlex 86PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr) { |
| 87 PetscInt num_elem, elem_size, num_dof, num_comp, *elem_restr_offsets; | 87 PetscInt num_elem, elem_size, num_dof, num_comp, *elem_restr_offsets_petsc; 88 CeedInt *elem_restr_offsets_ceed; |
| 88 89 PetscFunctionBeginUser; | 89 90 PetscFunctionBeginUser; |
| 90 PetscCall(DMPlexGetLocalOffsets(dm, domain_label, value, height, 0, &num_elem, &elem_size, &num_comp, &num_dof, &elem_restr_offsets)); | 91 PetscCall(DMPlexGetLocalOffsets(dm, domain_label, value, height, 0, &num_elem, &elem_size, &num_comp, &num_dof, &elem_restr_offsets_petsc)); |
| 91 | 92 |
| 92 CeedElemRestrictionCreate(ceed, num_elem, elem_size, num_comp, 1, num_dof, CEED_MEM_HOST, CEED_COPY_VALUES, elem_restr_offsets, elem_restr); 93 PetscCall(PetscFree(elem_restr_offsets)); | 93 PetscCall(IntArrayPetscToCeed(num_elem * elem_size, &elem_restr_offsets_petsc, &elem_restr_offsets_ceed)); 94 CeedElemRestrictionCreate(ceed, num_elem, elem_size, num_comp, 1, num_dof, CEED_MEM_HOST, CEED_COPY_VALUES, elem_restr_offsets_ceed, elem_restr); 95 PetscCall(PetscFree(elem_restr_offsets_ceed)); |
| 94 95 PetscFunctionReturn(PETSC_SUCCESS); 96}; 97 98// Utility function to get Ceed Restriction for each domain 99PetscErrorCode GetRestrictionForDomain(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, PetscInt value, CeedInt Q, CeedInt q_data_size, 100 CeedElemRestriction *elem_restr_q, CeedElemRestriction *elem_restr_x, CeedElemRestriction *elem_restr_qd_i) { | 96 97 PetscFunctionReturn(PETSC_SUCCESS); 98}; 99 100// Utility function to get Ceed Restriction for each domain 101PetscErrorCode GetRestrictionForDomain(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, PetscInt value, CeedInt Q, CeedInt q_data_size, 102 CeedElemRestriction *elem_restr_q, CeedElemRestriction *elem_restr_x, CeedElemRestriction *elem_restr_qd_i) { |
| 101 DM dm_coord; 102 CeedInt dim, num_local_elem; 103 CeedInt Q_dim; | 103 DM dm_coord; 104 CeedInt num_local_elem, Q_dim; 105 PetscInt dim; |
| 104 105 PetscFunctionBeginUser; 106 107 PetscCall(DMGetDimension(dm, &dim)); 108 dim -= height; 109 Q_dim = CeedIntPow(Q, dim); 110 PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 111 PetscCall(DMPlexSetClosurePermutationTensor(dm_coord, PETSC_DETERMINE, NULL)); --- 13 unchanged lines hidden (view full) --- 125}; 126 127// Set up libCEED on the fine grid for a given degree 128PetscErrorCode SetupLibceedFineLevel(DM dm, DM dm_energy, DM dm_diagnostic, Ceed ceed, AppCtx app_ctx, CeedQFunctionContext phys_ctx, 129 ProblemData problem_data, PetscInt fine_level, PetscInt num_comp_u, PetscInt U_g_size, PetscInt U_loc_size, 130 CeedVector force_ceed, CeedVector neumann_ceed, CeedData *data) { 131 CeedInt P = app_ctx->level_degrees[fine_level] + 1; 132 CeedInt Q = app_ctx->level_degrees[fine_level] + 1 + app_ctx->q_extra; | 106 107 PetscFunctionBeginUser; 108 109 PetscCall(DMGetDimension(dm, &dim)); 110 dim -= height; 111 Q_dim = CeedIntPow(Q, dim); 112 PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 113 PetscCall(DMPlexSetClosurePermutationTensor(dm_coord, PETSC_DETERMINE, NULL)); --- 13 unchanged lines hidden (view full) --- 127}; 128 129// Set up libCEED on the fine grid for a given degree 130PetscErrorCode SetupLibceedFineLevel(DM dm, DM dm_energy, DM dm_diagnostic, Ceed ceed, AppCtx app_ctx, CeedQFunctionContext phys_ctx, 131 ProblemData problem_data, PetscInt fine_level, PetscInt num_comp_u, PetscInt U_g_size, PetscInt U_loc_size, 132 CeedVector force_ceed, CeedVector neumann_ceed, CeedData *data) { 133 CeedInt P = app_ctx->level_degrees[fine_level] + 1; 134 CeedInt Q = app_ctx->level_degrees[fine_level] + 1 + app_ctx->q_extra; |
| 133 CeedInt dim, num_comp_x, num_comp_e = 1, num_comp_d = 5; | 135 CeedInt num_comp_x, num_comp_e = 1, num_comp_d = 5; |
| 134 CeedInt num_qpts; 135 CeedInt q_data_size = problem_data.q_data_size; 136 forcingType forcing_choice = app_ctx->forcing_choice; 137 DM dm_coord; 138 Vec coords; | 136 CeedInt num_qpts; 137 CeedInt q_data_size = problem_data.q_data_size; 138 forcingType forcing_choice = app_ctx->forcing_choice; 139 DM dm_coord; 140 Vec coords; |
| 139 PetscInt c_start, c_end, num_elem; | 141 PetscInt c_start, c_end, num_elem, dim; |
| 140 const PetscScalar *coordArray; 141 CeedVector x_coord; 142 CeedQFunction qf_setup_geo, qf_residual, qf_jacobian, qf_energy, qf_diagnostic; 143 CeedOperator op_setup_geo, op_residual, op_jacobian, op_energy, op_diagnostic; 144 145 PetscFunctionBeginUser; 146 147 // --------------------------------------------------------------------------- --- 347 unchanged lines hidden (view full) --- 495 496// Set up libCEED multigrid level for a given degree 497// Prolongation and Restriction are between level and level+1 498PetscErrorCode SetupLibceedLevel(DM dm, Ceed ceed, AppCtx app_ctx, ProblemData problem_data, PetscInt level, PetscInt num_comp_u, PetscInt U_g_size, 499 PetscInt U_loc_size, CeedVector fine_mult, CeedData *data) { 500 CeedInt fine_level = app_ctx->num_levels - 1; 501 CeedInt P = app_ctx->level_degrees[level] + 1; 502 CeedInt Q = app_ctx->level_degrees[fine_level] + 1 + app_ctx->q_extra; | 142 const PetscScalar *coordArray; 143 CeedVector x_coord; 144 CeedQFunction qf_setup_geo, qf_residual, qf_jacobian, qf_energy, qf_diagnostic; 145 CeedOperator op_setup_geo, op_residual, op_jacobian, op_energy, op_diagnostic; 146 147 PetscFunctionBeginUser; 148 149 // --------------------------------------------------------------------------- --- 347 unchanged lines hidden (view full) --- 497 498// Set up libCEED multigrid level for a given degree 499// Prolongation and Restriction are between level and level+1 500PetscErrorCode SetupLibceedLevel(DM dm, Ceed ceed, AppCtx app_ctx, ProblemData problem_data, PetscInt level, PetscInt num_comp_u, PetscInt U_g_size, 501 PetscInt U_loc_size, CeedVector fine_mult, CeedData *data) { 502 CeedInt fine_level = app_ctx->num_levels - 1; 503 CeedInt P = app_ctx->level_degrees[level] + 1; 504 CeedInt Q = app_ctx->level_degrees[fine_level] + 1 + app_ctx->q_extra; |
| 503 CeedInt dim; | 505 PetscInt dim; |
| 504 CeedOperator op_jacobian, op_prolong, op_restrict; 505 506 PetscFunctionBeginUser; 507 508 PetscCall(DMGetDimension(dm, &dim)); 509 510 // --------------------------------------------------------------------------- 511 // libCEED restrictions --- 31 unchanged lines hidden --- | 506 CeedOperator op_jacobian, op_prolong, op_restrict; 507 508 PetscFunctionBeginUser; 509 510 PetscCall(DMGetDimension(dm, &dim)); 511 512 // --------------------------------------------------------------------------- 513 // libCEED restrictions --- 31 unchanged lines hidden --- |