ceed-elemrestriction.c (05fa913c62a5b5aaff243ce604e99ba489aa7f63) ceed-elemrestriction.c (0930e4e786557ee92f6edf1a51db869c03c3f660)
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 <ceed-impl.h>

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

305 Ceed ceed;
306 const CeedInt *offsets;
307
308 CeedCall(CeedElemRestrictionGetCeed(rstr, &ceed));
309 CeedCheck(rstr->rstr_type == CEED_RESTRICTION_POINTS, ceed, CEED_ERROR_INCOMPATIBLE,
310 "Can only retrieve the number of points for a points CeedElemRestriction");
311
312 CeedCall(CeedElemRestrictionGetOffsets(rstr, CEED_MEM_HOST, &offsets));
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 <ceed-impl.h>

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

305 Ceed ceed;
306 const CeedInt *offsets;
307
308 CeedCall(CeedElemRestrictionGetCeed(rstr, &ceed));
309 CeedCheck(rstr->rstr_type == CEED_RESTRICTION_POINTS, ceed, CEED_ERROR_INCOMPATIBLE,
310 "Can only retrieve the number of points for a points CeedElemRestriction");
311
312 CeedCall(CeedElemRestrictionGetOffsets(rstr, CEED_MEM_HOST, &offsets));
313 *num_points = offsets[elem - 1] - offsets[elem];
313 *num_points = offsets[elem + 1] - offsets[elem];
314 CeedCall(CeedElemRestrictionRestoreOffsets(rstr, &offsets));
315 return CEED_ERROR_SUCCESS;
316}
317
318/**
319
320 @brief Get the E-vector layout of a CeedElemRestriction
321

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

1178 CeedCheck(n <= u->length, rstr->ceed, CEED_ERROR_DIMENSION,
1179 "Input vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT
1180 ") for element %" CeedInt_FMT,
1181 u->length, m, n, elem);
1182 CeedCheck(m <= ru->length, rstr->ceed, CEED_ERROR_DIMENSION,
1183 "Output vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT
1184 ") for element %" CeedInt_FMT,
1185 ru->length, m, n, elem);
314 CeedCall(CeedElemRestrictionRestoreOffsets(rstr, &offsets));
315 return CEED_ERROR_SUCCESS;
316}
317
318/**
319
320 @brief Get the E-vector layout of a CeedElemRestriction
321

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

1178 CeedCheck(n <= u->length, rstr->ceed, CEED_ERROR_DIMENSION,
1179 "Input vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT
1180 ") for element %" CeedInt_FMT,
1181 u->length, m, n, elem);
1182 CeedCheck(m <= ru->length, rstr->ceed, CEED_ERROR_DIMENSION,
1183 "Output vector size %" CeedInt_FMT " not compatible with element restriction (%" CeedInt_FMT ", %" CeedInt_FMT
1184 ") for element %" CeedInt_FMT,
1185 ru->length, m, n, elem);
1186 CeedCheck(elem <= rstr->num_elem, rstr->ceed, CEED_ERROR_DIMENSION,
1186 CeedCheck(elem < rstr->num_elem, rstr->ceed, CEED_ERROR_DIMENSION,
1187 "Cannot retrieve element %" CeedInt_FMT ", element %" CeedInt_FMT " > total elements %" CeedInt_FMT "", elem, elem, rstr->num_elem);
1188 if (rstr->num_elem > 0) CeedCall(rstr->ApplyAtPointsInElement(rstr, elem, t_mode, u, ru, request));
1189 return CEED_ERROR_SUCCESS;
1190}
1191
1192/**
1193 @brief Restrict an L-vector to a block of an E-vector or apply its transpose
1194

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

1413 @param[in] rstr CeedElemRestriction to view
1414 @param[in] stream Stream to write; typically stdout/stderr or a file
1415
1416 @return Error code: 0 - success, otherwise - failure
1417
1418 @ref User
1419**/
1420int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream) {
1187 "Cannot retrieve element %" CeedInt_FMT ", element %" CeedInt_FMT " > total elements %" CeedInt_FMT "", elem, elem, rstr->num_elem);
1188 if (rstr->num_elem > 0) CeedCall(rstr->ApplyAtPointsInElement(rstr, elem, t_mode, u, ru, request));
1189 return CEED_ERROR_SUCCESS;
1190}
1191
1192/**
1193 @brief Restrict an L-vector to a block of an E-vector or apply its transpose
1194

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

1413 @param[in] rstr CeedElemRestriction to view
1414 @param[in] stream Stream to write; typically stdout/stderr or a file
1415
1416 @return Error code: 0 - success, otherwise - failure
1417
1418 @ref User
1419**/
1420int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream) {
1421 char stridesstr[500];
1421 CeedRestrictionType rstr_type;
1422
1422
1423 if (rstr->strides) {
1424 sprintf(stridesstr, "[%" CeedInt_FMT ", %" CeedInt_FMT ", %" CeedInt_FMT "]", rstr->strides[0], rstr->strides[1], rstr->strides[2]);
1423 CeedCall(CeedElemRestrictionGetType(rstr, &rstr_type));
1424
1425 if (rstr_type == CEED_RESTRICTION_POINTS) {
1426 CeedInt max_points;
1427
1428 CeedCall(CeedElemRestrictionGetMaxPointsInElement(rstr, &max_points));
1429 fprintf(stream,
1430 "CeedElemRestriction at points from (%td, %" CeedInt_FMT ") to %" CeedInt_FMT " elements with a maximum of %" CeedInt_FMT
1431 " points on an element\n",
1432 rstr->l_size, rstr->num_comp, rstr->num_elem, max_points);
1425 } else {
1433 } else {
1426 sprintf(stridesstr, "%" CeedInt_FMT, rstr->comp_stride);
1427 }
1434 char stridesstr[500];
1428
1435
1429 fprintf(stream, "%sCeedElemRestriction from (%td, %" CeedInt_FMT ") to %" CeedInt_FMT " elements with %" CeedInt_FMT " nodes each and %s %s\n",
1430 rstr->block_size > 1 ? "Blocked " : "", rstr->l_size, rstr->num_comp, rstr->num_elem, rstr->elem_size,
1431 rstr->strides ? "strides" : "component stride", stridesstr);
1436 if (rstr->strides) {
1437 sprintf(stridesstr, "[%" CeedInt_FMT ", %" CeedInt_FMT ", %" CeedInt_FMT "]", rstr->strides[0], rstr->strides[1], rstr->strides[2]);
1438 } else {
1439 sprintf(stridesstr, "%" CeedInt_FMT, rstr->comp_stride);
1440 }
1441 fprintf(stream, "%sCeedElemRestriction from (%td, %" CeedInt_FMT ") to %" CeedInt_FMT " elements with %" CeedInt_FMT " nodes each and %s %s\n",
1442 rstr->block_size > 1 ? "Blocked " : "", rstr->l_size, rstr->num_comp, rstr->num_elem, rstr->elem_size,
1443 rstr->strides ? "strides" : "component stride", stridesstr);
1444 }
1432 return CEED_ERROR_SUCCESS;
1433}
1434
1435/**
1436 @brief Destroy a CeedElemRestriction
1437
1438 @param[in,out] rstr CeedElemRestriction to destroy
1439

--- 23 unchanged lines hidden ---
1445 return CEED_ERROR_SUCCESS;
1446}
1447
1448/**
1449 @brief Destroy a CeedElemRestriction
1450
1451 @param[in,out] rstr CeedElemRestriction to destroy
1452

--- 23 unchanged lines hidden ---