Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
223232b
distributed code from test.h and test.cpp to separate files, appears …
aabrown100-git Jun 30, 2025
43c0b2d
Refactor mooney rivlin tests, make helper function inline to fix link…
aabrown100-git Jul 2, 2025
405bf5e
Refactoring holzapfel ogden and holapfel ogden MA tests
aabrown100-git Jul 2, 2025
7c78a71
Refactoring CANN NH and HO tests. Fix typo in holzapfel_ogden header …
aabrown100-git Jul 2, 2025
b085c01
Refactoring the 3 volumetric penalty model tests
aabrown100-git Jul 10, 2025
5984dd7
Removing original test.h and test.cpp, since all code from these file…
aabrown100-git Jul 10, 2025
c9869ea
Moved all material model tests into subfolder, modified CMakeLists.tx…
aabrown100-git Jul 10, 2025
bedf081
Add copyright notices to all material model test files
aabrown100-git Jul 10, 2025
f61d509
Fix typo in test_material_holzapfel_ogden_MA.h
aabrown100-git Jul 10, 2025
ba58719
cosmetic changes to two helper functions
aabrown100-git Jul 10, 2025
3dfc890
Remove extraneous comments from unit test files, following comments b…
aabrown100-git Jul 11, 2025
2ef9a22
Refactor fiber and sheet direction handling in Holzapfel-Ogden materi…
aabrown100-git Jul 11, 2025
fb83503
Refactor deformation gradient lists to contain Array<double> instead …
aabrown100-git Jul 11, 2025
eb511b7
Adjust convergence order tolerances slightly for HO-ma tests so they …
aabrown100-git Jul 12, 2025
f58fe19
Replacing 1e-6 tolerance for f.s check with std::numeric_limits<doubl…
aabrown100-git Jul 12, 2025
f6416ba
Use static constexpr and capital case for material test tolerances etc.
aabrown100-git Jul 14, 2025
2eac2d5
Minor changes to CANN material testing files
aabrown100-git Jul 15, 2025
3274910
Remove unnecessary nullptr assignments in TearDown methods across var…
aabrown100-git Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Code/Source/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,17 @@ if(ENABLE_UNIT_TEST)

# add test.cpp for unit test

# remove the main.cpp and add test.cpp
set(TEST_SOURCES "../../../tests/unitTests/test.cpp")
# Automatically find all test files under unitTests directory
file(GLOB_RECURSE TEST_SOURCES
"../../../tests/unitTests/*.cpp"
)
list(LENGTH TEST_SOURCES TEST_SOURCES_COUNT)
message(STATUS "Found ${TEST_SOURCES_COUNT} test files")
foreach(TEST_SOURCE ${TEST_SOURCES})
# Print the file being copied for debugging
message(STATUS "TEST_SOURCE: ${TEST_SOURCE}")
endforeach()

list(REMOVE_ITEM CSRCS "main.cpp")
list(APPEND CSRCS ${TEST_SOURCES})

Expand Down
155 changes: 155 additions & 0 deletions tests/unitTests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Unit Tests for svMultiPhysics

This directory contains unit tests for svMultiPhysics

## Building and Running Tests

### Prerequisites
- svMultiPhysics must be built with unit tests enabled:
```bash
cmake -DENABLE_UNIT_TEST=ON ..
```

### Building Tests
1. Navigate to the build directory:
```bash
cd <svMultiPhysics_root_directory>/build/svMultiPhysics-build/Source/solver
```

2. Build the tests:
```bash
make
```

### Running Tests
Run all unit tests:
```bash
ctest --verbose
```

Or run the test executable directly:
```bash
./run_all_unit_tests
```

## Common Files
### `test_common.h`
- Contains mock objects for svMultiPhysics components
- Provides `TestBase` class with common test infrastructure
- Includes Google Test framework



## Material Model Testing

Each material model follows this pattern:

1. **Parameter Class** (e.g., `NeoHookeanParams`)
- Inherits from `MatParams`
- Contains material-specific parameters

2. **Test Material Class** (e.g., `TestNeoHookean`)
- Inherits from `TestMaterialModel`
- Implements required virtual methods:
- `printMaterialParameters()`
- `computeStrainEnergy()`
- Sets up material parameters for svMultiPhysics

3. **Test Fixture Class** (e.g., `NeoHookeanTest`)
- Inherits from `MaterialTestFixture`
- Sets up test parameters and objects

4. **Test Cases**
- Use Google Test macros (`TEST_F`)
- Test the material model second Piola-Kirchoff stress and material elasticity tensor in a variety of ways

### Material Models Currently Tested

#### Hyperelastic Models
- **Neo-Hookean**: Basic hyperelastic model
- **Mooney-Rivlin**: Two-parameter hyperelastic model
- **Holzapfel-Ogden**: Anisotropic hyperelastic model for soft tissues
- **Holzapfel-Ogden Modified Anisotropy**: Enhanced version with modified anisotropy

#### Artificial Neural Network Models
- **CANN Neo-Hookean**: Neural network approximation of Neo-Hookean behavior
- **CANN Holzapfel-Ogden**: Neural network approximation of Holzapfel-Ogden behavior

#### Volumetric Penalty Models
- **Quadratic**: Simple quadratic volumetric penalty
- **Simo-Taylor 91**: Simo-Taylor volumetric penalty model
- **Miehe 94**: Miehe volumetric penalty model


### Adding a New Material Model

To add a new material model for testing:

#### 1. Create Header File (`test_material_newmodel.h`)
```cpp
#ifndef TEST_MATERIAL_NEWMODEL_H
#define TEST_MATERIAL_NEWMODEL_H

#include "test_material_common.h"

// Parameter class
class NewModelParams : public MatParams {
public:
double param1, param2;
// Constructors...
};

// Test material class
class TestNewModel : public TestMaterialModel {
public:
NewModelParams params;

TestNewModel(const NewModelParams &params_) :
TestMaterialModel(consts::ConstitutiveModelType::stIso_NewModel,
consts::ConstitutiveModelType::stVol_ST91),
params(params_) {
// Set parameters for svMultiPhysics
}

void printMaterialParameters() override {
// Print parameters
}

double computeStrainEnergy(const Array<double> &F) override {
// Compute strain energy density
}
};

#endif
```

#### 2. Create Source File (`test_material_newmodel.cpp`)
```cpp
#include "test_material_newmodel.h"

class NewModelTest : public MaterialTestFixture {
protected:
NewModelParams params;
TestNewModel* TestNM;

void SetUp() override {
MaterialTestFixture::SetUp();
// Set up parameters
TestNM = new TestNewModel(params);
}

void TearDown() override {
delete TestNM;
}
};

// Test cases
TEST_F(NewModelTest, TestPK2StressIdentityF) {
// Test implementation
}
```


#### 3. Automatic Discovery of Test Files
The CMakeLists.txt automatically finds all `.cpp` files under `unitTests/`, so no build configuration changes are needed.

Loading
Loading