diff --git a/chronoseulersimulationmodel.cpp b/chronoseulersimulationmodel.cpp index 08a0fd5..6eb1efb 100644 --- a/chronoseulersimulationmodel.cpp +++ b/chronoseulersimulationmodel.cpp @@ -1,5 +1,4 @@ #include "chronoseulersimulationmodel.hpp" -#include "chrono/physics/ChLoadContainer.h" #include #include #include @@ -8,6 +7,7 @@ #include #include #include +#include "chrono/physics/ChLoadContainer.h" #include #include @@ -16,242 +16,268 @@ using namespace chrono; using namespace chrono::fea; std::shared_ptr ChronosEulerSimulationModel::convertToChronosMesh_Euler( - const std::shared_ptr &pMesh, - std::vector> &edgeMeshVertsToChronosNodes) -{ - auto mesh_chronos = chrono_types::make_shared(); - edgeMeshVertsToChronosNodes.clear(); - edgeMeshVertsToChronosNodes.resize(pMesh->VN(), nullptr); + const std::shared_ptr& pMesh, + std::vector>& + edgeMeshVertsToChronosNodes) { + auto mesh_chronos = chrono_types::make_shared(); + edgeMeshVertsToChronosNodes.clear(); + edgeMeshVertsToChronosNodes.resize(pMesh->VN(), nullptr); - //add nodes - for (int vi = 0; vi < pMesh->VN(); vi++) { - const auto &vertex = pMesh->vert[vi]; - ChVector<> vertexPos(vertex.cP()[0], vertex.cP()[1], vertex.cP()[2]); - edgeMeshVertsToChronosNodes[vi] = chrono_types::make_shared( - ChFrame<>(vertexPos)); - mesh_chronos->AddNode(edgeMeshVertsToChronosNodes[vi]); - } - //add elements - ChBuilderBeamEuler builder; - for (int ei = 0; ei < pMesh->EN(); ei++) { - const SimulationMesh::EdgeType &edge = pMesh->edge[ei]; - //define end-points - const auto vi0 = pMesh->getIndex(edge.cV(0)); - const auto vi1 = pMesh->getIndex(edge.cV(1)); - //define cross section - const Element &element = pMesh->elements[ei]; - const double beam_wz = element.dimensions.getDim1(); - const double beam_wy = element.dimensions.getDim2(); - const double E = element.material.youngsModulus; - // const double poisson = element.material.poissonsRatio; - const double density = 1e0; + // add nodes + for (int vi = 0; vi < pMesh->VN(); vi++) { + const auto& vertex = pMesh->vert[vi]; + ChVector<> vertexPos(vertex.cP()[0], vertex.cP()[1], vertex.cP()[2]); + edgeMeshVertsToChronosNodes[vi] = + chrono_types::make_shared(ChFrame<>(vertexPos)); + mesh_chronos->AddNode(edgeMeshVertsToChronosNodes[vi]); + } + // add elements + ChBuilderBeamEuler builder; + for (int ei = 0; ei < pMesh->EN(); ei++) { + const SimulationEdgeMesh::EdgeType& edge = pMesh->edge[ei]; + // define end-points + const auto vi0 = pMesh->getIndex(edge.cV(0)); + const auto vi1 = pMesh->getIndex(edge.cV(1)); + // define cross section + const Element& element = pMesh->elements[ei]; + const double beam_wz = element.dimensions.getDim1(); + const double beam_wy = element.dimensions.getDim2(); + const double E = element.material.youngsModulus; + // const double poisson = element.material.poissonsRatio; + const double density = 1e0; - // auto msection = chrono_types::make_shared(); - auto msection = chrono_types::make_shared( + // auto msection = + // chrono_types::make_shared(); + auto msection = + chrono_types::make_shared( beam_wy, beam_wz, E, element.material.G, density); - // msection->SetDensity(density); - // msection->SetYoungModulus(E); - // msection->SetGwithPoissonRatio(poisson); - // // msection->SetBeamRaleyghDamping(0.0); - // msection->SetAsRectangularSection(beam_wy, beam_wz); - builder - .BuildBeam(mesh_chronos, // the mesh where to put the created nodes and elements - msection, // the ChBeamSectionEuler to use for the ChElementBeamEuler elements - 1, // the number of ChElementBeamEuler to create - edgeMeshVertsToChronosNodes[vi0], // the 'A' point in space (beginning of beam) - edgeMeshVertsToChronosNodes[vi1], // the 'B' point in space (end of beam) - ChVector<>(0, 0, 1) - // ChVector<>(0, cos(rot_rad), sin(rot_rad)) - ); // the 'Y' up direction of the section for the beam - } + msection->SetArea(element.dimensions.A); + msection->SetIyy(element.dimensions.inertia.I2); + msection->SetIzz(element.dimensions.inertia.I3); + msection->SetJ(element.dimensions.inertia.J); + // msection->SetDensity(density); + // msection->SetYoungModulus(E); + // msection->SetGwithPoissonRatio(poisson); + // // msection->SetBeamRaleyghDamping(0.0); + // msection->SetAsRectangularSection(beam_wy, beam_wz); + builder.BuildBeam( + mesh_chronos, // the mesh where to put the created nodes and elements + msection, // the ChBeamSectionEuler to use for the ChElementBeamEuler + // elements + 1, // the number of ChElementBeamEuler to create + edgeMeshVertsToChronosNodes[vi0], // the 'A' point in space (beginning + // of beam) + edgeMeshVertsToChronosNodes[vi1], // the 'B' point in space (end of + // beam) + ChVector<>(0, 0, 1) + // ChVector<>(0, cos(rot_rad), sin(rot_rad)) + ); // the 'Y' up direction of the section for the beam + } - return mesh_chronos; + return mesh_chronos; } ChronosEulerSimulationModel::ChronosEulerSimulationModel() {} -//SimulationResults ChronosEulerSimulationModel::executeSimulation( +// SimulationResults ChronosEulerSimulationModel::executeSimulation( // const std::shared_ptr &pJob) //{} -//chrono::ChSystemSMC convertToChronosSystem(const std::shared_ptr &pJob) +// chrono::ChSystemSMC convertToChronosSystem(const +// std::shared_ptr &pJob) //{ // chrono::ChSystemSMC my_system; //} void ChronosEulerSimulationModel::parseForces( - const std::shared_ptr &mesh_chronos, - const std::vector> &edgeMeshVertsToChronoNodes, - const std::unordered_map &nodalExternalForces) -{ - mesh_chronos->SetAutomaticGravity(false); - for (const std::pair &externalForce : nodalExternalForces) { - const int &forceVi = externalForce.first; - const Vector6d &force = externalForce.second; - edgeMeshVertsToChronoNodes[forceVi]->SetForce(ChVector<>(force[0], force[1], force[2])); - edgeMeshVertsToChronoNodes[forceVi]->SetTorque(ChVector<>(force[3], force[4], force[5])); - } + const std::shared_ptr& mesh_chronos, + const std::vector>& + edgeMeshVertsToChronoNodes, + const std::unordered_map& nodalExternalForces) { + mesh_chronos->SetAutomaticGravity(false); + for (const std::pair& externalForce : + nodalExternalForces) { + const int& forceVi = externalForce.first; + const Vector6d& force = externalForce.second; + edgeMeshVertsToChronoNodes[forceVi]->SetForce( + ChVector<>(force[0], force[1], force[2])); + edgeMeshVertsToChronoNodes[forceVi]->SetTorque( + ChVector<>(force[3], force[4], force[5])); + } } void ChronosEulerSimulationModel::parseConstrainedVertices( - const std::shared_ptr &pJob, - const std::vector> &edgeMeshVertsToChronoNodes, - chrono::ChSystemSMC &my_system) -{ - assert(!edgeMeshVertsToChronoNodes.empty()); - for (const std::pair> &constrainedVertex : - pJob->constrainedVertices) { - const int &constrainedVi = constrainedVertex.first; - const std::unordered_set &constrainedDoF = constrainedVertex.second; - // Create a truss - auto truss = chrono_types::make_shared(); - truss->SetBodyFixed(true); - my_system.Add(truss); - const auto &constrainedChronoNode = edgeMeshVertsToChronoNodes[constrainedVi]; - // Create a constraint at the end of the beam - auto constr_a = chrono_types::make_shared(); - constr_a->SetConstrainedCoords(constrainedDoF.contains(0), - constrainedDoF.contains(1), - constrainedDoF.contains(2), - constrainedDoF.contains(3), - constrainedDoF.contains(4), - constrainedDoF.contains(5)); - constr_a->Initialize(constrainedChronoNode, - truss, - false, - constrainedChronoNode->Frame(), - constrainedChronoNode->Frame()); - // const auto frameNode = constrainedChronoNode->Frame(); - my_system.Add(constr_a); + const std::shared_ptr& pJob, + const std::vector>& + edgeMeshVertsToChronoNodes, + chrono::ChSystemSMC& my_system) { + assert(!edgeMeshVertsToChronoNodes.empty()); + for (const std::pair>& + constrainedVertex : pJob->constrainedVertices) { + const int& constrainedVi = constrainedVertex.first; + const std::unordered_set& constrainedDoF = constrainedVertex.second; + // Create a truss + auto truss = chrono_types::make_shared(); + truss->SetBodyFixed(true); + my_system.Add(truss); + const auto& constrainedChronoNode = + edgeMeshVertsToChronoNodes[constrainedVi]; + // Create a constraint at the end of the beam + auto constr_a = chrono_types::make_shared(); + constr_a->SetConstrainedCoords( + constrainedDoF.contains(0), constrainedDoF.contains(1), + constrainedDoF.contains(2), constrainedDoF.contains(3), + constrainedDoF.contains(4), constrainedDoF.contains(5)); + constr_a->Initialize(constrainedChronoNode, truss, false, + constrainedChronoNode->Frame(), + constrainedChronoNode->Frame()); + // const auto frameNode = constrainedChronoNode->Frame(); + my_system.Add(constr_a); - // edgeMeshVertsToChronoNodes[constrainedVi]->SetFixed(true); - // if (vertexIsFullyConstrained) { - // } else { - // std::cerr << "Currently only rigid vertices are handled." << std::endl; - // // SimulationResults simulationResults; - // // simulationResults.converged = false; - // // assert(false); - // // return simulationResults; - // } - } + // edgeMeshVertsToChronoNodes[constrainedVi]->SetFixed(true); + // if (vertexIsFullyConstrained) { + // } else { + // std::cerr << "Currently only rigid vertices are handled." << + // std::endl; + // // SimulationResults simulationResults; + // // simulationResults.converged = false; + // // assert(false); + // // return simulationResults; + // } + } } SimulationResults ChronosEulerSimulationModel::executeSimulation( - const std::shared_ptr &pJob) -{ - // assert(pJob->pMesh->VN() != 0); - // const bool structureInitialized = mesh_chronos != nullptr; - // const bool wasInitializedWithDifferentStructure = structureInitialized - // && (pJob->pMesh->EN() - // != mesh_chronos->GetNelements() - // || pJob->pMesh->VN() - // != mesh_chronos->GetNnodes()); - // if (!structureInitialized || wasInitializedWithDifferentStructure) { - setStructure(pJob->pMesh); - // } - chrono::ChSystemSMC my_system; - // chrono::irrlicht::ChIrrApp application(&my_system, - // L"Irrlicht FEM visualization", - // irr::core::dimension2d(800, 600), - // chrono::irrlicht::VerticalDir::Z, - // false, - // true); - // const std::string chronoDataFolderPath = "/home/iason/Coding/build/external " - // "dependencies/CHRONO-src/data/"; - // application.AddTypicalLogo(chronoDataFolderPath + "logo_chronoengine_alpha.png"); - // application.AddTypicalSky(chronoDataFolderPath + "skybox/"); - // application.AddTypicalLights(); - // application.AddTypicalCamera(irr::core::vector3df(0, (irr::f32) 0.6, -1)); - // my_system.SetTimestepperType(chrono::ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); - //parse forces - parseForces(mesh_chronos, edgeMeshVertsToChronoNodes, pJob->nodalExternalForces); - //parse constrained vertices - parseConstrainedVertices(pJob, edgeMeshVertsToChronoNodes, my_system); - // std::dynamic_pointer_cast>(mesh_chronos->GetNode(1)) - // ->SetFixed(true); - // and load containers must be added to your system - // auto mvisualizemesh = chrono_types::make_shared(*(mesh_chronos.get())); - // mvisualizemesh->SetFEMdataType(ChVisualizationFEAmesh::E_PLOT_NODE_DISP_NORM); - // mvisualizemesh->SetColorscaleMinMax(0.0, 5.50); - // mvisualizemesh->SetShrinkElements(false, 0.85); - // mvisualizemesh->SetSmoothFaces(false); - // mesh_chronos->AddAsset(mvisualizemesh); + const std::shared_ptr& pJob) { + assert(pJob->pMesh->VN() != 0); + // const bool structureInitialized = mesh_chronos != nullptr; + // const bool wasInitializedWithDifferentStructure = + // structureInitialized && + // (pJob->pMesh->EN() != mesh_chronos->GetNelements() || + // pJob->pMesh->VN() != mesh_chronos->GetNnodes()); + // if (!structureInitialized || wasInitializedWithDifferentStructure) { + setStructure(pJob->pMesh); + // } + chrono::ChSystemSMC my_system; + // chrono::irrlicht::ChIrrApp application(&my_system, + // L"Irrlicht FEM visualization", + // irr::core::dimension2d(800, + // 600), + // chrono::irrlicht::VerticalDir::Z, + // false, + // true); + // const std::string chronoDataFolderPath = + // "/home/iason/Coding/build/external " + // "dependencies/CHRONO-src/data/"; + // application.AddTypicalLogo(chronoDataFolderPath + + // "logo_chronoengine_alpha.png"); + // application.AddTypicalSky(chronoDataFolderPath + "skybox/"); + // application.AddTypicalLights(); + // application.AddTypicalCamera(irr::core::vector3df(0, (irr::f32) 0.6, + // -1)); + // my_system.SetTimestepperType(chrono::ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); + // parse forces + parseForces(mesh_chronos, edgeMeshVertsToChronoNodes, + pJob->nodalExternalForces); + // parse constrained vertices + parseConstrainedVertices(pJob, edgeMeshVertsToChronoNodes, my_system); + // std::dynamic_pointer_cast>(mesh_chronos->GetNode(1)) + // ->SetFixed(true); + // and load containers must be added to your system + // auto mvisualizemesh = + // chrono_types::make_shared(*(mesh_chronos.get())); + // mvisualizemesh->SetFEMdataType(ChVisualizationFEAmesh::E_PLOT_NODE_DISP_NORM); + // mvisualizemesh->SetColorscaleMinMax(0.0, 5.50); + // mvisualizemesh->SetShrinkElements(false, 0.85); + // mvisualizemesh->SetSmoothFaces(false); + // mesh_chronos->AddAsset(mvisualizemesh); - // application.AssetBindAll(); - // application.AssetUpdateAll(); - my_system.Add(mesh_chronos); + // application.AssetBindAll(); + // application.AssetUpdateAll(); + my_system.Add(mesh_chronos); - auto solver = chrono_types::make_shared(); - my_system.SetSolver(solver); - solver->SetMaxIterations(1e5); - // solver->SetTolerance(1e-12); - solver->EnableWarmStart(true); // IMPORTANT for convergence when using EULER_IMPLICIT_LINEARIZED - solver->EnableDiagonalPreconditioner(true); - my_system.SetSolverForceTolerance(1e-9); - solver->SetVerbose(false); + auto solver = chrono_types::make_shared(); + my_system.SetSolver(solver); + // solver->SetMaxIterations(1e5); + // solver->SetTolerance(1e-12); + solver->EnableWarmStart( + true); // IMPORTANT for convergence when using EULER_IMPLICIT_LINEARIZED + solver->EnableDiagonalPreconditioner(true); + my_system.SetSolverForceTolerance(1e-9); + solver->SetVerbose(false); - SimulationResults simulationResults; + SimulationResults simulationResults; + if (settings.analysisType == Settings::AnalysisType::Linear) { + simulationResults.converged = my_system.DoStaticLinear(); + } else { simulationResults.converged = my_system.DoStaticNonlinear(); - // simulationResults.converged = my_system.DoStaticLinear(); - if (!simulationResults.converged) { - std::cerr << "Simulation failed" << std::endl; - assert(false); - return simulationResults; - } - - // my_system.SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); - // application.SetTimestep(0.001); - - // while (application.GetDevice()->run()) { - // application.BeginScene(); - // application.DrawAll(); - // application.EndScene(); - // } - simulationResults.pJob = pJob; - simulationResults.displacements.resize(pJob->pMesh->VN()); - simulationResults.rotationalDisplacementQuaternion.resize(pJob->pMesh->VN()); - for (size_t vi = 0; vi < pJob->pMesh->VN(); vi++) { - const auto node_chronos = edgeMeshVertsToChronoNodes[vi]; - const auto posDisplacement = node_chronos->Frame().GetPos() - - node_chronos->GetX0().GetPos(); - // std::cout << "Node " << vi << " coordinate x= " << node_chronos->Frame().GetPos().x() - // << " y=" << node_chronos->Frame().GetPos().y() - // << " z=" << node_chronos->Frame().GetPos().z() << "\n"; - //Translations - simulationResults.displacements[vi][0] = posDisplacement[0]; - simulationResults.displacements[vi][1] = posDisplacement[1]; - simulationResults.displacements[vi][2] = posDisplacement[2]; - //Rotations - chrono::ChQuaternion rotQuat = node_chronos->GetRot(); - simulationResults.rotationalDisplacementQuaternion[vi] - = Eigen::Quaternion(rotQuat.e0(), rotQuat.e1(), rotQuat.e2(), rotQuat.e3()); - const ChVector eulerAngles = rotQuat.Q_to_Euler123(); - // std::cout << "Euler angles:" << eulerAngles << std::endl; - simulationResults.displacements[vi][3] = eulerAngles[0]; - simulationResults.displacements[vi][4] = eulerAngles[1]; - simulationResults.displacements[vi][5] = eulerAngles[2]; - } - - simulationResults.simulationModelUsed = label; + } + if (!simulationResults.converged) { + std::cerr << "Simulation failed" << std::endl; + assert(false); return simulationResults; + } - // VCGEdgeMesh deformedMesh; - // deformedMesh.copy(*(pJob->pMesh)); - // for (size_t vi = 0; vi < pJob->pMesh->VN(); vi++) { - // const std::shared_ptr node_chronos = edgeMeshVertsToChronosNodes[vi]; - // deformedMesh.vert[vi].P() = CoordType(node_chronos->GetPos()[0], - // node_chronos->GetPos()[1], - // node_chronos->GetPos()[2]); - // } + // my_system.SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); + // application.SetTimestep(0.001); - // deformedMesh.updateEigenEdgeAndVertices(); - // deformedMesh.setLabel("deformed"); - // deformedMesh.registerForDrawing(); - // polyscope::show(); - // return simulationResults; + // while (application.GetDevice()->run()) { + // application.BeginScene(); + // application.DrawAll(); + // application.EndScene(); + // } + simulationResults.pJob = pJob; + simulationResults.displacements.resize(pJob->pMesh->VN()); + simulationResults.rotationalDisplacementQuaternion.resize(pJob->pMesh->VN()); + for (size_t vi = 0; vi < pJob->pMesh->VN(); vi++) { + const auto node_chronos = edgeMeshVertsToChronoNodes[vi]; + const auto posDisplacement = + node_chronos->Frame().GetPos() - node_chronos->GetX0().GetPos(); + // std::cout << "Node " << vi << " coordinate x= " << + // node_chronos->Frame().GetPos().x() + // << " y=" << node_chronos->Frame().GetPos().y() + // << " z=" << node_chronos->Frame().GetPos().z() << + // "\n"; + // Translations + simulationResults.displacements[vi][0] = posDisplacement[0]; + simulationResults.displacements[vi][1] = posDisplacement[1]; + simulationResults.displacements[vi][2] = posDisplacement[2]; + // Rotations + chrono::ChQuaternion rotQuat = node_chronos->GetRot(); + simulationResults.rotationalDisplacementQuaternion[vi] = + Eigen::Quaternion(rotQuat.e0(), rotQuat.e1(), rotQuat.e2(), + rotQuat.e3()); + const Eigen::Vector3d eulerAngles = + simulationResults.rotationalDisplacementQuaternion[vi] + .toRotationMatrix() + .eulerAngles(0, 1, 2); + // std::cout << "Euler angles:" << eulerAngles << std::endl; + simulationResults.displacements[vi][3] = eulerAngles[0]; + simulationResults.displacements[vi][4] = eulerAngles[1]; + simulationResults.displacements[vi][5] = eulerAngles[2]; + } + + simulationResults.simulationModelUsed = label; + return simulationResults; + + // VCGEdgeMesh deformedMesh; + // deformedMesh.copy(*(pJob->pMesh)); + // for (size_t vi = 0; vi < pJob->pMesh->VN(); vi++) { + // const std::shared_ptr node_chronos = + // edgeMeshVertsToChronosNodes[vi]; deformedMesh.vert[vi].P() = + // CoordType(node_chronos->GetPos()[0], + // node_chronos->GetPos()[1], + // node_chronos->GetPos()[2]); + // } + + // deformedMesh.updateEigenEdgeAndVertices(); + // deformedMesh.setLabel("deformed"); + // deformedMesh.registerForDrawing(); + // polyscope::show(); + // return simulationResults; } -void ChronosEulerSimulationModel::setStructure(const std::shared_ptr &pMesh) -{ - mesh_chronos = convertToChronosMesh_Euler(pMesh, edgeMeshVertsToChronoNodes); +void ChronosEulerSimulationModel::setStructure( + const std::shared_ptr& pMesh) { + mesh_chronos = convertToChronosMesh_Euler(pMesh, edgeMeshVertsToChronoNodes); } diff --git a/chronoseulersimulationmodel.hpp b/chronoseulersimulationmodel.hpp index 1a9b02d..2d49b01 100644 --- a/chronoseulersimulationmodel.hpp +++ b/chronoseulersimulationmodel.hpp @@ -28,12 +28,19 @@ class ChronosEulerSimulationModel : public SimulationModel public: ChronosEulerSimulationModel(); SimulationResults executeSimulation(const std::shared_ptr &pJob) override; - void setStructure(const std::shared_ptr &pMesh) override; + void setStructure(const std::shared_ptr &pMesh) override; static std::shared_ptr convertToChronosMesh_Euler( - const std::shared_ptr &pMesh, + const std::shared_ptr &pMesh, std::vector> &edgeMeshVertsToChronosNodes); - inline const static std::string label{"Chronos_nonLinear_Euler"}; + inline const static std::string label{"Chronos_Euler"}; + + struct Settings + { + enum AnalysisType { Linear = 0, NonLinear }; + AnalysisType analysisType{NonLinear}; + }; + Settings settings; }; #endif // CHRONOSEULERSIMULATIONMODEL_HPP diff --git a/chronosigasimulationmodel.cpp b/chronosigasimulationmodel.cpp index 76b4bb9..b5455a2 100644 --- a/chronosigasimulationmodel.cpp +++ b/chronosigasimulationmodel.cpp @@ -16,7 +16,7 @@ using namespace chrono; using namespace chrono::fea; std::shared_ptr ChronosIGASimulationModel::convertToChronosMesh_IGA( - const std::shared_ptr &pMesh, + const std::shared_ptr &pMesh, std::vector> &edgeMeshVertsToChronosNodes) { auto mesh_chronos = chrono_types::make_shared(); @@ -34,7 +34,7 @@ std::shared_ptr ChronosIGASimulationModel::convertToChronosMesh_IGA( //add elements ChBuilderBeamIGA builder; for (int ei = 0; ei < pMesh->EN(); ei++) { - const SimulationMesh::EdgeType &edge = pMesh->edge[ei]; + const SimulationEdgeMesh::EdgeType &edge = pMesh->edge[ei]; //define end-points const auto vi0 = pMesh->getIndex(edge.cV(0)); const auto vi1 = pMesh->getIndex(edge.cV(1)); @@ -54,15 +54,16 @@ std::shared_ptr ChronosIGASimulationModel::convertToChronosMesh_IGA( // msection->SetGwithPoissonRatio(poisson); // // msection->SetBeamRaleyghDamping(0.0); // msection->SetAsRectangularSection(beam_wy, beam_wz); - builder.BuildBeam( - mesh_chronos, // the mesh where to put the created nodes and elements - msection, // the ChBeamSectionEuler to use for the ChElementBeamEuler elements - 4, // the number of ChElementBeamEuler to create - edgeMeshVertsToChronosNodes[vi0]->GetPos(), // the 'A' point in space (beginning of beam) - edgeMeshVertsToChronosNodes[vi1]->GetPos(), // the 'B' point in space (end of beam) - ChVector<>(0, 0, 1) - // ChVector<>(0, cos(rot_rad), sin(rot_rad)) - ); // the 'Y' up direction of the section for the beam + builder + .BuildBeam(mesh_chronos, // the mesh where to put the created nodes and elements + msection, // the ChBeamSectionEuler to use for the ChElementBeamEuler elements + 1, // the number of ChElementBeamEuler to create + edgeMeshVertsToChronosNodes[vi0], // the 'A' point in space (beginning of beam) + edgeMeshVertsToChronosNodes[vi1], // the 'B' point in space (end of beam) + ChVector<>(0, 0, 1), + 3 + // ChVector<>(0, cos(rot_rad), sin(rot_rad)) + ); // the 'Y' up direction of the section for the beam const auto lastBeamNodesVector = builder.GetLastBeamNodes(); // assert(lastBeamNodesVector.size() == 4); edgeMeshVertsToChronosNodes[vi0] = std::dynamic_pointer_cast( @@ -195,7 +196,8 @@ SimulationResults ChronosIGASimulationModel::executeSimulation( //parse constrained vertices // std::cout << node_0->GetCoord().pos[0] << " " << node_0->GetCoord().pos[1] << " " // << node_0->GetCoord().pos[2] << std::endl; - parseConstrainedVertices(pJob, edgeMeshVertsToChronoNodes, my_system); + // parseConstrainedVertices(pJob, edgeMeshVertsToChronoNodes, my_system); + // std::cout << node_0->GetCoord().pos[0] << " " << node_0->GetCoord().pos[1] << " " // << node_0->GetCoord().pos[2] << std::endl; // std::dynamic_pointer_cast>(mesh_chronos->GetNode(1)) @@ -290,7 +292,7 @@ SimulationResults ChronosIGASimulationModel::executeSimulation( // return simulationResults; } -void ChronosIGASimulationModel::setStructure(const std::shared_ptr &pMesh) +void ChronosIGASimulationModel::setStructure(const std::shared_ptr &pMesh) { mesh_chronos = convertToChronosMesh_IGA(pMesh, edgeMeshVertsToChronoNodes); } diff --git a/chronosigasimulationmodel.hpp b/chronosigasimulationmodel.hpp index b30c6cc..27cc915 100644 --- a/chronosigasimulationmodel.hpp +++ b/chronosigasimulationmodel.hpp @@ -28,9 +28,9 @@ class ChronosIGASimulationModel : public SimulationModel public: ChronosIGASimulationModel(); SimulationResults executeSimulation(const std::shared_ptr &pJob) override; - void setStructure(const std::shared_ptr &pMesh) override; + void setStructure(const std::shared_ptr &pMesh) override; static std::shared_ptr convertToChronosMesh_IGA( - const std::shared_ptr &pMesh, + const std::shared_ptr &pMesh, std::vector> &edgeMeshVertsToChronosNodes); inline const static std::string label{"Chronos_linear_IGA"}; diff --git a/der_leimer.cpp b/der_leimer.cpp index e2da1fd..a629ed0 100644 --- a/der_leimer.cpp +++ b/der_leimer.cpp @@ -4210,7 +4210,7 @@ Eigen::Vector3d DER_leimer::getPerpendicularVector(const Eigen::Vector3d &t) con } DER_leimer::RodConfig *DER_leimer::readRodGrid( - const std::shared_ptr &pMesh, + const std::shared_ptr &pMesh, const std::vector &numVertsPerRod, const std::vector & vInd, //index after the physVerts in the verts vector? Contains "global" indices of all centerline vertices eg at intersections all endpoints vertices get the same "global" index. Do interior centerline vertices get a global index? @@ -4837,7 +4837,7 @@ int DER_leimer::RodConfig::getNumDoF() const return ndofs; } -void DER_leimer::setStructure(const std::shared_ptr &pMesh) +void DER_leimer::setStructure(const std::shared_ptr &pMesh) { std::cout << "This function is currently not implemented" << std::endl; assert(false); diff --git a/der_leimer.hpp b/der_leimer.hpp index d983d9c..1493654 100644 --- a/der_leimer.hpp +++ b/der_leimer.hpp @@ -140,7 +140,7 @@ public: int getNumDoF() const; }; - void setStructure(const std::shared_ptr &pMesh) override; + void setStructure(const std::shared_ptr &pMesh) override; private: bool simulateOneStepGrid(RodConfig *config); @@ -159,7 +159,7 @@ private: std::vector> *Hu_index = NULL, std::vector *Hu_value = NULL); - RodConfig *readRodGrid(const std::shared_ptr &pMesh, + RodConfig *readRodGrid(const std::shared_ptr &pMesh, const std::vector &numVertsPerRod, const std::vector &vInd, const std::vector &verts,