CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Pointwise & Gridgen (https://www.cfd-online.com/Forums/pointwise/)
-   -   Twisting a mesh while extrusion along a path (https://www.cfd-online.com/Forums/pointwise/134716-twisting-mesh-while-extrusion-along-path.html)

Arvind_CFD May 4, 2014 14:27

Twisting a mesh while extrusion along a path
 
I have to generate a structured mesh for hellically twisted pipe of elliptic cross-section. I plan on creating a 2-d surface mesh for the ellipse and then twisting it along the path of specific length with a specific angle of twist in order to create a 3-d block. Does pointwise have any options in extrusion or sweep to do such an operation ?

jchawner May 4, 2014 17:58

Arvind:

You can extrude the grid along a path defined by a connector. That command is built-in to the code.

I seem to recall a script that someone wrote to create a helical shape. You might want to check the Glyph Script Exchange (see our website) to see if it's there. If it is, great. If not, you might need to take the scripting approach depending on what your other constraints are.

Best Regards.

pdp.aero May 4, 2014 18:09

2 Attachment(s)
Quote:

Originally Posted by Arvind_CFD (Post 489744)
I have to generate a structured mesh for hellically twisted pipe of elliptic cross-section. I plan on creating a 2-d surface mesh for the ellipse and then twisting it along the path of specific length with a specific angle of twist in order to create a 3-d block. Does pointwise have any options in extrusion or sweep to do such an operation ?

Hi,

For rotating a domain while it is being extruded, check the "Use the path rotation" in the "Creat\ Extrude\ Path"
For creating your elliptic domain you may write a simple script, it will be easier to use. I have created an elliptic domain, using 2 concentric circle. You can follow the same way in your script for drawing an ellipse. You will find the way in the "StrEllipse" attachment, also the 3D structured block using path extrusion on the helix curve will be find in the "StrBlock" attachment.

Bests,
Payam

cnsidero May 5, 2014 08:36

Quote:

Originally Posted by Arvind_CFD (Post 489744)
I have to generate a structured mesh for hellically twisted pipe of elliptic cross-section. I plan on creating a 2-d surface mesh for the ellipse and then twisting it along the path of specific length with a specific angle of twist in order to create a 3-d block. Does pointwise have any options in extrusion or sweep to do such an operation ?

Here's the link to the DB/con ellipse script: https://github.com/pointwise/ConEllipse

If understand what you after - rotating the elliptic cross section about the pipe axis - this one is a bit tougher. "Use path rotation" will only try to keep the cross-section normal the extrusion direction so this won't do what you need it to. The only way I can think of doing this in Pointwise to get the correct shape is start with the analytic function script:

https://github.com/pointwise/CreateFromAnalyticFunction

and then define the surface of your shape parametrically. I've found the parametric form of an elliptic cylinder from Wolfram:

http://mathworld.wolfram.com/EllipticCylinder.html

so you'll just need to figure out how to incorporate the section rotation into the parametric definition.

Arvind_CFD May 5, 2014 10:14

I tried extrusion along a path but that doesn't actually rotate the cross-section and the rotate option tries to rotate the cross-section about an axis in a plane. I am a beginner in pointwise so any help on how to get started with scripting is appreciated. Thanks for the help

dgarlisch May 5, 2014 10:44

Pointwise scripting uses the Glyph language (a Tcl derivative).

For a quick exploration, turn ON journaling in the message window (in right click menu) and run a few Pointwise tools like Creat\ Extrude\ Path.

Another good way to learn is by looking at the numerous scripts on the script exchange. Find one that is similar to what you want to accomplish and study it.

You can find the Glyph man pages here:
http://www.pointwise.com/glyph2/

You can find the script exchange here:
https://github.com/pointwise/

You can find a good Tcl manual here:
http://tcl.activestate.com/man/tcl8....d/contents.htm

cnsidero May 5, 2014 11:51

3 Attachment(s)
Ok, this problem was too interesting to leave alone ... so I figured out the parametric equations for a twisting elliptic tube and created a script that can be used with the CreateFromAnalyticFunction.glf script. See the first image for an example whereby there's a quarter of a rotation per unit length.

Now, to generate the surface in the image you first need to download the CreateFromAnalyticFunction.glf script from the link I provided in my last post. If you're not interested in learning/using git to get the script, simply click the "Download zip" button on the right side of the page. Download and extract the contents of the zip file to some convenient location on your computer.

To generate the twisted elliptic tube, you will also need the code that defines the surface - this is what I wrote. It's attached to this post - called "twistedEllipticSurf.txt". I had to change the extension to .txt because the forums won't allow me to attach .glf files. Download this and change the extension to .glf (it's not technically necessary to do so but you might want to do so to be consistent) or copy the code from below into a text file.

Finally, start Pointwise, go to Script, Execute ... browse to the location of the CreateFromAnalyticFunction.glf script, select it and click "Open". A little GUI will pop open on top of Pointwise. Click the "Browse" button and go to the location of "twistedEllipticSurf.glf". Enter value for start, end and number of control points. U is normalized in 2*pi increments so a valid value would be between 0 and 1, where 1 is a closed ellipse. V corresponds to the length. The axes of the ellipse and number of rotations per unit length are defined in "twistedEllipticSurf.glf" so you'll have to edit that file with a text editor to the values you desire.

The values I used for the attached image are: begin UV = 0 0, end UV = 1 1, control points = 100 100 and the surface parameters inside the script are R1 = 0.25, R2 = 0.4, N = 0.25

I've also included an image of a structured mesh on the geometry. I used the "ButterflyMaker.glf" script to make the OH topology.

Here's the code for the "twistedEllipticSurf.glf" for those interested in the parametric equations:

Code:

proc computeSurfacePoint { u v } {

  set pi 3.1415926535897931

  # 1st axis
  set R1 0.25
  # 2nd axis
  set R2 0.4
  # number of rotations per unit length
  set N 0.25

  set phi [expr { $u * $pi * 2.0 } ]
  set theta [expr { $N * $v * $pi * 2.0 } ]

  set x [expr { $R1 * cos($phi) * cos($theta) - $R2 * sin($phi) * sin($theta) }]
  set y [expr { $R1 * cos($phi) * sin($theta) + $R2 * sin($phi) * cos($theta) }]
  set z [expr { $v }]

  return "$x $y $z"
}


dgarlisch May 5, 2014 12:06

Go Chris! :)

dgarlisch May 5, 2014 13:02

1 Attachment(s)
slightly modified script to allow Z offset distance.

proc computeSurfacePoint { u v } {

set pi 3.1415926535897931

# 1st axis
set R1 0.25

# 2nd axis
set R2 0.4

# number of rotations over the total Z length << MODIFIED
set N 2.0

# Total Z length << NEW
set zScale 4.0

set phi [expr { $u * $pi * 2.0 } ]
set theta [expr { $N * $v * $pi * 2.0 } ]

set x [expr { $R1 * cos($phi) * cos($theta) - $R2 * sin($phi) * sin($theta) }]
set y [expr { $R1 * cos($phi) * sin($theta) + $R2 * sin($phi) * cos($theta) }]
set z [expr { $v * $zScale }]

return "$x $y $z"
}

cnsidero May 5, 2014 13:43

Quote:

Originally Posted by dgarlisch (Post 489949)
slightly modified script to allow Z offset distance.

David,

Offset is handled by the begin and end UV pairs. And the length (Z) is taken care of by V itself. V can be greater than 1 (or less than 0 for that matter), i.e. V = Z.

-Chris

dgarlisch May 5, 2014 14:44

Quote:

Originally Posted by cnsidero (Post 489956)
David,

Offset is handled by the begin and end UV pairs. And the length (Z) is taken care of by V itself. V can be greater than 1 (or less than 0 for that matter), i.e. V = Z.

-Chris

I tried v > 1.0 in the dlg box. It did not create a surface.

However, I just tried your original script again and now it is working! I must have been entering improper values before.

Please ignore my script changes. For a fully closed, 4 unit long twist, enter:
Start UV: 0 0
End UV: 1 4

Arvind_CFD May 5, 2014 16:40

Chris, your post was very informative and of immense help to me. Could you please elaborate a bit on creating a structured mesh using ButterflyMaker.glf for this geometry as shown in your attachment? When i run the script i was not able to find any block to choose.

cnsidero May 6, 2014 09:23

1 Attachment(s)
Here's the basic steps.

- Split the surface into 5 pieces. The script will create a single surface and splitting it will make it easier to create a structured mesh. Select the surface, Edit>Split, check Advance frame, enter UV = 0.125 1, click Enter key, enter UV = 0.375 1, click Enter key, enter UV = 0.625 1, and enter UV = 0.875 1, click Enter key. Click Ok button.
- Join the first (surface-1-split-1) and fifth (surface-1-split-5) surfaces. Select surface, Edit Join

Doing the above split procedure will leaves seams not at the ellipse major/minor axes but mid-way between them. This location is slightly more optimal for creating a structured topology on an ellipse.

- Enter a default dimension in Defaults panel, e.g. 11
- Create 4 structured domains: select the four surfaces, ensure Structured Mesh type is selected, click Domains on Database button on toolbar.
- Hide database display: toggle View>Show Database off
- Increase dimension along pipe length: select four connectors along pipe seams, enter dimension = 21 on tool, click Enter key
- Create structured domain on end of pipe: select four connectors at one of pipe in elliptic shape, click Create Domains button on toolbar. Repeat for other end of pipe.
- Create structured block: select all domains, click Create Block button on toolbar
- Check orientation of block: select the block, Edit>Orient, record computational coordinate along pipe length, ie. I

At this point, you have a structured volume mesh. However, it's in an H-topology configuration which isn't optimal for this shape of geometry. To check the quality, select the block, Examine>Min Inc Angle., you will find cells with values well below 20 deg (i.e. not very good). Change it to OH-topology also known as butter-fly or 5 block topology.

- download ButterflyMaker.glf from Pointwise script exchange. Similar to procedure for CreateFromAnalyticFunction.
- Execute ButterflyMaker.glf: Script>Execute, browse for and open script
- Select block: in the script GUI, select the block from the list on left side.
- Select topological direction: choose the I, J, K, All radio button that corresponds to the computation direction recorded from previous step, ie. I-dir, as we want the butterfly topology to propagate in the direction along the pipe.
- Enter region scalar: choose values such that the center block is somewhat center and even in each direction. There's no "exact" number to use here - just use your best judgement. Use the User Preview Topology to see temporary results. Change values if needed. For this case, 0.3 0.4 1.0 worked well.
- Enter # points on ribs: These will be the new connectors in a direction roughly normal to the wall. If you plan on creating a resolved BL, enter enough points to support that, i.e. 10 points in BL, enter >11 rib points. I choose 11.
- Finish: Click Run. Click Ok

This will get you to where I showed earlier but you likely want BL resolution so a couple of more steps are needed.

- Redistribute points on rib connectors: select the 8 new rib connectors, Edit>Redistribute
* Spacing tab: select 8 spacing constraints adjacent to pipe wall and enter a ds value, e.g. 0.004
* Functions tab: change function to either Tanh, Geometric or Growth, e.g. Goemetric

The points are packed toward the pipe wall but due to structured domain initialization algorithm, the point spacing near the wall is not uniform in the domains/blocks.
- Smooth domains at end of pipe: select 5 domains at one end of pipe, Grid>Solve
* Edge Attributes tab: Change Angle Control, Angle: to Current Grid (this will "lock" the angle of the interior grids as we're happy with where they're at)
* Solve tab: enter 100 iterations, click Run, click Ok
- Repeat for other end of pipe
- Re-initialize blocks: select all blocks, click Initialize button on toolbar. This will propagate the previous step's domain smoothing through the block.

To check the quality now, select the blocks, Examine>Min Inc Angle., you will find cells with values well above 20 deg (i.e. very good).

Done. See attached picture for final result. Of course, change the values to suit your needs and liking.

-Chris

Arvind_CFD May 6, 2014 14:09

1 Attachment(s)
Chris,

I had a problem executing the butterflyMaker.glf script though i chose the same values as you did. Do you know a reason why this could happen ?

cnsidero May 6, 2014 14:53

Quote:

Originally Posted by Arvind_CFD (Post 490187)
Chris,

I had a problem executing the butterflyMaker.glf script though i chose the same values as you did. Do you know a reason why this could happen ?

What version of Pointwise are you using?

Arvind_CFD May 6, 2014 16:09

Quote:

Originally Posted by cnsidero (Post 490195)
what version of pointwise are you using?

17.0 r1 .....

later tried it on a 17.1 and it worked :)

pdp.aero May 10, 2014 18:11

4 Attachment(s)
Hello again,

Sorry for my delayed response and for my previous mistake on twisting together with extruding an ellipse.

Thank Chris for making the point clear and for all the hints that you gave us on scripting.

Yep, Its too interesting to leave alone...
I already worked on progressive cavity pump which had the same helical twisted stator shape and always was looking for an opportunity to work back. I used unstructured grid due to motion of non-symmetrical rotor in that case. However, this threat might be the beginning...

By the way, using Analytic Function script for creating the geometry is a very good idea, it will save the time. Besides, due to the curvature of the side surface, using geometry for creating surface mesh puts the mesh to the right place. However, I followed different approach for this case.

Because, we know the parametric equations, we can create the connectors directly without using any geometric database, but the point is the side surface curvature might get in the way of reaching the right surface. I wrote a Glyph script specifically for this case. I used parametric equations for creating elliptical-section and side-surface connectors which restrict the surface mesh to be at the right place. Then, I used every two of side-surface connectors and two of elliptical-section connectors to create domains. After that, I joined the side-surface domains together and balanced them to create the structured block.

The interesting point is that we can use this way for different shape rather than elliptical too. Besides, it allows us to extrude and twist a surface mesh in the middle of something; also it could be used for unstructured domains extrusion. However, all the different purposes need a little change at the beginning of the script to get the right side-surface connectors.

The script has been attached. I didn't write a Tk for the script, so just download the text file and change the extension from the .txt to the .glf. When you are looking at the script, you will see the description at the first part for defining the parameters. For controlling the extrusion, I defined one variable, called "steps". The variable determines the side-surface connector's dimension and the ellipticall connectors dimension. I defined the same dimension for longitudinal and lateral connectors because the resolution and cell's aspect ratio can be adjust easier with one parameter. Following this further, other parameters include length of the semimajor and semiminor axis for the elliptical section, called "a" and "b" respectively , the length of the pipe, indicated by "h", the rotational angle of first elliptical section, called "teta1" and the rotational angle of the last elliptical section, called "teta2". The total twist will be teta2 minus teta1.

In this way, because we are defining the connectors and, consequently, the grid resolution base on number of the steps, how well the surface mesh match with the proposed geometry depends on this parameter. In the “steps” picture at the attachment you will find how the quality of the grid will be increased by increasing the steps. The minimum number of steps for the script in this case is 8.

In the “continuous_twist” picture, you see how you would use the script for creating a structured block with a narrow elliptical section and continuing the twist for creating a desired block.

In the “highresolutiongrid” picture, you see how well you might control the resolution for the structured block with different steps.

The following demonstrates part of the code, which I wrote, base on parametric equation. The "u" is trigonometric variable, the "x1, y1, z1" are points of the first elliptical section, the "x2, y2, z2" are points of the last elliptical section, and the "xp, yp, zp" are the point of the side-surface connectors.

Cheers,
PDP

Code:


foreach xx $u {
        lappend x1 [expr {$a * cos($xx) * cos($teta1d) - $b * sin($xx) * sin($teta1d)}]
        lappend y1 [expr {$a * cos($xx) * sin($teta1d) + $b * sin($xx) * cos($teta1d)}]
        lappend x2 [expr {$a * cos($xx) * cos($teta2d) - $b * sin($xx) * sin($teta2d)}]
        lappend y2 [expr {$a * cos($xx) * sin($teta2d) + $b * sin($xx) * cos($teta2d)}]
        }

if {$j > $uasize} {
        set n $uasize
        } else {
        set n [expr floor($uasize/$j)]
        }

for {set i 0} {$i <= [expr {$j+1}]} {set i [expr {$i+1}]} {
        set itm [expr int($n * ($i-1)+1)]
        set zt [expr int($uasize-1)]
        lappend up [lindex $u $itm]
        lappend z2 [lindex $zp $zt]
        lappend z1 [lindex $zp 0]
        set xp($i) {}
        set yp($i) {}
        for {set k 0} { $k <= [expr {$j+1}]} {set k [expr {$k+1}]} {
                set uppt [expr int($i)]
                set ttt [expr int($k)]
                set upp [lindex $u $uppt]
                set tt        [lindex $tet $ttt]
                lappend xp($i) [expr {$a * cos($upp) * cos($tt) - $b * sin($upp) * sin($tt)}]
                lappend yp($i) [expr {$a * cos($upp) * sin($tt) + $b * sin($upp) * cos($tt)}]
                }
        }


dgarlisch May 12, 2014 10:33

After reading this thread, I submitted a change to the CreateFromAnalyticFunction script on the Pointwise script exchange. This modification adds support for a new surface function:

Code:

proc computeSurfacePoint { u v minUV maxUV }
This new proc signature allows the analytic function to apply global fields to the returned data. See the CreateFromAnalyticFunction README page for more details.

For instance, I was able to create a new version of your twisted elliptic extrude script that also applies a varying scale factor along its length (image below). The scale factor is controlled by a law curve. You can see the modified script here.

The glyph-extrudeProfile script is a work in progress. When I am finished, I hope to have a general purpose Profile Extruder that will build a mesh surface from a profile. The extrusion will be controlled by:
  • One or more (co-planar) profile curves
  • A profile pivot point
  • A spine curve
  • A scale curve
  • A total twist angle

When finished, I intend to place this script on the Pointwise Script Exchange. In the meantime, if you are interested, you can follow the progress on my github account.

https://raw.githubusercontent.com/db...f_lawCurve.png

cnsidero May 12, 2014 11:08

The parametric form I posted is already usable for any cross-section twisting along a path if the cross section is/can be defined in it's own parametric coordinate system. Simply replace the elliptic portion of the equations with the desired cross-section defined as a function of the 'u' parameter. Below I've taken out the elliptic definition and replaced it with f_x(u) and f_y(u) that are the parametric functions of the cross sections x' and y' coordinate respectively.

Code:

proc computeSurfacePoint { u v } {

  set pi 3.1415926535897931

  # number of rotations per unit length
  set N 0.25

  set theta [expr { $N * $v * $pi * 2.0 } ]

  set x [expr { f_x(u) * cos($theta) - f_y(u) * sin($theta) }]
  set y [expr { f_x(u) * sin($theta) + f_y(u) * cos($theta) }]
  set z [expr { $v }]

  return "$x $y $z"
}

Combine this with David's cross section scaling functionality and this has become a pretty generic extrusion tool. I suppose the last change one could make would be to have the z coordinate vary with 'v' (i.e. stretch and/shrink along axis trajectory).

pdp.aero May 13, 2014 03:21

Quote:

For instance, I was able to create a new version of your twisted elliptic extrude script that also applies a varying scale factor along its length (image below). The scale factor is controlled by a law curve. You can see the modified script here.

The glyph-extrudeProfile script is a work in progress. When I am finished, I hope to have a general purpose Profile Extruder that will build a mesh surface from a profile. The extrusion will be controlled by:
One or more (co-planar) profile curves
A profile pivot point
A spine curve
A scale curve
A total twist angle

When finished, I intend to place this script on the Pointwise Script Exchange. In the meantime, if you are interested, you can follow the progress on my github account.
David,

Thank you for the point. I already read the CreateFromAnalyticFunction README description.
Yep, it is very interesting, adding scaling functionality to the extrusion. Sure, I will follow the progress. Thank you again for your hints on scaling functionality and controlling extrusion parameters.

Quote:

The parametric form I posted is already usable for any cross-section twisting along a path if the cross section is/can be defined in it's own parametric coordinate system. Simply replace the elliptic portion of the equations with the desired cross-section defined as a function of the 'u' parameter. Below I've taken out the elliptic definition and replaced it with f_x(u) and f_y(u) that are the parametric functions of the cross sections x' and y' coordinate respectively.
Combine this with David's cross section scaling functionality and this has become a pretty generic extrusion tool. I suppose the last change one could make would be to have the z coordinate vary with 'v' (i.e. stretch and/shrink along axis trajectory).
Chris,

Thank you for the advice.
Yep, I aware that it can be use for different profiles, I mentioned the way that I follow can be use as well. I didn't define surface from the calculated points. Directly creating the connectors and surface mesh from the calculated points, because making it easy to evade negative volume cells for the user by changing the parameters, particularly in structured mesh. However, I used the same equation. At this point, I prefer to extend the extrusion features for elliptical profile and then make it general for different types of profiles. It would be easier for me to find the bugs.
Exactly, when initially I run the aforementioned script, I was thinking about developing it more as extrusion tool and adding extrusion along the path for different types of profile to the script. I didn't think of scaling the profile at that time, but I would consider it.
Of course I will continue adding these features to the script and making it general.


All times are GMT -4. The time now is 06:11.