ceed-preconditioning.c (2efebffe38fa9227caaeab504b43e3a698cb86d7) ceed-preconditioning.c (2c2ea1dbee80fceecd2c97f30b09f8c87820a53e)
1// Copyright (c) 2017-2022, 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 <assert.h>

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

894 @param[in] dim Dimension of basis
895 @param[out] mass Assembled mass matrix in one dimension
896 @param[out] laplace Assembled perturbed Laplacian in one dimension
897
898 @return An error code: 0 - success, otherwise - failure
899
900 @ref Developer
901**/
1// Copyright (c) 2017-2022, 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 <assert.h>

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

894 @param[in] dim Dimension of basis
895 @param[out] mass Assembled mass matrix in one dimension
896 @param[out] laplace Assembled perturbed Laplacian in one dimension
897
898 @return An error code: 0 - success, otherwise - failure
899
900 @ref Developer
901**/
902CeedPragmaOptimizeOff static int CeedBuildMassLaplace(const CeedScalar *interp_1d, const CeedScalar *grad_1d, const CeedScalar *q_weight_1d,
903 CeedInt P_1d, CeedInt Q_1d, CeedInt dim, CeedScalar *mass, CeedScalar *laplace) {
902CeedPragmaOptimizeOff
903static int CeedBuildMassLaplace(const CeedScalar *interp_1d, const CeedScalar *grad_1d, const CeedScalar *q_weight_1d, CeedInt P_1d, CeedInt Q_1d,
904 CeedInt dim, CeedScalar *mass, CeedScalar *laplace) {
904 for (CeedInt i = 0; i < P_1d; i++) {
905 for (CeedInt j = 0; j < P_1d; j++) {
906 CeedScalar sum = 0.0;
907 for (CeedInt k = 0; k < Q_1d; k++) sum += interp_1d[k * P_1d + i] * q_weight_1d[k] * interp_1d[k * P_1d + j];
908 mass[i + j * P_1d] = sum;
909 }
910 }
911 // -- Laplacian
912 for (CeedInt i = 0; i < P_1d; i++) {
913 for (CeedInt j = 0; j < P_1d; j++) {
914 CeedScalar sum = 0.0;
915 for (CeedInt k = 0; k < Q_1d; k++) sum += grad_1d[k * P_1d + i] * q_weight_1d[k] * grad_1d[k * P_1d + j];
916 laplace[i + j * P_1d] = sum;
917 }
918 }
919 CeedScalar perturbation = dim > 2 ? 1e-6 : 1e-4;
920 for (CeedInt i = 0; i < P_1d; i++) laplace[i + P_1d * i] += perturbation;
921 return CEED_ERROR_SUCCESS;
922}
905 for (CeedInt i = 0; i < P_1d; i++) {
906 for (CeedInt j = 0; j < P_1d; j++) {
907 CeedScalar sum = 0.0;
908 for (CeedInt k = 0; k < Q_1d; k++) sum += interp_1d[k * P_1d + i] * q_weight_1d[k] * interp_1d[k * P_1d + j];
909 mass[i + j * P_1d] = sum;
910 }
911 }
912 // -- Laplacian
913 for (CeedInt i = 0; i < P_1d; i++) {
914 for (CeedInt j = 0; j < P_1d; j++) {
915 CeedScalar sum = 0.0;
916 for (CeedInt k = 0; k < Q_1d; k++) sum += grad_1d[k * P_1d + i] * q_weight_1d[k] * grad_1d[k * P_1d + j];
917 laplace[i + j * P_1d] = sum;
918 }
919 }
920 CeedScalar perturbation = dim > 2 ? 1e-6 : 1e-4;
921 for (CeedInt i = 0; i < P_1d; i++) laplace[i + P_1d * i] += perturbation;
922 return CEED_ERROR_SUCCESS;
923}
923CeedPragmaOptimizeOn;
924CeedPragmaOptimizeOn
924
925/// @}
926
927/// ----------------------------------------------------------------------------
928/// CeedOperator Backend API
929/// ----------------------------------------------------------------------------
930/// @addtogroup CeedOperatorBackend
931/// @{

--- 1568 unchanged lines hidden ---
925
926/// @}
927
928/// ----------------------------------------------------------------------------
929/// CeedOperator Backend API
930/// ----------------------------------------------------------------------------
931/// @addtogroup CeedOperatorBackend
932/// @{

--- 1568 unchanged lines hidden ---