Skip to content

Commit edc8ede

Browse files
authored
Merge pull request #120 from DataAnalyticsEngineering/FANS-v0.6.1
2 parents 9d7c94f + 6072710 commit edc8ede

File tree

18 files changed

+498
-94
lines changed

18 files changed

+498
-94
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
UBUNTU_VERSION: [noble, jammy]
3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v5
33+
uses: actions/checkout@v6
3434

3535
- name: Set up pixi
3636
uses: prefix-dev/[email protected]

.github/workflows/docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v5
15+
uses: actions/checkout@v6
1616

1717
- name: Set up QEMU
1818
uses: docker/setup-qemu-action@v3

.github/workflows/pixi_build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
os: [ubuntu-latest, macos-latest]
2121
steps:
2222
- name: Checkout code
23-
uses: actions/checkout@v5
23+
uses: actions/checkout@v6
2424

2525
- name: Set up pixi
2626
uses: prefix-dev/[email protected]

.github/workflows/run-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out repository
16-
uses: actions/checkout@v5
16+
uses: actions/checkout@v6
1717
- name: Create markdownlint config
1818
run: |
1919
cat > .markdownlint.json << 'EOF'
@@ -35,7 +35,7 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Check out repository
38-
uses: actions/checkout@v5
38+
uses: actions/checkout@v6
3939
- name: Create markdown-link-check config
4040
run: |
4141
cat > .markdown-link-check-config.json << 'EOF'
@@ -59,7 +59,7 @@ jobs:
5959
name: pre-commit checks
6060
runs-on: ubuntu-latest
6161
steps:
62-
- uses: actions/checkout@v5
62+
- uses: actions/checkout@v6
6363
- name: Setup python
6464
uses: actions/setup-python@v6
6565
with:

.github/workflows/test_pyfans.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323

2424
- name: Checkout repository
25-
uses: actions/checkout@v5
25+
uses: actions/checkout@v6
2626

