Skip to content

Commit

Permalink
backup work
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed May 27, 2024
1 parent 9b718b6 commit 8d7b313
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
32 changes: 15 additions & 17 deletions scenes/TearingEngine/SquareTissue_01_gravity.scn
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<BVHNarrowPhase/>
<CollisionResponse response="PenalityContactForceField" />
<MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" />


<!--
<Node name="SquareGravity_FEM">
<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" />
Expand All @@ -48,51 +49,48 @@
<BoxROI name="FixedSide" box="-0.1 9.9 0.1 10.1 10.1 -0.1" drawBoxes="1" />
<FixedConstraint name="FixedConstraint" indices="@FixedSide.indices" />
<TriangularFEMForceField name="FEM" youngModulus="60" poissonRatio="0.3" method="large" computePrincipalStress="1"/>
<TriangularBendingSprings name="FEM-Bend" stiffness="300" />
<TriangularFEMForceField name="FEM" youngModulus="60" poissonRatio="0.3" method="large" computePrincipalStress="1" showStressVector="1"/>
<TriangularBendingSprings name="FEM-Bend" stiffness="100" showSprings="0" />
<PlaneForceField normal="0 1 0" d="-20" stiffness="100000" showPlane="1" showPlaneSize="20"/>
<TriangleCollisionModel />

<TearingEngine name="TearingEngine" input_position="@Mo.position" stressThreshold="1.0"
step="30" nbFractureMax="40" showFracturePath="0"/>

<Node >
<OglModel name="Visual" color="red" />
<IdentityMapping input="@.." output="@Visual" />
</Node>
</Node>
-->


<!--
<Node name="SquareGravity_FEM_optim">
<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" />
<MeshGmshLoader name="meshLoader" filename="mesh/square3.msh" scale="10" createSubelements="true" translation="10 0 0"/>
<MeshGmshLoader name="meshLoader" filename="mesh/square3.msh" scale="10" createSubelements="true" />

<TriangleSetTopologyContainer name="Container" src="@meshLoader" fileTopology="" tags=" " />
<TriangleSetTopologyModifier name="Modifier" />
<TriangleSetGeometryAlgorithms name="GeomAlgo" template="Vec3d" />

<MechanicalObject name="Mo"/>
<DiagonalMass massDensity="10.0" />
<DiagonalMass massDensity="1.0" />

<BoxROI name="FixedSide" box="9.9 9.9 0.1 20.1 10.1 -0.1" drawBoxes="1" />
<BoxROI name="FixedSide" box="-0.1 9.9 0.1 10.1 10.1 -0.1" drawBoxes="1" />
<FixedConstraint name="FixedConstraint" indices="@FixedSide.indices" />

<TriangularFEMForceFieldOptim name="FEM" youngModulus="60" poissonRatio="0.3" method="large" />
<TriangularBendingSprings name="FEM-Bend" stiffness="300" />
<!--<TriangularFEMForceField name="FEM" youngModulus="60" poissonRatio="0.3" method="large" computePrincipalStress="1" showStressVector="1"/>-->
<TriangularFEMForceFieldOptim name="FEM" youngModulus="300" poissonRatio="0.3" method="large" computePrincipalStress="1" showStressVector="1" showStressThreshold="20"/>
<TriangularBendingSprings name="FEM-Bend" stiffness="100" showSprings="0" />
<PlaneForceField normal="0 1 0" d="-20" stiffness="100000" showPlane="1" showPlaneSize="20"/>
<TriangleCollisionModel />

<TearingEngine name="TearingEngine" input_position="@Mo.position" stressThreshold="30.0"
step="30" nbFractureMax="40" showFracturePath="1"/>
<TriangleCollisionModel />
<TearingEngine name="TearingEngine" input_position="@Mo.position" stressThreshold="20.0"
step="30" nbFractureMax="40" showFracturePath="1" showTearableTriangle="1"/>
<Node >
<OglModel name="Visual" color="blue" />
<IdentityMapping input="@.." output="@Visual" />
</Node>
</Node>
-->

