CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Selecting & Colouring Edges using Scheme

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2018, 05:10
Default Selecting & Colouring Edges using Scheme
  #1
New Member
 
Join Date: Jul 2018
Posts: 3
Rep Power: 8
pcristini is on a distinguished road
EDIT: Apologies, I selected the wrong forum when posting, can this be moved please?

I'm trying to automate some of the visualization checks we perform before running a simulation. This includes colour-coding some edges and zones. However I'm having some issues finding/figuring out the functions to call. I'm new to scheme and fluent, so please understand I may be looking at the wrong areas.

First Issue: setting edge colour. The only way I've found to set specific edge colours was to record the journal of the clicks to manually set it. However, this results in sometimes the colour not applying to the edge. Adding a (cx-pause) guarantees that it's applied, however this has an obvious fault. I would have figured the /display/update-scene/display function would be able to set edge colour, as this seems to be the function that emulates the form used to set colours, but it doesn't.

Code:
(define (set_edge_color name_filter edge_r edge_g edge_b edge_t is_edge)
    (let ()         
        (if (not (and (equal? is_edge 1) is_edge))
            (set! is_edge 0)
            (set! is_edge 1))

        (ti-menu-load-string (format #f "/display/surface-mesh '(~a)" name_filter))
        (ti-menu-load-string "/display/views/auto-scale")

        (cx-gui-do cx-activate-item "Ribbon*Frame1*Frame7(Viewing)*Table1*Table3(Graphics)*PushButton4(Compose)")
        (cx-gui-do cx-activate-item "Scene Description*Frame1*List1(Names)")
        (cx-gui-do cx-activate-item "Scene Description*PushButton2(fl_SelectAll)")
        (cx-gui-do cx-activate-item "Scene Description*Frame5(Geometry Attributes)*ButtonBox2*PushButton1(Display)")
        (cx-gui-do cx-set-list-selections "Display Properties*Frame3(Colors)*DropDownList1(Color)" '( 1))
        (cx-gui-do cx-activate-item "Display Properties*Frame3(Colors)*DropDownList1(Color)")

        (display (format #f "Setting red to: ~a\n" edge_r))
        (cx-gui-do cx-set-scale "Display Properties*Frame3(Colors)*Scale2(Red)" edge_r)

        (display (format #f "Setting green to: ~a\n" edge_g))
        (cx-gui-do cx-set-scale "Display Properties*Frame3(Colors)*Scale3(Green)" edge_g)

        (display (format #f "Setting blue to: ~a\n" edge_b))
        (cx-gui-do cx-set-scale "Display Properties*Frame3(Colors)*Scale4(Blue)" edge_b)
        
        (if (not (equal? is_edge 1))
            (cx-gui-do cx-set-scale "Display Properties*Frame3(Colors)*Scale5(Transparency)" edge_t)
        )

        ;STUPID HACK TO GET COLOR TO APPLY
        (if color_pause (cx-pause))
        (cx-gui-do cx-activate-item "Display Properties*PanelButtons*PushButton1(OK)")
        (cx-gui-do cx-activate-item "Display Properties*PanelButtons*PushButton2(Cancel)")

        (cx-gui-do cx-activate-item "Scene Description*PanelButtons*PushButton1(OK)")
        (cx-gui-do cx-activate-item "Scene Description*PanelButtons*PushButton2(Cancel)")
    ))
Second Issue: I have coloured faces based on zone names, and now I want to display all of them. The only method I've found of displaying faces is by calling:
Code:
;display new zone
(display (format #f "Displaying ~a~%" elem))
(ti-menu-load-string (format #f "/display/surface-mesh '(~a)~%" elem ))

;select it                        
(display (format #f "Selecting ~a~%" elem))
(ti-menu-load-string (format #f "/display/update-scene/select-geometry ~a ~a ~a~%"
  "yes"
  elem
  "no"))

;color it
(ti-menu-load-string (format #f "/display/update-scene/display ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a~%"
  "yes"
   "no"
   "yes"
   "no"
   "no"
   "no"
   "no"
   "no"
   "no"
   (list-ref zone_colors 0)
   (list-ref zone_colors 1)
   (list-ref zone_colors 2)
   (list-ref zone_colors 3)
 ))
But this only displays one face at a time. I'm not sure of the format to pass into /display/update-scene/select-geometry to select multiple elements, and /display/surface-mesh (which can accept a list of wildcarded elements, eg. alu_* if my aluminum components are named alu_compressor, etc) will display the edges of the zones, and therefore the actual mesh, not a solid coloured face.

Any input/suggestions would be greatly appreciated!
pcristini is offline   Reply With Quote

Old   July 26, 2018, 04:18
Default
  #2
New Member
 
Join Date: Jul 2018
Posts: 3
Rep Power: 8
pcristini is on a distinguished road
In the spirit of not abandoning a thread. I've figured out the solution to one of the issues. After inspecting several functions related to surfaces I finally found the following:

Code:
(cx-store-surface-desc-attr (cx-get-surface surface_id) edge-color|face-color (1 0 0 0))
*italicized values are variables passed in.
The colors are percentages of 255 and in order r g b trans

This can set edge or face color easily enough. Now to figure out how to display faces properly...
pcristini is offline   Reply With Quote

Old   July 26, 2018, 04:36
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
what is ~% in your code? What is functionality of this expression?
Code:
(display (format #f "Displaying ~a~%" elem))
looks like here elem is a list of faces, that you want to choose.
May be you should make a loop to go though the whole list and execute calling function each time?

best regards
AlexanderZ is offline   Reply With Quote

Old   July 26, 2018, 05:08
Default
  #4
New Member
 
Join Date: Jul 2018
Posts: 3
Rep Power: 8
pcristini is on a distinguished road
~% just causes a new line to be appended to the displayed string.
pcristini is offline   Reply With Quote

Reply

Tags
colouring, edges, faces, scheme, scheme programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] SnappyHexMesh for internal Flow vishwa OpenFOAM Meshing & Mesh Conversion 24 June 27, 2016 09:54
[surface handling] SurfaceFeatureExtract Foam::error::printStack donQi OpenFOAM Meshing & Mesh Conversion 1 August 15, 2013 01:43
Tutorial for sprayEngineFoam ed_teller OpenFOAM Running, Solving & CFD 4 May 27, 2013 08:03
Problem? with Installation of OpenFOAM 2.1.0 on to Ubuntu 10.4.4 VirtualBox Stubby OpenFOAM Installation 8 March 5, 2012 16:12
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43


All times are GMT -4. The time now is 12:40.