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 /// @file 18ccaff030SJeremy L Thompson /// Boundary condition functions for solid mechanics example using PETSc 19ccaff030SJeremy L Thompson 20ccaff030SJeremy L Thompson #include "../elasticity.h" 21ccaff030SJeremy L Thompson 22ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 23ccaff030SJeremy L Thompson // Boundary Functions 24ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 25ccaff030SJeremy L Thompson // Note: If additional boundary conditions are added, an update is needed in 26ccaff030SJeremy L Thompson // elasticity.h for the boundaryOptions variable. 27ccaff030SJeremy L Thompson 28ccaff030SJeremy L Thompson // BCMMS - boundary function 29ccaff030SJeremy L Thompson // Values on all points of the mesh is set based on given solution below 30ccaff030SJeremy L Thompson // for u[0], u[1], u[2] 31ccaff030SJeremy L Thompson PetscErrorCode BCMMS(PetscInt dim, PetscReal loadIncrement, 32ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 33ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 34ccaff030SJeremy L Thompson PetscScalar x = coords[0]; 35ccaff030SJeremy L Thompson PetscScalar y = coords[1]; 36ccaff030SJeremy L Thompson PetscScalar z = coords[2]; 37ccaff030SJeremy L Thompson 38ccaff030SJeremy L Thompson PetscFunctionBeginUser; 39ccaff030SJeremy L Thompson 40ccaff030SJeremy L Thompson u[0] = exp(2*x)*sin(3*y)*cos(4*z) / 1e8 * loadIncrement; 41ccaff030SJeremy L Thompson u[1] = exp(3*y)*sin(4*z)*cos(2*x) / 1e8 * loadIncrement; 42ccaff030SJeremy L Thompson u[2] = exp(4*z)*sin(2*x)*cos(3*y) / 1e8 * loadIncrement; 43ccaff030SJeremy L Thompson 44ccaff030SJeremy L Thompson PetscFunctionReturn(0); 45ccaff030SJeremy L Thompson }; 46ccaff030SJeremy L Thompson 47ccaff030SJeremy L Thompson // BCZero - fix boundary values at zero 48ccaff030SJeremy L Thompson PetscErrorCode BCZero(PetscInt dim, PetscReal loadIncrement, 49ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 50ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 51ccaff030SJeremy L Thompson PetscFunctionBeginUser; 52ccaff030SJeremy L Thompson 53ccaff030SJeremy L Thompson u[0] = 0; 54ccaff030SJeremy L Thompson u[1] = 0; 55ccaff030SJeremy L Thompson u[2] = 0; 56ccaff030SJeremy L Thompson 57ccaff030SJeremy L Thompson PetscFunctionReturn(0); 58ccaff030SJeremy L Thompson }; 59ccaff030SJeremy L Thompson 60ccaff030SJeremy L Thompson // BCClamp - fix boundary values at fraction of load increment 61ccaff030SJeremy L Thompson PetscErrorCode BCClamp(PetscInt dim, PetscReal loadIncrement, 62ccaff030SJeremy L Thompson const PetscReal coords[], PetscInt ncompu, 63ccaff030SJeremy L Thompson PetscScalar *u, void *ctx) { 64*e4659345Sjeremylt PetscScalar (*clampMax) = (PetscScalar(*))ctx; 65*e4659345Sjeremylt 66ccaff030SJeremy L Thompson PetscFunctionBeginUser; 67ccaff030SJeremy L Thompson 68*e4659345Sjeremylt u[0] = clampMax[0]*loadIncrement; 69*e4659345Sjeremylt u[1] = clampMax[1]*loadIncrement; 70*e4659345Sjeremylt u[2] = clampMax[2]*loadIncrement; 71ccaff030SJeremy L Thompson 72ccaff030SJeremy L Thompson PetscFunctionReturn(0); 73ccaff030SJeremy L Thompson }; 74