Creating a mesh of a braid fabric

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
Martin
Project Leader
Posts: 70
Joined: Wed Mar 28, 2007 9:05 am
Location: Nottingham
Contact:

Creating a mesh of a braid fabric

Post by Martin »

Here is a sample script for creating a braided fabric. It was done fairly quickly without any reference to real fabrics so don't expect the geometry to be very accurate. In order to load this into TexGen cut and paste the contents below into a text file with a .py extension (e.g. "triaxial_braid.py"). Then in TexGen go to Python -> Run Script... and select the file you created.

Code: Select all

from TexGen.Core import *
import math

# Create a textile
Textile = CTextile()

# Create a python list containing 3 yarns
Yarns = [CYarn(), CYarn(), CYarn()]

# Add nodes to the yarns to describe their paths
# First define the angled yarns
Yarns[0].AddNode(CNode(XYZ(0, 0, 0)))
Yarns[0].AddNode(CNode(XYZ(0.5, 0.2887, 0.2)))
Yarns[0].AddNode(CNode(XYZ(1, 0.5774, 0.2)))
Yarns[0].AddNode(CNode(XYZ(1.5, 0.8660, 0)))
Yarns[0].AddNode(CNode(XYZ(2, 1.1547, 0)))

Yarns[1].AddNode(CNode(XYZ(0, 0, 0.2)))
Yarns[1].AddNode(CNode(XYZ(0.5, -0.2887, 0)))
Yarns[1].AddNode(CNode(XYZ(1, -0.5774, 0)))
Yarns[1].AddNode(CNode(XYZ(1.5, -0.8660, 0.2)))
Yarns[1].AddNode(CNode(XYZ(2, -1.1547, 0.2)))

# Define a straight yarn
Yarns[2].AddNode(CNode(XYZ(-0.25, 0, 0.1)))
Yarns[2].AddNode(CNode(XYZ(-0.25, 0.57735, 0.1)))

# Create a lenticular section for the +- angled yarns
AngledSection = CSectionLenticular(0.45, 0.13)

# The section will be rotated at the appropriate points to avoid interference
# So create an interpolated yarn section
AngledYarnSection = CYarnSectionInterpPosition(True, True)
# This is the rotation angle defined
RotationAngle = math.radians(12)

# Add rotated sections at 1/8 and 5/8 of the way along the yarn
# at angles of +- RotationAngle
AngledYarnSection.AddSection(1.0/8.0, CSectionRotated(AngledSection, -RotationAngle))
AngledYarnSection.AddSection(5.0/8.0, CSectionRotated(AngledSection, RotationAngle))

# Add unrotated sections to the interpolation at intervals of 1/4
AngledYarnSection.AddSection(0.0/4.0, AngledSection)
AngledYarnSection.AddSection(1.0/4.0, AngledSection)
AngledYarnSection.AddSection(2.0/4.0, AngledSection)
AngledYarnSection.AddSection(3.0/4.0, AngledSection)

# Assign the rotating cross-section to the angled yarns
Yarns[0].AssignSection(AngledYarnSection)
Yarns[1].AssignSection(AngledYarnSection)
# Add repeats to those yarns
Yarns[0].AddRepeat(XYZ(2, 0, 0))
Yarns[1].AddRepeat(XYZ(2, 0, 0))

# Create a lenticular section for the straight yarns and assign it
StraightSection = CSectionLenticular(0.6, 0.15)
Yarns[2].AssignSection(CYarnSectionConstant(StraightSection))
# Add repeats for the straight yarn
Yarns[2].AddRepeat(XYZ(1, 0, 0))


# Loop over all the yarns in the list
for Yarn in Yarns:
    # Set the interpolation function
    Yarn.AssignInterpolation(CInterpolationCubic())
    # Set the resolution of the surface mesh created
    Yarn.SetResolution(20)
    # Add common repeat vector to the yarn
    Yarn.AddRepeat(XYZ(0, 0.57735, 0))
    # Add the yarn to our textile
    Textile.AddYarn(Yarn)

# Create a domain and assign it to the textile
Textile.AssignDomain(CDomainPlanes(XYZ(0+0.25, 0, -0.1), XYZ(1+0.25, 1, 0.3)))

# Add the textile
AddTextile("triaxialbraid", Textile)
The result in TexGen should look something like this:

Image

Once it is loaded into TexGen you can export the mesh by going to File -> Export -> Volume mesh... . If you want to run some kinda of optimisation algorithm or create a batch of meshes it would be better to incorporate the exporting of the mesh into the script itself.

In any case if you want to modify the geometry you will need to get your hands dirty and edit the sample script. There is some documentation about that on the website at http://texgen.sourceforge.net/index.php/Scripting_Guide
lxtlixuetao
Posts: 4
Joined: Tue Nov 20, 2007 9:29 pm

Re: Creating a mesh of a braid fabric

Post by lxtlixuetao »

For the example you gave above, I did a little big change, made the domain larger, like "Textile.AssignDomain(CDomainPlanes(XYZ(0+0.25, 0, -0.1), XYZ(2+0.25, 2, 0.3)))", then tried to output the mesh, with seed size is .1, and keep tolerence default. This program failed to give any mesh script. What could be the reason? Thanks.

I just put this as an example, actually, my general question is, what will cause the meshing failure, because I met with this situation several times.
Martin
Project Leader
Posts: 70
Joined: Wed Mar 28, 2007 9:05 am
Location: Nottingham
Contact:

Post by Martin »

Yes, I see the problem. I tried meshing with the change you mentioned and it crashes :(. I've isolated which function is causing the problem, I will have a look into it and report back once I've found a solution.
yanxueotft
Posts: 7
Joined: Fri Oct 21, 2011 4:26 am

Re:

Post by yanxueotft »

Martin wrote:Yes, I see the problem. I tried meshing with the change you mentioned and it crashes :(. I've isolated which function is causing the problem, I will have a look into it and report back once I've found a solution.
I have the same problem...I wonder if there is any solution?
thanks!!!
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Creating a mesh of a braid fabric

Post by louisepb »

Hi Yanxue,

I have just run this script and then made the adjustment to the domain. I then exported it as a .inp file using File->Export->Volume Mesh. This ran fine and then I imported the model into Abaqus as shown here ( I removed the matrix set in the display to make it easier to visualize)
AbaqusTriaxialBraid.png
AbaqusTriaxialBraid.png (35.46 KiB) Viewed 13423 times
This was all done using the latest release version 3.5.0. I assume that Martin must have solved the problem when it was initially raised but am not sure why you are having problems with it now...

Louise
Hemanth_T_N
Regular
Posts: 24
Joined: Tue Sep 18, 2018 11:41 am

Re: Creating a mesh of a braid fabric

Post by Hemanth_T_N »

Hi Dr. Louise,

which source should I lookup if I want to understand what the functions used in the script (like CSectionLenticular) is doing.

Have a great day..!

Thanks and Regards,
Hemanth T N
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Creating a mesh of a braid fabric

Post by louisepb »

Hi Hemanth,

You can find descriptions of the cross-section functions in the scripting guide here: https://github.com/louisepb/TexGenScriptingGuide

Hope that helps,
Louises
Post Reply