-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update loops to use jax calls and JIT some functions #27
Draft
chahak13
wants to merge
21
commits into
geoelements:main
Choose a base branch
from
chahak13:jax_apply_loops
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0880975
Remove extra example files
chahak13 3e309e0
Restructure code and add materials subdir
chahak13 8b4f1c0
Pass `particles` as arg to compute stress
chahak13 763af13
Add Newtonian material
chahak13 6120e44
Convert list loops to tree_map calls and jit funcs
chahak13 0055007
Run benchmark on cpu
chahak13 f285088
Temp commit: To be squashed
chahak13 3518368
Make Nodes as state
chahak13 25289e7
Working nonfrozen node state
chahak13 00f9822
Working frozen Nodestate
chahak13 28e7bff
Working nonfrozen particle state
chahak13 4158e11
Working frozen particle state
chahak13 3d0e43e
Reset node state in scheme and separate bc apply
chahak13 f6e1880
Return changed element arrays, not new state
chahak13 5f3b5f7
Working on completely stateless design
chahak13 09bd261
Working uniaxial stress and nodal forces benchmark
chahak13 a07cadf
Broken traction
chahak13 b4b2e38
Update tests
chahak13 1034d4f
Change loops to scan and add optim example
chahak13 03f112c
Update optim file
chahak13 fcec796
Add uniaxial stress optim example plot
chahak13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,5 @@ | ||
from importlib.metadata import version | ||
from pathlib import Path | ||
|
||
import diffmpm.writers as writers | ||
from diffmpm.io import Config | ||
from diffmpm.solver import MPMExplicit | ||
|
||
__all__ = ["MPM", "__version__"] | ||
__all__ = ["__version__"] | ||
|
||
__version__ = version("diffmpm") | ||
|
||
|
||
class MPM: | ||
def __init__(self, filepath): | ||
self._config = Config(filepath) | ||
mesh = self._config.parse() | ||
out_dir = Path(self._config.parsed_config["output"]["folder"]).joinpath( | ||
self._config.parsed_config["meta"]["title"], | ||
) | ||
|
||
write_format = self._config.parsed_config["output"].get("format", None) | ||
if write_format is None or write_format.lower() == "none": | ||
writer_func = None | ||
elif write_format == "npz": | ||
writer_func = writers.NPZWriter().write | ||
else: | ||
raise ValueError(f"Specified output format not supported: {write_format}") | ||
|
||
if self._config.parsed_config["meta"]["type"] == "MPMExplicit": | ||
self.solver = MPMExplicit( | ||
mesh, | ||
self._config.parsed_config["meta"]["dt"], | ||
velocity_update=self._config.parsed_config["meta"]["velocity_update"], | ||
sim_steps=self._config.parsed_config["meta"]["nsteps"], | ||
out_steps=self._config.parsed_config["output"]["step_frequency"], | ||
out_dir=out_dir, | ||
writer_func=writer_func, | ||
) | ||
else: | ||
raise ValueError("Wrong type of solver specified.") | ||
|
||
def solve(self): | ||
"""Solve the MPM simulation using JIT solver.""" | ||
arrays = self.solver.solve_jit( | ||
self._config.parsed_config["external_loading"]["gravity"], | ||
) | ||
return arrays |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import click | ||
|
||
from diffmpm import MPM | ||
from diffmpm.mpm import MPM | ||
|
||
|
||
@click.command() # type: ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be vel in the docstring or obj in the function, same issue with all the functions.