Skip to content

Commit b82348d

Browse files
committed
wip - bddc
1 parent d8d9c82 commit b82348d

File tree

11 files changed

+1170
-35
lines changed

11 files changed

+1170
-35
lines changed

examples/petsc/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ area.o = $(area.c:%.c=$(OBJDIR)/%.o)
4646
area: $(area.o) | $(PETSc.pc) $(ceed.pc)
4747
$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
4848

49+
bddc.c := bddc.c $(utils.c)
50+
bddc.o = $(bddc.c:%.c=$(OBJDIR)/%.o)
51+
bddc: $(bddc.o) | $(PETSc.pc) $(ceed.pc)
52+
$(call quiet,LINK.o) $(CEED_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
53+
4954
bps.c := bps.c $(utils.c)
5055
bps.o = $(bps.c:%.c=$(OBJDIR)/%.o)
5156
bps: $(bps.o) | $(PETSc.pc) $(ceed.pc)
@@ -89,7 +94,7 @@ print: $(PETSc.pc) $(ceed.pc)
8994
@true
9095

9196
clean:
92-
$(RM) -r $(OBJDIR) *.vtu area bps bpsraw bpssphere multigrid
97+
$(RM) -r $(OBJDIR) *.vtu area bddc bps bpsraw bpssphere multigrid
9398

9499
$(PETSc.pc):
95100
$(if $(wildcard $@),,$(error \

examples/petsc/bddc.c

Lines changed: 568 additions & 0 deletions
Large diffs are not rendered by default.

examples/petsc/bddc.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2+
// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3+
// reserved. See files LICENSE and NOTICE for details.
4+
//
5+
// This file is part of CEED, a collection of benchmarks, miniapps, software
6+
// libraries and APIs for efficient high-order finite element and spectral
7+
// element discretizations for exascale applications. For more information and
8+
// source code availability see http://github.com/ceed.
9+
//
10+
// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11+
// a collaborative effort of two U.S. Department of Energy organizations (Office
12+
// of Science and the National Nuclear Security Administration) responsible for
13+
// the planning and preparation of a capable exascale ecosystem, including
14+
// software, applications, hardware, advanced system engineering and early
15+
// testbed platforms, in support of the nation's exascale computing imperative.
16+
17+
#ifndef bddc_h
18+
#define bddc_h
19+
20+
#include "include/bpsproblemdata.h"
21+
#include "include/petscmacros.h"
22+
#include "include/petscutils.h"
23+
#include "include/matops.h"
24+
#include "include/structs.h"
25+
#include "include/libceedsetup.h"
26+
#include "bps.h"
27+
28+
#include <ceed.h>
29+
#include <petsc.h>
30+
#include <petscdmplex.h>
31+
#include <petscfe.h>
32+
#include <petscsys.h>
33+
#include <stdbool.h>
34+
#include <string.h>
35+
36+
#if PETSC_VERSION_LT(3,12,0)
37+
#ifdef PETSC_HAVE_CUDA
38+
#include <petsccuda.h>
39+
// Note: With PETSc prior to version 3.12.0, providing the source path to
40+
// include 'cublas_v2.h' will be needed to use 'petsccuda.h'.
41+
#endif
42+
#endif
43+
44+
// -----------------------------------------------------------------------------
45+
// Command Line Options
46+
// -----------------------------------------------------------------------------
47+
48+
// Coarsening options
49+
typedef enum {
50+
INJECTION_SCALED = 0, INJECTION_HARMONIC = 1
51+
} InjectionType;
52+
static const char *const injection_types [] = {"scaled", "harmonic",
53+
"InjectionType", "INJECTION", 0
54+
};
55+
56+
#endif // bddc_h

examples/petsc/include/libceedsetup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "structs.h"
88

99
PetscErrorCode CeedDataDestroy(CeedInt i, CeedData data);
10+
PetscErrorCode CeedDataBDDCDestroy(CeedDataBDDC data);
1011
PetscErrorCode SetupLibceedByDegree(DM dm, Ceed ceed, CeedInt degree,
1112
CeedInt topo_dim, CeedInt q_extra,
1213
PetscInt num_comp_x, PetscInt num_comp_u,
@@ -17,5 +18,8 @@ PetscErrorCode SetupLibceedByDegree(DM dm, Ceed ceed, CeedInt degree,
1718
PetscErrorCode CeedLevelTransferSetup(Ceed ceed, CeedInt num_levels,
1819
CeedInt num_comp_u, CeedData *data, CeedInt *leveldegrees,
1920
CeedQFunction qf_restrict, CeedQFunction qf_prolong);
21+
PetscErrorCode SetupLibceedBDDC(DM dm_vertex, CeedData data_fine,
22+
CeedDataBDDC data_bddc, PetscInt g_vertex_size,
23+
PetscInt xl_vertex_size, BPData bp_data);
2024

2125
#endif // libceedsetup_h

examples/petsc/include/matops.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ PetscErrorCode MatMult_Ceed(Mat A, Vec X, Vec Y);
1313
PetscErrorCode FormResidual_Ceed(SNES snes, Vec X, Vec Y, void *ctx);
1414
PetscErrorCode MatMult_Prolong(Mat A, Vec X, Vec Y);
1515
PetscErrorCode MatMult_Restrict(Mat A, Vec X, Vec Y);
16+
PetscErrorCode PCShellApply_BDDC(PC pc, Vec X, Vec Y);
17+
PetscErrorCode PCShellSetup_BDDC(PC pc);
18+
PetscErrorCode MatMult_BDDCSchur(SNES snes, Vec X, Vec Y, void *ctx);
1619
PetscErrorCode ComputeErrorMax(UserO user, CeedOperator op_error,
1720
Vec X, CeedVector target, PetscReal *max_error);
1821

examples/petsc/include/petscutils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ typedef PetscErrorCode (*BCFunction)(PetscInt dim, PetscReal time,
1818
PetscErrorCode SetupDMByDegree(DM dm, PetscInt degree, PetscInt num_comp_u,
1919
PetscInt topo_dim,
2020
bool enforce_bc, BCFunction bc_func);
21+
PetscErrorCode SetupVertexDMFromDM(DM dm, DM dm_vertex, PetscInt num_comp_u,
22+
bool enforce_bc, BCFunction bc_func);
2123
PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt P,
2224
CeedInt topo_dim, CeedInt height, DMLabel domain_label, CeedInt value,
2325
CeedElemRestriction *elem_restr);

examples/petsc/include/structs.h

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,6 @@
44
#include <ceed.h>
55
#include <petsc.h>
66

7-
// -----------------------------------------------------------------------------
8-
// PETSc Operator Structs
9-
// -----------------------------------------------------------------------------
10-
11-
// Data for PETSc Matshell
12-
typedef struct UserO_ *UserO;
13-
struct UserO_ {
14-
MPI_Comm comm;
15-
DM dm;
16-
Vec X_loc, Y_loc, diag;
17-
CeedVector x_ceed, y_ceed;
18-
CeedOperator op;
19-
Ceed ceed;
20-
};
21-
22-
// Data for PETSc Prolong/Restrict Matshells
23-
typedef struct UserProlongRestr_ *UserProlongRestr;
24-
struct UserProlongRestr_ {
25-
MPI_Comm comm;
26-
DM dmc, dmf;
27-
Vec loc_vec_c, loc_vec_f, mult_vec;
28-
CeedVector ceed_vec_c, ceed_vec_f;
29-
CeedOperator op_prolong, op_restrict;
30-
Ceed ceed;
31-
};
32-
337
// -----------------------------------------------------------------------------
348
// libCEED Data Structs
359
// -----------------------------------------------------------------------------
@@ -45,6 +19,18 @@ struct CeedData_ {
4519
CeedVector q_data, x_ceed, y_ceed;
4620
};
4721

22+
// libCEED data struct for BDDC
23+
typedef struct CeedDataBDDC_ *CeedDataBDDC;
24+
struct CeedDataBDDC_ {
25+
CeedBasis basis_Pi, basis_Pi_r;
26+
CeedInt strides[3];
27+
CeedElemRestriction elem_restr_Pi, elem_restr_r;
28+
CeedOperator op_Pi_r, op_r_Pi, op_Pi_Pi, op_r_r, op_r_r_inv,
29+
op_inject_Pi, op_inject_r, op_restrict_Pi, op_restrict_r;
30+
CeedVector x_ceed, y_ceed, x_Pi_ceed, y_Pi_ceed, x_r_ceed, y_r_ceed, z_r_ceed,
31+
mult_ceed, mask_r_ceed, mask_Gamma_ceed, mask_I_ceed;
32+
};
33+
4834
// BP specific data
4935
typedef struct {
5036
CeedInt num_comp_x, num_comp_u, topo_dim, q_data_size, q_extra;
@@ -57,4 +43,41 @@ typedef struct {
5743
PetscInt, PetscScalar *, void *);
5844
} BPData;
5945

46+
// -----------------------------------------------------------------------------
47+
// PETSc Operator Structs
48+
// -----------------------------------------------------------------------------
49+
50+
// Data for PETSc Matshell
51+
typedef struct UserO_ *UserO;
52+
struct UserO_ {
53+
MPI_Comm comm;
54+
DM dm;
55+
Vec X_loc, Y_loc, diag;
56+
CeedVector x_ceed, y_ceed;
57+
CeedOperator op;
58+
Ceed ceed;
59+
};
60+
61+
// Data for PETSc Prolong/Restrict Matshells
62+
typedef struct UserProlongRestr_ *UserProlongRestr;
63+
struct UserProlongRestr_ {
64+
MPI_Comm comm;
65+
DM dmc, dmf;
66+
Vec loc_vec_c, loc_vec_f, mult_vec;
67+
CeedVector ceed_vec_c, ceed_vec_f;
68+
CeedOperator op_prolong, op_restrict;
69+
Ceed ceed;
70+
};
71+
// Data for PETSc PCshell
72+
typedef struct UserBDDC_ *UserBDDC;
73+
struct UserBDDC_ {
74+
MPI_Comm comm;
75+
DM dm, dm_Pi;
76+
SNES snes_Pi;
77+
KSP ksp_S_Pi;
78+
Mat mat_S_Pi;
79+
Vec X_loc, Y_loc, X_Pi, Y_Pi, X_Pi_loc, Y_Pi_loc, mult;
80+
CeedDataBDDC ceed_data_bddc;
81+
};
82+
6083
#endif // structs_h

0 commit comments

Comments
 (0)