Skip to content

Commit d3ff337

Browse files
authored
Merge pull request #135 from DataAnalyticsEngineering/FANS-v0.6.2
2 parents edc8ede + 7342f86 commit d3ff337

13 files changed

Lines changed: 9023 additions & 8056 deletions

File tree

.github/workflows/build_and_test.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v6
3434

3535
- name: Set up pixi
36-
uses: prefix-dev/setup-pixi@v0.9.3
36+
uses: prefix-dev/setup-pixi@v0.9.4
3737
with:
3838
environments: dashboard
3939

@@ -46,17 +46,17 @@ jobs:
4646
cmake --version
4747
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
4848
49-
- uses: actions/upload-artifact@v5
49+
- uses: actions/upload-artifact@v7
5050
if: failure()
5151
with:
5252
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CMakeCache
5353
path: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt
54-
- uses: actions/upload-artifact@v5
54+
- uses: actions/upload-artifact@v7
5555
if: failure()
5656
with:
5757
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CMakeLogs
5858
path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log'
59-
- uses: actions/upload-artifact@v5
59+
- uses: actions/upload-artifact@v7
6060
if: failure()
6161
with:
6262
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CompileCommands
@@ -75,7 +75,7 @@ jobs:
7575
run: |
7676
su -c "ctest" ${{ env.FANS_MPI_USER }}
7777
78-
- uses: actions/upload-artifact@v5
78+
- uses: actions/upload-artifact@v7
7979
if: failure()
8080
with:
8181
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CTest logs
@@ -87,7 +87,7 @@ jobs:
8787
- name: Run pytest checks on HDF5 output
8888
run: pixi run -e dashboard pytest
8989

90-
- uses: actions/upload-artifact@v5
90+
- uses: actions/upload-artifact@v7
9191
if: failure()
9292
with:
9393
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} PyTest logs

.github/workflows/docker.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515
uses: actions/checkout@v6
1616

1717
- name: Set up QEMU
18-
uses: docker/setup-qemu-action@v3
18+
uses: docker/setup-qemu-action@v4
1919

2020
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@v3
21+
uses: docker/setup-buildx-action@v4
2222

2323
- name: Login to DockerHub
24-
uses: docker/login-action@v3
24+
uses: docker/login-action@v4
2525
with:
2626
username: ${{ secrets.DOCKERHUB_USERNAME }}
2727
password: ${{ secrets.DOCKERHUB_TOKEN }}
2828

2929
- name: Build and push fans-ci image
30-
uses: docker/build-push-action@v6
30+
uses: docker/build-push-action@v7
3131
with:
3232
context: ${{ github.workspace }}
3333
file: docker/Dockerfile
@@ -42,7 +42,7 @@ jobs:
4242
build-args: UBUNTU_VERSION=${{ matrix.ubuntu-version }}
4343

4444
- name: Build and push fans-dev image
45-
uses: docker/build-push-action@v6
45+
uses: docker/build-push-action@v7
4646
with:
4747
context: ${{ github.workspace }}
4848
file: docker/Dockerfile

.github/workflows/pixi_build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ jobs:
2323
uses: actions/checkout@v6
2424

2525
- name: Set up pixi
26-
uses: prefix-dev/setup-pixi@v0.9.3
26+
uses: prefix-dev/setup-pixi@v0.9.4
2727
with:
2828
environments: default
2929

3030
- name: Run pytest checks on HDF5 output
3131
run: pixi run test
3232

