Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
kumiori committed Dec 6, 2024
1 parent 46edba5 commit 7820a15
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 241 deletions.
407 changes: 223 additions & 184 deletions playground/IDRIS-CAMPAING-HYDRA/scripts/1d-film-second-order-stab-kick.py

Large diffs are not rendered by default.

29 changes: 22 additions & 7 deletions playground/benchmark-umut-at2/vs_analytics_at2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,34 @@
import ufl
import yaml
from dolfinx.common import list_timings
from dolfinx.fem import (Constant, Function, assemble_scalar, dirichletbc,
form, locate_dofs_geometrical)
from dolfinx.fem import (
Constant,
Function,
assemble_scalar,
dirichletbc,
form,
locate_dofs_geometrical,
)
from dolfinx.io import XDMFFile
from mpi4py import MPI
from petsc4py import PETSc
from pyvista.plotting.utilities import xvfbimport basix.ufl
from pyvista.plotting.utilities import xvfb
import basix.ufl

from irrevolutions.algorithms.am import HybridSolver
from irrevolutions.algorithms.so import BifurcationSolver, StabilitySolver
from irrevolutions.utils import (ColorPrint, Visualization, _logger,
_write_history_data, history_data)
from irrevolutions.utils.plots import (plot_AMit_load, plot_energies,
plot_force_displacement)
from irrevolutions.utils import (
ColorPrint,
Visualization,
_logger,
_write_history_data,
history_data,
)
from irrevolutions.utils.plots import (
plot_AMit_load,
plot_energies,
plot_force_displacement,
)
from irrevolutions.utils.viz import plot_profile, plot_scalar

petsc4py.init(sys.argv)
Expand Down
35 changes: 25 additions & 10 deletions playground/benchmark-umut-at2/vs_analytics_at2_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,35 @@
import ufl
import yaml
from dolfinx.common import list_timings
from dolfinx.fem import (Constant, Function, assemble_scalar, form,
locate_dofs_geometrical)
from dolfinx.fem import (
Constant,
Function,
assemble_scalar,
form,
locate_dofs_geometrical,
)
from dolfinx.io import XDMFFile, gmshio
from mpi4py import MPI
from petsc4py import PETSc
from pyvista.plotting.utilities import xvfbimport basix.ufl
from pyvista.plotting.utilities import xvfb
import basix.ufl

from irrevolutions.algorithms.am import HybridSolver
from irrevolutions.algorithms.so import BifurcationSolver, StabilitySolver
from irrevolutions.meshes.primitives import mesh_bar_gmshapi
from irrevolutions.models import \
BrittleMembraneOverElasticFoundation as ThinFilm
from irrevolutions.utils import (ColorPrint, Visualization, _logger,
_write_history_data, history_data)
from irrevolutions.utils.plots import (plot_AMit_load, plot_energies,
plot_force_displacement)
from irrevolutions.models import BrittleMembraneOverElasticFoundation as ThinFilm
from irrevolutions.utils import (
ColorPrint,
Visualization,
_logger,
_write_history_data,
history_data,
)
from irrevolutions.utils.plots import (
plot_AMit_load,
plot_energies,
plot_force_displacement,
)
from irrevolutions.utils.viz import plot_profile, plot_scalar, plot_vector

petsc4py.init(sys.argv)
Expand Down Expand Up @@ -101,7 +114,9 @@ def run_computation(parameters, storage=None):
file.write_mesh(mesh)

# Functional Setting
element_u = basix.ufl.element("Lagrange", mesh.basix_cell(), degree=1, shape=(tdim,))
element_u = basix.ufl.element(
"Lagrange", mesh.basix_cell(), degree=1, shape=(tdim,)
)
element_alpha = basix.ufl.element("Lagrange", mesh.basix_cell(), degree=1)