</Node>
2 changes: 2 additions & 0 deletions src/Tearing/TearingAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class TearingAlgorithms
void algoFracturePath(Coord Pa, Index indexA, Coord Pb, Coord Pc,
const Index indexTriangleMaxStress, const Coord principalStressDirection, const VecCoord& input_position);

void algoFracturePath2(const Index triID, Coord Pa, Coord Pb, Coord Pc, const Coord principalStressDirection, const VecCoord& input_position);

int getFractureNumber() const { return m_fractureNumber; }

const sofa::type::vector< sofa::type::vector<int> >& getTjunctionTriangles() const { return m_TjunctionTriangle; }
Expand Down
27 changes: 27 additions & 0 deletions src/Tearing/TearingAlgorithms.inl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ TearingAlgorithms<DataTypes>::~TearingAlgorithms()
}



template <class DataTypes>
void TearingAlgorithms<DataTypes>::algoFracturePath2(const Index triID, Coord Pa, Coord Pb, Coord Pc, const Coord principalStressDirection, const VecCoord& input_position)
{
m_fracturePath.clear();
m_fracturePath.push_back(Pa);
double EPS = 1e-8;
core::topology::BaseMeshTopology::TriangleID idxA;
core::topology::BaseMeshTopology::TriangleID idxB;
// Output declarations
//sofa::type::vector< sofa::core::topology::TopologyElementType> topoPath_list;
//sofa::type::vector<Index> indices_list;
//sofa::type::vector< type::Vec3 > coords2_list;

//bool path_ok = m_triangleGeo->computeIntersectedObjectsList(sofa::InvalidID, Pa, Pb, idxA, idxB, topoPath_list, indices_list, coords2_list);
//if (!path_ok)
//{
// msg_error("TearingAlgorithms") << " in computeIntersectedObjectsList in algoFracturePath2";
// return;
//}

////std::cout << "topoPath_list: " << topoPath_list << std::endl;
//std::cout << "indices_list: " << indices_list << std::endl;
//std::cout << "coords2_list: " << coords2_list << std::endl;
}


template <class DataTypes>
void TearingAlgorithms<DataTypes>::algoFracturePath(Coord Pa, Index indexA, Coord Pb, Coord Pc,
const Index indexTriangleMaxStress, const Coord principalStressDirection, const VecCoord& input_position)
Expand Down
4 changes: 4 additions & 0 deletions src/Tearing/TearingEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class TearingEngine : public core::DataEngine
void performFractureScenario();

void computeFractureDirection(Coord principleStressDirection, Coord& fracture_direction);

void algoFracturePath2();

/// <summary>
/// compute extremities of fracture Pb and Pc from a start point Pa
Expand Down Expand Up @@ -216,6 +218,8 @@ class TearingEngine : public core::DataEngine
int m_stepCounter = 0; ///< counter of doUpdate called by the simulation. Used to put gap between consecutives fractures
TriangleID m_maxStressTriangleIndex = 0; ///< Triangle ID of the triangle from filter candadites with the max stress
Index m_maxStressVertexIndex = 0; ///< Global Vertex Id where the stress is maximum. Vertex is part of @sa m_maxStressTriangleIndex Triangle

Coord m_Pa, m_Pb, m_Pc;
};

#if !defined(SOFA_COMPONENT_ENGINE_TEARINGENGINE_CPP)
Expand Down
8 changes: 8 additions & 0 deletions src/Tearing/TearingEngine.inl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ void TearingEngine<DataTypes>::updateTriangleInformation()
}


template <class DataTypes>
void TearingEngine<DataTypes>::algoFracturePath2()
{
std::cout << "TearingEngine<DataTypes>::algoFracturePath2" << std::endl;
m_tearingAlgo->algoFracturePath2(m_maxStressTriangleIndex, m_Pa, m_Pb, m_Pc, Coord(0, 0, 0), d_input_positions.getValue());
}


template <class DataTypes>
void TearingEngine<DataTypes>::algoFracturePath()
{
Expand Down

0 comments on commit 8d7b313

Please sign in to comment.