Skip to content

Commit 33490f6

Browse files
authored
Merge pull request #1927 from CEED/jeremy/scalar-multiplicity
Scalar Multigrid Multiplicity
2 parents e6340a4 + 397d7ab commit 33490f6

38 files changed

+217
-48
lines changed

gallery/ceed-gallery-list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// At the time of this writing, all the gallery functions are defined, but we're adopting the same strategy here as for the backends because future gallery @ref CeedQFunction might depend on external libraries.
1414

1515
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Identity)
16+
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_IdentityScalar)
1617
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Mass1DBuild)
1718
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Mass2DBuild)
1819
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Mass3DBuild)
@@ -28,3 +29,4 @@ CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Vector3Poisson1DApply)
2829
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Vector3Poisson2DApply)
2930
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Vector3Poisson3DApply)
3031
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_Scale)
32+
CEED_GALLERY_QFUNCTION(CeedQFunctionRegister_ScaleScalar)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2017-2026, 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.h>
9+
#include <ceed/backend.h>
10+
#include <ceed/jit-source/gallery/ceed-identity-to-scalar.h>
11+
#include <stddef.h>
12+
#include <string.h>
13+
14+
/**
15+
@brief Set fields identity `CeedQFunction` that copies first input component directly into output
16+
**/
17+
static int CeedQFunctionInit_IdentityScalar(Ceed ceed, const char *requested, CeedQFunction qf) {
18+
// Check QFunction name
19+
const char *name = "Identity to scalar";
20+
21+
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
22+
23+
// QFunction fields 'input' and 'output' with requested emodes added by the library rather than being added here
24+
25+
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
26+
return CEED_ERROR_SUCCESS;
27+
}
28+
29+
/**
30+
@brief Register identity `CeedQFunction` that copies first input component directly into output
31+
**/
32+
CEED_INTERN int CeedQFunctionRegister_IdentityScalar(void) {
33+
return CeedQFunctionRegister("Identity to scalar", IdentityScalar_loc, 1, IdentityScalar, CeedQFunctionInit_IdentityScalar);
34+
}

gallery/identity/ceed-identity.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
static int CeedQFunctionInit_Identity(Ceed ceed, const char *requested, CeedQFunction qf) {
1818
// Check QFunction name
1919
const char *name = "Identity";
20+
2021
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2122

2223
// QFunction fields 'input' and 'output' with requested emodes added by the library rather than being added here
2324

24-
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
25-
2625
// Context data
2726
CeedQFunctionContext ctx;
2827
IdentityCtx ctx_data = {.size = 1};
28+
2929
CeedCall(CeedQFunctionContextCreate(ceed, &ctx));
3030
CeedCall(CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctx_data), &ctx_data));
3131
CeedCall(CeedQFunctionContextRegisterInt32(ctx, "size", offsetof(IdentityCtx, size), 1, "field size of identity QFunction"));
3232
CeedCall(CeedQFunctionSetContext(qf, ctx));
3333
CeedCall(CeedQFunctionContextDestroy(&ctx));
3434

35+
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
3536
return CEED_ERROR_SUCCESS;
3637
}
3738

gallery/mass-vector/ceed-vectormassapply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Vector3MassApply(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Vector3MassApply";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt num_comp = 3;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "u", num_comp, CEED_EVAL_INTERP));
2426
CeedCall(CeedQFunctionAddInput(qf, "qdata", 1, CEED_EVAL_NONE));
2527
CeedCall(CeedQFunctionAddOutput(qf, "v", num_comp, CEED_EVAL_INTERP));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, num_comp));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

gallery/mass/ceed-mass1dbuild.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Mass1DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Mass1DBuild";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt dim = 1;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
2426
CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
2527
CeedCall(CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 1));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

gallery/mass/ceed-mass2dbuild.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Mass2DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Mass2DBuild";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt dim = 2;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
2426
CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
2527
CeedCall(CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 4));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

gallery/mass/ceed-mass3dbuild.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Mass3DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Mass3DBuild";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt dim = 3;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
2426
CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
2527
CeedCall(CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 15));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

gallery/mass/ceed-massapply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
static int CeedQFunctionInit_MassApply(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "MassApply";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
@@ -24,7 +25,6 @@ static int CeedQFunctionInit_MassApply(Ceed ceed, const char *requested, CeedQFu
2425
CeedCall(CeedQFunctionAddOutput(qf, "v", 1, CEED_EVAL_INTERP));
2526

2627
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 1));
27-
2828
return CEED_ERROR_SUCCESS;
2929
}
3030

gallery/poisson-vector/ceed-vectorpoisson1dapply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Vector3Poisson1DApply(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Vector3Poisson1DApply";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt dim = 1, num_comp = 3;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "du", num_comp * dim, CEED_EVAL_GRAD));
2426
CeedCall(CeedQFunctionAddInput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
2527
CeedCall(CeedQFunctionAddOutput(qf, "dv", num_comp * dim, CEED_EVAL_GRAD));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, num_comp));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

gallery/poisson-vector/ceed-vectorpoisson2dapply.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
static int CeedQFunctionInit_Vector3Poisson2DApply(Ceed ceed, const char *requested, CeedQFunction qf) {
1717
// Check QFunction name
1818
const char *name = "Vector3Poisson2DApply";
19+
1920
CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
2021

2122
// Add QFunction fields
2223
const CeedInt dim = 2, num_comp = 3;
24+
2325
CeedCall(CeedQFunctionAddInput(qf, "du", num_comp * dim, CEED_EVAL_GRAD));
2426
CeedCall(CeedQFunctionAddInput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
2527
CeedCall(CeedQFunctionAddOutput(qf, "dv", num_comp * dim, CEED_EVAL_GRAD));
2628

2729
CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, num_comp * 6));
28-
2930
return CEED_ERROR_SUCCESS;
3031
}
3132

0 commit comments

Comments
 (0)