Fran,

Indeed.
GetNodeN must return a ChNodeFEAbase because it is a virtual method of the base 
class ChElementBase.

You need to cast the nodes to the proper type to get their positions.  
Something like:
    for (const auto& s : spring) {
        tools::drawSegment(vis.get(),
                                             
std::static_pointer_cast<ChNodeFEAxyz>(s->GetNode(0))->GetPos(),
                                             
std::static_pointer_cast<ChNodeFEAxyz>(s->GetNode(1))->GetPos());
    }

--Radu

From: [email protected] <[email protected]> On Behalf 
Of Fran Bottero
Sent: Tuesday, June 7, 2022 1:44 PM
To: ProjectChrono <[email protected]>
Subject: [chrono] ChElementSpring visualization

Radu,
Yes, I tried to do something similar. ChElementSpring has the function 
GetNodeN(int n), but this returns a ChNodeFEAbase (I don't know why is 
programmed like that, because to create the spring you need two ChNodeFEAxyz), 
and here it is not implemented the function GetPos() or GetX0() as in other 
kind of nodes types.

I tried also creating a vector of nodes but its not an option becouse of the 
order that they follow, the right solution would be similar to what you said 
before, I need to extract the  nodes from the element, but I am not able to 
programate it.

Thanks,

Fran

El martes, 7 de junio de 2022 a las 10:30:43 UTC+2, Radu Serban escribió:
Fran,

Not with the current Chrono code.
But why not do something like:

std::vector<std::shared_ptr<ChElementSpring>> springs;

// Create spring elements, add to mesh, add to list
auto spring1 = chrono_types::make_shared<ChElementSpring>();
spring1->SetNodes(nodeA, nodeB);
mesh->AddElement(spring1);
springs.push_back(spring1);

auto spring2 = …
…
springs.push_back(spring2);

// Simulation loop
while(…) {
…
    for (const auto& s : spring) {
    tools::drawSegment(vis.get(), s->GetNode(0)->GetPos(), 
s->GetNode(1)->GetPos());
    }
…
}

--Radu

P.S. Please continue conversations on the user mailing list. Thanks

From: Fran Bottero <[email protected]>
Sent: Tuesday, June 7, 2022 10:12 AM
To: Radu Serban <[email protected]>
Subject: Mensaje privado sobre: [chrono] ChElementSpring visualization

Great,

Yes its good  enough and it's working, just one more question, as I have to 
join several number of nodes following an predefined order (that I indicated 
when I create the springs), is it possible to do it outside the while loop (for 
example, adding another propertie to the  ChElementSpring)?

Thanks,

Fran



El lunes, 6 de junio de 2022 a las 13:43:02 UTC+2, Radu Serban escribió:
Hi Fran,

If rendering a line between the two nodes is good enough, you can simply call 
the function drawSegment() within your simulation loop (before the call to 
EndScene) and pass it the locations of the two nodes you want connected.
As an example, look at 
demo_IRR_gears<https://github.com/projectchrono/chrono/blob/eacf287b90483a5db51aa5fdb866a3a39892d85c/src/demos/irrlicht/demo_IRR_gears.cpp#L221>.

--Radu



From: [email protected] <[email protected]> On Behalf Of Fran 
Bottero
Sent: Monday, June 6, 2022 1:28 PM
To: ProjectChrono <[email protected]>
Subject: [chrono] ChElementSpring visualization


Hi there!



I am trying to visualise spring elements (ChElementSpring) on irrlicht app, but 
it has been quite impossible for me. I found some examples and I could 
replicate them and visualise some links as springs (ChLinkTSDA), but it is not 
what I need because this kind of links need two bodies to be created, and that 
is so inefficient for my model.

I was looking for a way to visualise the spring created between two nodes, my 
system is currently working. For simple models is possible to understand what 
is happening just with the representation of the nodes as dots, but if I want 
to make it more complex, will be so much easier to comprehend if I can see the 
springs on the irrlicht app.

On my script, first of all, I create some nodes and elements:


// Upper:
auto nodeA = chrono_types::make_shared<ChNodeFEAxyz>(ChVector<>(0, Ly, 0));
nodeA->SetMass(m);
mesh->AddNode(nodeA);

// Right:
auto nodeB = chrono_types::make_shared<ChNodeFEAxyz>(ChVector<>(Lx, 0, 0));
nodeB->SetMass(m);
mesh->AddNode(nodeB);

(…)

// Upper-Right
auto springAB = chrono_types::make_shared<ChElementSpring>();
springAB->SetNodes(nodeA, nodeB);
springAB->SetSpringK(K);
springAB->SetDamperR(0);
mesh->AddElement(springAB);



Then I represent the nodes as dots, as you can see in the following code:



auto visGlyph = 
chrono_types::make_shared<ChVisualizationFEAmesh>(*(mesh.get()));
visGlyph->SetFEMglyphType(ChVisualizationFEAmesh::E_GLYPH_NODE_DOT_POS);
visGlyph->SetFEMdataType(ChVisualizationFEAmesh::E_PLOT_NONE);
visGlyph->SetSymbolsThickness(0.02);
mesh->AddAsset(visGlyph);



I also tried to represent the springs, as I did it before for other kind of 
elements (for example with ChBeamEulerAdvance) but I do not know how to 
configurate them. Is there any option or function to do it? I do not need 
something complex, with a simple line is enough.



Thanks!

Fran
--
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/e5a30dc1-37ed-4d2e-b0e9-607c9186279fn%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/e5a30dc1-37ed-4d2e-b0e9-607c9186279fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/c94f531f-f002-4d8e-8189-2be1eb178c42n%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/c94f531f-f002-4d8e-8189-2be1eb178c42n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/PH0PR06MB82371A4D763EF25F68321746A7A59%40PH0PR06MB8237.namprd06.prod.outlook.com.

Reply via email to