CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Pointwise & Gridgen (https://www.cfd-online.com/Forums/pointwise/)
-   -   Journaling - Create 2 Point Connector (https://www.cfd-online.com/Forums/pointwise/135070-journaling-create-2-point-connector.html)

v_herw May 8, 2014 11:48

Journaling - Create 2 Point Connector
 
Hi,

I have a question regarding Journaling in Pointwise.
I want to create a script where I connect 2 Points with a Connector. The Journaling gives me this output:

Code:

set _TMP(mode_10) [pw::Application begin Create]
  set _TMP(PW_68) [pw::SegmentSpline create]
  set _CN(8) [pw::GridEntity getByName "con-6"]
  $_TMP(PW_68) addPoint [$_CN(1) getPosition -arc 1]
  $_TMP(PW_68) addPoint [$_CN(4) getPosition -arc 0]
  set _TMP(con_24) [pw::Connector create]
  $_TMP(con_24) addSegment $_TMP(PW_68)
  unset _TMP(PW_68)
  $_TMP(con_24) calculateDimension
$_TMP(mode_10) end
unset _TMP(mode_10)
pw::Application markUndoLevel {Create 2 Point Connector}

set _TMP(mode_10) [pw::Application begin Create]
  set _TMP(PW_69) [pw::SegmentSpline create]
  set _CN(9) [pw::GridEntity getByName "con-7"]
  $_TMP(PW_69) delete
  unset _TMP(PW_69)
$_TMP(mode_10) abort
unset _TMP(mode_10)
unset _TMP(con_24)

_CN(1) and _CN(4) are the two connectors I want to connect.

I am not sure what the second "Application begin Create" is all about. Can anyone explain it to me what it is about and why it is importend to have it in the script.

Thank you for your help.

Vanessa

cnsidero May 8, 2014 14:00

Quote:

Originally Posted by v_herw (Post 490663)
Hi,

I have a question regarding Journaling in Pointwise.
I want to create a script where I connect 2 Points with a Connector. The Journaling gives me this output:

Code:

set _TMP(mode_10) [pw::Application begin Create]
  set _TMP(PW_68) [pw::SegmentSpline create]
  set _CN(8) [pw::GridEntity getByName "con-6"]
  $_TMP(PW_68) addPoint [$_CN(1) getPosition -arc 1]
  $_TMP(PW_68) addPoint [$_CN(4) getPosition -arc 0]
  set _TMP(con_24) [pw::Connector create]
  $_TMP(con_24) addSegment $_TMP(PW_68)
  unset _TMP(PW_68)
  $_TMP(con_24) calculateDimension
$_TMP(mode_10) end
unset _TMP(mode_10)
pw::Application markUndoLevel {Create 2 Point Connector}

set _TMP(mode_10) [pw::Application begin Create] instead
  set _TMP(PW_69) [pw::SegmentSpline create]
  set _CN(9) [pw::GridEntity getByName "con-7"]
  $_TMP(PW_69) delete
  unset _TMP(PW_69)
$_TMP(mode_10) abort
unset _TMP(mode_10)
unset _TMP(con_24)

_CN(1) and _CN(4) are the two connectors I want to connect.

I am not sure what the second "Application begin Create" is all about. Can anyone explain it to me what it is about and why it is importend to have it in the script.

Thank you for your help.

Vanessa

Vanessa,

The "pw::Application begin Create" function is creating a mode to create an entity. In this case a connector. A mode is analogous to entering a panel when using the GUI - think of it like a temporary working state and nothing actually changes until the mode is accepted with Ok or Apply. The "$mode end" command is used to "Apply" the changes. So every time you enter a mode (panel) while journaling, it will add the correspond Glyph mode commands.

Internally Pointwise uses modes for many things. For some simple tasks, there's no requirement a mode be used. And if that operation is only carried out a few times, the effort to code up the mode may not be worth it. However, if the create or modification is being done many times, doing so within a mode can have huge performance benefits.

Here's an example to explain. I want to change the dimension of a connector to a specified avg spacing. Here's how you would do it without a mode:

Code:

set con [pw::Grid getByName "con-1"]
set avgSpacing 0.5
$con setDimensionFromSpacing $avgSpacing

Pretty straightforward. But now imagine I want to modify many (e.g. 100's) connectors - all of which are connected to domains. Every time a connector is modified the domain will reinitialize, which for large, complex domains might take a long time. And if this occurs for 100s of connectors it could taking a really long time. If, however, a modify mode is used, the connector's would be redimensioned without reinitializing the domains each time one is modified. The reinitialization would only occur when the mode ended. Here's how the above would be done in a mode:

Code:

set allCons [pw::Grid getAll -type pw::Connectors]
set conRedimMode [pw::Application begin Modify $cons]
foreach con $allCons {
  $con setDimensionFromSpacing $avgSpacing
}
$conRedimMode end

There's many mode types in Glyph. You best start here: http://www.pointwise.com/glyph2/file...lication.begin and then refer to the specific mode type for the details or journal the operation like you've done.

-Chris


All times are GMT -4. The time now is 14:02.