1*5aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 35754ecacSJeremy L Thompson // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 55754ecacSJeremy L Thompson // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 75754ecacSJeremy L Thompson 85754ecacSJeremy L Thompson /// @file 95754ecacSJeremy L Thompson /// Linear elasticity manufactured solution forcing term for solid mechanics example using PETSc 105754ecacSJeremy L Thompson 115754ecacSJeremy L Thompson #ifndef MANUFACTURED_H 125754ecacSJeremy L Thompson #define MANUFACTURED_H 135754ecacSJeremy L Thompson 14c9c2c079SJeremy L Thompson #include <ceed.h> 155754ecacSJeremy L Thompson #include <math.h> 165754ecacSJeremy L Thompson 175754ecacSJeremy L Thompson #ifndef PHYSICS_STRUCT 185754ecacSJeremy L Thompson #define PHYSICS_STRUCT 195754ecacSJeremy L Thompson typedef struct Physics_private *Physics; 205754ecacSJeremy L Thompson struct Physics_private { 215754ecacSJeremy L Thompson CeedScalar nu; // Poisson's ratio 225754ecacSJeremy L Thompson CeedScalar E; // Young's Modulus 235754ecacSJeremy L Thompson }; 245754ecacSJeremy L Thompson #endif 255754ecacSJeremy L Thompson 265754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 275754ecacSJeremy L Thompson // Forcing term for linear elasticity manufactured solution 285754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 292b730f8bSJeremy L Thompson CEED_QFUNCTION(SetupMMSForce)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 305754ecacSJeremy L Thompson // Inputs 315754ecacSJeremy L Thompson const CeedScalar *coords = in[0], *q_data = in[1]; 325754ecacSJeremy L Thompson 335754ecacSJeremy L Thompson // Outputs 345754ecacSJeremy L Thompson CeedScalar *force = out[0]; 355754ecacSJeremy L Thompson 365754ecacSJeremy L Thompson // Context 375754ecacSJeremy L Thompson const Physics context = (Physics)ctx; 385754ecacSJeremy L Thompson const CeedScalar E = context->E; 395754ecacSJeremy L Thompson const CeedScalar nu = context->nu; 405754ecacSJeremy L Thompson 415754ecacSJeremy L Thompson // Quadrature Point Loop 422b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 435754ecacSJeremy L Thompson // Setup 445754ecacSJeremy L Thompson CeedScalar x = coords[i + 0 * Q], y = coords[i + 1 * Q], z = coords[i + 2 * Q]; 455754ecacSJeremy L Thompson CeedScalar wdetJ = q_data[i]; 465754ecacSJeremy L Thompson 475754ecacSJeremy L Thompson // Forcing function 485754ecacSJeremy L Thompson // -- Component 1 492b730f8bSJeremy L Thompson force[i + 0 * Q] = (-(E * (cos(x * 2.0) * cos(y * 3.0) * exp(z * 4.0) * 4.0 - cos(z * 4.0) * sin(y * 3.0) * exp(x * 2.0) * 8.0) * (nu - 0.5)) / 505754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 512b730f8bSJeremy L Thompson (E * (cos(z * 4.0) * sin(y * 3.0) * exp(x * 2.0) * (4.5) + sin(x * 2.0) * sin(z * 4.0) * exp(y * 3.0) * 3.0) * (nu - 0.5)) / 525754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 532b730f8bSJeremy L Thompson (E * nu * cos(x * 2.0) * cos(y * 3.0) * exp(z * 4.0) * 8.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 542b730f8bSJeremy L Thompson (E * nu * sin(x * 2.0) * sin(z * 4.0) * exp(y * 3.0) * 6.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 552b730f8bSJeremy L Thompson (E * cos(z * 4.0) * sin(y * 3.0) * exp(x * 2.0) * (nu - 1.0) * 4.0) / ((nu * 2.0 - 1.0) * (nu + 1.0))) * 562b730f8bSJeremy L Thompson wdetJ / 1e8; 575754ecacSJeremy L Thompson 585754ecacSJeremy L Thompson // -- Component 2 592b730f8bSJeremy L Thompson force[i + 1 * Q] = (-(E * (cos(y * 3.0) * cos(z * 4.0) * exp(x * 2.0) * 3.0 - cos(x * 2.0) * sin(z * 4.0) * exp(y * 3.0) * 2.0) * (nu - 0.5)) / 605754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 612b730f8bSJeremy L Thompson (E * (cos(x * 2.0) * sin(z * 4.0) * exp(y * 3.0) * 8.0 + sin(x * 2.0) * sin(y * 3.0) * exp(z * 4.0) * 6.0) * (nu - 0.5)) / 625754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 632b730f8bSJeremy L Thompson (E * nu * cos(y * 3.0) * cos(z * 4.0) * exp(x * 2.0) * 6.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 642b730f8bSJeremy L Thompson (E * nu * sin(x * 2.0) * sin(y * 3.0) * exp(z * 4.0) * 12.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 652b730f8bSJeremy L Thompson (E * cos(x * 2.0) * sin(z * 4.0) * exp(y * 3.0) * (nu - 1.0) * 9.0) / ((nu * 2.0 - 1.0) * (nu + 1.0))) * 662b730f8bSJeremy L Thompson wdetJ / 1e8; 675754ecacSJeremy L Thompson 685754ecacSJeremy L Thompson // -- Component 3 692b730f8bSJeremy L Thompson force[i + 2 * Q] = (-(E * (cos(x * 2.0) * cos(z * 4.0) * exp(y * 3.0) * 6.0 - cos(y * 3.0) * sin(x * 2.0) * exp(z * 4.0) * (4.5)) * (nu - 0.5)) / 705754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 712b730f8bSJeremy L Thompson (E * (cos(y * 3.0) * sin(x * 2.0) * exp(z * 4.0) * 2.0 + sin(y * 3.0) * sin(z * 4.0) * exp(x * 2.0) * 4.0) * (nu - 0.5)) / 725754ecacSJeremy L Thompson ((nu * 2.0 - 1.0) * (nu + 1.0)) + 732b730f8bSJeremy L Thompson (E * nu * cos(x * 2.0) * cos(z * 4.0) * exp(y * 3.0) * 12.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 742b730f8bSJeremy L Thompson (E * nu * sin(y * 3.0) * sin(z * 4.0) * exp(x * 2.0) * 8.0) / ((nu * 2.0 - 1.0) * (nu + 1.0)) - 752b730f8bSJeremy L Thompson (E * cos(y * 3.0) * sin(x * 2.0) * exp(z * 4.0) * (nu - 1.0) * 16.0) / ((nu * 2.0 - 1.0) * (nu + 1.0))) * 762b730f8bSJeremy L Thompson wdetJ / 1e8; 775754ecacSJeremy L Thompson 785754ecacSJeremy L Thompson } // End of Quadrature Point Loop 795754ecacSJeremy L Thompson 805754ecacSJeremy L Thompson return 0; 815754ecacSJeremy L Thompson } 825754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 835754ecacSJeremy L Thompson 845754ecacSJeremy L Thompson #endif // End MANUFACTURED_H 85