2727
- name: Generate build directory
2828
run: mkdir -p ${{ env.FANS_BUILD_DIR }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# FANS Changelog
22

3+
## v0.6.1
4+
5+
- Adds support to write integration point data to disk [#117](https://github.com/DataAnalyticsEngineering/FANS/pull/117)
6+
37
## v0.6.0
48

59
- Introduce MaterialManager abstraction class to handle multiple material models within the microstructure [#115](https://github.com/DataAnalyticsEngineering/FANS/pull/115)

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.21)
55
# ##############################################################################
66

77
project(FANS
8-
VERSION 0.6.0
8+
VERSION 0.6.1
99
LANGUAGES C CXX
1010
)
1111

@@ -165,6 +165,7 @@ set_property(TARGET FANS_FANS PROPERTY PUBLIC_HEADER
165165
include/material_models/LinearElastic.h
166166
include/material_models/PseudoPlastic.h
167167
include/material_models/J2Plasticity.h
168+
include/material_models/J2PlasticityNew.h
168169

169170
include/material_models/SaintVenantKirchhoff.h
170171
include/material_models/CompressibleNeoHookean.h

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ To get started immediately, we include ready to use example [input files](test/i
6262

6363
FANS requires the following dependencies:
6464

65-
| Dependency | Purpose | |
66-
|------------|---------|------------------|
65+
| Dependency | Purpose | |
66+
| ------------ | --------- | ------------------ |
6767
| **C++ Compiler** | (GCC, Clang, etc.) | C++17 or newer |
6868
| **CMake** | Build system | ≥ 3.21 |
6969
| **MPI** | Parallel computing | (OpenMPI, MPICH, Intel MPI) |
@@ -186,7 +186,7 @@ cd ../test
186186
**Build options:**
187187

188188
| CMake Option | Description | Default |
189-
|--------------|-------------|---------|
189+
| -------------- | ------------- | --------- |
190190
| `CMAKE_BUILD_TYPE` | Build type: `Debug`, `Release`, `RelWithDebInfo` | `NONE` |
191191
| `CMAKE_INTERPROCEDURAL_OPTIMIZATION` | Enable link-time optimization (LTO) | `ON` (if supported) |
192192
| `FANS_BUILD_STATIC` | Build static library | `OFF` |
@@ -359,9 +359,10 @@ FANS also supports mixed boundary conditions, where some components can be strai
359359
- `microstructure`: The original microstructure data.
360360
- `displacement`: The displacement field (for mechanical problems) and temperature field (for thermal problems) at each voxel in the microstructure.
361361
- `displacement_fluctuation`: The periodic displacement fluctuation field (for mechanical problems) and periodic temperature fluctuation field (for thermal problems at each voxel in the microstructure).
362-
- `stress` and `strain`: The stress and strain fields at each voxel in the microstructure.
362+
- `stress` and `strain`: The stress and strain fields (element-averaged) at each voxel in the microstructure.
363+
- `stress_gp` and `strain_gp`: The stress and strain fields at all Gauss points within each element.
363364

364-
- Additional material model-specific results can be included depending on the problem type and material model.
365+
- Additional material model-specific results can be included depending on the problem type and material model. For plasticity models, internal variables such as `plastic_strain`, `isotropic_hardening_variable`, etc., are available. Append `_gp` to these field names (e.g., `plastic_strain_gp`) to output data at all Gauss points.
365366

366367
## Acknowledgements
367368

include/material_models/GBDiffusion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class GBDiffusion : public ThermalModel, public LinearModel<1, 3> {
179179
GBnormals_field[element_idx * 3 + 2] = GBnormals[3 * mat_index + 2];
180180
}
181181
}
182-
reader.writeSlab("GBnormals", load_idx, time_idx, GBnormals_field, 3);
182+
reader.writeSlab("GBnormals", load_idx, time_idx, GBnormals_field, {3});
183183
FANS_free(GBnormals_field);
184184
}
185185
}

include/material_models/J2Plasticity.h

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,21 +244,81 @@ class J2ViscoPlastic_NonLinearIsotropicHardening : public J2Plasticity {
244244

245245
inline void J2Plasticity::postprocess(Solver<3, 6> &solver, Reader &reader, int load_idx, int time_idx)
246246
{
247-
int n_str = 6; // The plastic strain and stress vectors have 6 components each
248-
VectorXd mean_plastic_strain = VectorXd::Zero(solver.local_n0 * solver.n_y * solver.n_z * n_str);
249-
VectorXd mean_isotropic_hardening_variable = VectorXd::Zero(solver.local_n0 * solver.n_y * solver.n_z);
250-
VectorXd mean_kinematic_hardening_variable = VectorXd::Zero(solver.local_n0 * solver.n_y * solver.n_z * n_str);
247+
int n_str = 6;
248+
int n_gp = plasticStrain_t[0].cols();
249+
250+
// Check what user requested
251+
auto &results = reader.resultsToWrite;
252+
bool need_plastic_strain = std::find(results.begin(), results.end(), "plastic_strain") != results.end();
253+
bool need_plastic_strain_gp = std::find(results.begin(), results.end(), "plastic_strain_gp") != results.end();
254+
bool need_iso_hard = std::find(results.begin(), results.end(), "isotropic_hardening_variable") != results.end();
255+
bool need_iso_hard_gp = std::find(results.begin(), results.end(), "isotropic_hardening_variable_gp") != results.end();
256+
bool need_kin_hard = std::find(results.begin(), results.end(), "kinematic_hardening_variable") != results.end();
257+
bool need_kin_hard_gp = std::find(results.begin(), results.end(), "kinematic_hardening_variable_gp") != results.end();
258+
259+
// Conditional allocation
260+
VectorXd *plastic_strain_elem = need_plastic_strain ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z * n_str) : nullptr;
261+
VectorXd *plastic_strain_gp = need_plastic_strain_gp ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z * n_gp * n_str) : nullptr;
262+
VectorXd *iso_hard_elem = need_iso_hard ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z) : nullptr;
263+
VectorXd *iso_hard_gp = need_iso_hard_gp ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z * n_gp) : nullptr;
264+
VectorXd *kin_hard_elem = need_kin_hard ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z * n_str) : nullptr;
265+
VectorXd *kin_hard_gp = need_kin_hard_gp ? new VectorXd(solver.local_n0 * solver.n_y * solver.n_z * n_gp * n_str) : nullptr;
251266

