Skip to content
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
11 changes: 9 additions & 2 deletions gel/gel.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def __init__(self,
tola=1e-10,
tolr=1e-9,
traction=None,
u_init=None,
formulation_kwargs=dict(),
**kwargs
):
Expand Down Expand Up @@ -267,10 +268,12 @@ def __init__(self,
be in 1st order Lagrange space, will ignore DoFs outside of
surface. "zero" will automatically contruct a 0 traction
function
* `u_init`: str path to full-shape .xdmf file with initial
displacements
* `formulation_kwargs`: dict of additional kwargs to the
material model formulation (if applicable) implemented in
`gel.mechanics`
* `kwargs`: dict of kwargs to the the geometry, for instance
* `kwargs`: dict of kwargs to the geometry, for instance
the arguments to `gel.geometry.Geometry`
"""
# Validate, get geometry
Expand All @@ -285,10 +288,14 @@ def __init__(self,
"""Corresponding object of type `gel.geometry.Geometry`"""

# Initialize displacements, kinematic quantities
self.kinematics = Kinematics(self.geo)
self.kinematics = None
"""Object of type `gel.kinematics.Kinematics` with displacement
information
"""
if u_init is None:
self.kinematics = Kinematics(self.geo)
else:
self.kinematics = kinematics_from_file(self.geo, u_init)

# Prepare modulus control variable
self.ctl = create_mod_repr(self.geo, mod_repr_init)
Expand Down
8 changes: 8 additions & 0 deletions gel/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_common_parser(*args, **kwargs):
-p PRECONDITIONER
--bci CELL_SURF_MESH
--bco OUTER_SURF_MESH
--u-init U_INIT
```
"""
if "formatter_class" not in kwargs:
Expand Down Expand Up @@ -111,6 +112,13 @@ def get_common_parser(*args, **kwargs):
default=None,
help="filename of meshio-compatible mesh with outer nodes and u"
)
parser.add_argument(
"--u-init",
type=str,
metavar="U_INIT",
default=None,
help="filename of full-shape .xdmf file with initial displacements"
)

return parser

Expand Down
14 changes: 11 additions & 3 deletions gel/scripts/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"upper_bound",
"Inner Mesh",
"Outer Mesh",
"u_init",
"time"
]
"""Names of columns in `table.csv`"""
Expand Down Expand Up @@ -77,7 +78,8 @@ def run_experiments(args):
args.b[0],
args.b[1],
args.bci,
args.bco
args.bco,
args.u_init
)

logger.info(f"Beginning experiment with arguments {exp_info}.")
Expand Down Expand Up @@ -109,7 +111,8 @@ def output_single_forward_result(
lower_bound,
upper_bound,
bci,
bco
bco,
u_init
):
r"""Runs a single forward model experiment, writes subdirectory and
logs progress.
Expand Down Expand Up @@ -137,6 +140,8 @@ def output_single_forward_result(
`gel.geometry.Geometry` for details
* `bco`: str path to .vtk file with outer BC info, see
`gel.geometry.Geometry` for details
* `u_init`: str path to full-shape .xdmf file with initial
displacements

Side-effects: writes many files in new subdirectory to
`results_dir`, see intro to `gel.scripts.forward`
Expand All @@ -163,7 +168,8 @@ def output_single_forward_result(
lower_bound,
upper_bound,
bci,
bco
bco,
u_init
)

# Setup logging
Expand All @@ -183,6 +189,7 @@ def output_single_forward_result(
logger.info(f"Using load steps: {load_steps}")
logger.info(f"Override inner BC: {bci}")
logger.info(f"Override outer BC: {bco}")
logger.info(f"Initial displacements: {u_init}")

# Timer start
timer = ExperimentTimer()
Expand All @@ -208,6 +215,7 @@ def output_single_forward_result(
tola=tola,
tolr=tolr,
traction=traction,
u_init=u_init,
formulation_kwargs=formulation_kwargs,
**addn_args
)
Expand Down
11 changes: 9 additions & 2 deletions gel/scripts/inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _expand_obj_info(exp_info):
"bci",
"bco",
"mu_ff",
"u_init",
"outcome",
"pure_obj",
"reg",
Expand Down Expand Up @@ -143,7 +144,8 @@ def main(args):
args.opt_backend,
args.bci,
args.bco,
args.mu
args.mu,
args.u_init
)

logger.info(f"Beginning experiment with arguments {exp_info}.")
Expand Down Expand Up @@ -208,7 +210,8 @@ def gel_inverse(
optimizer_backend="scipy",
bci=None,
bco=None,
mu=108.0
mu=108.0,
u_init=None
):
r"""Runs the inverse model, writes subdirectory and logs progress.

Expand Down Expand Up @@ -248,6 +251,8 @@ def gel_inverse(
* `bco`: str path to .vtk file with outer BC info, see
`gel.geometry.Geometry` for details
* `mu`: float far-field shear modulus from rheometry
* `u_init`: str path to full-shape .xdmf file with initial
displacements

Side-effects: writes many files in new subdirectory to
`results_dir`, see intro to `gel.scripts.inverse`
Expand Down Expand Up @@ -318,6 +323,7 @@ def gel_inverse(
logger.info(f"Override inner BC: {bci}")
logger.info(f"Override outer BC: {bco}")
logger.info(f"Far field modulus: {mu}")
logger.info(f"Initial displacements: {u_init}")
objective_info.log_info(logger)

# RESET TAPE
Expand Down Expand Up @@ -351,6 +357,7 @@ def gel_inverse(
data_directory=cell_data_dir,
restrict_ctl_dofs_to_veh=restrict_ctl_dofs_to_veh,
pc=preconditioner,
u_init=u_init,
formulation_kwargs=formulation_kwargs,
**addn_args
)
Expand Down
Loading