matops.c (a171b6ef1192a8f5f3031330339aaab2ded4c8fb) matops.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

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

214
215 PetscFunctionReturn(PETSC_SUCCESS);
216};
217
218// This function calculates the strain energy in the final solution
219PetscErrorCode ComputeStrainEnergy(DM dmEnergy, UserMult user, CeedOperator op_energy, Vec X, PetscReal *energy) {
220 PetscScalar *x;
221 PetscMemType x_mem_type;
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

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

214
215 PetscFunctionReturn(PETSC_SUCCESS);
216};
217
218// This function calculates the strain energy in the final solution
219PetscErrorCode ComputeStrainEnergy(DM dmEnergy, UserMult user, CeedOperator op_energy, Vec X, PetscReal *energy) {
220 PetscScalar *x;
221 PetscMemType x_mem_type;
222 CeedInt length;
222 PetscInt length;
223
224 PetscFunctionBeginUser;
225
226 // Global-to-local
227 PetscCall(VecZeroEntries(user->X_loc));
228 PetscCall(DMGlobalToLocal(user->dm, X, INSERT_VALUES, user->X_loc));
229 PetscCall(DMPlexInsertBoundaryValues(user->dm, PETSC_TRUE, user->X_loc, user->load_increment, NULL, NULL, NULL));
230
231 // Setup libCEED input vector
232 PetscCall(VecGetArrayReadAndMemType(user->X_loc, (const PetscScalar **)&x, &x_mem_type));
233 CeedVectorSetArray(user->x_ceed, MemTypeP2C(x_mem_type), CEED_USE_POINTER, x);
234
235 // Setup libCEED output vector
236 Vec E_loc;
237 CeedVector e_loc;
223
224 PetscFunctionBeginUser;
225
226 // Global-to-local
227 PetscCall(VecZeroEntries(user->X_loc));
228 PetscCall(DMGlobalToLocal(user->dm, X, INSERT_VALUES, user->X_loc));
229 PetscCall(DMPlexInsertBoundaryValues(user->dm, PETSC_TRUE, user->X_loc, user->load_increment, NULL, NULL, NULL));
230
231 // Setup libCEED input vector
232 PetscCall(VecGetArrayReadAndMemType(user->X_loc, (const PetscScalar **)&x, &x_mem_type));
233 CeedVectorSetArray(user->x_ceed, MemTypeP2C(x_mem_type), CEED_USE_POINTER, x);
234
235 // Setup libCEED output vector
236 Vec E_loc;
237 CeedVector e_loc;
238
238 PetscCall(DMCreateLocalVector(dmEnergy, &E_loc));
239 PetscCall(VecGetSize(E_loc, &length));
240 PetscCall(VecDestroy(&E_loc));
241 CeedVectorCreate(user->ceed, length, &e_loc);
242
243 // Apply libCEED operator
244 CeedOperatorApply(op_energy, user->x_ceed, e_loc, CEED_REQUEST_IMMEDIATE);
245

--- 16 unchanged lines hidden ---
239 PetscCall(DMCreateLocalVector(dmEnergy, &E_loc));
240 PetscCall(VecGetSize(E_loc, &length));
241 PetscCall(VecDestroy(&E_loc));
242 CeedVectorCreate(user->ceed, length, &e_loc);
243
244 // Apply libCEED operator
245 CeedOperatorApply(op_energy, user->x_ceed, e_loc, CEED_REQUEST_IMMEDIATE);
246

--- 16 unchanged lines hidden ---