# 3D Contact Tutorial This tutorial gives a short introduction to the setup of a simple 3D contact problem. The goal of this tutorial is to give an overview of the general workflow in 4C and to show how to create a working input file. It is neither intended to be an introduction to the theory of contact mechanics, nor demonstrate all possible optional settings for a given (contact) problem. ## Overview 1. [Problem description](#problem-description) 1. [Create files](#create-files) 1. [Define Geometry](#define-geometry) 1. [Define Boundary Conditions](#define-boundary-conditions) 1. [Specify Simulation Settings](#specify-simulation-settings) 1. [Run Simulation in 4C, Post-processing and visualization in Paraview](#run-simulation) ## Problem description In this tutorial we create two cubes with sizes 1x1x1 and 0.5x0.5x0.5, with a time dependent Dirichlet boundary condition ( DBC) imposed on the right outer surface of the smaller cube. As a result, the smaller cube is pressed horizontally against the larger counterpart, which is clamped on the left outer surface. Mortar methodology is applied for the discretization of the contact constraints and the subdomains are coupled with dual Lagrange multipliers. The cubes are assumed to consist of two different materials, represented by a St.Venant-Kirchhoff material model with different values of the Young's modulus and density for each cube. ## Create files To create valid input for 4C we need two files: - `.exo`/`.e` file containing the geometry and mesh - `.4C.yaml` file containing all relevant parameters for the simulation ### Define Geometry Information on the geometry and mesh are passed on to 4C as part of a binary EXODUS file (`.e`). This file can be generated using the pre-processing software Cubit. Before we can export an `.exo` file from Cubit (File -> Export -> Files of type: `.e`), we need to specify the geometry and meshing parameters in Cubit. This can be done using the GUI or read from a journal file (`.jou`) containing the specific Cubit commands. A tutorial on how to use the Cubit GUI can be found on the [coreform webpage](https://coreform.com/products/coreform-cubit/tutorials/) and can be useful to get to know some of the basic functionalities. The syntax of a Cubit command to a corresponding Input using the GUI can be seen in the Cubit terminal. > Remark: After learning the syntax of the basic Cubit commands, it may be more convenient to exclusively use journal > files for an easy adaptation and reproduction of your geometry and/or use in e.g. python scripts for parameter studies > etc. In `tutorial_contact_3d.jou` it can be seen, that apart from the basic geometry definition and meshing, nodesets and element blocks are assigned to the corresponding nodes/lines/surfaces/volumes. The nodesets are used later on to assign the boundary conditions, whereas the element blocks are used to assign material properties. Additionally, the last line in the given journal file includes a terminal command to export the `.exo`/`.e` file from cubit. The journal file can be called in Cubit from the Terminal with the command ```bash /path/to/cubit/executable -nographics /path/to/tutorial_contact_3d.jou ``` This saves an EXODUS file in the current work directory. We refer to this file in our main input file in the section ``STRUCTURE GEOMETRY`` as follows: ```yaml STRUCTURE GEOMETRY: FILE: tutorial_contact_3d.e ELEMENT_BLOCKS: - ID: 1 ELEMENT_NAME: SOLID ELEMENT_DATA: MAT 1 KINEM nonlinear - ID: 2 ELEMENT_NAME: SOLID ELEMENT_DATA: MAT 2 KINEM nonlinear ``` We assign two different materials to the two cubes, which are defined in the ``MATERIALS`` section of the input file as follows: ```yaml MATERIALS: - MAT: 1 MAT_Struct_StVenantKirchhoff: YOUNG: 100 NUE: 0.3 DENS: 0.5 - MAT: 2 MAT_Struct_StVenantKirchhoff: YOUNG: 4000 NUE: 0.3 DENS: 1 ``` ### Define Boundary Conditions For the boundary conditions, we defined nodesets for the clamped surface of the large cube and the displacement controlled surface of the small cube in the mesh file. The Dirichlet boundary conditions are defined as follows: ```yaml DESIGN SURF DIRICH CONDITIONS: - E: 3 ENTITY_TYPE: node_set_id NUMDOF: 3 ONOFF: - 1 - 1 - 1 VAL: - 0 - 0 - 0 FUNCT: - null - null - null - E: 4 ENTITY_TYPE: node_set_id NUMDOF: 3 ONOFF: - 1 - 0 - 0 VAL: - -1.0 - 0.0 - 0.0 FUNCT: - 1 - null - null ``` Node set 3 contains the nodes on the clamped surface of the large cube, and is fixed in all three directions. Node set 4 contains the nodes on the displacement controlled surface of the small cube, and is subject to a time-dependent Dirichlet boundary condition. The time-dependent behavior is controlled by ```yaml FUNCT1: - COMPONENT: 0 SYMBOLIC_FUNCTION_OF_SPACE_TIME: a - VARIABLE: 0 NAME: a TYPE: linearinterpolation NUMPOINTS: 3 TIMES: - 0 - 0.1 - 2 VALUES: - 0 - 0.02 - 0.02 ``` The master and slave surfaces for the definition of the contact mortar problem can be specified as: ```yaml DESIGN SURF MORTAR CONTACT CONDITIONS 3D: - E: 1 ENTITY_TYPE: node_set_id InterfaceID: 1 Side: Slave - E: 2 ENTITY_TYPE: node_set_id InterfaceID: 1 Side: Master ``` Here, one of the interface sides is defined as ``master`` and the other as ``slave`` surface. > Remark: It is common practice to choose the side with the finer discretization as the slave side. ### Specify Simulation Settings Since we solve a structural dynamics problem, we need to choose the correct problem type, ```yaml PROBLEM TYPE: PROBLEMTYPE: Structure ``` and set parameters in the corresponding section: ```yaml STRUCTURAL DYNAMIC: INT_STRATEGY: Standard TIMESTEP: 0.02 NUMSTEP: 2 MAXTIME: 0.04 DYNAMICTYPE: GenAlpha RESULTSEVERY: 1 DAMPING: Rayleigh M_DAMP: 1e-05 K_DAMP: 1e-05 TOLDISP: 1e-08 LINEAR_SOLVER: 1 ``` The time integration method `DYNAMICTYPE` (Generalized alpha method), time step size `TIMESTEP` and final time `MAXTIME` are specified for structural dynamics. An important parameter is `RESULTSEVERY`, which specifies how often output is written and thus directly controls the size of the output file. The contact specific parameters are here ```yaml MORTAR COUPLING: ALGORITHM: Mortar LM_SHAPEFCN: Dual SEARCH_ALGORITHM: BinaryTree ``` Dual Lagrange multipliers are chosen for the coupling of the interface. Either the `BruteForceEleBased` algorithm, or the more efficient `BinaryTree` can be chosen as the contact search algorithm. ## Run Simulation Again, following the instructions from the [README.md](https://github.com/4C-multiphysics/4C/blob/main/README.md), the 4C executable can be invoked with the `tutorial_contact_3d.4C.yaml` input file