-
Notifications
You must be signed in to change notification settings - Fork 16
feat(materials): add substepper for finite strain materials #32
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
Open
alexdummer
wants to merge
13
commits into
MAteRialMOdelingToolbox:next_v26.05
Choose a base branch
from
alexdummer:finite-strain-substepper-only
base: next_v26.05
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.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
314d371
add substepper for finite strain materials
alexdummer 7af2ce3
Update modules/core/MarmotFiniteStrainMechanicsCore/include/Marmot/Ma…
alexdummer e6b9171
Update modules/core/MarmotFiniteStrainMechanicsCore/include/Marmot/Ma…
alexdummer 79c404a
Update modules/core/MarmotMathCore/src/MarmotNumericalDifferentiation…
alexdummer 790ce78
Update modules/core/MarmotFiniteStrainMechanicsCore/include/Marmot/Ma…
alexdummer 54e7f59
Update examples/finite-strain-mp-solver/FiniteStrainJ2PlasticitySubst…
alexdummer f4e53d6
Update modules/core/MarmotFiniteStrainMechanicsCore/include/Marmot/Ma…
alexdummer 0707d8b
Update modules/core/MarmotFiniteStrainMechanicsCore/include/Marmot/Ma…
alexdummer 8f3a230
Update examples/finite-strain-mp-solver/FiniteStrainJ2PlasticitySubst…
alexdummer ca9f405
change to cmake
alexdummer c2a3ec6
move extended stress update to substepper class
alexdummer c4996dc
remove unused import and fix type
alexdummer 66cc149
Merge branch 'next_v26.05' into finite-strain-substepper-only
alexdummer 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
examples/finite-strain-mp-solver/FiniteStrainJ2PlasticitySubstepped/CMakeLists.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
| project(MarmotSolverExample LANGUAGES CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
|
||
| find_package(Python3 COMPONENTS Interpreter REQUIRED) | ||
|
|
||
| execute_process( | ||
| COMMAND "${Python3_EXECUTABLE}" -c "import sys; print(sys.prefix, end='')" | ||
| OUTPUT_VARIABLE PYTHON_PREFIX | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
|
|
||
| set(MARMOT_ROOT "${PYTHON_PREFIX}") | ||
| set(EIGEN_DIR "${PYTHON_PREFIX}/include/eigen3") | ||
| set(FASTOR_DIR "${PYTHON_PREFIX}/include/Fastor") | ||
|
|
||
| add_executable(solver_example example.cpp) | ||
|
|
||
| target_include_directories(solver_example PRIVATE | ||
| "${MARMOT_ROOT}/include" | ||
| "${EIGEN_DIR}" | ||
| "${FASTOR_DIR}" | ||
| ) | ||
|
|
||
| target_link_directories(solver_example PRIVATE "${MARMOT_ROOT}/lib") | ||
|
|
||
| target_link_libraries(solver_example PRIVATE Marmot) | ||
|
|
||
| target_compile_options(solver_example PRIVATE -Wall -Wextra -fPIC) | ||
|
|
||
| set_target_properties(solver_example PROPERTIES | ||
| BUILD_RPATH "${MARMOT_ROOT}/lib" | ||
| INSTALL_RPATH "${MARMOT_ROOT}/lib" | ||
| ) |
94 changes: 94 additions & 0 deletions
94
examples/finite-strain-mp-solver/FiniteStrainJ2PlasticitySubstepped/example.cpp
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #include "Marmot/MarmotFastorTensorBasics.h" | ||
| #include "Marmot/MarmotMaterialPointSolverFiniteStrain.h" | ||
| // Ensure the registration unit is linked or included if using static registration | ||
| // #include "Marmot/MaterialRegistration.cpp" | ||
|
|
||
| int main() | ||
| { | ||
| using namespace Marmot::Solvers; | ||
| using namespace Marmot::FastorStandardTensors; | ||
|
|
||
| // 1) Define the material model | ||
| // Must match the key used in MarmotMaterialFiniteStrainFactory::registerMaterial | ||
| std::string materialName = "FINITESTRAINJ2PLASTICITY_SUBSTEPPED"; | ||
|
|
||
| // Define Properties | ||
| // [0]: nSubsteps (Specific to SubsteppingMaterial) | ||
| // [1...8]: Standard FiniteStrainJ2Plasticity properties | ||
| double properties[] = { | ||
| 20, // nSubsteps (20 substeps per global increment) | ||
| 35, // K (Bulk Modulus) | ||
| 15, // G (Shear Modulus) | ||
| 0.45, // fy (Initial Yield Stress) | ||
| 0.75, // fyInf (Saturated Yield Stress) | ||
| 0.5, // eta (Saturation rate) | ||
| 0.1, // H (Linear Hardening) | ||
| 1.0, // implementationType (1 = Full Analytical Return Mapping) | ||
| 0.0 // density | ||
| }; | ||
| int nProps = 9; | ||
|
|
||
| // 2) Configure solver options | ||
| // With a consistent analytical tangent from the substepper, | ||
| // we expect quadratic convergence (typically < 5 iterations). | ||
| MarmotMaterialPointSolverFiniteStrain::SolverOptions options; | ||
| options.maxIterations = 15; | ||
| options.residualTolerance = 1e-8; | ||
| options.correctionTolerance = 1e-8; | ||
|
|
||
| // 3) Create solver instance | ||
| // The factory will instantiate SubsteppingMaterial, which internally instantiates FiniteStrainJ2Plasticity | ||
| MarmotMaterialPointSolverFiniteStrain solver( materialName, properties, nProps, options ); | ||
|
|
||
| // 5) Define Loading Steps | ||
|
|
||
| // --- Step 1: Loading (Uniaxial extension to 10%) --- | ||
| MarmotMaterialPointSolverFiniteStrain::Step step1; | ||
| step1.timeStart = 0.0; | ||
| step1.timeEnd = 1.0; | ||
| step1.dTStart = 1e-0; // 10 global increments | ||
| step1.dTMin = 1e-1; | ||
| step1.dTMax = 0.5; | ||
|
|
||
| step1.gradUIncrementTarget = Tensor33d( 0.0 ); | ||
| step1.stressIncrementTarget = Tensor33d( 0.0 ); | ||
| step1.isGradUComponentControlled = Tensor33t< bool >( false ); | ||
| step1.isStressComponentControlled = Tensor33t< bool >( true ); | ||
|
|
||
| // Control gradU_11 (stretch to 10%) | ||
| step1.gradUIncrementTarget( 0, 0 ) = 1; | ||
| step1.isGradUComponentControlled( 0, 0 ) = true; | ||
| step1.isStressComponentControlled( 0, 0 ) = false; | ||
|
|
||
| // Mixed control for lateral contraction (Plane Stress approximation via Solver) | ||
| // We keep stress 22 and 33 controlled to 0.0 (default true) | ||
|
|
||
| solver.addStep( step1 ); | ||
|
|
||
| // --- Step 2: Unloading (Return to 0% global strain) --- | ||
| // This validates that F_n is correctly updated and stored between steps | ||
| MarmotMaterialPointSolverFiniteStrain::Step step2 = step1; | ||
| step2.timeStart = 1.0; | ||
| step2.timeEnd = 2.0; | ||
|
|
||
| // Reverse direction: target increment is -0.10 to go back to 0 | ||
| step2.gradUIncrementTarget( 0, 0 ) = -1; | ||
|
|
||
| solver.addStep( step2 ); | ||
|
|
||
| // 6) Run the solver | ||
| try { | ||
| solver.solve(); | ||
| } | ||
| catch ( const std::exception& e ) { | ||
| // Catch exceptions thrown by the substepper (e.g., if inner Newton fails) | ||
| std::cerr << "\n!!! SOLVER FAILED !!!\nError: " << e.what() << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| // 7) Output the results | ||
| // The CSV will contain extra columns for the substepper state (Substepping_F_n components) | ||
| solver.exportHistoryToCSV( "j2_substepped_results.csv" ); | ||
|
|
||
| return 0; | ||
| } | ||
This file contains hidden or 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.
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.
The comment on line 17 states "Standard FiniteStrainJ2Plasticity properties" for indices [1...8], but only 8 properties are defined (indices 1-8), which is correct. However, the comment could be clearer about which property is at which index. Consider adding inline comments for each property value to improve readability and maintainability.