-
Notifications
You must be signed in to change notification settings - Fork 18
Draft - Initial indentation example #286
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
pabloseleson
wants to merge
16
commits into
ORNL:main
Choose a base branch
from
pabloseleson:indentation_example
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.
+1,195
−1
Open
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6f87490
Initial indentation example
pabloseleson 9dbb288
Added flat indenter example
0c7889d
Merge branch 'indentation_example' of https://github.com/pabloseleson…
danschappel 39f3de7
added spherical indentor example
danschappel 0ff7d7b
added spherical indentor example
danschappel 4fe074a
Initial indentation example
pabloseleson db6d477
Added flat indenter example
12657b8
added spherical indentor example
danschappel 296381b
added spherical indentor example
danschappel 6d21a37
Merge branch 'indentation_example' of https://github.com/pabloseleson…
danschappel 2507b0d
updated spherical indenter
danschappel 3999687
Cleaned up example
pabloseleson 6f2e419
Added force output
pabloseleson 5b68cd6
Initial example of conical indenter
pabloseleson f10eebf
Added missing indenter examples
pabloseleson 07a9bb4
Added initial Berkovich indenter example
pabloseleson 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 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
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,164 @@ | ||
| /**************************************************************************** | ||
| * Copyright (c) 2022 by Oak Ridge National Laboratory * | ||
| * All rights reserved. * | ||
| * * | ||
| * This file is part of CabanaPD. CabanaPD is distributed under a * | ||
| * BSD 3-clause license. For the licensing terms see the LICENSE file in * | ||
| * the top-level directory. * | ||
| * * | ||
| * SPDX-License-Identifier: BSD-3-Clause * | ||
| ****************************************************************************/ | ||
|
|
||
| #include <fstream> | ||
| #include <iostream> | ||
|
|
||
| #include "mpi.h" | ||
|
|
||
| #include <Kokkos_Core.hpp> | ||
|
|
||
| #include <CabanaPD.hpp> | ||
|
|
||
| // Simulate crack branching from an pre-crack. | ||
| void flatIndenterExample( const std::string filename ) | ||
| { | ||
| // ==================================================== | ||
| // Choose Kokkos spaces | ||
| // ==================================================== | ||
| using exec_space = Kokkos::DefaultExecutionSpace; | ||
| using memory_space = typename exec_space::memory_space; | ||
|
|
||
| // ==================================================== | ||
| // Read inputs | ||
| // ==================================================== | ||
| CabanaPD::Inputs inputs( filename ); | ||
|
|
||
| // ==================================================== | ||
| // Material parameters | ||
| // ==================================================== | ||
| double rho0 = inputs["density"]; | ||
| double E = inputs["elastic_modulus"]; | ||
| double nu = 0.25; // Use bond-based model | ||
| double K = E / ( 3 * ( 1 - 2 * nu ) ); | ||
| double G0 = inputs["fracture_energy"]; | ||
| double horizon = inputs["horizon"]; | ||
| horizon += 1e-10; | ||
|
|
||
| // ==================================================== | ||
| // Discretization | ||
| // ==================================================== | ||
| std::array<double, 3> low_corner = inputs["low_corner"]; | ||
| std::array<double, 3> high_corner = inputs["high_corner"]; | ||
|
|
||
| // ==================================================== | ||
| // Pre-notch | ||
| // ==================================================== | ||
| /* | ||
| double height = inputs["system_size"][0]; | ||
| double thickness = inputs["system_size"][2]; | ||
| double L_prenotch = height / 2.0; | ||
| double y_prenotch = 0.0; | ||
| Kokkos::Array<double, 3> p01 = { low_corner[0], y_prenotch, low_corner[2] }; | ||
| Kokkos::Array<double, 3> v1 = { L_prenotch, 0, 0 }; | ||
| Kokkos::Array<double, 3> v2 = { 0, 0, thickness }; | ||
| Kokkos::Array<Kokkos::Array<double, 3>, 1> notch_positions = { p01 }; | ||
| CabanaPD::Prenotch<1> prenotch( v1, v2, notch_positions ); | ||
| */ | ||
| // ==================================================== | ||
| // Force model | ||
| // ==================================================== | ||
| using model_type = CabanaPD::PMB; | ||
| CabanaPD::ForceModel force_model( model_type{}, horizon, K, G0 ); | ||
|
|
||
| // ==================================================== | ||
| // Particle generation | ||
| // ==================================================== | ||
| CabanaPD::Particles particles( memory_space{}, model_type{} ); | ||
|
|
||
| // Note that individual inputs can be passed instead (see other examples). | ||
| particles.domain( inputs ); | ||
| particles.create( exec_space{} ); | ||
|
|
||
| // ==================================================== | ||
| // Boundary conditions planes | ||
| // ==================================================== | ||
|
|
||
| double dz = particles.dx[2]; | ||
| CabanaPD::Region<CabanaPD::RectangularPrism> square_pressure( | ||
| 0.5 * low_corner[0], 0.5 * high_corner[0], 0.5 * low_corner[1], | ||
| 0.5 * high_corner[1], high_corner[2] - dz, high_corner[2] + dz ); | ||
|
|
||
| // ==================================================== | ||
| // Custom particle initialization | ||
| // ==================================================== | ||
| auto rho = particles.sliceDensity(); | ||
| auto x = particles.sliceReferencePosition(); | ||
| auto v = particles.sliceVelocity(); | ||
| auto f = particles.sliceForce(); | ||
| auto nofail = particles.sliceNoFail(); | ||
|
|
||
|
|
||
| auto init_functor = KOKKOS_LAMBDA( const int pid ) | ||
| { | ||
|
|
||
| // Density | ||
| rho( pid ) = rho0; | ||
| /* | ||
| // No-fail zone | ||
| if ( x( pid, 1 ) <= plane1.low[1] + horizon + 1e-10 || | ||
| x( pid, 1 ) >= plane2.high[1] - horizon - 1e-10 ) | ||
| nofail( pid ) = 1; | ||
| */ | ||
| }; | ||
| particles.update( exec_space{}, init_functor ); | ||
|
|
||
| // ==================================================== | ||
| // Create solver | ||
| // ==================================================== | ||
| CabanaPD::Solver solver( inputs, particles, force_model ); | ||
|
|
||
| // ==================================================== | ||
| // Boundary conditions | ||
| // ==================================================== | ||
| // Create BC last to ensure ghost particles are included. | ||
| double sigma0 = inputs["traction"]; | ||
| double b0 = -sigma0 / dz; | ||
| auto indent_force = 0; | ||
| f = solver.particles.sliceForce(); | ||
| x = solver.particles.sliceReferencePosition(); | ||
| // Create a symmetric force BC in the z-direction. | ||
|
|
||
| auto bc_op = KOKKOS_LAMBDA( const int pid, const double ) | ||
| { | ||
| double xsq = x(pid,0) * x(pid,0); | ||
| double ysq = x(pid,1) * x(pid,1); | ||
| double rsq = xsq + ysq; | ||
|
|
||
| if ( xsq + ysq < 9e-6 ) | ||
| { | ||
| f( pid, 2 ) += b0; | ||
| } | ||
|
|
||
|
|
||
| }; | ||
| auto bc = createBoundaryCondition( bc_op, exec_space{}, solver.particles, | ||
| true, square_pressure ); | ||
|
|
||
| // ==================================================== | ||
| // Simulation run | ||
| // ==================================================== | ||
| //solver.init( bc, prenotch ); | ||
| solver.init( bc ); | ||
| solver.run( bc ); | ||
| } | ||
|
|
||
| // Initialize MPI+Kokkos. | ||
| int main( int argc, char* argv[] ) | ||
| { | ||
| MPI_Init( &argc, &argv ); | ||
| Kokkos::initialize( argc, argv ); | ||
|
|
||
| flatIndenterExample( argv[1] ); | ||
|
|
||
| Kokkos::finalize(); | ||
| MPI_Finalize(); | ||
| } |
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,164 @@ | ||
| /**************************************************************************** | ||
| * Copyright (c) 2022 by Oak Ridge National Laboratory * | ||
| * All rights reserved. * | ||
| * * | ||
| * This file is part of CabanaPD. CabanaPD is distributed under a * | ||
| * BSD 3-clause license. For the licensing terms see the LICENSE file in * | ||
| * the top-level directory. * | ||
| * * | ||
| * SPDX-License-Identifier: BSD-3-Clause * | ||
| ****************************************************************************/ | ||
|
|
||
| #include <fstream> | ||
| #include <iostream> | ||
|
|
||
| #include "mpi.h" | ||
|
|
||
| #include <Kokkos_Core.hpp> | ||
|
|
||
| #include <CabanaPD.hpp> | ||
|
|
||
| // Simulate crack branching from an pre-crack. | ||
| void crackBranchingExample( const std::string filename ) | ||
| { | ||
| // ==================================================== | ||
| // Choose Kokkos spaces | ||
| // ==================================================== | ||
| using exec_space = Kokkos::DefaultExecutionSpace; | ||
| using memory_space = typename exec_space::memory_space; | ||
|
|
||
| // ==================================================== | ||
| // Read inputs | ||
| // ==================================================== | ||
| CabanaPD::Inputs inputs( filename ); | ||
|
|
||
| // ==================================================== | ||
| // Material parameters | ||
| // ==================================================== | ||
| double rho0 = inputs["density"]; | ||
| double E = inputs["elastic_modulus"]; | ||
| double nu = 0.25; // Use bond-based model | ||
| double K = E / ( 3 * ( 1 - 2 * nu ) ); | ||
| double G0 = inputs["fracture_energy"]; | ||
| double horizon = inputs["horizon"]; | ||
| horizon += 1e-10; | ||
|
|
||
| // ==================================================== | ||
| // Discretization | ||
| // ==================================================== | ||
| std::array<double, 3> low_corner = inputs["low_corner"]; | ||
| std::array<double, 3> high_corner = inputs["high_corner"]; | ||
|
|
||
| // ==================================================== | ||
| // Pre-notch | ||
| // ==================================================== | ||
| /* | ||
| double height = inputs["system_size"][0]; | ||
| double thickness = inputs["system_size"][2]; | ||
| double L_prenotch = height / 2.0; | ||
| double y_prenotch = 0.0; | ||
| Kokkos::Array<double, 3> p01 = { low_corner[0], y_prenotch, low_corner[2] }; | ||
| Kokkos::Array<double, 3> v1 = { L_prenotch, 0, 0 }; | ||
| Kokkos::Array<double, 3> v2 = { 0, 0, thickness }; | ||
| Kokkos::Array<Kokkos::Array<double, 3>, 1> notch_positions = { p01 }; | ||
| CabanaPD::Prenotch<1> prenotch( v1, v2, notch_positions ); | ||
| */ | ||
|
|
||
| // ==================================================== | ||
| // Force model | ||
| // ==================================================== | ||
| using model_type = CabanaPD::PMB; | ||
| CabanaPD::ForceModel force_model( model_type{}, horizon, K, G0 ); | ||
|
|
||
| // ==================================================== | ||
| // Particle generation | ||
| // ==================================================== | ||
| CabanaPD::Particles particles( memory_space{}, model_type{} ); | ||
|
|
||
| // Note that individual inputs can be passed instead (see other examples). | ||
| particles.domain( inputs ); | ||
| particles.create( exec_space{} ); | ||
|
|
||
| // ==================================================== | ||
| // Boundary conditions planes | ||
| // ==================================================== | ||
| // double dy = particles.dx[1]; | ||
| // CabanaPD::Region<CabanaPD::RectangularPrism> plane1( | ||
| // low_corner[0], high_corner[0], low_corner[1] - dy, low_corner[1] + dy, | ||
| // low_corner[2], high_corner[2] ); | ||
| // CabanaPD::Region<CabanaPD::RectangularPrism> plane2( | ||
| // low_corner[0], high_corner[0], high_corner[1] - dy, high_corner[1] + | ||
| // dy, low_corner[2], high_corner[2] ); | ||
|
|
||
| double dz = particles.dx[2]; | ||
| CabanaPD::Region<CabanaPD::RectangularPrism> square_pressure( | ||
| 0.5 * low_corner[0], 0.5 * high_corner[0], 0.5 * low_corner[1], | ||
| 0.5 * high_corner[1], high_corner[2] - dz, high_corner[2] + dz ); | ||
|
|
||
| // ==================================================== | ||
| // Custom particle initialization | ||
| // ==================================================== | ||
| auto rho = particles.sliceDensity(); | ||
| auto x = particles.sliceReferencePosition(); | ||
| auto v = particles.sliceVelocity(); | ||
| auto f = particles.sliceForce(); | ||
| auto nofail = particles.sliceNoFail(); | ||
|
|
||
| auto init_functor = KOKKOS_LAMBDA( const int pid ) | ||
| { | ||
| // Density | ||
| rho( pid ) = rho0; | ||
| // No-fail zone | ||
| // if ( x( pid, 1 ) <= plane1.low[1] + horizon + 1e-10 || | ||
| // x( pid, 1 ) >= plane2.high[1] - horizon - 1e-10 ) | ||
| // nofail( pid ) = 1; | ||
| }; | ||
| particles.update( exec_space{}, init_functor ); | ||
|
|
||
| // ==================================================== | ||
| // Create solver | ||
| // ==================================================== | ||
| CabanaPD::Solver solver( inputs, particles, force_model ); | ||
|
|
||
| // ==================================================== | ||
| // Boundary conditions | ||
| // ==================================================== | ||
| // Create BC last to ensure ghost particles are included. | ||
| double sigma0 = inputs["traction"]; | ||
| // double b0 = sigma0 / dy; | ||
| double b0 = -sigma0 / dz; | ||
| f = solver.particles.sliceForce(); | ||
| x = solver.particles.sliceReferencePosition(); | ||
| // Create a symmetric force BC in the y-direction. | ||
| auto bc_op = KOKKOS_LAMBDA( const int pid, const double ) | ||
| { | ||
| // auto ypos = x( pid, 1 ); | ||
| // auto sign = std::abs( ypos ) / ypos; | ||
| // f( pid, 1 ) += b0 * sign; | ||
| f( pid, 2 ) += b0; | ||
| }; | ||
| // auto bc = createBoundaryCondition( bc_op, exec_space{}, solver.particles, | ||
| // true, plane1, plane2 ); | ||
|
|
||
| auto bc = createBoundaryCondition( bc_op, exec_space{}, solver.particles, | ||
| true, square_pressure ); | ||
|
|
||
| // ==================================================== | ||
| // Simulation run | ||
| // ==================================================== | ||
| // solver.init( bc, prenotch ); | ||
| solver.init( bc ); | ||
| solver.run( bc ); | ||
| } | ||
|
|
||
| // Initialize MPI+Kokkos. | ||
| int main( int argc, char* argv[] ) | ||
| { | ||
| MPI_Init( &argc, &argv ); | ||
| Kokkos::initialize( argc, argv ); | ||
|
|
||
| crackBranchingExample( argv[1] ); | ||
|
|
||
| Kokkos::finalize(); | ||
| MPI_Finalize(); | ||
| } |
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,14 @@ | ||
| { | ||
| "num_cells" : {"value": [400, 160, 8]}, | ||
| "system_size" : {"value": [0.1, 0.04, 0.002], "unit": "m"}, | ||
| "density" : {"value": 2440, "unit": "kg/m^3"}, | ||
| "elastic_modulus" : {"value": 72e+9, "unit": "Pa"}, | ||
| "fracture_energy" : {"value": 3.8, "unit": "J/m^2"}, | ||
| "horizon" : {"value": 0.001, "unit": "m"}, | ||
| "traction" : {"value": 2e6, "unit": "Pa"}, | ||
| "final_time" : {"value": 43e-6, "unit": "s"}, | ||
| "timestep" : {"value": 4.5e-8, "unit": "s"}, | ||
| "timestep_safety_factor" : {"value": 0.85}, | ||
| "output_frequency" : {"value": 5}, | ||
| "output_reference" : {"value": true} | ||
| } |
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,19 @@ | ||
| { | ||
| "num_cells_OLD" : {"value": [400, 400, 80]}, | ||
| "num_cells" : {"value": [200, 200, 40]}, | ||
| "system_size_OLD" : {"value": [0.1, 0.04, 0.002], "unit": "m"}, | ||
| "system_size" : {"value": [0.1, 0.1, 0.02], "unit": "m"}, | ||
| "density" : {"value": 2440, "unit": "kg/m^3"}, | ||
| "elastic_modulus" : {"value": 72e+9, "unit": "Pa"}, | ||
| "fracture_energy" : {"value": 3.8, "unit": "J/m^2"}, | ||
| "horizon_ref" : {"value": 0.001, "unit": "m"}, | ||
| "horizon" : {"value": 0.0015, "unit": "m"}, | ||
| "traction" : {"value": 2e6, "unit": "Pa"}, | ||
| "final_time" : {"value": 43e-6, "unit": "s"}, | ||
| "timestep_OLD" : {"value": 4.5e-8, "unit": "s"}, | ||
| "timestep" : {"value": 6.75e-8, "unit": "s"}, | ||
| "timestep_safety_factor" : {"value": 0.85}, | ||
| "output_frequency" : {"value": 5}, | ||
| "output_reference_OLD" : {"value": true}, | ||
| "output_reference" : {"value": false} | ||
| } |
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.
@pabloseleson this is causing the CI failure - these files do not exist