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 4731dc5d86Sjeremylt #ifndef M_PI 4831dc5d86Sjeremylt # define M_PI 3.14159265358979323846 4931dc5d86Sjeremylt #endif 5031dc5d86Sjeremylt 51*d642641fSjeremylt // BCClamp - fix boundary values with affine transformation at fraction of load 52*d642641fSjeremylt // increment 53*d642641fSjeremylt PetscErrorCode BCClamp(PetscInt dim, PetscReal loadIncrement, 5431dc5d86Sjeremylt const PetscReal coords[], PetscInt ncompu, 5531dc5d86Sjeremylt PetscScalar *u, void *ctx) { 5631dc5d86Sjeremylt PetscScalar x = coords[0]; 5731dc5d86Sjeremylt PetscScalar y = coords[1]; 5831dc5d86Sjeremylt PetscScalar z = coords[2]; 5931dc5d86Sjeremylt PetscScalar (*clampMax) = (PetscScalar(*))ctx; 6031dc5d86Sjeremylt 6131dc5d86Sjeremylt PetscFunctionBeginUser; 6231dc5d86Sjeremylt 63*d642641fSjeremylt PetscScalar lx = clampMax[0]*loadIncrement, ly = clampMax[1]*loadIncrement, 64*d642641fSjeremylt lz = clampMax[2]*loadIncrement, 65*d642641fSjeremylt theta = clampMax[6]*M_PI*loadIncrement, 66*d642641fSjeremylt kx = clampMax[3], ky = clampMax[4], kz = clampMax[5]; 6731dc5d86Sjeremylt PetscScalar c = cos(theta), s = sin(theta); 6831dc5d86Sjeremylt 69*d642641fSjeremylt u[0] = lx + s*(-kz*y + ky*z) + (1-c)*(-ky*ky+kz*kz*x + kx*ky*y + kx*kz*z); 70*d642641fSjeremylt u[1] = ly + s*(kz*x + -kx*z) + (1-c)*(kx*ky*x - (kx*kx+kz*kz)*y + ky*kz*z); 71*d642641fSjeremylt u[2] = lz + s*(-ky*x + kx*y) + (1-c)*(kx*kz*x + ky*kz*y - (kx*kx+ky*ky)*z); 7231dc5d86Sjeremylt 7331dc5d86Sjeremylt PetscFunctionReturn(0); 7431dc5d86Sjeremylt }; 75