xref: /libCEED/examples/solids/problems/finite-strain-neo-hookean.c (revision bdee0278611904727ee35fcc2d0d7c3bf83db4c4)
1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 #include "../qfunctions/finite-strain-neo-hookean.h"
9 
10 #include <ceed.h>
11 #include <petscsys.h>
12 
13 #include "../include/setup-libceed.h"
14 #include "../include/structs.h"
15 #include "../problems/neo-hookean.h"
16 #include "../problems/problems.h"
17 #include "../qfunctions/common.h"
18 
19 static const char *const field_names[] = {"gradu"};
20 static CeedInt           field_sizes[] = {9};
21 
22 ProblemData finite_strain_neo_Hookean = {
23     .setup_geo            = SetupGeo,
24     .setup_geo_loc        = SetupGeo_loc,
25     .q_data_size          = 10,
26     .quadrature_mode      = CEED_GAUSS,
27     .residual             = ElasFSResidual_NH,
28     .residual_loc         = ElasFSResidual_NH_loc,
29     .number_fields_stored = 1,
30     .field_names          = field_names,
31     .field_sizes          = field_sizes,
32     .jacobian             = ElasFSJacobian_NH,
33     .jacobian_loc         = ElasFSJacobian_NH_loc,
34     .energy               = ElasFSEnergy_NH,
35     .energy_loc           = ElasFSEnergy_NH_loc,
36     .diagnostic           = ElasFSDiagnostic_NH,
37     .diagnostic_loc       = ElasFSDiagnostic_NH_loc,
38 };
39 
40 PetscErrorCode SetupLibceedFineLevel_ElasFSNH(DM dm, DM dm_energy, DM dm_diagnostic, Ceed ceed, AppCtx app_ctx, CeedQFunctionContext phys_ctx,
41                                               PetscInt fine_level, PetscInt num_comp_u, PetscInt U_g_size, PetscInt U_loc_size, CeedVector force_ceed,
42                                               CeedVector neumann_ceed, CeedData *data) {
43   PetscFunctionBegin;
44 
45   PetscCall(SetupLibceedFineLevel(dm, dm_energy, dm_diagnostic, ceed, app_ctx, phys_ctx, finite_strain_neo_Hookean, fine_level, num_comp_u, U_g_size,
46                                   U_loc_size, force_ceed, neumann_ceed, data));
47 
48   PetscFunctionReturn(PETSC_SUCCESS);
49 };
50 
51 PetscErrorCode SetupLibceedLevel_ElasFSNH(DM dm, Ceed ceed, AppCtx app_ctx, PetscInt level, PetscInt num_comp_u, PetscInt U_g_size,
52                                           PetscInt U_loc_size, CeedVector fine_mult, CeedData *data) {
53   PetscFunctionBegin;
54 
55   PetscCall(SetupLibceedLevel(dm, ceed, app_ctx, finite_strain_neo_Hookean, level, num_comp_u, U_g_size, U_loc_size, fine_mult, data));
56 
57   PetscFunctionReturn(PETSC_SUCCESS);
58 };
59