<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Yusuf,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">as posting attachments on the <a href="https://discourse.itk.org/t/itk-fem-solver-update-problem/280">discourse</a> forum is not allowed, here is the updated source code to run on VTK8.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 10, 2017 at 11:36 AM, Yusuf OEZBEK via Insight-users <span dir="ltr"><<a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:10px"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6316"><span></span></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6446"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7856" size="3">Hello,</font></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6473"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6986" dir="ltr"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7968" size="3">Thank you for the answer </font><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6559" size="3"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7969" size="3">Francois</font>. Even chaning from raw- to smart-pointer for itkMesh did'nt bring any solution. The number of proints, cells and cell types are the same for vtkUnstructured grid and itkMesh after converting. But I got a new error : "</font><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7058" size="3">vnl_error_vector_dimension:<wbr>vnl_matrix::set_row: Dimensions [3] and [2] donot match" after the calling </font><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7079" size="2">m_FemSolver->Update(); function.</font></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6551" class="m_-1146510568008448008qtdSeparateBR"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7114"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7141" size="3">Do you (or someone else) know</font>, <font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7221" size="3">which matrix dimension is meant hier? </font></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7742"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7479" dir="ltr"><br><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7221" size="3">Same quation is also asked here. But unfortunately without answer: <a id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7478" href="https://itk.org/pipermail/insight-users/2009-July/031536.html" target="_blank">https://itk.org/pipermail/<wbr>insight-users/2009-July/<wbr>031536.html</a> <br></font></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7486"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7536"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7369"><font size="3"><br></font></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7164"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7772" size="3">Best regards</font><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7105"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7198"><br></div><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7244"><br></div></div><div style="display:block" id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6508" class="m_-1146510568008448008yahoo_quoted"> <div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6507" style="font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:10px"> <div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6506" style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><span class=""> <div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6544" dir="ltr"><font id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6543" face="Arial" size="2"> Francois Budin <<a href="mailto:francois.budin@kitware.com" target="_blank">francois.budin@kitware.com</a>> schrieb am 19:35 Montag, 9.Oktober 2017:<br></font></div> <br><br> </span><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6505" class="m_-1146510568008448008y_msg_container"><div id="m_-1146510568008448008yiv3537223775"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6504"><span class=""><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6503" dir="ltr"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6502"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6501"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6500"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6499"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6498"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_6497">Hello Yusuf,<br clear="none"><br clear="none"></div>I am not sure what the problem is, but here are some ideas you can try to understand it or try to solve it:<br clear="none"></div>1) Use ITK smart pointers instead of raw pointers. The crash seem to indicate that the program was trying to unregister a smart pointer, but your mesh is declared as a raw pointer. The issue could come from this.<br clear="none"></div>2) Have you tried to look at your data, once converted, to make sure that it was converted correctly? Maybe there is a problem during your conversion which leads to an empty mesh or something worst.<br clear="none"><br clear="none"></div>Hope this helps,<br clear="none"></div>Francois<br clear="none"><br clear="none"></div>PS: As a side note, you may want to join the ITK discourse forum to ask your question or help others. The mailing list is still active but more people seem to be using the discourse forum now that it is available (<a rel="nofollow" shape="rect" href="http://discourse.itk.org/" target="_blank">http://discourse.itk.org/</a>)<br clear="none"></div></span><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7024" class="m_-1146510568008448008yiv3537223775gmail_extra"><br clear="none"><div class="m_-1146510568008448008yiv3537223775yqt2765477433" id="m_-1146510568008448008yiv3537223775yqtfd56568"><div id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7023" class="m_-1146510568008448008yiv3537223775gmail_quote"><span class="">On Mon, Oct 9, 2017 at 8:08 AM, Yusuf OEZBEK via Insight-users <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>></span> wrote:<br clear="none"></span><blockquote id="m_-1146510568008448008yui_3_16_0_ym19_1_1507634908991_7022" class="m_-1146510568008448008yiv3537223775gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear ITK Users,<br clear="none">
<br clear="none">
According the mail <a rel="nofollow" shape="rect" href="https://public.kitware.com/pipermail/insight-users/2007-November/024272.html" target="_blank">https://public.kitware.com/ pipermail/insight-users/2007- November/024272.html</a> , I have converted my vtkUnstructuredGrid, wich I extracted from a vtkPolyData and contains TRIANGLE_CELL's to the itkMesh and than from itkMesh to itk::Fem::Object to deform my mesh:<span class=""><br clear="none">
My problem is: If I call "m_FemSolver->Update();" ,I get a segmentation fault, which I really not understand.<br clear="none">
<br clear="none">
Program received signal SIGSEGV, Segmentation fault.<br clear="none">
0x00007fffb1086dd5 in itk::fem::FEMObject<2u>:: DeepCopy (this=0x4cc5ee0,<br clear="none">
Copy=0x4cc1780)<br clear="none"></span>
at /home/toolkits/itk-4.7.2/ Modules/Numerics/FEM/include/ itkFEMObject.hxx:157<span class=""><br clear="none">
157 a->UnRegister();<br clear="none">
<br clear="none">
<br clear="none">
void itkMeshToFemMesh:: updateItkMeshSlot(itk::Mesh< double, 3, MeshTraitsType> *itkMesh)<br clear="none">
{<br clear="none">
typedef itk::fem::FEMObject<3> FemObjectType;<br clear="none">
FemObjectType::Pointer m_FemObject= FemObjectType::New();<br clear="none">
<br clear="none">
typedef itk::fem::Solver<3> SolverType;<br clear="none">
typedef SolverType::Pointer SolverPointerType;<br clear="none">
SolverPointerType m_FemSolver= SolverType::New();<br clear="none">
<br clear="none">
// Define the Element Material properties<br clear="none">
typedef itk::fem:: MaterialLinearElasticity MaterialType;<br clear="none">
MaterialType::Pointer material= MaterialType::New();<br clear="none">
material->SetGlobalNumber(0);<br clear="none">
material->SetYoungsModulus( 200E6);<br clear="none">
material-> SetCrossSectionalArea(1.0);<br clear="none">
material->SetThickness(1.0);<br clear="none">
material->SetMomentOfInertia( 1.0);<br clear="none">
material->SetPoissonsRatio(0. 2);<br clear="none">
material-> SetDensityHeatProduct(1.0);<br clear="none">
m_FemObject->AddNextMaterial( material);<br clear="none">
<br clear="none">
// Define the element type<br clear="none"></span>
typedef itk::fem:: Element2DC0LinearTriangularStr ain TriangularElementType;<div><div class="h5"><br clear="none">
TriangularElementType::Pointer triangularElement= TriangularElementType::New();<br clear="none">
triangularElement-> SetMaterial(material. GetPointer());<br clear="none">
<br clear="none">
// Convert mesh points into nodes<br clear="none">
VectorType point(3);<br clear="none">
PointType*ptr;<br clear="none">
PointType pt;<br clear="none">
ptr= &pt;<br clear="none">
<br clear="none">
int numOfPoints= itkMesh->GetNumberOfPoints();<br clear="none">
cout<<"itkMesh numOfPoints: "<<numOfPoints<<endl;<br clear="none">
<br clear="none">
int numberOfCells= itkMesh->GetNumberOfCells();<br clear="none">
cout<<"itkMesh numberOfCells: "<<numberOfCells<<endl;<br clear="none">
<br clear="none">
CellsContainerPointer cellIterator= itkMesh->GetCells();<br clear="none">
CellIterator cells= cellIterator->Begin();<br clear="none">
<br clear="none">
bool flag= true;<br clear="none">
<br clear="none">
for(int k=0; k< numberOfCells; k++)<br clear="none">
{<br clear="none">
CellType *cellPtr= cells.Value();<br clear="none">
cout<<"Cell Value: "<< cells.Value() << " Cell Type= " << cellPtr->GetType()<<endl;<br clear="none">
<br clear="none">
switch(cellPtr->GetType())<br clear="none">
{<br clear="none">
case CellType::TRIANGLE_CELL:<br clear="none">
{<br clear="none">
if(flag== true) // To make sure that the nodes are created just once<br clear="none">
{<br clear="none">
for(int j= 0; j< numOfPoints; j++)<br clear="none">
{<br clear="none">
itkMesh->GetPoint(j, ptr);<br clear="none">
<br clear="none">
typedef TriangularElementType::Node TriangularNodeType;<br clear="none">
TriangularNodeType::Pointer triangularNode= TriangularNodeType::New();<br clear="none">
point[0]= -1.0;<br clear="none">
point[1]= 2.0;<br clear="none">
point[2]= 3.0;<br clear="none">
triangularNode-> SetCoordinates(point);<br clear="none">
triangularNode-> SetGlobalNumber(j);<br clear="none">
m_FemObject->AddNextNode( triangularNode.GetPointer());<br clear="none">
}<br clear="none">
flag= false;<br clear="none">
}<br clear="none">
PointIdIterator pointIt= cellPtr->PointIdsBegin();<br clear="none">
int i= 0;<br clear="none">
<br clear="none">
while(pointIt!= cellPtr->PointIdsEnd())<br clear="none">
{<br clear="none">
triangularElement->SetNode(i, m_FemObject->GetNode(*pointIt) );<br clear="none">
pointIt++;<br clear="none">
i++;<br clear="none">
}<br clear="none">
cells++;<br clear="none">
triangularElement-> SetGlobalNumber(k);<br clear="none">
m_FemObject->AddNextElement( triangularElement.GetPointer() );<br clear="none">
break;<br clear="none">
}<br clear="none">
}<br clear="none">
}<br clear="none">
<br clear="none">
// Define some Load<br clear="none">
LoadNodePointerType loadNode =LoadNodeType::New();<br clear="none">
loadNode->SetElement( triangularElement);<br clear="none">
loadNode->SetGlobalNumber(3);<br clear="none">
loadNode->SetNode(1);<br clear="none">
<br clear="none">
vnl_vector<double> force(2);<br clear="none">
force[0]= 20.0;<br clear="none">
force[1]= -20.0;<br clear="none">
force[2]= 10.0;<br clear="none">
loadNode->SetForce(force);<br clear="none">
m_FemObject->AddNextLoad( loadNode);<br clear="none">
<br clear="none">
//Solve for displacements.<br clear="none">
m_FemObject->FinalizeMesh();<br clear="none">
m_FemSolver->SetInput(m_ FemObject);<br clear="none">
m_FemSolver->Update(); // SEGMENTATION FAULT<br clear="none">
<br clear="none">
cout<< "Fem Solver Output: "<< m_FemSolver->GetOutput()<< endl;<br clear="none">
<br clear="none">
const unsigned int invalidId= itk::fem::Element:: InvalidDegreeOfFreedomID;<br clear="none">
int numberOfNodes= m_FemSolver->GetInput()-> GetNumberOfNodes();<br clear="none">
<br clear="none">
for(int i= 0; i< numberOfNodes; i++)<br clear="none">
{<br clear="none">
itk::fem::Element::Node:: Pointer node= m_FemSolver->GetInput()-> GetNode(i);<br clear="none">
cout<<"Fem Node : "<< node->GetGlobalNumber()<<endl;<br clear="none">
<br clear="none">
for(unsigned int j= 0, dof; (dof= node->GetDegreeOfFreedom(j))!= invalidId; j++)<br clear="none">
{<br clear="none">
cout <<"Solver GetSolution: "<< m_FemSolver->GetSolution(dof)< <endl;<br clear="none">
}<br clear="none">
}<br clear="none">
<br clear="none">
// Write the deformed mesh<br clear="none">
typedef itk::FEMObjectSpatialObject<3> FemObjectSpatialObjectType;<br clear="none">
FemObjectSpatialObjectType:: Pointer m_FemSpatialObject= FemObjectSpatialObjectType:: New();<br clear="none">
m_FemSpatialObject-> SetFEMObject(m_FemSolver-> GetOutput());<br clear="none">
<br clear="none">
typedef itk::FEMSpatialObjectWriter<3><wbr> FemSpatialObjectWriterType;<br clear="none">
FemSpatialObjectWriterType:: Pointer femSpatialWriter= FemSpatialObjectWriterType:: New();<br clear="none">
femSpatialWriter->SetInput(m_ FemSpatialObject);<br clear="none">
femSpatialWriter->SetFileName( "deformedMesh.meta");<br clear="none">
femSpatialWriter->Update();<br clear="none">
}<br clear="none">
<br clear="none">
Thank you for any help!<br clear="none">
The ITK community is transitioning from this mailing list to <a rel="nofollow" shape="rect" href="http://discourse.itk.org/" target="_blank">discourse.itk.org</a>. Please join us there!<br clear="none">
______________________________ __<br clear="none">
Powered by <a rel="nofollow" shape="rect" href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br clear="none">
<br clear="none">
Visit other Kitware open-source projects at<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/ opensource/opensource.html</a><br clear="none">
<br clear="none">
Kitware offers ITK Training Courses, for more information visit:<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/ products/protraining.php</a><br clear="none">
<br clear="none">
Please keep messages on-topic and check the ITK FAQ at:<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_ FAQ</a><br clear="none">
<br clear="none">
Follow this link to subscribe/unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/ mailman/listinfo/insight-users</a><br clear="none">
</div></div></blockquote></div><br clear="none"></div></div></div></div><br><br></div> </div> </div> </div></div></div><br>The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">discourse.itk.org</a>. Please join us there!<br>
______________________________<wbr>__<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>