Skip to content
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

Enable particle input from file #33

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft

Conversation

diehlpk
Copy link
Contributor

@diehlpk diehlpk commented Jul 27, 2023

Attempt to read particles from a CSV file.

Closes #9

@streeve streeve changed the title Crack branching Crack branching with file input Jul 27, 2023
@diehlpk diehlpk mentioned this pull request Jul 27, 2023
2 tasks
@streeve
Copy link
Collaborator

streeve commented Aug 8, 2023

Updated here now that the crack branching problem is merged; also split into a new example to separate the specific file format from the source

@diehlpk
Copy link
Contributor Author

diehlpk commented Aug 31, 2023

@streeve I tried to compile the new version of the example.

  1. I added the example to CMake to finally compile it
  2. I fixed some of the C++ compiler errors for reading the CSV file

However, I get some Kokkos errors while compiling.

/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp: In function ‘void read_particles(std::__cxx11::string, ParticleType&)’:
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:56:14: error: there are no arguments to ‘slice_v’ that depend on a template parameter, so a declaration of ‘slice_v’ must be available [-fpermissive]
     auto v = slice_v();
              ^~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:56:14: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:57:14: error: there are no arguments to ‘slice_f’ that depend on a template parameter, so a declaration of ‘slice_f’ must be available [-fpermissive]
     auto f = slice_f();
              ^~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:58:17: error: there are no arguments to ‘slice_type’ that depend on a template parameter, so a declaration of ‘slice_type’ must be available [-fpermissive]
     auto type = slice_type();
                 ^~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:59:16: error: there are no arguments to ‘slice_rho’ that depend on a template parameter, so a declaration of ‘slice_rho’ must be available [-fpermissive]
     auto rho = slice_rho();
                ^~~~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:60:14: error: there are no arguments to ‘slice_u’ that depend on a template parameter, so a declaration of ‘slice_u’ must be available [-fpermissive]
     auto u = slice_u();
              ^~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:61:19: error: there are no arguments to ‘slice_nofail’ that depend on a template parameter, so a declaration of ‘slice_nofail’ must be available [-fpermissive]
     auto nofail = slice_nofail();
                   ^~~~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:66:41: error: expected primary-expression before ‘policy’
         Kokkos::RangePolicy<exec_space> policy( 0, x.size() ),
                                         ^~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp: In lambda function:
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:69:19: error: ‘pid’ was not declared in this scope
             pvol( pid ) = vol( i );
                   ^~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp: In function ‘int main(int, char**)’:
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:159:19: error: ‘class std::shared_ptr<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB> >’ has no member named ‘update_after_read’
         particles.update_after_read( exec_space(), halo_width, num_cell );
                   ^~~~~~~~~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp: In instantiation of ‘void read_particles(std::__cxx11::string, ParticleType&) [with ParticleType = std::shared_ptr<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB> >; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:157:46:   required from here
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:49:61: error: no type named ‘memory_space’ in ‘class std::shared_ptr<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB> >’
     using memory_space = typename ParticleType::memory_space;
                                                             ^
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:54:25: error: ‘class std::shared_ptr<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB> >’ has no member named ‘slice_x’
     auto px = particles.slice_x();
               ~~~~~~~~~~^~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:55:27: error: ‘class std::shared_ptr<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB> >’ has no member named ‘slice_vol’
     auto pvol = particles.slice_vol();
                 ~~~~~~~~~~^~~~~~~~~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:56:21: error: ‘slice_v’ was not declared in this scope
     auto v = slice_v();
              ~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:56:21: note: suggested alternative: ‘ssize_t’
     auto v = slice_v();
              ~~~~~~~^~
              ssize_t
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:57:21: error: ‘slice_f’ was not declared in this scope
     auto f = slice_f();
              ~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:57:21: note: suggested alternative: ‘ssize_t’
     auto f = slice_f();
              ~~~~~~~^~
              ssize_t
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:58:27: error: ‘slice_type’ was not declared in this scope
     auto type = slice_type();
                 ~~~~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:58:27: note: suggested alternative: ‘H5Rget_type’
     auto type = slice_type();
                 ~~~~~~~~~~^~
                 H5Rget_type
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:59:25: error: ‘slice_rho’ was not declared in this scope
     auto rho = slice_rho();
                ~~~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:60:21: error: ‘slice_u’ was not declared in this scope
     auto u = slice_u();
              ~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:60:21: note: suggested alternative: ‘ssize_t’
     auto u = slice_u();
              ~~~~~~~^~
              ssize_t
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:61:31: error: ‘slice_nofail’ was not declared in this scope
     auto nofail = slice_nofail();
                   ~~~~~~~~~~~~^~
/home/diehlpk/Compile/CabanaPD/examples/read_file.cpp:61:31: note: suggested alternative: ‘nofail’
     auto nofail = slice_nofail();
                   ~~~~~~~~~~~~^~

Could you please have a look?

examples/read_file.cpp Outdated Show resolved Hide resolved
@streeve
Copy link
Collaborator

streeve commented Aug 31, 2023

@diehlpk I fixed the compilation locally - should be much more usable now

@diehlpk
Copy link
Contributor Author

diehlpk commented Aug 31, 2023

@streeve thanks, I will compile and test a uniform bar.

@diehlpk
Copy link
Contributor Author

diehlpk commented Sep 1, 2023

@streeve

I get now a new error which was not there before:

In file included from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:16,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp: In member function ‘void CabanaPD::HaloIds<LocalGridType, PositionSliceType>::build(const LocalGridType&)’:
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:114:33: error: ‘getTopology’ is not a member of ‘Cajita’
         auto topology = Cajita::getTopology( local_grid );
                                 ^~~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:114:33: note: suggested alternative:
In file included from /home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cajita.hpp:34,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD_Boundary.hpp:18,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:15,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cajita_ParticleGridDistributor.hpp:57:1: note:   ‘Cajita::Impl::getTopology’
 getTopology( const LocalGridType& local_grid )
 ^~~~~~~~~~~
In file included from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:16,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:115:40: error: ‘getUniqueTopology’ is not a member of ‘Cabana’
         auto unique_topology = Cabana::getUniqueTopology(
                                        ^~~~~~~~~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:115:40: note: suggested alternative:
In file included from /home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cabana_Distributor.hpp:20,
                 from /home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cabana_Core.hpp:40,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD_Boundary.hpp:17,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:15,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cabana_CommunicationPlan.hpp:360:25 note:   ‘Cabana::Impl::getUniqueTopology’
 inline std::vector<int> getUniqueTopology( MPI_Comm comm,
                         ^~~~~~~~~~~~~~~~~
In file included from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:16,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp: In constructor ‘CabanaPD::Comm<ParticleType, CabanaPD::PMB>::Comm(ParticleType&, int)’:
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:207:33: error: ‘getTopology’ is not a member of ‘Cajita’
         auto topology = Cajita::getTopology( *local_grid );
                                 ^~~~~~~~~~~
/home/diehlpk/Compile/CabanaPD/src/CabanaPD_Comm.hpp:207:33: note: suggested alternative:
In file included from /home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cajita.hpp:34,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD_Boundary.hpp:18,
                 from /home/diehlpk/Compile/CabanaPD/src/CabanaPD.hpp:15,
                 from /home/diehlpk/Compile/CabanaPD/examples/elastic_wave.cpp:19:
/home/diehlpk/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-8.5.0/cabana-master-35llli4s5ak7e2at4sxta22swwr6ydzb/include/Cajita_ParticleGridDistributor.hpp:57:1: note:   ‘Cajita::Impl::getTopology’
 getTopology( const LocalGridType& local_grid )
 ^~~~~~~~~~~
make[2]: *** [examples/CMakeFiles/ElasticWave.dir/build.make:76: examples/CMakeFiles/ElasticWave.dir/elastic_wave.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:175: examples/CMakeFiles/ElasticWave.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

@streeve
Copy link
Collaborator

streeve commented Sep 1, 2023

Sorry, I forgot to say you'll need to update to the latest Cabana master (readme has been updated with the minimum commit necessary)

@diehlpk
Copy link
Contributor Author

diehlpk commented Sep 4, 2023

@streeve The code compiles now, but we get a segmentation fault after reading the CSV file.

I nailed it down between

// Create unmanaged Views in order to copy to device.
a and .

Here is the output:

[rostam1:3546840] *** Process received signal ***
[rostam1:3546840] Signal: Segmentation fault (11)
[rostam1:3546840] Signal code: Address not mapped (1)
[rostam1:3546840] Failing at address: (nil)
[rostam1:3546840] [ 0] /lib64/libpthread.so.0(+0x12cf0)[0x7f5291425cf0]
[rostam1:3546840] [ 1] ./examples/ReadFile[0x416c0b]
[rostam1:3546840] [ 2] ./examples/ReadFile[0x407a39]
[rostam1:3546840] [ 3] /lib64/libc.so.6(__libc_start_main+0xe5)[0x7f5291088d85]
[rostam1:3546840] [ 4] ./examples/ReadFile[0x408b5e]
[rostam1:3546840] *** End of error message ***
Segmentation fault (core dumped)

and with gdb, we get

 Thread 1 "ReadFile" received signal SIGSEGV, Segmentation fault.
0x0000000000416c0b in void read_particles<CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB, 3> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, CabanaPD::Particles<Kokkos::Device<Kokkos::Serial, Kokkos::HostSpace>, CabanaPD::PMB, 3>&) ()
Missing separate debuginfos, use: yum debuginfo-install libgcc-8.5.0-18.el8.x86_64 libstdc++-8.5.0-18.el8.x86_64 munge-libs-0.5.13-2.el8.x86_64

I am attending a conference this week and just had a few minutes to test things. I can have a more detailed look next week.

@streeve
Copy link
Collaborator

streeve commented Sep 5, 2023

If you attach an example file I can test as well

@diehlpk
Copy link
Contributor Author

diehlpk commented Sep 19, 2023

This is the CSV file easy.csv and the image of the corresponding mesh

mesh

@streeve
Copy link
Collaborator

streeve commented Sep 28, 2023

@diehlpk as you can see from the last commit, there were a lot of necessary changes. Runs for me now locally

@diehlpk
Copy link
Contributor Author

diehlpk commented Sep 28, 2023

@streeve thanks. I will try to run a larger geometry and apply the boundary conditions.

@streeve
Copy link
Collaborator

streeve commented Oct 27, 2023

To do:

  • Generalize boundary for fields other than forces
  • Remove dx (build a grid with the cutoff distance and fix halo=1)

@streeve streeve changed the title Crack branching with file input Enable particle input from file Nov 1, 2023
@streeve
Copy link
Collaborator

streeve commented Nov 1, 2023

@diehlpk made the changes we discussed - let me know if you have any issues or if you have larger files for me to test with

@diehlpk
Copy link
Contributor Author

diehlpk commented Nov 1, 2023

@streeve thanks, I will upload the coarsest grid, we used in the previous simulations this evening.

@diehlpk
Copy link
Contributor Author

diehlpk commented Nov 2, 2023

@streeve Please find attached a mesh more suitable for the comparison with the experiment.

new-mesh

Here is the file astm-d638.csv

If that mesh works, we would be good to setup the experimet.

@diehlpk
Copy link
Contributor Author

diehlpk commented Nov 2, 2023

@streeve mayve we should add a very small CSV file to the repo to execute the example. What do you think?

@streeve
Copy link
Collaborator

streeve commented Nov 7, 2023

mayve we should add a very small CSV file to the repo to execute the example. What do you think?

I'm okay with that as long as it's very small (a dog-bone with 100s of particles would be nice)

@streeve
Copy link
Collaborator

streeve commented Nov 7, 2023

I ran with the astm file and can correctly create the BC we want, but I'm not sure if the issues I see locally are because of input magnitudes or a bug

@streeve
Copy link
Collaborator

streeve commented Nov 10, 2023

@diehlpk should be ready to test. The last commit adds the linear ramp for BC (as well as the option to turn off the BC at some point in the simulation). I also had to remove some duplicate positions with the test mesh I was using

@streeve
Copy link
Collaborator

streeve commented Nov 14, 2023

@diehlpk let me know if you notice any issues - I can try to fix before we meet next

@diehlpk
Copy link
Contributor Author

diehlpk commented Nov 15, 2023

@streeve I was attending SC. I will testbit before the meeting back home.

@diehlpk
Copy link
Contributor Author

diehlpk commented Nov 29, 2023

@streeve I prepared a 3D mesh and uploaded the mesh to the shared folder.

I will try this week to setup the 2d case with the experimental data.

Could you please try the 3d mesh?

@streeve streeve mentioned this pull request Aug 1, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read particles from file
2 participants