3333
- name: Upload test logs
34-
uses: actions/upload-artifact@v5
34+
uses: actions/upload-artifact@v7
3535
with:
3636
name: ${{ matrix.os }} test-logs
3737
path: test/output/*.log
3838

39-
- uses: actions/upload-artifact@v5
39+
- uses: actions/upload-artifact@v7
4040
if: failure()
4141
with:
4242
name: ${{ matrix.os }} PyTest logs

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.2
4+
5+
- Fix bug demanding a leading slash in the datasetname and exiting ungracefully [#123](https://github.com/DataAnalyticsEngineering/FANS/pull/123)
6+
37
## v0.6.1
48

59
- Adds support to write integration point data to disk [#117](https://github.com/DataAnalyticsEngineering/FANS/pull/117)

CMakeLists.txt

Lines changed: 1 addition & 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.1
8+
VERSION 0.6.2
99
LANGUAGES C CXX
1010
)
1111

include/reader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Reader {
3030
json materialProperties;
3131
double TOL;
3232
json errorParameters;
33+
int ls_max_iter{5};
34+
double ls_tol{1e-2};
35+
bool extrapolate_displacement{true};
3336
json microstructure;
3437
int n_it;
3538
vector<LoadCase> load_cases;

include/solver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ void Solver<howmany, n_str>::postprocess(Reader &reader, int load_idx, int time_
702702
}
703703
reader.writeData("homogenized_tangent", load_idx, time_idx, homogenized_tangent.data(), dims, 2);
704704
}
705-
extrapolateDisplacement(); // prepare v_u for next time step
706705
}
707706

708707
template <int howmany, int n_str>

include/solverCG.h

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SolverCG : public Solver<howmany, n_str> {
2323
RealArray s_real;
2424
RealArray d_real;
2525
RealArray rnew_real;
26+
double alpha_warm{0.1};
2627

2728
void internalSolve();
2829
void LineSearchSecant();
@@ -64,6 +65,7 @@ void SolverCG<howmany, n_str>::internalSolve()
6465
printf("\n# Start FANS - Conjugate Gradient Solver \n");
6566

6667
bool islinear = this->matmanager->all_linear;
68+
alpha_warm = 0.1;
6769

6870
s_real.setZero();
6971
d_real.setZero();
@@ -117,33 +119,44 @@ void SolverCG<howmany, n_str>::internalSolve()
117119
template <int howmany, int n_str>
118120
void SolverCG<howmany, n_str>::LineSearchSecant()
119121
{
120-
double err = 10.0;
121-
int MaxIter = 5;
122-
double tol = 1e-2;
123-
int _iter = 0;
124-
double alpha_new = 0.0001;
125-
double alpha_old = 0;
126-
127-
double r1pd;
128-
double rpd = dotProduct(v_r_real, d_real);
122+
double err = 10.0;
123+
const int MaxIter = this->reader.ls_max_iter;
124+
const double tol = this->reader.ls_tol;
125+
int _iter = 0;
126+
double alpha_prev = 0.0;
127+
double alpha_curr = alpha_warm;
129128

130-
while (((_iter < MaxIter) && (err > tol))) {
129+
double rpd = dotProduct(v_r_real, d_real);
130+
v_u_real += d_real * alpha_curr;
131+
this->updateMixedBC();
132+
this->template compute_residual<0>(rnew_real, v_u_real);
133+
double r1pd = dotProduct(rnew_real, d_real);
134+
135+
double denom, alpha_next;
136+
while (_iter < MaxIter && err > tol) {
137+
denom = r1pd - rpd;
138+
if (fabs(denom) < 1e-14 * (fabs(r1pd) + fabs(rpd)))
139+
break;
140+
141+
alpha_next = alpha_curr - r1pd * (alpha_curr - alpha_prev) / denom;
142+
if (alpha_next <= 0.0)
143+
alpha_next = 0.5 * (alpha_prev + alpha_curr);
144+
err = fabs(alpha_next - alpha_curr);
145+
146+
v_u_real += d_real * (alpha_next - alpha_curr);
147+
alpha_prev = alpha_curr;
148+
rpd = r1pd;
149+
alpha_curr = alpha_next;
150+
_iter++;
131151

132-
v_u_real += d_real * (alpha_new - alpha_old);
133152
this->updateMixedBC();
134153
this->template compute_residual<0>(rnew_real, v_u_real);
135154
r1pd = dotProduct(rnew_real, d_real);
136-
137-
alpha_old = alpha_new;
138-
alpha_new *= rpd / (rpd - r1pd);
139-
140-
err = fabs(alpha_new - alpha_old);
141-
_iter++;
142155
}
143-
v_u_real += d_real * (alpha_new - alpha_old);
144-
v_r_real = rnew_real;
156+
alpha_warm = (_iter == MaxIter && err > tol) ? 0.1 : alpha_curr;
157+
v_r_real = rnew_real;
145158
if (this->world_rank == 0)
146-
printf("line search iter %i, alpha %f - error %e - ", _iter, alpha_new, err);
159+
printf("line search iter %i, alpha %f - error %e - ", _iter, alpha_curr, err);
147160
}
148161

149162
template <int howmany, int n_str>

0 commit comments

Comments
 (0)