sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
871 stars 297 forks source link

RegularGridTopology dimensions #270

Closed epernod closed 6 years ago

epernod commented 7 years ago

Small PR on GridTopology and RegularGridTopology link to issue: #163

CHANGELOG:

Reviewers will merge only if all these checks are true.

epernod commented 7 years ago

@damienmarchal I have added a RegularGridTopology_test. In fact I don't think GridTopology is used like this as a component. It is more a mother class for Regular/Cylindrical and sphereGridTopology (which each has tests now)

damienmarchal commented 7 years ago

Thanks Eric for the fixes and the additional test.

Your answer about GridTopology rise other questions:

EDIT: Maybe these questions should be for a new Issue and not to handle in this PR.

epernod commented 7 years ago

In fact most of the methods I'm testing are directly inside the mother class. So I'm not sure a gridTopology_test is needed. But to remove GridTopology from the factory is maybe possible. We need to investigate if someone is using it as a component.

damienmarchal commented 7 years ago

Hi Erik,

There is one test crash in TetrahedronFEMForceField_test. Is this related to your changes ?

DM

epernod commented 7 years ago

Should not but I will check. Yes in fact my fix in TetrahedronFEMFF reveals that the test was doing nothing: This the log on the master branch:

[ RUN      ] TetrahedronDiffusionFEMForceField_test/0.extension
[ERROR]   [TetrahedronFEMForceField(fem)]  object must have a mesh topology. The component is inactivated.  To remove this error message please add a topology component to your scene.

Right now it crashes... will see if I understand enough the test to fix it.

guparan commented 7 years ago

Hi @epernod Is this PR also linked to #162 ?

damienmarchal commented 7 years ago

Hi @epernod

Can I add more tests on this PR ? Because I think we should validate a bit more "negative/bad" case to enforce the behavior of component when used improperly.

epernod commented 7 years ago

help yourself.

damienmarchal commented 7 years ago

@matthieu-nesme
Do you think we should remove the dimension ? Or is it ok to have this PR switched to the ready state ?

matthieu-nesme commented 6 years ago

To me the notion of dimension is not well defined, keeping it as a function w/o Data would be better. unsigned getMaterialDimension() const ?

untereiner commented 6 years ago

I would suggest unsigned getDimension() const because the object should be considered as a topological space of a given dimension and not as a material since it does not have material properties yet.

epernod commented 6 years ago

I agree, "Material" does not mean something in this base component. This parameter should only be informative, not a Data, there is no mechanism to change the grid resolution if you change this dimension.

epernod commented 6 years ago

Finally do we have an agreement here? @matthieu-nesme @untereiner @damienmarchal Or do we remove that field?

damienmarchal commented 6 years ago

getDimmension() sounds ok to me. Not needed to have it as a Data. It can be recomputed each time getDimmension is called, there is no need to store it.

damienmarchal commented 6 years ago

@epernod, @matthieu-nesme do you agreed so that we can merge soon ?

epernod commented 6 years ago

It is ok for me. We are just speaking about an informative int or an enum. I can do the change (if any) as soon as their is a final decision.

damienmarchal commented 6 years ago

@hugtalbot, you set this PR to ready but didn't dismissed @matthieu-nesme's "request for change", it looks a bit ambiguous to me.

Let's take it easy, I will dismissed the request for change and do the merge. If this is not what was intented don't hesitate to revert or submit a small fix to remove the Grid_dimmension as matthieu suggested.

damienmarchal commented 6 years ago

[ci-build]

matthieu-nesme commented 6 years ago

I still do not get the interest of storing m_gridDim. What is the limitation of a simple function? So you never have to change the value of this variable to keep it consistent.

If it was in a data you want to plug in a Data/Engine graph, it would indeed be necessary to store it, but it is not the case here.

damienmarchal commented 6 years ago

Everyone agreed there is no interest in storing m_gridDim.
9 days ago erik asked: " Or do we remove that field?" followed by "I can do the change (if any) as soon as their is a final decision."

He is waiting for an answer since 9 days.
So here is the answer, "yes do the change and remove this field" :)

epernod commented 6 years ago

yes we can change the test to removebadDim as now the dim is not computed at the same time.

No, _n[i] = 1 works. n = [1; 5; 5] give a plan grid of 25 cells. -> Dim = 2

matthieu-nesme commented 6 years ago

@epernod If I am not wrong, if you have n=[2,2,2] your code will give dim=0 where it should give dim=3. Only a test could check that ;)

epernod commented 6 years ago

Indeed... my bad. This Pr already add tests for the gridTopology but the Tests needed a test. Thanks @matthieu-nesme for the review. It should be good now.

damienmarchal commented 6 years ago

[ci-build]

EDIT: Thank you all to make things moving and progressing.

damienmarchal commented 6 years ago

Hi Erik,

It seems that this PR introduced a new examples RegularGrid_dimmension that is failing because it use a component <EdgeSet/> that does not seems to be part of Sofa.

Can you provide a bit of details please.