Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

joss-dev #21

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
- PETSc dependencies: `parmetis`, `scotch`, `suitesparse`, `superlu_dist`, `ml`, `hypre`
- (optional): `gmsh`, `mshr`, `jupyter`


## Recommended installation using Anaconda
### Installation with pip
1. Create an environment with `FEniCS` and appropriate dependencies and activate environment
```
conda create -n soupy -c conda-forge fenics==2019.1.0 matplotlib scipy jupyter
conda create -n soupy -c conda-forge python=3.11 fenics==2019.1.0 petsc4py==3.19 matplotlib scipy jupyter
conda activate soupy
```

Expand All @@ -40,7 +39,7 @@ Examples in the `applications` directory can now be run. We refer to the full `F
### Installation for developers
1. Create an environment with `FEniCS` with appropriate dependencies
```
conda create -n soupy -c conda-forge fenics==2019.1.0 matplotlib scipy jupyter
conda create -n soupy -c conda-forge python=3.11 fenics==2019.1.0 petsc4py==3.19 matplotlib scipy jupyter
```

2. Clone the `hIPPYlib` [repository](https://github.com/hippylib/hippylib).
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperelasticity/driver_hyperelasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
plt.savefig("%s/u_soft.png" %(save_dir))

plt.figure()
ax = dl.plot(hp.vector2Function(x[soupy.CONTROL], Vh[soupy.CONTROL]))
ax = dl.plot(hp.vector2Function(x[soupy.CONTROL], Vh[soupy.CONTROL]), vmin=0.0, vmax=1.0, extend='max')
plt.colorbar(ax)
plt.title("Optimal design")
plt.savefig("%s/z_opt.png" %(save_dir))
Expand Down
31 changes: 15 additions & 16 deletions examples/hyperelasticity/hyperelasticityControlPDE.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(self, Vh, varf_handler, bc, bc0, load_steps=[1.0], max_newton_iter=
self.max_newton_iter_increment = max_newton_iter_increment
self.backtrack = backtrack

default_solver_parameters = {'newton_solver': {'linear_solver' : 'lu', 'maximum_iterations': self.max_newton_iter}}
default_solver_parameters = {'newton_solver': {'linear_solver' : 'lu', 'maximum_iterations': self.max_newton_iter, 'error_on_nonconvergence' : False}}
self.default_newton_solver = soupy.NonlinearVariationalSolver(default_solver_parameters)

self.backtrack_newton_solver = soupy.NewtonBacktrackSolver()
Expand All @@ -141,25 +141,24 @@ def solveFwd(self, state, x):
Do load increments using backtracking newton if full solve fails
"""
self.n_calls["forward"] += 1
try:
print("Process %d: Try immediate solve" %(MPI.COMM_WORLD.Get_rank()))
# Make functions
u = hp.vector2Function(x[soupy.STATE], self.Vh[soupy.STATE])
m = hp.vector2Function(x[soupy.PARAMETER], self.Vh[soupy.PARAMETER])
p = dl.TestFunction(self.Vh[soupy.ADJOINT])
z = hp.vector2Function(x[soupy.CONTROL], self.Vh[soupy.CONTROL])
print("Process %d: Try immediate solve" %(MPI.COMM_WORLD.Get_rank()))
# Make functions
u = hp.vector2Function(x[soupy.STATE], self.Vh[soupy.STATE])
m = hp.vector2Function(x[soupy.PARAMETER], self.Vh[soupy.PARAMETER])
p = dl.TestFunction(self.Vh[soupy.ADJOINT])
z = hp.vector2Function(x[soupy.CONTROL], self.Vh[soupy.CONTROL])

# Define full nonlinear problem
res_form = self.varf_handler(u, m, p, z)
jacobian_form = dl.derivative(res_form, u)
# Define full nonlinear problem
res_form = self.varf_handler(u, m, p, z)
jacobian_form = dl.derivative(res_form, u)

num_iters, converged = self.default_newton_solver.solve(res_form, u, self.bc, jacobian_form)
self.n_linear_solves += num_iters
num_iters, converged = self.default_newton_solver.solve(res_form, u, self.bc, jacobian_form)
self.n_linear_solves += num_iters

if converged:
print("Process %d: Immediate solve succeeded" %(MPI.COMM_WORLD.Get_rank()))
if converged:
print("Process %d: Immediate solve succeeded" %(MPI.COMM_WORLD.Get_rank()))

except:
else:
print("Process %d: Increment load instead starting form zero with backtracking" %(MPI.COMM_WORLD.Get_rank()))

# Start with zero initial guess
Expand Down
2 changes: 1 addition & 1 deletion paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors:
- name: Umberto Villa
affiliation: 1
- name: Omar Ghattas
affiliation: "1 3"
affiliation: "1, 3"
affiliations:
- name: Oden Institute for Computational Engineering and Sciences, The University of Texas at Austin, USA
index: 1
Expand Down
Loading