CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Pointwise & Gridgen (https://www.cfd-online.com/Forums/pointwise/)
-   -   Farfield Script (https://www.cfd-online.com/Forums/pointwise/164971-farfield-script.html)

weigl January 6, 2016 12:55

Farfield Script
 
1 Attachment(s)
I want to automate the process of creating a rectangular farfield around an airfoil with a baffle.

For example if the length of the airfoil is 1 unit then the baffle goes 20*airfoil length and similarly all the way around until it completes the square/rectangle for the farfield.

And I want it to start from the trailing edge of the airfoil. I have attached a pic of the kind of farfield I am looking for.

But I can't seem to generate one that starts from the trailing edge.

dgarlisch January 7, 2016 10:47

Pointwise has a full scripting language called Glyph.

You can create the automation you want using Glyph.

There are many example scripts on the Pointwise Github Repository.

Also see:

weigl January 7, 2016 12:27

Quote:

Originally Posted by dgarlisch (Post 579965)
Pointwise has a full scripting language called Glyph.

You can create the automation you want using Glyph.

There are many example scripts on the Pointwise Github Repository.

Also see:

Hi. I have looked at the shape wizard glyph. I have been able to create a farfield using that method, but i cant seem to create a baffle line from the trailing edge to the farfield

dgarlisch January 8, 2016 10:50

1 Attachment(s)
After creating the farfield domain, you will need to:
  1. Delete the farfield domain (only the connectors remain)
  2. Split the trailing farfield connector at the appropriate location (Edit, Split...)
  3. Create the connector from the trailing edge of the airfoil to the split
  4. Assemble a new domain (Create, Assemble Special, Domain...)
    • You will need to select the baffle connector twice during assembly
Technically, this is not a baffle because it is part of the outer loop of the domain.
I have attached an image that shows the topology of the domain's outer loop.

This assembly procedure is the same you will be using in your automation script.

To see the commands you will need, I suggest creating a journal file while assembling the domain (Script, Begin Journaling...).

weigl January 11, 2016 09:19

Quote:

Originally Posted by dgarlisch (Post 580115)
After creating the farfield domain, you will need to:
  1. Delete the farfield domain (only the connectors remain)
  2. Split the trailing farfield connector at the appropriate location (Edit, Split...)
  3. Create the connector from the trailing edge of the airfoil to the split
  4. Assemble a new domain (Create, Assemble Special, Domain...)
    • You will need to select the baffle connector twice during assembly
Technically, this is not a baffle because it is part of the outer loop of the domain.
I have attached an image that shows the topology of the domain's outer loop.

This assembly procedure is the same you will be using in your automation script.

To see the commands you will need, I suggest creating a journal file while assembling the domain (Script, Begin Journaling...).

Ok, I tried that.

But when I try to create a line, instead of starting from the trailing edge it starts from the 0,0,0 point.

I want the script to be able to find the end of the curve automatically.

dgarlisch January 11, 2016 11:36

Not much more I can do to help without seeing your starting airfoil data and the glyph script.

There are glyph calls to extract XYZ locations on curves and connectors.
See docs for:
pw::Curve
pw::Connector

You can also attend a Pointwise Glyph scripting class.

weigl January 11, 2016 11:50

1 Attachment(s)
Quote:

Originally Posted by dgarlisch (Post 580459)
Not much more I can do to help without seeing your starting airfoil data and the glyph script.

There are glyph calls to extract XYZ locations on curves and connectors.
See docs for:
pw::Curve
pw::Connector

You can also attend a Pointwise Glyph scripting class.

I have attached the aerofoil and the script.

I also can't seem to apply a value to the script to define a basic distance

I will try those other things out

dgarlisch January 11, 2016 19:53

I have looked at the dat file and the script file.

You are very close. Unfortunately, I am not sure exactly what you are trying to accomplish. It would be helpful to post a PW file that contains an example of what you want the final grid to look like. Build this grid by hand while journaling.
  1. Turn on journaling (Script, Begin Journaling...)
  2. Manually do the entire process of importing the dat file, adding airfoil connectors, adding far field connectors, assembling the domain.
  3. Stop journaling (Script, End Journaling).

Examine the journal to find the relevant commands you will need in your script.

Please take a look at AirfoilMesh Script for an example.

Good luck.

weigl January 12, 2016 07:51

Quote:

Originally Posted by dgarlisch (Post 580532)
I have looked at the dat file and the script file.

You are very close. Unfortunately, I am not sure exactly what you are trying to accomplish. It would be helpful to post a PW file that contains an example of what you want the final grid to look like. Build this grid by hand while journaling.
  1. Turn on journaling (Script, Begin Journaling...)
  2. Manually do the entire process of importing the dat file, adding airfoil connectors, adding far field connectors, assembling the domain.
  3. Stop journaling (Script, End Journaling).

Examine the journal to find the relevant commands you will need in your script.

Please take a look at AirfoilMesh Script for an example.

Good luck.

Hi. Thank you so much for all your help.

I am not having issues with the grid generation or dimensioning etc.

I only seem to be having issues automatically generating that line from the trailing edge that works as a baffle as described by the T-Rex tutorial.

I tried the journaling way. In the journal itself it has this command:

Quote:

set _DB(1) [pw::DatabaseEntity getByName "curve-1"]
$_TMP(PW_1) addPoint[list 1 0 $_DB(1)]
$_TMP(PW_3) addPoint [pwu::Vector3 add [pw::Application getXYZ[list 1 0 $_DB(1)]] {20 0 0}]
I want to generalise this part. Get the script to find the trailing edge for the first point and then use the "farfield" value inputted by the user to generate the second point.

Like for example when i journal it I get a line that says:

Quote:

addPoint [pwu::Vector3 add {11 0 0} {0 10 0}]
I want to replace the X & Y coordinates with $farfield so it reads the value provided by user-input

dgarlisch January 12, 2016 12:24

If I understand correctly, the $farfield value is the distance from the trailing edge point to the rear farfield.

Code:

# Get one of the airfoil curves
set airfoilCrv [pw::DatabaseEntity getByName "curve-1"]

# Get a curve point using parametric position: [list u v crv].
# This assumes that the curve's direction goes from LEdge (u=0) to TEdge (u=1).
# Since this is a curve, the v parameter is ignored.
set trailingEdgePt [pw::Application getXYZ [list 1 0 $airfoilCrv]]

# compute the xyz at the rear farfield.
set rearFarFieldPt [pwu::Vector3 add $trailingEdgePt [list $farfield 0 0]]

# You can now create the "baffle" curve using $trailingEdgePt and $rearFarFieldPt

You can compute the other 4 farfield corner points using similar logic:

Code:

set farfieldX2 [expr {$farfield * 2}]
set topRightFarFieldPt [pwu::Vector3 add $rearFarFieldPt  [list 0 $farfield 0]]
set topLeftFarFieldPt [pwu::Vector3 add $topRightFarFieldPt  [list -$farfieldX2 0 0]]
set bottomLeftFarFieldPt [pwu::Vector3 add $topLeftFarFieldPt  [list 0 -$farfieldX2 0]]
set bottomRightFarFieldPt [pwu::Vector3 add $bottomLeftFarFieldPt  [list $farfieldX2 0 0]]

I hope this helps.

You can find all the documentation for these glyph calls on the Pointwise website.

weigl January 12, 2016 13:17

Quote:

Originally Posted by dgarlisch (Post 580669)
If I understand correctly, the $farfield value is the distance from the trailing edge point to the rear farfield.

Code:

# Get one of the airfoil curves
set airfoilCrv [pw:DatabaseEntity getByName "curve-1"]

# Get a curve point using parametric position: [list u v crv].
# This assumes that the curve's direction goes from LEdge (u=0) to TEdge (u=1).
# Since this is a curve, the v parameter is ignored.
set trailingEdgePt [pw::Application getXYZ [list 1 0 $airfoilCrv]]

# compute the xyz at the rear farfield.
set rearFarFieldPt [pwu::Vector3 add $trailingEdgePt [list $farfield 0 0]]

# You can now create the "baffle" curve using $trailingEdgePt and $rearFarFieldPt

You can compute the other 4 farfield corner points using similar logic:

Code:

set farfieldX2 [expr {$farfield * 2}]
set topRightFarFieldPt [pwu::Vector3 add $rearFarFieldPt  [list 0 $farfield 0]]
set topLeftFarFieldPt [pwu::Vector3 add $topRightFarFieldPt  [list -$farfieldX2 0 0]]
set bottomLeftFarFieldPt [pwu::Vector3 add $topLeftFarFieldPt  [list 0 -$farfieldX2 0]]
set bottomRightFarFieldPt [pwu::Vector3 add $bottomLeftFarFieldPt  [list $farfieldX2 0 0]]

I hope this helps.

You can find all the documentation for these glyph calls on the Pointwise website.

yea even that is not working. i keep getting the same error as I do with my script:

Code:

invalid command name "pw:DatabaseEntity"
invalid command name "pw:DatabaseEntity"
    while executing
"pw:DatabaseEntity getByName "curve-1""
    (procedure "afMesh" line 25)
    invoked from within
"afMesh"
    invoked from within
".mesh.af2.dbb invoke "
    invoked from within
".mesh.af2.dbb instate {pressed !disabled} { .mesh.af2.dbb state !pressed; .mesh.af2.dbb invoke } "
    (command bound to event)


dgarlisch January 12, 2016 13:27

Sorry. There was a typo in my script!

pw:DatabaseEntity should be pw::DatabaseEntity

weigl January 12, 2016 13:51

Quote:

Originally Posted by dgarlisch (Post 580678)
Sorry. There was a typo in my script!

pw:DatabaseEntity should be pw::DatabaseEntity

thank you soo much. it works perfectly.

sorry to be such a bugger.

Unfortunately I have very less time to finish this script so I don't have the luxury of learning it from beginning to end.

Thank you very very much.


All times are GMT -4. The time now is 23:44.