Home › Forum › SOFA › Using SOFA › How to make local refined tetrahedral mesh?
Tagged: 64_bits, local mesh refinement, Plugin_other, SOFA_1906, Windows_10
- This topic has 23 replies, 3 voices, and was last updated 4 years, 10 months ago by
Wong.
-
AuthorPosts
-
29 September 2019 at 11:53 #14309
Wong
BlockedHow to make local refined tetrahedral mesh?
Hello everyone,
I want to use tetrahedral mesh to model a soft body which has fine local deformation.
But to meet this requirement, too much tetrahedral elements are needed, which would lead to heavy overhead.
So I want to perform tetrahedral mesh refinement to make some importent parts of the soft body with fine tetrahedrons to have good local deformation.
How can I do?Wong
30 September 2019 at 15:17 #14317Hugo
KeymasterHi @outtt
It is a complicated question. Interactive simulation is always a trade-off between efficiency and accuracy. This is what you face willing to have “good local deformation” and reasonable computation time.
Different methods do exist to solve this like: multigrid methods, model order reduction (see the associated plugin), adaptive integration schemes, remeshing techniques, immersed models etc.
Today, a plugin for model order reduction does already exist. The SOFA Symposium could be a good place to discuss such problems (19/11/2019 in Paris).
Hugo
7 October 2019 at 14:03 #14350Wong
BlockedHello @hugo
Thank you for your reply.
Well, I have already tried the MOR plugin, but it is hard for me to define the shake function to meet my deformation requirement. In other words, it is hard for me to utilize it.And unfortunately, I am not a French and my country is far away from France so I am not be able to go to the Symposium.
Thanks,
Wong7 October 2019 at 15:07 #14353Hugo
KeymasterHi @outtt
I can understand it is hard in the first steps to use a new plugin. You can maybe try to create an issue on the associated GitHub if it’s dev questions. If it is user question, you can post them here. I would poke the authors.
Indeed, coming to the SOFA Week is the perfect time for this. Are you sure not to be able to join us?
Best
Hugo
8 October 2019 at 11:19 #14356Wong
BlockedHello @hugo
Well, however this plugin is extraordinarily hard. I once raised this issue on the forum but the author of the plugin did not give an example about free contacts on some local area of a soft body. And this plugin is temporarily used for soft robots not for free contacts.
So if any relevant developers & authors do not have time to patiently explain how to use the plugin, I can never learn how to use it.
Wong
8 October 2019 at 11:41 #14357Hugo
KeymasterHi @outtt
You can share with us the simulation case you would like to accelerate. I could give a look at it. I could also give a try using the MOR plugin.
You know that this plugin freshly comes from research and is made open-source. Documentation and support is unfortunately time consuming and researchers dedicate themself on their spare time.
I am willing to help you, let me know how.
Hugo
16 October 2019 at 10:43 #14407Wong
BlockedHello @hugo
This is my example. I hope you can literately help me. The issue is described in ReadMe.txt so you should be make sure that you read it beforehand.
https://www.dropbox.com/s/epexah0rjj49zh0/problem.rar?dl=0
The version of Sofa is 19.06. You can use your own method to modify(refine) the tetrahedral mesh because if I provide it, it would not necessarily be suitable.
Thanks
Wong22 October 2019 at 10:58 #1442622 October 2019 at 17:14 #14441Hugo
KeymasterHi @outtt
I got the following error compiling your code:
error: type 'int' cannot be used prior to '::' because it has no members typedef typename T::SPtr SPtr; ^ In file included from ../ROIBarycentricMapping.cpp:2: ../ROIBarycentricMapping.inl:94:4: error: use of undeclared identifier 'm_mapper' m_mapper = m; ^ ../ROIBarycentricMapping.inl:117:6: error: use of undeclared identifier 'm_mapper' if (m_mapper) ^ ../ROIBarycentricMapping.inl:119:3: error: use of undeclared identifier 'm_mapper' m_mapper->setName("mapper"); ^ ../ROIBarycentricMapping.inl:120:18: error: use of undeclared identifier 'm_mapper' this->addSlave(m_mapper.get()); ^ ../ROIBarycentricMapping.inl:121:3: error: use of undeclared identifier 'm_mapper' m_mapper->maskFrom = this->maskFrom; ^ ../ROIBarycentricMapping.inl:122:3: error: use of undeclared identifier 'm_mapper' m_mapper->maskTo = this->maskTo; ^ ../ROIBarycentricMapping.inl:129:2: error: use of undeclared identifier 'topology_from' topology_from = this->fromModel->getContext()->getMeshTopology(); ^ ../ROIBarycentricMapping.inl:130:2: error: use of undeclared identifier 'topology_to' topology_to = this->toModel->getContext()->getMeshTopology(); ^ fatal error: too many errors emitted, stopping now [-ferror-limit=]
Note also that your CMakeLists.txt needs changes to be compiled externally from SOFA:
cmake_minimum_required(VERSION 2.8.12) project(ROIBarycentricMapping) find_package(SofaFramework REQUIRED) find_package(SofaBase REQUIRED) find_package(SofaGeneral REQUIRED) set(HEADER_FILES initPlugin.h ROIBarycentricMapping.h ROIBarycentricMapping.inl ) set(SOURCE_FILES initPlugin.cpp ROIBarycentricMapping.cpp ) add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${SCENES_FILES} ${README_FILES}) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DPLUGIN_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"") set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DSOFA_BUILD_ROIBARYCENTRICMAPPING") target_link_libraries(${PROJECT_NAME} SofaCore SofaHelper SofaUserInteraction SofaBaseMechanics SofaEigen2Solver) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..") install(TARGETS ${PROJECT_NAME} COMPONENT ROIBarycentricMapping_libraries EXPORT ROIBarycentricMappingTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
Cheers
Hugo
23 October 2019 at 03:12 #14443Wong
BlockedHello @Hugo,
I use Sofa v19.06 and there is no any compile error.
And can you tell me how to make it an external plugin?Wong
23 October 2019 at 14:52 #14447Hugo
KeymasterNo @outtt
The m_mapper variable l.94 in ROIBarycentricMapping.inl is used but not declared in your code. Where does it come from?
Hugo
23 October 2019 at 17:12 #14451Wong
BlockedHello @hugo
ROIBarycentricMapping does inherit from BarycentricMapping.
You can see the m_mapper there.
Wong
25 October 2019 at 03:32 #1446625 October 2019 at 18:13 #14477Hugo
Keymasterhi @outtt
I am out of the office for meeting partners of the community. I will give a try next week for sure.
BestHugo
29 October 2019 at 05:38 #1448231 October 2019 at 11:54 #1450131 October 2019 at 15:06 #1450531 October 2019 at 15:42 #14506Hugo
KeymasterAfter modifying templates and others in your code, it now works. I am just missing an Omni to fully test your scene.
I don’t understand what you are doing with the ROIBarycentricMapping since you are coupling both the needle and the brain. Is this on purpose ?
What would be now the next step you would like to achieve based on this scene?
Hugo
5 November 2019 at 05:27 #14534Wong
BlockedHello @hugo
I did not couple the needle and the brain though. You saw such scene at the beginning just because the Geomagic plugin was not at work.
Well, what I want to achieve is to make the local deformation closer to reality as you can see in the picture of the realistic surgery in the attachment.
Did you see the two pictures in that attachment?
Wong
8 November 2019 at 20:49 #14570Hugo
KeymasterHi @outtt
Alright.
At the occasion of the SOFA Week 2019, a tutorial session is organized on 20th Nov (morning). I will attend the Model Order Reduction session. Your simulation case could be interesting to test.
Would this be of interest for you?Hugo
9 November 2019 at 06:11 #14573Wong
BlockedHello @hugo
Do you mean you will talk about this case in the session?
After all I will be not be able to attend this session and I do not know if you will find a solution at last.
So I think I will try another method to solve this issue, such as remeshing techniques and will also at the same time wait your news after the session.Wong
9 November 2019 at 11:04 #14574epernod
BlockedHi,
sorry I didn’t read the whole conversation but did you give a try with SubsetTopologyEngine ?
You can split the mesh using a boxROI and then use tetra FEM on the ROI you want to simulate with accuracy and use a Grid + HexaFEM for the rest of the mesh.
It is more a trick than an accurate solution. Otherwise I would recommand to generate a better mesh with CGal for example and putting more seeds where you need finer meshSee example : examples/Components/engine/SubsetTopoloy_refiningMesh.scn
regards,
9 November 2019 at 16:49 #14575Wong
BlockedHello @epernod
Well, I have to say that I have ever tried to use SubsetTopology.
But the first problem is that using SubsetTopology would make the scene more complicated and inefficient. Secondly, the spring connecting the Hex and Tet mesh would result in abnormal behavior when the haptic feedback involves. And the constraint solving process would be time-consuming. Or you can provide an example to prove that this way is viable?I also have looked for relevant information about CGAL to solve the problem. But coding for CGAL is very complicated and there are too little examples. Can you tell me how to put seeds using CGAL?
Wong
11 November 2019 at 09:07 #14578 -
AuthorPosts
- You must be logged in to reply to this topic.