openworm / sibernetic

This is a C++/OpenCL implementation of the PCISPH algorithm supplemented with a set of biomechanics related features applied to C. elegans locomotion
Other
360 stars 105 forks source link

Rerun (-l_from) simulation inside openworm container #154

Closed lungd closed 5 years ago

lungd commented 5 years ago

There is an issue with the rerun of the Sibernetic simulatoin: https://github.com/openworm/OpenWorm/issues/291 (Sibernetic crashes while rerunning simulation)

It seems like that issue starts with https://github.com/openworm/sibernetic/commit/688a717aa1b5e19208c7eb6225105d32ab15d049 (compile error) and https://github.com/openworm/sibernetic/commit/1b638144b9f93060a33526a7ce99ef8fcb49bf55

I did some debugging and figuered out the following: Sibernetic crashes at line https://github.com/openworm/sibernetic/blob/a52006ecf5edb0ef4a2ab634d1bd730bb3ca9ef6/src/owWorldSimulation.cpp#L404 'i' (https://github.com/openworm/sibernetic/blob/a52006ecf5edb0ef4a2ab634d1bd730bb3ca9ef6/src/owWorldSimulation.cpp#L398) is a random int. I think the random value comes from an array initialization with 0 elements https://github.com/openworm/sibernetic/blob/4c29d5f8e1687dea591d41d640d02881777a5e4f/src/owHelper.cpp#L658

After removing the comment from https://github.com/openworm/sibernetic/blob/4c29d5f8e1687dea591d41d640d02881777a5e4f/src/owHelper.cpp#L656, the recording of the Sibernetic simulation (startet with -l_from) works but there is an issue with the membranes. The recorded output looks like the following with_membranes

If I remove the loop for drawing the membranes https://github.com/openworm/sibernetic/blob/a52006ecf5edb0ef4a2ab634d1bd730bb3ca9ef6/src/owWorldSimulation.cpp#L397, the recorded output looks more like it is supposed to look like without_membranes

I am not sure whether the membrane issue is related to the code of Sibernetic (loadTo / loadFrom) or to a misconfigured system.

Any ideas?

lungd commented 5 years ago

And I think there is an issue with the code starting with https://github.com/openworm/sibernetic/blob/4c29d5f8e1687dea591d41d640d02881777a5e4f/src/owHelper.cpp#L655:

I think it should be:

      int m_count = 0;
      membranesFile >> m_count;
      int i = 0;
      membranes = new int[3 * m_count];
      while (membranesFile.good() && i < m_count) {
        membranesFile >> membranes[3 * i + 0] >> membranes[3 * i + 1] >> membranes[3 * i + 2];
        i++;
      }

and not:

      int m_count = 0;
      membranesFile >> m_count;
      int i = 0;
      membranes = new int[4 * m_count];
      while (membranesFile.good() && i < m_count) {
        membranesFile >> membranes[4 * i + 0] >> membranes[4 * i + 1] >> membranes[4 * i + 2] >> membranes[4 * i + 3];
        i++;
      }

But this patch doesn't change the membrane issue described above

lungd commented 5 years ago

Update: The membrane issue is most likely related to the implementation of OpenGL.

I think with a prev version of Sibernetic, the membranes didn't get displayed while rerunning a simulation. With the current version, including the changes described above, the membranes get displayed but the result looks pretty bad because of the CPU only docker container.

@a-palyanov @skhayrulin, what do you think about adding a parameter defining whether the membranes should get displayed?

skhayrulin commented 5 years ago

Hi @lungd sorry for late answer, I'll review this at the near time

lungd commented 5 years ago

Fixed