Skip to content

Commit

Permalink
make format and rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
rezgarshakeri committed Nov 19, 2022
1 parent 5a308c5 commit a7b7801
Show file tree
Hide file tree
Showing 75 changed files with 2,836 additions and 3,347 deletions.
246 changes: 120 additions & 126 deletions examples/Hdiv-mass/basis/Hdiv-hex.h

Large diffs are not rendered by default.

75 changes: 35 additions & 40 deletions examples/Hdiv-mass/basis/Hdiv-quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,34 @@
// To see how the nodal basis is constructed visit:
// https://github.com/rezgarshakeri/H-div-Tests
int NodalHdivBasisQuad(CeedScalar *x, CeedScalar *Bx, CeedScalar *By) {

Bx[0] = 0.125*x[0]*x[0] - 0.125 ;
By[0] = -0.25*x[0]*x[1] + 0.25*x[0] + 0.25*x[1] - 0.25 ;
Bx[1] = 0.125 - 0.125*x[0]*x[0] ;
By[1] = 0.25*x[0]*x[1] - 0.25*x[0] + 0.25*x[1] - 0.25 ;
Bx[2] = -0.25*x[0]*x[1] + 0.25*x[0] - 0.25*x[1] + 0.25 ;
By[2] = 0.125*x[1]*x[1] - 0.125 ;
Bx[3] = 0.25*x[0]*x[1] + 0.25*x[0] + 0.25*x[1] + 0.25 ;
By[3] = 0.125 - 0.125*x[1]*x[1] ;
Bx[4] = 0.125*x[0]*x[0] - 0.125 ;
By[4] = -0.25*x[0]*x[1] - 0.25*x[0] + 0.25*x[1] + 0.25 ;
Bx[5] = 0.125 - 0.125*x[0]*x[0] ;
By[5] = 0.25*x[0]*x[1] + 0.25*x[0] + 0.25*x[1] + 0.25 ;
Bx[6] = -0.25*x[0]*x[1] + 0.25*x[0] + 0.25*x[1] - 0.25 ;
By[6] = 0.125*x[1]*x[1] - 0.125 ;
Bx[7] = 0.25*x[0]*x[1] + 0.25*x[0] - 0.25*x[1] - 0.25 ;
By[7] = 0.125 - 0.125*x[1]*x[1] ;
Bx[0] = 0.125 * x[0] * x[0] - 0.125;
By[0] = -0.25 * x[0] * x[1] + 0.25 * x[0] + 0.25 * x[1] - 0.25;
Bx[1] = 0.125 - 0.125 * x[0] * x[0];
By[1] = 0.25 * x[0] * x[1] - 0.25 * x[0] + 0.25 * x[1] - 0.25;
Bx[2] = -0.25 * x[0] * x[1] + 0.25 * x[0] - 0.25 * x[1] + 0.25;
By[2] = 0.125 * x[1] * x[1] - 0.125;
Bx[3] = 0.25 * x[0] * x[1] + 0.25 * x[0] + 0.25 * x[1] + 0.25;
By[3] = 0.125 - 0.125 * x[1] * x[1];
Bx[4] = 0.125 * x[0] * x[0] - 0.125;
By[4] = -0.25 * x[0] * x[1] - 0.25 * x[0] + 0.25 * x[1] + 0.25;
Bx[5] = 0.125 - 0.125 * x[0] * x[0];
By[5] = 0.25 * x[0] * x[1] + 0.25 * x[0] + 0.25 * x[1] + 0.25;
Bx[6] = -0.25 * x[0] * x[1] + 0.25 * x[0] + 0.25 * x[1] - 0.25;
By[6] = 0.125 * x[1] * x[1] - 0.125;
Bx[7] = 0.25 * x[0] * x[1] + 0.25 * x[0] - 0.25 * x[1] - 0.25;
By[7] = 0.125 - 0.125 * x[1] * x[1];
return 0;
}
static void HdivBasisQuad(CeedInt Q, CeedScalar *q_ref, CeedScalar *q_weights,
CeedScalar *interp, CeedScalar *div, CeedQuadMode quad_mode) {

static void HdivBasisQuad(CeedInt Q, CeedScalar *q_ref, CeedScalar *q_weights, CeedScalar *interp, CeedScalar *div, CeedQuadMode quad_mode) {
// Get 1D quadrature on [-1,1]
CeedScalar q_ref_1d[Q], q_weight_1d[Q];
switch (quad_mode) {
case CEED_GAUSS:
CeedGaussQuadrature(Q, q_ref_1d, q_weight_1d);
break;
case CEED_GAUSS_LOBATTO:
CeedLobattoQuadrature(Q, q_ref_1d, q_weight_1d);
break;
case CEED_GAUSS:
CeedGaussQuadrature(Q, q_ref_1d, q_weight_1d);
break;
case CEED_GAUSS_LOBATTO:
CeedLobattoQuadrature(Q, q_ref_1d, q_weight_1d);
break;
}

// Divergence operator; Divergence of nodal basis for ref element
Expand All @@ -66,22 +63,20 @@ static void HdivBasisQuad(CeedInt Q, CeedScalar *q_ref, CeedScalar *q_weights,
CeedScalar Bx[8], By[8];
CeedScalar x[2];

for (CeedInt i=0; i<Q; i++) {
for (CeedInt j=0; j<Q; j++) {
CeedInt k1 = Q*i+j;
q_ref[k1] = q_ref_1d[j];
q_ref[k1 + Q*Q] = q_ref_1d[i];
q_weights[k1] = q_weight_1d[j]*q_weight_1d[i];
x[0] = q_ref_1d[j];
x[1] = q_ref_1d[i];
for (CeedInt i = 0; i < Q; i++) {
for (CeedInt j = 0; j < Q; j++) {
CeedInt k1 = Q * i + j;
q_ref[k1] = q_ref_1d[j];
q_ref[k1 + Q * Q] = q_ref_1d[i];
q_weights[k1] = q_weight_1d[j] * q_weight_1d[i];
x[0] = q_ref_1d[j];
x[1] = q_ref_1d[i];
NodalHdivBasisQuad(x, Bx, By);
for (CeedInt k=0; k<8; k++) {
interp[k1*8+k] = Bx[k];
interp[k1*8+k+8*Q*Q] = By[k];
div[k1*8+k] = D;
for (CeedInt k = 0; k < 8; k++) {
interp[k1 * 8 + k] = Bx[k];
interp[k1 * 8 + k + 8 * Q * Q] = By[k];
div[k1 * 8 + k] = D;
}
}
}
}


2 changes: 1 addition & 1 deletion examples/Hdiv-mass/include/cl-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ PetscErrorCode RegisterProblems_Hdiv(AppCtx app_ctx);
// Process general command line options
PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx);

#endif // cloptions_h
#endif // cloptions_h
5 changes: 2 additions & 3 deletions examples/Hdiv-mass/include/matops.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

PetscErrorCode ApplyLocal_Ceed(User user, Vec X, Vec Y);
PetscErrorCode MatMult_Ceed(Mat A, Vec X, Vec Y);
PetscErrorCode ComputeError(User user, Vec X, CeedVector target,
CeedScalar *l2_error);
PetscErrorCode ComputeError(User user, Vec X, CeedVector target, CeedScalar *l2_error);

#endif // matops_h
#endif // matops_h
16 changes: 8 additions & 8 deletions examples/Hdiv-mass/include/petsc-macros.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef petsc_macros
#define petsc_macros

#if PETSC_VERSION_LT(3,14,0)
# define DMPlexGetClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexGetClosureIndices(a,b,c,d,f,g,i)
# define DMPlexRestoreClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexRestoreClosureIndices(a,b,c,d,f,g,i)
#if PETSC_VERSION_LT(3, 14, 0)
#define DMPlexGetClosureIndices(a, b, c, d, e, f, g, h, i) DMPlexGetClosureIndices(a, b, c, d, f, g, i)
#define DMPlexRestoreClosureIndices(a, b, c, d, e, f, g, h, i) DMPlexRestoreClosureIndices(a, b, c, d, f, g, i)
#endif

#if PETSC_VERSION_LT(3,14,0)
# define DMAddBoundary(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DMAddBoundary(a,b,c,e,h,i,j,k,f,g,m)
#elif PETSC_VERSION_LT(3,16,0)
# define DMAddBoundary(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DMAddBoundary(a,b,c,e,h,i,j,k,l,f,g,m)
#if PETSC_VERSION_LT(3, 14, 0)
#define DMAddBoundary(a, b, c, d, e, f, g, h, i, j, k, l, m, n) DMAddBoundary(a, b, c, e, h, i, j, k, f, g, m)
#elif PETSC_VERSION_LT(3, 16, 0)
#define DMAddBoundary(a, b, c, d, e, f, g, h, i, j, k, l, m, n) DMAddBoundary(a, b, c, e, h, i, j, k, l, f, g, m)
#else
# define DMAddBoundary(a,b,c,d,e,f,g,h,i,j,k,l,m,n) DMAddBoundary(a,b,c,d,f,g,h,i,j,k,l,m,n)
#define DMAddBoundary(a, b, c, d, e, f, g, h, i, j, k, l, m, n) DMAddBoundary(a, b, c, d, f, g, h, i, j, k, l, m, n)
#endif

#endif
2 changes: 1 addition & 1 deletion examples/Hdiv-mass/include/problems.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ PetscErrorCode Hdiv_POISSON_MASS3D(ProblemData *problem_data, void *ctx);

// 4) richard

#endif // problems_h
#endif // problems_h
8 changes: 4 additions & 4 deletions examples/Hdiv-mass/include/setup-dm.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef setupdm_h
#define setupdm_h

#include <ceed.h>
#include <petsc.h>
#include <petscdmplex.h>
#include <petscsys.h>
#include <ceed.h>

#include "../include/structs.h"

// ---------------------------------------------------------------------------
// Set-up DM
// ---------------------------------------------------------------------------
PetscErrorCode CreateDistributedDM(MPI_Comm comm, ProblemData *problem_data,
DM *dm);
PetscErrorCode CreateDistributedDM(MPI_Comm comm, ProblemData *problem_data, DM *dm);

#endif // setupdm_h
#endif // setupdm_h
13 changes: 4 additions & 9 deletions examples/Hdiv-mass/include/setup-libceed.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ PetscErrorCode CeedDataDestroy(CeedData ceed_data);
// Utility function - essential BC dofs are encoded in closure indices as -(i+1)
PetscInt Involute(PetscInt i);
// Utility function to create local CEED restriction from DMPlex
PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm,
CeedInt height, DMLabel domain_label, CeedInt value,
CeedElemRestriction *elem_restr);
PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr);
// Utility function to create local CEED Oriented restriction from DMPlex
PetscErrorCode CreateRestrictionFromPlexOriented(Ceed ceed, DM dm,
CeedInt P, CeedElemRestriction *elem_restr_oriented);
PetscErrorCode CreateRestrictionFromPlexOriented(Ceed ceed, DM dm, CeedInt P, CeedElemRestriction *elem_restr_oriented);
// Set up libCEED for a given degree
PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
ProblemData *problem_data, PetscInt U_g_size,
PetscInt U_loc_size, CeedData ceed_data,
PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx, ProblemData *problem_data, PetscInt U_g_size, PetscInt U_loc_size, CeedData ceed_data,
CeedVector rhs_ceed, CeedVector *target);
#endif // setuplibceed_h
#endif // setuplibceed_h
17 changes: 8 additions & 9 deletions examples/Hdiv-mass/include/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
typedef struct AppCtx_ *AppCtx;
struct AppCtx_ {
// libCEED arguments
PetscInt degree;
PetscInt q_extra;
PetscInt degree;
PetscInt q_extra;
// Problem type arguments
PetscFunctionList problems;
char problem_name[PETSC_MAX_PATH_LEN];
Expand All @@ -19,8 +19,7 @@ struct AppCtx_ {
typedef struct CeedData_ *CeedData;
struct CeedData_ {
CeedBasis basis_x, basis_u;
CeedElemRestriction elem_restr_x, elem_restr_u,
elem_restr_u_i;
CeedElemRestriction elem_restr_x, elem_restr_u, elem_restr_u_i;
CeedQFunction qf_residual, qf_error;
CeedOperator op_residual, op_error;
CeedVector x_ceed, y_ceed;
Expand Down Expand Up @@ -52,8 +51,8 @@ struct PH3DContext_ {
// Struct that contains all enums and structs used for the physics of all problems
typedef struct Physics_ *Physics;
struct Physics_ {
PQ2DContext pq2d_ctx;
PH3DContext ph3d_ctx;
PQ2DContext pq2d_ctx;
PH3DContext ph3d_ctx;
};

// PETSc user data
Expand All @@ -72,11 +71,11 @@ struct User_ {
// Problem specific data
typedef struct {
CeedQFunctionUser setup_rhs, residual, setup_error;
const char *setup_rhs_loc, *residual_loc, *setup_error_loc;
const char *setup_rhs_loc, *residual_loc, *setup_error_loc;
CeedQuadMode quadrature_mode;
CeedInt elem_node, dim;
PetscErrorCode (*setup_ctx)(Ceed, CeedData, Physics);
PetscErrorCode (*setup_ctx)(Ceed, CeedData, Physics);

} ProblemData;

#endif // structs_h
#endif // structs_h
Loading

0 comments on commit a7b7801

Please sign in to comment.