1ccaff030SJeremy L Thompson // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2ccaff030SJeremy L Thompson // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3ccaff030SJeremy L Thompson // reserved. See files LICENSE and NOTICE for details. 4ccaff030SJeremy L Thompson // 5ccaff030SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6ccaff030SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7ccaff030SJeremy L Thompson // element discretizations for exascale applications. For more information and 8ccaff030SJeremy L Thompson // source code availability see http://github.com/ceed. 9ccaff030SJeremy L Thompson // 10ccaff030SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11ccaff030SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12ccaff030SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13ccaff030SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14ccaff030SJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15ccaff030SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16ccaff030SJeremy L Thompson 17ccaff030SJeremy L Thompson #ifndef setup_h 18ccaff030SJeremy L Thompson #define setup_h 19ccaff030SJeremy L Thompson 20ccaff030SJeremy L Thompson #include <stdbool.h> 21ccaff030SJeremy L Thompson #include <string.h> 22ccaff030SJeremy L Thompson 23ccaff030SJeremy L Thompson #include <petsc.h> 24ccaff030SJeremy L Thompson #include <petscdmplex.h> 25ccaff030SJeremy L Thompson #include <petscksp.h> 26ccaff030SJeremy L Thompson #include <petscfe.h> 27ccaff030SJeremy L Thompson 28ccaff030SJeremy L Thompson #include <ceed.h> 29ccaff030SJeremy L Thompson 303ab4fca6SValeria Barra #if PETSC_VERSION_LT(3,14,0) 313ab4fca6SValeria Barra # define DMAddBoundary(a,b,c,d,e,f,g,h,i,j,k,l) DMAddBoundary(a,b,c,d,e,f,g,h,j,k,l) 323ab4fca6SValeria Barra #endif 333ab4fca6SValeria Barra 34ccaff030SJeremy L Thompson #ifndef PHYSICS_STRUCT 35ccaff030SJeremy L Thompson #define PHYSICS_STRUCT 36ccaff030SJeremy L Thompson typedef struct Physics_private *Physics; 37ccaff030SJeremy L Thompson struct Physics_private { 38ccaff030SJeremy L Thompson CeedScalar nu; // Poisson's ratio 39ccaff030SJeremy L Thompson CeedScalar E; // Young's Modulus 40ccaff030SJeremy L Thompson }; 41ccaff030SJeremy L Thompson #endif 42ccaff030SJeremy L Thompson 43ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 44ccaff030SJeremy L Thompson // Command Line Options 45ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 46ccaff030SJeremy L Thompson // Problem options 47ccaff030SJeremy L Thompson typedef enum { 48ccaff030SJeremy L Thompson ELAS_LIN = 0, ELAS_HYPER_SS = 1, ELAS_HYPER_FS = 2 49ccaff030SJeremy L Thompson } problemType; 50ccaff030SJeremy L Thompson static const char *const problemTypes[] = {"linElas", 51ccaff030SJeremy L Thompson "hyperSS", 52ccaff030SJeremy L Thompson "hyperFS", 53ccaff030SJeremy L Thompson "problemType","ELAS_",0 54ccaff030SJeremy L Thompson }; 55ccaff030SJeremy L Thompson static const char *const problemTypesForDisp[] = {"Linear elasticity", 56ccaff030SJeremy L Thompson "Hyper elasticity small strain", 57ccaff030SJeremy L Thompson "Hyper elasticity finite strain" 58ccaff030SJeremy L Thompson }; 59ccaff030SJeremy L Thompson 60ccaff030SJeremy L Thompson // Forcing function options 61ccaff030SJeremy L Thompson typedef enum { 62ccaff030SJeremy L Thompson FORCE_NONE = 0, FORCE_CONST = 1, FORCE_MMS = 2 63ccaff030SJeremy L Thompson } forcingType; 64ccaff030SJeremy L Thompson static const char *const forcingTypes[] = {"none", 65ccaff030SJeremy L Thompson "constant", 66ccaff030SJeremy L Thompson "mms", 67ccaff030SJeremy L Thompson "forcingType","FORCE_",0 68ccaff030SJeremy L Thompson }; 69ccaff030SJeremy L Thompson static const char *const forcingTypesForDisp[] = {"None", 70ccaff030SJeremy L Thompson "Constant", 71ccaff030SJeremy L Thompson "Manufactured solution" 72ccaff030SJeremy L Thompson }; 73ccaff030SJeremy L Thompson 74ccaff030SJeremy L Thompson // Multigrid options 75ccaff030SJeremy L Thompson typedef enum { 76ccaff030SJeremy L Thompson MULTIGRID_LOGARITHMIC = 0, MULTIGRID_UNIFORM = 1, MULTIGRID_NONE = 2 77ccaff030SJeremy L Thompson } multigridType; 78ccaff030SJeremy L Thompson static const char *const multigridTypes [] = {"logarithmic", 79ccaff030SJeremy L Thompson "uniform", 80ccaff030SJeremy L Thompson "none", 81ccaff030SJeremy L Thompson "multigridType","MULTIGRID",0 82ccaff030SJeremy L Thompson }; 83ccaff030SJeremy L Thompson static const char *const multigridTypesForDisp[] = {"P-multigrid, logarithmic coarsening", 84ccaff030SJeremy L Thompson "P-multigrind, uniform coarsening", 85ccaff030SJeremy L Thompson "No multigrid" 86ccaff030SJeremy L Thompson }; 87ccaff030SJeremy L Thompson 88ccaff030SJeremy L Thompson typedef PetscErrorCode BCFunc(PetscInt, PetscReal, const PetscReal *, PetscInt, 89ccaff030SJeremy L Thompson PetscScalar *, void *); 90ccaff030SJeremy L Thompson // Note: These variables should be updated if additional boundary conditions 91ccaff030SJeremy L Thompson // are added to boundary.c. 92ccaff030SJeremy L Thompson BCFunc BCMMS, BCZero, BCClamp; 93ccaff030SJeremy L Thompson 9462e9c006SJeremy L Thompson // MemType Options 9562e9c006SJeremy L Thompson static const char *const memTypes[] = {"host","device","memType", 9662e9c006SJeremy L Thompson "CEED_MEM_",0 9762e9c006SJeremy L Thompson }; 9862e9c006SJeremy L Thompson 99ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 100ccaff030SJeremy L Thompson // Structs 101ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 102ccaff030SJeremy L Thompson // Units 103ccaff030SJeremy L Thompson typedef struct Units_private *Units; 104ccaff030SJeremy L Thompson struct Units_private { 105ccaff030SJeremy L Thompson // Fundamental units 106ccaff030SJeremy L Thompson PetscScalar meter; 107ccaff030SJeremy L Thompson PetscScalar kilogram; 108ccaff030SJeremy L Thompson PetscScalar second; 109ccaff030SJeremy L Thompson // Derived unit 110ccaff030SJeremy L Thompson PetscScalar Pascal; 111ccaff030SJeremy L Thompson }; 112ccaff030SJeremy L Thompson 113ccaff030SJeremy L Thompson // Application context from user command line options 114ccaff030SJeremy L Thompson typedef struct AppCtx_private *AppCtx; 115ccaff030SJeremy L Thompson struct AppCtx_private { 116ccaff030SJeremy L Thompson char ceedResource[PETSC_MAX_PATH_LEN]; // libCEED backend 117ccaff030SJeremy L Thompson char meshFile[PETSC_MAX_PATH_LEN]; // exodusII mesh file 118ccaff030SJeremy L Thompson PetscBool testMode; 119ccaff030SJeremy L Thompson PetscBool viewSoln; 12012b49b89SJeremy L Thompson PetscBool viewFinalSoln; 121ccaff030SJeremy L Thompson problemType problemChoice; 122ccaff030SJeremy L Thompson forcingType forcingChoice; 123ccaff030SJeremy L Thompson multigridType multigridChoice; 124f7b4142eSJeremy L Thompson PetscScalar nuSmoother; 125ccaff030SJeremy L Thompson PetscInt degree; 12612b49b89SJeremy L Thompson PetscInt qextra; 127ccaff030SJeremy L Thompson PetscInt numLevels; 128ccaff030SJeremy L Thompson PetscInt *levelDegrees; 129ccaff030SJeremy L Thompson PetscInt numIncrements; // Number of steps 130d642641fSjeremylt PetscInt bcClampCount; 131*fe394131Sjeremylt PetscInt bcClampFaces[16]; 132d642641fSjeremylt PetscScalar bcClampMax[16][7]; 133*fe394131Sjeremylt PetscInt bcTractionCount; 134*fe394131Sjeremylt PetscInt bcTractionFaces[16]; 135*fe394131Sjeremylt PetscScalar bcTractionVector[16][3]; 136c83beb56Sjeremylt PetscScalar forcingVector[3]; 13762e9c006SJeremy L Thompson PetscBool petscHaveCuda, setMemTypeRequest; 13862e9c006SJeremy L Thompson CeedMemType memTypeRequested; 139ccaff030SJeremy L Thompson }; 140ccaff030SJeremy L Thompson 141ccaff030SJeremy L Thompson // Problem specific data 142b8eaa5f0SJeremy L Thompson // *INDENT-OFF* 143ccaff030SJeremy L Thompson typedef struct { 144ccaff030SJeremy L Thompson CeedInt qdatasize; 1455c25879aSJeremy L Thompson CeedQFunctionUser setupgeo, apply, jacob, energy, diagnostic; 1465c25879aSJeremy L Thompson const char *setupgeofname, *applyfname, *jacobfname, *energyfname, 1475c25879aSJeremy L Thompson *diagnosticfname; 148ccaff030SJeremy L Thompson CeedQuadMode qmode; 149ccaff030SJeremy L Thompson } problemData; 150b8eaa5f0SJeremy L Thompson // *INDENT-ON* 151ccaff030SJeremy L Thompson 152ccaff030SJeremy L Thompson // Data specific to each problem option 1539e9355a0SJed Brown extern problemData problemOptions[3]; 154ccaff030SJeremy L Thompson 155ccaff030SJeremy L Thompson // Forcing function data 156ccaff030SJeremy L Thompson typedef struct { 157ccaff030SJeremy L Thompson CeedQFunctionUser setupforcing; 158ccaff030SJeremy L Thompson const char *setupforcingfname; 159ccaff030SJeremy L Thompson } forcingData; 160ccaff030SJeremy L Thompson 1619e9355a0SJed Brown extern forcingData forcingOptions[3]; 162ccaff030SJeremy L Thompson 163ccaff030SJeremy L Thompson // Data for PETSc Matshell 164ccaff030SJeremy L Thompson typedef struct UserMult_private *UserMult; 165ccaff030SJeremy L Thompson struct UserMult_private { 166ccaff030SJeremy L Thompson MPI_Comm comm; 167ccaff030SJeremy L Thompson DM dm; 168*fe394131Sjeremylt Vec Xloc, Yloc, NBCs; 169ccaff030SJeremy L Thompson CeedVector Xceed, Yceed; 170ccaff030SJeremy L Thompson CeedOperator op; 171f7b4142eSJeremy L Thompson CeedQFunction qf; 172ccaff030SJeremy L Thompson Ceed ceed; 173ccaff030SJeremy L Thompson PetscScalar loadIncrement; 174777ff853SJeremy L Thompson CeedQFunctionContext ctxPhys, ctxPhysSmoother; 17562e9c006SJeremy L Thompson CeedMemType memType; 17662e9c006SJeremy L Thompson int (*VecGetArray)(Vec, PetscScalar **); 17762e9c006SJeremy L Thompson int (*VecGetArrayRead)(Vec, const PetscScalar **); 17862e9c006SJeremy L Thompson int (*VecRestoreArray)(Vec, PetscScalar **); 17962e9c006SJeremy L Thompson int (*VecRestoreArrayRead)(Vec, const PetscScalar **); 180ccaff030SJeremy L Thompson }; 181ccaff030SJeremy L Thompson 182ccaff030SJeremy L Thompson // Data for Jacobian setup routine 183ccaff030SJeremy L Thompson typedef struct FormJacobCtx_private *FormJacobCtx; 184ccaff030SJeremy L Thompson struct FormJacobCtx_private { 185ccaff030SJeremy L Thompson UserMult *jacobCtx; 186ccaff030SJeremy L Thompson PetscInt numLevels; 187ccaff030SJeremy L Thompson SNES snesCoarse; 188ccaff030SJeremy L Thompson Mat *jacobMat, jacobMatCoarse; 189ccaff030SJeremy L Thompson Vec Ucoarse; 190ccaff030SJeremy L Thompson }; 191ccaff030SJeremy L Thompson 192ccaff030SJeremy L Thompson // Data for PETSc Prolongation/Restriction Matshell 193ccaff030SJeremy L Thompson typedef struct UserMultProlongRestr_private *UserMultProlongRestr; 194ccaff030SJeremy L Thompson struct UserMultProlongRestr_private { 195ccaff030SJeremy L Thompson MPI_Comm comm; 196ccaff030SJeremy L Thompson DM dmC, dmF; 197d99fa3c5SJeremy L Thompson Vec locVecC, locVecF; 198ccaff030SJeremy L Thompson CeedVector ceedVecC, ceedVecF; 199ccaff030SJeremy L Thompson CeedOperator opProlong, opRestrict; 200ccaff030SJeremy L Thompson Ceed ceed; 20162e9c006SJeremy L Thompson CeedMemType memType; 20262e9c006SJeremy L Thompson int (*VecGetArray)(Vec, PetscScalar **); 20362e9c006SJeremy L Thompson int (*VecGetArrayRead)(Vec, const PetscScalar **); 20462e9c006SJeremy L Thompson int (*VecRestoreArray)(Vec, PetscScalar **); 20562e9c006SJeremy L Thompson int (*VecRestoreArrayRead)(Vec, const PetscScalar **); 206ccaff030SJeremy L Thompson }; 207ccaff030SJeremy L Thompson 208ccaff030SJeremy L Thompson // libCEED data struct for level 209ccaff030SJeremy L Thompson typedef struct CeedData_private *CeedData; 210ccaff030SJeremy L Thompson struct CeedData_private { 211ccaff030SJeremy L Thompson Ceed ceed; 2125c25879aSJeremy L Thompson CeedBasis basisx, basisu, basisCtoF, basisEnergy, basisDiagnostic; 2132d93065eSjeremylt CeedElemRestriction Erestrictx, Erestrictu, Erestrictqdi, 2145c25879aSJeremy L Thompson ErestrictGradui, ErestrictEnergy, ErestrictDiagnostic, 2155c25879aSJeremy L Thompson ErestrictqdDiagnostici; 2165c25879aSJeremy L Thompson CeedQFunction qfApply, qfJacob, qfEnergy, qfDiagnostic; 2175c25879aSJeremy L Thompson CeedOperator opApply, opJacob, opRestrict, opProlong, opEnergy, 2185c25879aSJeremy L Thompson opDiagnostic; 2195c25879aSJeremy L Thompson CeedVector qdata, qdataDiagnostic, gradu, xceed, yceed, truesoln; 220ccaff030SJeremy L Thompson }; 221ccaff030SJeremy L Thompson 222ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 223ccaff030SJeremy L Thompson // Process command line options 224ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 225ccaff030SJeremy L Thompson // Process general command line options 226ccaff030SJeremy L Thompson PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx appCtx); 227ccaff030SJeremy L Thompson 228ccaff030SJeremy L Thompson // Process physics options 229ccaff030SJeremy L Thompson PetscErrorCode ProcessPhysics(MPI_Comm comm, Physics phys, Units units); 230ccaff030SJeremy L Thompson 231ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 232ccaff030SJeremy L Thompson // Setup DM 233ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 234ccaff030SJeremy L Thompson PetscErrorCode CreateBCLabel(DM dm, const char name[]); 235ccaff030SJeremy L Thompson 236ccaff030SJeremy L Thompson // Create FE by degree 237ccaff030SJeremy L Thompson PetscErrorCode PetscFECreateByDegree(DM dm, PetscInt dim, PetscInt Nc, 238ccaff030SJeremy L Thompson PetscBool isSimplex, const char prefix[], 239ccaff030SJeremy L Thompson PetscInt order, PetscFE *fem); 240ccaff030SJeremy L Thompson 241ccaff030SJeremy L Thompson // Read mesh and distribute DM in parallel 242ccaff030SJeremy L Thompson PetscErrorCode CreateDistributedDM(MPI_Comm comm, AppCtx appCtx, DM *dm); 243ccaff030SJeremy L Thompson 244ccaff030SJeremy L Thompson // Setup DM with FE space of appropriate degree 245ccaff030SJeremy L Thompson PetscErrorCode SetupDMByDegree(DM dm, AppCtx appCtx, PetscInt order, 246a3c02c40SJeremy L Thompson PetscBool boundary, PetscInt ncompu); 247ccaff030SJeremy L Thompson 248ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 249ccaff030SJeremy L Thompson // libCEED Functions 250ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 251ccaff030SJeremy L Thompson // Destroy libCEED objects 252ccaff030SJeremy L Thompson PetscErrorCode CeedDataDestroy(CeedInt level, CeedData data); 253ccaff030SJeremy L Thompson 254*fe394131Sjeremylt // Utility function - essential BC dofs are encoded in closure indices as -(i+1) 255*fe394131Sjeremylt PetscInt Involute(PetscInt i); 256*fe394131Sjeremylt 257*fe394131Sjeremylt // Utility function to create local CEED restriction from DMPlex 258*fe394131Sjeremylt PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt P, 259*fe394131Sjeremylt CeedInt height, DMLabel domainLabel, CeedInt value, 260*fe394131Sjeremylt CeedElemRestriction *Erestrict); 261*fe394131Sjeremylt 262*fe394131Sjeremylt // Utility function to get Ceed Restriction for each domain 263*fe394131Sjeremylt PetscErrorCode GetRestrictionForDomain(Ceed ceed, DM dm, CeedInt height, 264*fe394131Sjeremylt DMLabel domainLabel, PetscInt value, CeedInt P, CeedInt Q, CeedInt qdatasize, 265*fe394131Sjeremylt CeedElemRestriction *restrictq, CeedElemRestriction *restrictx, 266*fe394131Sjeremylt CeedElemRestriction *restrictqdi); 267ccaff030SJeremy L Thompson 268ccaff030SJeremy L Thompson // Set up libCEED for a given degree 269a3c02c40SJeremy L Thompson PetscErrorCode SetupLibceedFineLevel(DM dm, DM dmEnergy, DM dmDiagnostic, 270777ff853SJeremy L Thompson Ceed ceed, AppCtx appCtx, 271777ff853SJeremy L Thompson CeedQFunctionContext physCtx, 272a3c02c40SJeremy L Thompson CeedData *data, PetscInt fineLevel, 273a3c02c40SJeremy L Thompson PetscInt ncompu, PetscInt Ugsz, 274*fe394131Sjeremylt PetscInt Ulocsz, CeedVector forceCeed, 275*fe394131Sjeremylt CeedVector neumannCeed); 276ccaff030SJeremy L Thompson 277d99fa3c5SJeremy L Thompson // Set up libCEED multigrid level for a given degree 278777ff853SJeremy L Thompson PetscErrorCode SetupLibceedLevel(DM dm, Ceed ceed, AppCtx appCtx, 279ccaff030SJeremy L Thompson CeedData *data, PetscInt level, 280ccaff030SJeremy L Thompson PetscInt ncompu, PetscInt Ugsz, 281777ff853SJeremy L Thompson PetscInt Ulocsz, CeedVector fineMult); 282ccaff030SJeremy L Thompson 283ccaff030SJeremy L Thompson // Setup context data for Jacobian evaluation 284ccaff030SJeremy L Thompson PetscErrorCode SetupJacobianCtx(MPI_Comm comm, AppCtx appCtx, DM dm, Vec V, 285ccaff030SJeremy L Thompson Vec Vloc, CeedData ceedData, Ceed ceed, 286777ff853SJeremy L Thompson CeedQFunctionContext ctxPhys, 287777ff853SJeremy L Thompson CeedQFunctionContext ctxPhysSmoother, 288ccaff030SJeremy L Thompson UserMult jacobianCtx); 289ccaff030SJeremy L Thompson 290ccaff030SJeremy L Thompson // Setup context data for prolongation and restriction operators 29162e9c006SJeremy L Thompson PetscErrorCode SetupProlongRestrictCtx(MPI_Comm comm, AppCtx appCtx, DM dmC, 29262e9c006SJeremy L Thompson DM dmF, Vec VF, Vec VlocC, Vec VlocF, 29362e9c006SJeremy L Thompson CeedData ceedDataC, CeedData ceedDataF, 29462e9c006SJeremy L Thompson Ceed ceed, 295ccaff030SJeremy L Thompson UserMultProlongRestr prolongRestrCtx); 296ccaff030SJeremy L Thompson 297ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 298ccaff030SJeremy L Thompson // Jacobian setup 299ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 300ccaff030SJeremy L Thompson PetscErrorCode FormJacobian(SNES snes, Vec U, Mat J, Mat Jpre, void *ctx); 301ccaff030SJeremy L Thompson 302ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 3035c25879aSJeremy L Thompson // Solution output 304ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 305ccaff030SJeremy L Thompson PetscErrorCode ViewSolution(MPI_Comm comm, Vec U, PetscInt increment, 306ccaff030SJeremy L Thompson PetscScalar loadIncrement); 307ccaff030SJeremy L Thompson 3085c25879aSJeremy L Thompson PetscErrorCode ViewDiagnosticQuantities(MPI_Comm comm, DM dmU, 3095c25879aSJeremy L Thompson UserMult user, Vec U, 3105c25879aSJeremy L Thompson CeedElemRestriction ErestrictDiagnostic); 3115c25879aSJeremy L Thompson 312ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 313ccaff030SJeremy L Thompson // libCEED Operators for MatShell 314ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 315ccaff030SJeremy L Thompson // This function uses libCEED to compute the local action of an operator 316ccaff030SJeremy L Thompson PetscErrorCode ApplyLocalCeedOp(Vec X, Vec Y, UserMult user); 317ccaff030SJeremy L Thompson 318ccaff030SJeremy L Thompson // This function uses libCEED to compute the non-linear residual 319ccaff030SJeremy L Thompson PetscErrorCode FormResidual_Ceed(SNES snes, Vec X, Vec Y, void *ctx); 320ccaff030SJeremy L Thompson 321ccaff030SJeremy L Thompson // This function uses libCEED to apply the Jacobian for assembly via a SNES 322ccaff030SJeremy L Thompson PetscErrorCode ApplyJacobianCoarse_Ceed(SNES snes, Vec X, Vec Y, void *ctx); 323ccaff030SJeremy L Thompson 324ccaff030SJeremy L Thompson // This function uses libCEED to compute the action of the Jacobian 325ccaff030SJeremy L Thompson PetscErrorCode ApplyJacobian_Ceed(Mat A, Vec X, Vec Y); 326ccaff030SJeremy L Thompson 327ccaff030SJeremy L Thompson // This function uses libCEED to compute the action of the prolongation operator 328ccaff030SJeremy L Thompson PetscErrorCode Prolong_Ceed(Mat A, Vec X, Vec Y); 329ccaff030SJeremy L Thompson 330ccaff030SJeremy L Thompson // This function uses libCEED to compute the action of the restriction operator 331ccaff030SJeremy L Thompson PetscErrorCode Restrict_Ceed(Mat A, Vec X, Vec Y); 3322d93065eSjeremylt 333ccaff030SJeremy L Thompson // This function returns the computed diagonal of the operator 334ccaff030SJeremy L Thompson PetscErrorCode GetDiag_Ceed(Mat A, Vec D); 335ccaff030SJeremy L Thompson 3362d93065eSjeremylt // This function calculates the strain energy in the final solution 337a3c02c40SJeremy L Thompson PetscErrorCode ComputeStrainEnergy(DM dmEnergy, UserMult user, 338a3c02c40SJeremy L Thompson CeedOperator opEnergy, Vec X, 339a3c02c40SJeremy L Thompson PetscReal *energy); 3402d93065eSjeremylt 341ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 342ccaff030SJeremy L Thompson // Boundary Functions 343ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 344ccaff030SJeremy L Thompson // Note: If additional boundary conditions are added, an update is needed in 345ccaff030SJeremy L Thompson // elasticity.h for the boundaryOptions variable. 346ccaff030SJeremy L Thompson 347ccaff030SJeremy L Thompson // BCMMS - boundary function 348ccaff030SJeremy L Thompson // Values on all points of the mesh is set based on given solution below 349ccaff030SJeremy L Thompson // for u[0], u[1], u[2] 350ccaff030SJeremy L Thompson PetscErrorCode BCMMS(PetscInt dim, PetscReal loadIncrement, 351ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 352ccaff030SJeremy L Thompson PetscScalar *u, void *ctx); 353ccaff030SJeremy L Thompson 354d642641fSjeremylt // BCClamp - fix boundary values with affine transformation at fraction of load 355d642641fSjeremylt // increment 356d642641fSjeremylt PetscErrorCode BCClamp(PetscInt dim, PetscReal loadIncrement, 357ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 358ccaff030SJeremy L Thompson PetscScalar *u, void *ctx); 359ccaff030SJeremy L Thompson 360ccaff030SJeremy L Thompson #endif //setup_h 361