Commit 27fbbceb authored by Jeremy L Thompson's avatar Jeremy L Thompson
Browse files

Merge branch 'jeremy/short-names' into 'main'

Models - minor reorg and default versions

Closes #109

See merge request !1325
parents b0e4f6c2 667c3bf4
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ On this page we provide a summary of the main API changes, new features and exam

- Add support of user setting any 2 of the 5 neo-Hookean model parameters: Poisson's ratio, Young's modulus, shear modulus, Lame's first parameter, and bulk modulus.
- Add flexible flux boundary conditions with time variance during a quasistatic or dynamic simulation.
- Add command line option `-view_models` to display list of all Ratel material models.

### Breaking changes

+8 −6
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ info-basic:
	$(info ENZYME_LIB    = $(or $(ENZYME_LIB),(not found)))
	$(info ADOLC_LIB     = $(or $(ADOLC_LIB),(not found)))
	$(info ADOLC_INCLUDE = $(or $(ADOLC_INCLUDE),(not found)))
	$(info FC (UHyper)   = $(or $(FC),(not found)))
	$(info )
	$(info -----------------------------------------)
	$(info )
@@ -228,6 +229,7 @@ info:
	$(info ENZYME_LIB     = $(or $(ENZYME_LIB),(not found)))
	$(info ADOLC_LIB      = $(or $(ADOLC_LIB),(not found)))
	$(info ADOLC_INCLUDE  = $(or $(ADOLC_INCLUDE),(not found)))
	$(info FC (UHyper)   = $(or $(FC),(not found)))
	$(info )
	$(info -----------------------------------------)
	$(info )
@@ -289,12 +291,12 @@ RATEL_LIB = -lratel
# Source files
# ------------------------------------------------------------

libratel.c := $(sort $(filter-out $(SRCDIR)/internal/ratel-jit-source-root-$(if $(for_install),default,install).c %-ad-enzyme.c %-ad-adolc.c %-uhyper.c, $(shell find $(SRCDIR) -type f -name "*.c")))
libratel.c := $(sort $(filter-out $(SRCDIR)/internal/ratel-jit-source-root-$(if $(for_install),default,install).c %-ad-enzyme.c %-ad-adolc.c %uhyper.c, $(shell find $(SRCDIR) -type f -name "*.c")))