252-
// Compute the mean values for each element
253267
for (ptrdiff_t elem_idx = 0; elem_idx < solver.local_n0 * solver.n_y * solver.n_z; ++elem_idx) {
254-
mean_plastic_strain.segment(n_str * elem_idx, n_str) = plasticStrain_t[elem_idx].rowwise().mean();
255-
mean_isotropic_hardening_variable(elem_idx) = psi_t[elem_idx].mean();
256-
mean_kinematic_hardening_variable.segment(n_str * elem_idx, n_str) = psi_bar_t[elem_idx].rowwise().mean();
268+
// Element averages
269+
if (need_plastic_strain) {
270+
(*plastic_strain_elem).segment(n_str * elem_idx, n_str) = plasticStrain_t[elem_idx].rowwise().mean();
271+
}
272+
if (need_iso_hard) {
273+
(*iso_hard_elem)(elem_idx) = psi_t[elem_idx].mean();
274+
}
275+
if (need_kin_hard) {
276+
(*kin_hard_elem).segment(n_str * elem_idx, n_str) = psi_bar_t[elem_idx].rowwise().mean();
277+
}
278+
279+
// All Gauss point data
280+
if (need_plastic_strain_gp || need_iso_hard_gp || need_kin_hard_gp) {
281+
for (int gp = 0; gp < n_gp; ++gp) {
282+
if (need_plastic_strain_gp) {
283+
(*plastic_strain_gp).segment(n_str * n_gp * elem_idx + n_str * gp, n_str) = plasticStrain_t[elem_idx].col(gp);
284+
}
285+
if (need_iso_hard_gp) {
286+
(*iso_hard_gp)(n_gp *elem_idx + gp) = psi_t[elem_idx](gp);
287+
}
288+
if (need_kin_hard_gp) {
289+
(*kin_hard_gp).segment(n_str * n_gp * elem_idx + n_str * gp, n_str) = psi_bar_t[elem_idx].col(gp);
290+
}
291+
}
292+
}
257293
}
258294

259-
reader.writeSlab("plastic_strain", load_idx, time_idx, mean_plastic_strain.data(), n_str);
260-
reader.writeSlab("isotropic_hardening_variable", load_idx, time_idx, mean_isotropic_hardening_variable.data(), 1);
261-
reader.writeSlab("kinematic_hardening_variable", load_idx, time_idx, mean_kinematic_hardening_variable.data(), n_str);
295+
// Write only what was requested
296+
if (need_plastic_strain)
297+
reader.writeSlab("plastic_strain", load_idx, time_idx, plastic_strain_elem->data(), {n_str});
298+
if (need_plastic_strain_gp)
299+
reader.writeSlab("plastic_strain_gp", load_idx, time_idx, plastic_strain_gp->data(), {n_gp, n_str});
300+
if (need_iso_hard)
301+
reader.writeSlab("isotropic_hardening_variable", load_idx, time_idx, iso_hard_elem->data(), {1});
302+
if (need_iso_hard_gp)
303+
reader.writeSlab("isotropic_hardening_variable_gp", load_idx, time_idx, iso_hard_gp->data(), {n_gp});
304+
if (need_kin_hard)
305+
reader.writeSlab("kinematic_hardening_variable", load_idx, time_idx, kin_hard_elem->data(), {n_str});
306+
if (need_kin_hard_gp)
307+
reader.writeSlab("kinematic_hardening_variable_gp", load_idx, time_idx, kin_hard_gp->data(), {n_gp, n_str});
308+
309+
// Cleanup
310+
if (plastic_strain_elem)
311+
delete plastic_strain_elem;
312+
if (plastic_strain_gp)
313+
delete plastic_strain_gp;
314+
if (iso_hard_elem)
315+
delete iso_hard_elem;
316+
if (iso_hard_gp)
317+
delete iso_hard_gp;
318+
if (kin_hard_elem)
319+
delete kin_hard_elem;
320+
if (kin_hard_gp)
321+
delete kin_hard_gp;
262322
}
263323

264324
#endif // J2PLASTICITY_H

0 commit comments

Comments
 (0)