1*ccaff030SJeremy L Thompson // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2*ccaff030SJeremy L Thompson // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3*ccaff030SJeremy L Thompson // reserved. See files LICENSE and NOTICE for details. 4*ccaff030SJeremy L Thompson // 5*ccaff030SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6*ccaff030SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7*ccaff030SJeremy L Thompson // element discretizations for exascale applications. For more information and 8*ccaff030SJeremy L Thompson // source code availability see http://github.com/ceed. 9*ccaff030SJeremy L Thompson // 10*ccaff030SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11*ccaff030SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12*ccaff030SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13*ccaff030SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14*ccaff030SJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15*ccaff030SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16*ccaff030SJeremy L Thompson 17*ccaff030SJeremy L Thompson /// @file 18*ccaff030SJeremy L Thompson /// Boundary condition functions for solid mechanics example using PETSc 19*ccaff030SJeremy L Thompson 20*ccaff030SJeremy L Thompson #include "../elasticity.h" 21*ccaff030SJeremy L Thompson 22*ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 23*ccaff030SJeremy L Thompson // Boundary Functions 24*ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 25*ccaff030SJeremy L Thompson // Note: If additional boundary conditions are added, an update is needed in 26*ccaff030SJeremy L Thompson // elasticity.h for the boundaryOptions variable. 27*ccaff030SJeremy L Thompson 28*ccaff030SJeremy L Thompson // BCMMS - boundary function 29*ccaff030SJeremy L Thompson // Values on all points of the mesh is set based on given solution below 30*ccaff030SJeremy L Thompson // for u[0], u[1], u[2] 31*ccaff030SJeremy L Thompson PetscErrorCode BCMMS(PetscInt dim, PetscReal loadIncrement, 32*ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 33*ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 34*ccaff030SJeremy L Thompson PetscScalar x = coords[0]; 35*ccaff030SJeremy L Thompson PetscScalar y = coords[1]; 36*ccaff030SJeremy L Thompson PetscScalar z = coords[2]; 37*ccaff030SJeremy L Thompson 38*ccaff030SJeremy L Thompson PetscFunctionBeginUser; 39*ccaff030SJeremy L Thompson 40*ccaff030SJeremy L Thompson u[0] = exp(2*x)*sin(3*y)*cos(4*z) / 1e8 * loadIncrement; 41*ccaff030SJeremy L Thompson u[1] = exp(3*y)*sin(4*z)*cos(2*x) / 1e8 * loadIncrement; 42*ccaff030SJeremy L Thompson u[2] = exp(4*z)*sin(2*x)*cos(3*y) / 1e8 * loadIncrement; 43*ccaff030SJeremy L Thompson 44*ccaff030SJeremy L Thompson PetscFunctionReturn(0); 45*ccaff030SJeremy L Thompson }; 46*ccaff030SJeremy L Thompson 47*ccaff030SJeremy L Thompson // BCZero - fix boundary values at zero 48*ccaff030SJeremy L Thompson PetscErrorCode BCZero(PetscInt dim, PetscReal loadIncrement, 49*ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 50*ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 51*ccaff030SJeremy L Thompson PetscFunctionBeginUser; 52*ccaff030SJeremy L Thompson 53*ccaff030SJeremy L Thompson u[0] = 0; 54*ccaff030SJeremy L Thompson u[1] = 0; 55*ccaff030SJeremy L Thompson u[2] = 0; 56*ccaff030SJeremy L Thompson 57*ccaff030SJeremy L Thompson PetscFunctionReturn(0); 58*ccaff030SJeremy L Thompson }; 59*ccaff030SJeremy L Thompson 60*ccaff030SJeremy L Thompson // BCClamp - fix boundary values at fraction of load increment 61*ccaff030SJeremy L Thompson PetscErrorCode BCClamp(PetscInt dim, PetscReal loadIncrement, 62*ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 63*ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 64*ccaff030SJeremy L Thompson PetscScalar clampMax = *(PetscScalar *)ctx; 65*ccaff030SJeremy L Thompson PetscFunctionBeginUser; 66*ccaff030SJeremy L Thompson 67*ccaff030SJeremy L Thompson u[0] = 0; 68*ccaff030SJeremy L Thompson u[1] = clampMax*loadIncrement; 69*ccaff030SJeremy L Thompson u[2] = 0; 70*ccaff030SJeremy L Thompson 71*ccaff030SJeremy L Thompson PetscFunctionReturn(0); 72*ccaff030SJeremy L Thompson }; 73