V_u = dolfinx.fem.functionspace(mesh, element_u)
Expand Down
16 changes: 13 additions & 3 deletions src/irrevolutions/practice/pacman-cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@
import ufl
import yaml
from dolfinx.common import list_timings, timing
from dolfinx.fem import (Constant, Function, FunctionSpace, assemble_scalar,
dirichletbc, form, locate_dofs_topological, set_bc)
from dolfinx.fem import (
Constant,
Function,
FunctionSpace,
assemble_scalar,
dirichletbc,
form,
locate_dofs_topological,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio
from dolfinx.mesh import locate_entities_boundary

#
from mpi4py import MPI
from petsc4py import PETSc
from pyvista.plotting.utilities import xvfbimport basix.ufl
from pyvista.plotting.utilities import xvfb
import basix.ufl

sys.path.append("../")

Expand Down
13 changes: 10 additions & 3 deletions src/irrevolutions/practice/pacman_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@
import matplotlib.pyplot as plt
import pyvista
import yaml
from dolfinx.fem import (Function, FunctionSpace, dirichletbc,
locate_dofs_topological, set_bc)
from dolfinx.fem import (
Function,
FunctionSpace,
dirichletbc,
locate_dofs_topological,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio
from dolfinx.mesh import locate_entities_boundary
from pyvista.plotting.utilities import xvfbimport basix.ufl
from pyvista.plotting.utilities import xvfb
import basix.ufl

sys.path.append("../")


Expand Down
22 changes: 17 additions & 5 deletions src/irrevolutions/practice/thinfilm-bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,23 @@
import ufl
import yaml
from dolfinx.common import list_timings
from dolfinx.fem import (Constant, Function, FunctionSpace, assemble_scalar,
dirichletbc, form, locate_dofs_geometrical, set_bc)
from dolfinx.fem import (
Constant,
Function,
FunctionSpace,
assemble_scalar,
dirichletbc,
form,
locate_dofs_geometrical,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio

#
from mpi4py import MPI
from petsc4py import PETSc
from pyvista.plotting.utilities import xvfbimport basix.ufl
from pyvista.plotting.utilities import xvfb
import basix.ufl

sys.path.append("../")
# from meshes.pacman import mesh_pacman
Expand Down Expand Up @@ -131,7 +141,9 @@ def main(parameters, storage=None):
mesh, mts, fts = gmshio.model_to_mesh(gmsh_model, comm, model_rank, tdim)

# functional space
element_u = basix.ufl.element("Lagrange", mesh.basix_cell(), degree=1, shape=(tdim,))
element_u = basix.ufl.element(
"Lagrange", mesh.basix_cell(), degree=1, shape=(tdim,)
)
V_u = FunctionSpace(mesh, element_u)

element_alpha = basix.ufl.element("Lagrange", mesh.basix_cell(), degree=1)
Expand Down Expand Up @@ -469,7 +481,7 @@ def load_parameters(file_path):

if "--ell_e" in sys.argv:
parameters, signature = parameters_vs_elle(
parameters= base_parameters, elle=np.float(args.ell_e)
parameters=base_parameters, elle=np.float(args.ell_e)
)
_storage = (
f"output/parametric/thinfilm-bar/vs_ell_e/{base_signature}/{signature}"
Expand Down
26 changes: 18 additions & 8 deletions src/irrevolutions/practice/traction-AT1_cone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from utils.viz import plot_scalar, plot_vector
from pyvista.plotting.utilities import xvfbimport pyvista
from pyvista.plotting.utilities import xvfb
import pyvista
from utils.plots import plot_AMit_load, plot_force_displacement
import hashlib
from irrevolutions.utils import ColorPrint
Expand All @@ -24,8 +25,16 @@
import ufl
import yaml
from dolfinx.common import list_timings
from dolfinx.fem import (Constant, Function, FunctionSpace, assemble_scalar,
dirichletbc, form, locate_dofs_geometrical, set_bc)
from dolfinx.fem import (
Constant,
Function,
FunctionSpace,
assemble_scalar,
dirichletbc,
form,
locate_dofs_geometrical,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio
from mpi4py import MPI
from petsc4py import PETSc
Expand Down Expand Up @@ -100,7 +109,6 @@
mesh, mts, fts = gmshio.model_to_mesh(gmsh_model, comm, model_rank, tdim)



signature = hashlib.md5(str(parameters).encode("utf-8")).hexdigest()

if comm.rank == 0:
Expand Down Expand Up @@ -157,7 +165,9 @@
alpha_ub.interpolate(lambda x: np.ones_like(x[0]))

for f in [zero_u, zero_alpha, u_, alpha_lb, alpha_ub]:
f.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
f.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

bc_u_left = dirichletbc(np.array([0, 0], dtype=PETSc.ScalarType), dofs_u_left, V_u)

Expand Down Expand Up @@ -242,7 +252,9 @@
for i_t, t in enumerate(loads):
# for i_t, t in enumerate([0., .99, 1.0, 1.01]):
u_.interpolate(lambda x: (t * np.ones_like(x[0]), np.zeros_like(x[1])))
u_.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
u_.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

# update the lower bound
alpha.x.petsc_vec.copy(alpha_lb.x.petsc_vec)
Expand Down Expand Up @@ -367,8 +379,6 @@
plot_force_displacement(history_data, file=f"{prefix}/{_nameExp}_stress-load.pdf")




#
xvfb.start_xvfb(wait=0.05)
pyvista.OFF_SCREEN = True
Expand Down
26 changes: 18 additions & 8 deletions src/irrevolutions/practice/traction-AT1_first_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from utils.viz import plot_scalar, plot_vector
from pyvista.plotting.utilities import xvfbimport pyvista
from pyvista.plotting.utilities import xvfb
import pyvista
from utils.plots import plot_AMit_load, plot_force_displacement
import hashlib
from irrevolutions.utils import ColorPrint
Expand All @@ -24,8 +25,16 @@
import ufl
import yaml
from dolfinx.common import list_timings
from dolfinx.fem import (Constant, Function, FunctionSpace, assemble_scalar,
dirichletbc, form, locate_dofs_geometrical, set_bc)
from dolfinx.fem import (
Constant,
Function,
FunctionSpace,
assemble_scalar,
dirichletbc,
form,
locate_dofs_geometrical,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio
from mpi4py import MPI
from petsc4py import PETSc
Expand Down Expand Up @@ -103,7 +112,6 @@
mesh, mts, fts = gmshio.model_to_mesh(gmsh_model, comm, model_rank, tdim)



signature = hashlib.md5(str(parameters).encode("utf-8")).hexdigest()

if comm.rank == 0:
Expand Down Expand Up @@ -160,7 +168,9 @@
alpha_ub.interpolate(lambda x: np.ones_like(x[0]))

for f in [zero_u, zero_alpha, u_, alpha_lb, alpha_ub]:
f.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
f.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

bc_u_left = dirichletbc(np.array([0, 0], dtype=PETSc.ScalarType), dofs_u_left, V_u)

Expand Down Expand Up @@ -245,7 +255,9 @@
for i_t, t in enumerate(loads):
# for i_t, t in enumerate([0., .99, 1.0, 1.01]):
u_.interpolate(lambda x: (t * np.ones_like(x[0]), np.zeros_like(x[1])))
u_.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
u_.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

# update the lower bound
alpha.x.petsc_vec.copy(alpha_lb.x.petsc_vec)
Expand Down Expand Up @@ -362,8 +374,6 @@
plot_force_displacement(history_data, file=f"{prefix}/{_nameExp}_stress-load.pdf")




#
xvfb.start_xvfb(wait=0.05)
pyvista.OFF_SCREEN = True
Expand Down
24 changes: 18 additions & 6 deletions src/irrevolutions/practice/traction-AT2_cone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from utils.viz import plot_scalar, plot_vector
from pyvista.plotting.utilities import xvfbimport pyvista
from pyvista.plotting.utilities import xvfb
import pyvista
from utils.plots import plot_AMit_load, plot_force_displacement
import hashlib
from irrevolutions.utils import ColorPrint
Expand All @@ -22,8 +23,16 @@
import petsc4py
import ufl
import yaml
from dolfinx.fem import (Constant, Function, FunctionSpace, assemble_scalar,
dirichletbc, form, locate_dofs_geometrical, set_bc)
from dolfinx.fem import (
Constant,
Function,
FunctionSpace,
assemble_scalar,
dirichletbc,
form,
locate_dofs_geometrical,
set_bc,
)
from dolfinx.io import XDMFFile, gmshio
from mpi4py import MPI
from petsc4py import PETSc
Expand Down Expand Up @@ -134,7 +143,9 @@ def w(self, alpha):
alpha_ub.interpolate(lambda x: np.ones_like(x[0]))

for f in [zero_u, zero_alpha, u_, alpha_lb, alpha_ub]:
f.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
f.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

bc_u_left = dirichletbc(np.array([0, 0], dtype=PETSc.ScalarType), dofs_u_left, V_u)
bc_u_right = dirichletbc(u_, dofs_u_right)
Expand Down Expand Up @@ -203,7 +214,9 @@ def w(self, alpha):

for i_t, t in enumerate(loads):
u_.interpolate(lambda x: (t * np.ones_like(x[0]), np.zeros_like(x[1])))
u_.x.petsc_vec.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
u_.x.petsc_vec.ghostUpdate(
addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD
)

alpha.x.petsc_vec.copy(alpha_lb.x.petsc_vec)
alpha_lb.x.petsc_vec.ghostUpdate(
Expand Down Expand Up @@ -310,7 +323,6 @@ def w(self, alpha):
plot_force_displacement(history_data, file=f"{prefix}/{_nameExp}_stress-load.pdf")



xvfb.start_xvfb(wait=0.05)
pyvista.OFF_SCREEN = True

Expand Down
Loading

0 comments on commit 7820a15

Please sign in to comment.