# Enzyme-AD
ifneq ($(ENZYME_LIB),)
	CFLAGS     += $(ENZYMEFLAGS)
	libratel.c += $(sort $(wildcard $(SRCDIR)/materials/*-ad-enzyme.c))
	libratel.c += $(sort $(wildcard $(SRCDIR)/materials/**/**/*-ad-enzyme.c))
endif

# ADOL-C
@@ -306,14 +308,14 @@ endif
ifneq ($(WITH_ADOLC),)
    LDLIBS       += -ladolc
    CXXFLAGS     += -fPIC
	libratel.c   += $(sort $(wildcard $(SRCDIR)/materials/*-ad-adolc.c))
	libratel.cpp += $(sort $(wildcard $(SRCDIR)/materials/*-ad-adolc-cpp.cpp))
	libratel.c   += $(sort $(wildcard $(SRCDIR)/materials/**/**/*-ad-adolc.c))
	libratel.cpp += $(sort $(wildcard $(SRCDIR)/materials/**/**/*-ad-adolc-cpp.cpp))
endif

# UHyper
ifneq ($(FC),)
  libratel.c   += $(sort $(wildcard $(SRCDIR)/materials/*-uhyper.c))
  libratel.for := $(sort $(wildcard $(SRCDIR)/materials/*_uhyper.for))
  libratel.c   += $(sort $(wildcard $(SRCDIR)/materials/**/**/*uhyper*.c))
  libratel.for := $(sort $(wildcard $(SRCDIR)/materials/**/**/*uhyper*.for))
endif

# Tests
+26 −1
Original line number Diff line number Diff line
# Developer Notes


## Style Guide

Please check your code for style issues by running
@@ -23,6 +24,7 @@ Prefer the use of PETSc functions, e.g. `PetscSNPrintf`, over their standard lib

Also, documentation files should have one sentence per line to help make git diffs clearer and less disruptive.


## Function Conventions

### Naming
@@ -84,6 +86,7 @@ PetscErrorCode RatelFunctionThatDoesSomething(Ratel ratel, PetscInt my_int_param
    All other functions should have their *declarations* prefixed with `RATEL_INTERN`.
    Function *definitions* should have neither.


## Logging

Ratel supports logging at four levels: trace, debug, info, and warn.
@@ -110,6 +113,7 @@ These macros each take the `Ratel` context followed by the arguments to `printf`
Previously, Ratel used macros `RatelDebug` and `RatelDebug256` for plain and colored debug output.
These macros are now deprecated.


### Logging Complex Data

Ratel also supports logging data which cannot be natively passed to `printf`.
@@ -161,7 +165,6 @@ PetscCall(RatelLogCeedTrace(ratel, op));
```



## Clang-tidy

Please check your code for common issues by running
@@ -172,6 +175,7 @@ which uses the `clang-tidy` utility included in recent releases of Clang.
This tool is much slower than actual compilation (`make -j` parallelism helps).
All issues reported by `make tidy` should be fixed.


## Header Files

Header inclusion for source files should follow the principal of 'include what you use' rather than relying upon transitive `#include` to define all symbols.
@@ -193,11 +197,13 @@ Header files should be listed in alphabetical order, with installed headers prec

Header guard macros should be done using `#pragma once`. This must be the very first non-comment line of the file.


## `restrict` Semantics

QFunction arguments can be assumed to have `restrict` semantics.
That is, each input and output array must reside in distinct memory without overlap.


## Continuous Integration (CI) and Testing

Whenever a merge request is created, the Ratel test suite is run against a variety of hardware and software configurations.
@@ -206,6 +212,24 @@ The log will provide the command which failed and relevant details (such as `dif
You can also see the CGNS or CSV output of a failed run, if applicable, by selecting "Download" on the Job Artifacts (to the right of the log).
Artifacts from failed runs will be contained in the `test_failure_artifacts` folder inside the artifacts archive.


## Adding New Material Models

Each material model (`elasticity-neo-hookean-damage-current`, etc.) requires files in several places.

- Any new typedefs for structs required by the material model go in `include/ratel/models/`. For example, the struct typedefs for neo-Hookean models are located in `include/ratel/models/neo-hookean.h`.

- The functions for creating these parameter structs from command line options goes in `src/materials/[model group]/params`, where `[model group]` is a broad category, such as `elasticity` or `poromechanics`. For example, the functions for creating the parameter structs for neo-Hookean damage are located in `src/materials/elasticity/params/neo-hookean.c` and `src/materials/elasticity/params/damage.c`.

- The QFunction source for the material model goes in `include/ratel/qfunctions/models/...`. Select the correct folder and file name based upon the material model. For example, the QFunction source file for neo-Hookean elasticity in the current configuration with damage is `include/ratel/qfunctions/models/elasticity/neo-hookean/damage-current.h`. Additional files in the folders under `include/ratel/qfunctions/...` may contain common code, such as `include/ratel/qfunctions/models/elasticity/neo-hookean/damage-common.h` or `include/ratel/qfunctions/utils.h`.

- The associated model data structs, creation function, and registration function for the material model goes in `src/materials/[model group]`, where `[model group]` is a broad category, such as `elasticity` or `poromechanics`. This folder may be further subdivided. For example, the file for neo-Hookean elasticity in the current configuration with damage is `src/materials/elasticity/neo-hookean/damage-current.h`. All of the functions in this file should have a common, unique suffix, such as `_ElasticityNeoHookeanDamageCurrent`.

- Finally, the command line option string for the material model and its unique function suffix should be added to `src/materials/ratel-model-list.h`, wrapped in the `RATEL_MODEL` macro. This macro is used in `src/materials/ratel-model.c` to register the full list of material models available to users.

- If the material model requires special dependencies, such as Enzyme or ADOL-C, then do not list this material model in `src/materials/ratel-model-list.h`. Instead, place the command line option string and unique function suffix in a separate header, such as `src/materials/ratel-model-list-enzyme.h` and include this header in `src/materials/ratel-model-list.h`. Also create a corresponding file in `src/materials/weak`, such as `src/materials/weak/ratel-model-enzyme-weak.c`, to register a weak symbol for this material model if the required dependencies are not available at compile time. Corresponding logic will also need to be added to `Makefile`.


## Adding New Boundary Conditions

Each boundary condition (e.g. pressure, slip, traction, flux, etc.) gets its own folder `include/ratel/boundary/[bc-name]` containing:
@@ -287,6 +311,7 @@ PetscCall(RatelMaterialSetBoundaryJacobianMultigridInfo(material, op_jacobian, o
                                                        &RatelBoundarySetupMultigridLevel_CellToFace));
```


## Adding New Initial Conditions

Ratel supports non-zero initial condition for linear poromechanincs MMS and as a constant value for other cases. If user needs to add non-zero initial condition as function of coordinate, a function with the same structure as `RatelSetupInitialConditionMMS` needs to be added with its own QFunction expressing the initial condition of each active field.
+5 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ The command line options just shown are the minimum requirements to run the appl
  -

* - `-model`
  - Material model to use (`elasticity-linear`, `elasticity-neo-hookean-current`, `elasticity-mooney-rivlin-initial`, etc.)
  - Material model to use (`elasticity-linear`, `elasticity-neo-hookean-current`, `elasticity-mooney-rivlin-initial`, etc.). Note: The option `-view_models` will display all valid values for this option.
  - `elasticity-linear`

* - `-forcing`
@@ -374,6 +374,10 @@ The command line options just shown are the minimum requirements to run the appl
* - `-help`
  - View comprehensive information about run-time options
  -

* - `-view_models`
  - View full list of material model command line options
  -
:::

To verify the convergence of the linear elasticity formulation on a given mesh with the method of manufactured solutions, run:
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@

#include "contact-common.h"
#include "friction.h"
#include "ratel/qfunctions/models/elasticity-common.h"
#include "ratel/qfunctions/models/elasticity/common.h"
#include "ratel/qfunctions/utils.h"

// Shapes
Loading