I’m Scott Burch and This Is How I Mesh

Scott Burch, Design Engineer, Development Series Team Manager, Garry Rogers Motorsport.

Scott Burch, Design Engineer, Development Series Team Manager, Garry Rogers Motorsport.

The first time I’d heard of CFD was when Ford Australia used it to develop their V8 Supercar in 2003 on their super computer in America.  When describing the power of the hardware, they said it was used to calculate nuclear bomb tests; which blew my mind.  I never thought that I’d be working at Garry Rogers Motorsport one day and using it to design a Volvo V8 Supercar.

In my final year of high school I was in the class of 2000 (does anyone remember that Y2K thing?). Originally wanting to be an architect, I was rejected from the degree after my final interview when they asked if I like reading. I responded with “I’d rather look at the pictures” (a CFD engineer in the making right there!).  I instead had to settle for a building design and drafting course and found that dedication was an issue because I was always going to car races and working on cars in my spare time.  Being the kind of person who just has to finish things, I completed my drafting course before taking steps to work in the automotive industry.

In 2004 I accepted a job working as a Fabricator and Painter for the design bucks and clay models of the then-upcoming Holden VE Commodore (Pontiac G6 in America).  I thoroughly enjoyed this job and remember putting in long hours (90 hour week once) to get these projects done on time.  This led to a Fitting and Turning apprenticeship with GM Holden at their engine manufacturing plant just across the road.

At the end of my apprenticeship in 2008, the GFC had hit.  While Australia was lucky to avoid much of the turmoil, times were very tough with Holden because it was part of GM and all apprentices were let go at the end of our time.  I had been studying Mechanical Engineering at night school for the entirety of my apprenticeship after initially enrolling just to show GM I was keen, but found that I really enjoyed it.  I was at a crossroad where I either continued with my trade or pushed on with my study.

I ended up selling my house and went to RMIT University to study Mechanical Engineering full-time.  At the age of 26 I was the old man of my class.  I became involved in the FSAE team (students design and build and small race car), which was great for turning our course knowledge into real useable skills and making friends who I now see regularly at the track and work for other teams—frienemies.

It was in my last year, when I finally began to study CFD and vehicle aerodynamics, that a job offer from Garry Rogers Motorsport was circulating the student email system.  They wanted to start a CFD program for full car aerodynamic analysis and it was right up my alley.  I applied, made about 4000 phone calls, had an interview, and told them how much I enjoy looking at the pictures. This time that line worked for me.

CFD seems to really play into my psyche.  You can do almost anything you can imagine and I always have an idea I would like try.  Coming in to work when a simulation is nearly complete is like Christmas morning; the surprise is there and ready to be opened.

  • Location: Dandenong, Victoria, Australia (Dandenong is based on the local Aboriginal word for ‘lofty mountain’)
  • Current position: Design Engineer, Development Series Team Manager
  • Current computer: CPU Intel Core I5-3570 CPU @ 3.40GHz, 32GB RAM, NVIDIA Quadro FX 1500, Windows 7 and 2 x CPU Intel Core E5-2670 CPU @ 3.10GHz, 190GB RAM, CentOS 6.7
  • One word that best describes how you work: Obsessed

What software or tools do you use every day?

Pointwise V18.0R1, Caelus 6.04, Solidworks2016, Outlook, Excel, TI-89 Calculator, and a Vernier caliper.

What does your workspace look like?

scottburchworkspace

The engineering office runs along the wall of the workshop directly behind the work bays for the cars and is shared by seven engineers.  We all have multiple roles on the team, apart from the two race engineers who are very much focused on the setup of the cars.  We have an air conditioner and constantly let the mechanics know about it on the 40°C (104°f) plus days.

I have all my data folders, category rule book, diary and my race car ONLY Toshiba Tectra laptop on the desk ready to go.  Scrap paper is used for roughing out calculations and design ideas and the occasional cartoon characters when the computer is thinking.  I’ve heard a rumor that the team owner enjoys stopping by my desk when I’m not around to see which character I’ve drawn.

I run two monitors/computers.  On the right is my Windows machine, and on the left is the Linux number crunching beast.  The computers are linked using the Synergy keyboard and mouse sharing program so that I can quickly jump between computers.

What do you see are the biggest challenges facing CFD in the next 5 years?

I suppose we have our own ideas depending on our experience in the industry.  I’d say in motorsport it would have to be finding the balance between the speed of solving and accuracy of the model.  It is difficult for people without the experience to accept this link.  Quite often you’re asked to make the mesh huge and detailed, while it has to be solved yesterday.

However the penetration of CFD, how it works, and what can be achieved, is slowly starting to become recognized by the public.  When I give sponsors and fans garage tours, the mention of CFD gets fewer confused looks than it did when I started.

What are you currently working on?

Many of our fans will be happy to hear that I’m still working hard on the Volvo S60 V8 Supercar.  With the introduction of mixed meshes in Pointwise, I am moving toward full car simulation to capture the out-of-symmetry features of the car.

What would you say is your meshing specialty?

Meshing high down force ground vehicles (or racecars for short) would have to be my specialty.  When considering the move to OpenFOAM, I had to rethink many of the ways I mesh when compared to the finite element solver I was using before.  In particular, when producing 2D surface meshes adjacent to each other, such as the front of the car and ground, the surface mesh should be generated using elements of similar edge lengths. Otherwise, once the volume is inflated between the two surface meshes there will be excessive centroid skewness, a metric our finite element solver was not as sensitive to.

Automotive aerodynamics is generally highly turbulent. This is especially true on production based body shapes with down force producing elements added to them.  Understanding of the flow separation regions goes a long way to producing consistent, reliable results and is something that using the source feature in V18 will be fantastic for.

Any tips for our users?

Download the Pointwise Y+ app.  It’s very useful for helping setup your T-Rex parameters.  Regularly refresh yourself on the fundamentals of CFD because sometimes you have to take that step back to take a step forward.

What project are you most proud of and why?

Definitely the Volvo S60 V8 supercar.  This was the first full car design we undertook using CFD, and it was a huge success.  I enjoyed researching not only the cars in our category, but cars in all forms of motorsport.  I ran models to test concepts and I had many “aha!” moments when the CFD revealed the key behind many design features that had puzzled me.

The Volvo also showed that there is no single solution to slap on an entire category of cars because their design features change so much between body types.  Even a seemingly insignificant change in surface area or changing the radius of an external component can make a profound difference to the aerodynamic behavior of the car.

What CFD solver and postprocessor do you use most often?

We spent a number of years using AcuSolve which is a finite element solver.  We had great success with this and our Pointwise meshes.  We’ve had an association with Applied CCM since 2012 as our technical CFD partner. Pointwise enthusiastically joined when Dr. Darrin Stephens told them about our struggles with the inflation of the volume mesh due to the complexity and size of the models we were building; very much a case of “challenge accepted.”

Since the release of Caelus from Applied CCM, we’ve pushed to utilize this solver for our work which has begun to work well for us after changing a few of our meshing methods.  After initially working in ParaView for post processing, we’ve moved to FieldView because our past experience has shown it is a very powerful tool for creating visuals and data.

Are you reading any interesting technical papers we should know about?

I subscribe to Racecar Engineering magazine.  They have a contributor named Simon McBeath and I’d credit him with helping me develop my methodology for evaluating my CFD models.  Mr. McBeath has recently done some features with Miqdad Ali from Dynamic Flow Solutions on Formula 1 CFD in OpenFOAM which have been really interesting.  In the September 2016 issue they evaluate the challenges with overtaking scenarios and aerodynamic behavior in anticipation of future rule changes in F1.

Do you plan on attending any conferences or workshops next year?

It is difficult to attend workshops and conferences from Australia, which is why writing for The Connector is really great.  Following the Twitter feeds of various people also help keep me up to date.

I attended the Pointwise UGM this year which was a great experience, and not just for meeting the people behind the scenes, but to also see what other users are doing with the software and share what they’ve learned.  The UGM was my first time using Pointwise V18 and I had brought a mesh of the Supercar with me. Within one hour I’d reduced the surface mesh size by 500k elements which would in turn reduce the volume mesh by ~10M elements once T-rex was applied.  I’d almost put all of those elements back in areas of interest by using the new sources feature.

What do you do outside the world of CFD?

I’m currently finishing the restoration of my 1971 Datsun 240Z.  When I started it was going to be a fire breathing track weapon. But the older I get the more I want it to look as it did when it came out of the factory, which is much harder to do than customizing it!  There were only 1,500 delivered to Australia, but 250,000 to the U.S., which makes it a treasure trove of rare bits.  I have spent years combing through online shops and auctions, and putting up with insane postage costs to get it to this point.  My parts always have a stopover in Hawaii on their way to Australia. Half my car has been there and I haven’t, what a mockery.  I have also begun the restoration of my father’s 1974 Ford Falcon GT.  If you’ve ever seen the movie Mad Max, then you’ve seen this car before.

I’m a bit of an artist and last year purchased a Wacom Cintiq 24HD drawing screen.  I initially wanted to draw my own comic strips, but have steered toward automotive painting and have done a few commission paintings for people. I also do a painting for the team and sponsors at the end of the year.  I have a profile on DeviantArt where I post my digital paintings and also see what other artists are doing.  I’m a big fan of futuristic sci-fi cityscapes and futuristic apocalyptic ruins. It’s so creative and I love dark landscapes, though I don’t have a dark personality, I swear.

Both of these hobbies involve a lot of patience.  Sometimes I’ll be so close to a milestone and realize I just can’t spend more time on it, or I have to order a part before I can progress.  So, tools down for the night.

Cars, cars, cars it would seem.

I hope to see a bit of the world in the future. My job does have me travelling to a different part of the country or world every 2-3 weeks, but I often only get to the see the hotel and race track.  Greece and Italy are currently high on the list.

What is some of the best CFD advice you’ve ever received?

“Wind tunnels find the What; CFD finds the Why.” – Aerodynamics of Road Vehicles, Wolf-Heinrich Hucho.

If you had to pick a place to have dinner, where would you go?

Can I go back to the early 90’s for this dinner?  There was a restaurant when I was about 8 or 9 called “Robs” and it was a Chinese restaurant, so I always found the name a bit odd.  They had the best food and plenty of it.  The front window had water cascading from the roof into a pool below with a big flame erupting from the middle.  As a kid I would run an Olympic marathon chasing my twin brother around the place. I’m surprised no one ever scolded me for it.  It was the best experience.

Posted in People & Places | Tagged , , , , , , , , , , , , , , | Leave a comment

This Week in CFD

Applications

  • CFD provides insight into stroke risk by simulating flow in the human heart. Video included at link.
  • Here’s a brief article describing some uses of the Kestrel CFD solver – F-35 inlet and transonic wind tunnel compressor – at the U.S. Air Force’s Arnold AFB.
  • Is CFD part of Industry 4.0? This article describes Industry 4.0 as a future in which “every manufacturing process and import it into one holistic system where the workflow, maintenance and management of every machine, process or even a factory’s entire shop floor can be monitored and controlled from one or number of remote or collocated hubs.” But the sole image in the article seems to be the flowfield around an aircraft.
  • FloEFD contributed to the NASCAR Whelen Euro Series Championship.
Garry Rogers Motorsport is using Pointwise and Caelus to model the aerodynamic performance of their S60 V8 Supercar, including brake cooling as shown here. Click image for article.

Garry Rogers Motorsport is using Pointwise and Caelus to model the aerodynamic performance of their S60 V8 Supercar, including brake cooling as shown here. Click image for article.

Pointwise News

  • We’ll be hosting a webinar on 14 December to share the newest meshing capabilities in Pointwise Version 18 including unstructured quad-dominant surface meshing, unstructured hex layer extrusion with T-Rex, and isotropic tetrahedral mesh clustering with sources.
  • Come see us at AIAA SciTech 2017 where we’ll be presenting technical papers on some of our latest work, demonstrating Pointwise in the exhibit hall, and hosting a reception.

Software

  • In advance of new products coming in 2017, Friendship Systems has announced a realignment of their CAESES product portfolio. In particular, CAESES Free is being discontinued.
  • New versions of Isight and Tosca are available with a webinar coming on 09 December.
  • The new features in FLOW-3D v11.2 will be the subject of a Flow Science webinar on 15 December.
  • Here’s a write-up on Numeca’s use of Nvidia’s OpenACC to accelerate the performance of their Fine/Turbo CFD code.
CFD was used to compute the heat transfer coefficient on fruit in cardboard boxes with various configurations of vent holes. Image from ScienceDirect. Click image for article.

CFD was used to compute the heat transfer coefficient on fruit in cardboard boxes with various configurations of vent holes. Image from ScienceDirect. Click image for article. [Fruit cooling!]

Events

  • At the EnSight 2016 Japan User Group Meeting, CEI revealed new software coming in 2017 including EnSight 10.2 and Nexus, “a browser-based hub for engineering data.”
  • The Talking CFD Podcast is 3 episodes into season two and you can get caught up [binge listen?] here.
    • And they’ve introduced something new this season, the Talking CFD Social “live” stream with the first episode including Pointwise’s Travis Carrigan and Manor Racing’s Simon Hubbard.

Mesh as Architecture

Our friends at Branch Technology (winner of the Meshy Award for 2016) have contributed to the construction of the world’s largest 3-D printed structure, a pavilion for the Design Miami fair. The structure, called Flotsam & Jetsam, was designed by SHoP Architects as part of their 2016 Design Miami Visionary Award.

It’s mind-boggling when you think about the fact that Branch Technology uses Pointwise to generate the meshes that are 3-D printed into these life-size forms.

Flotsam & Jetsam by SHoP Architects is the world's largest 3-D printed structure. Image provided by Branch Technology. See links above.

Flotsam & Jetsam by SHoP Architects is the world’s largest 3-D printed structure. Image provided by Branch Technology. See links above.

Video fly-through of Flotsam & Jetsam by SHoP Architects. Click image for video.

Video fly-through of Flotsam & Jetsam by SHoP Architects. Click image for video.

Bonus: ETH Zurich has developed Mesh Mould for “building load-bearing concrete elements of any any shape without formwork.” The Rhino software is part of their toolchain.

Posted in Applications, Events, News, People & Places, Software | Tagged , , , , , , , , , , , , | Leave a comment

This Week in CFD

Special “I’ve eaten too much turkey” Edition*

News & Events

  • Siemens PLM Software acquired Mentor Graphics for $4.5 billion. This deal brings together STAR-CCM+ and FloEFD.
    • DEVELOP3D also wrote about this announcement and their article includes a link to a Siemens PDF showing how Mentor fits within their portfolio of technology.
    • Mentor Graphics also announced a new release of FloEFD.
  • The 25th Annual Conference of the CFD Society of Canada will be held 18-21 June 2017 in Windsor, Ontario. The due date for extended (4-6 page) abstracts is 09 January 2017.
  • The 12th OpenFOAM Workshop will be held 24-27 July 2017 at the University of Exeter in the UK. [Sorry, no URL yet.]
  • Here’s a good summary of the 2016 FloEFD Simulation Conference from earlier this month. In this article you’ll read that their 2017 event will be in Berlin on 7-8 November.

Computing: Cloud, HPC, Exascale & More

This absolutely gorgeous image of a DEM simulation is from STAR-CCM+ v11.06. Image from Siemens. See link below.

This absolutely gorgeous image of a DEM simulation is from STAR-CCM+ v11.06. Image from Siemens. See link below.

Software

Applications

Alert reader Dan shared this image of the faceted styling of Logitech's MX Master wireless mouse. Click image for link.

Alert reader Dan shared this image of the faceted styling of Logitech’s MX Master wireless mouse. Click image for link.

Good Reading & Listening

  • 40% of women who earn an engineering degree either never enter or leave the field. Why? This HBR report cites evidence that women engineers are treated differently than their male peers, professors, and employers beginning in college and through internships. [I would appreciate reading comments on this from female engineers.]
  • The OpenFOAM Foundation launched a fundraising campaign to receive donations totaling €100,000 to fund the software’s development in 2017. The rationale for the foundation’s fundraising effort seem to be explained by a series of blog posts from CFD Direct.
  • The first two episodes of the new season of the Talking CFD Podcast are available for your listening pleasure. They’re with Kelly Senecal of Convergent Science and Nicolas Tonello of Renuda.

Geometry in the Wild

The fine folks at Colossal often feed my fetish for finding meshes, facets, and plain old geometry in art, nature, design, and just in real life (IRL) in general. Their article about the light installations of Nicolas Rivals is no exception. The juxtaposition of hard-edged, artificially-lit geometry and serene, dusky natural settings is quite arresting. More of the artist’s works can be found on his website.

La Linea Roja by Nicolas Rivals. Image from Colossal. See link above.

La Linea Roja by Nicolas Rivals. Image from Colossal. See link above.

Bonus: Behold the miracle of nature’s meshing as this mushroom extrudes a polygonal surface mesh. source

mushroom-poly-mesh

*Yesterday was the Thanksgiving Day holiday here in the U.S. where the tradition is to eat turkey with all the trimmings – and a lot of it.
Posted in Applications, Events, Hardware, News, Software | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

I’m Simon Hubbard and This Is How I Mesh

Simon Hubbard, Lead CFD Process Engineer at Manor Racing.

Simon Hubbard, Lead CFD Process Engineer at Manor Racing.

I was born in Harrow in North London, which I don’t remember too much of as my parents moved to Leighton Buzzard (strangely linked to North London through its use as a pun name for the North London based pub rock band the Leyton Buzzards). Growing up I always liked cars and planes and figuring out how things worked. I raced 1/10th scale off-road RC cars (one of these, but from 1992) for a while, something I’m thinking about getting back into, whilst harbouring desires for an aero or helicopter equivalent (which I never quite had enough money for). My A-level physics project was to measure the deceleration of my RC car on surfaces with varying grip levels.

I carried on this theme studying Mechanical Engineering at Leeds for three years where I enjoyed the CFD course and did a final year project using CFX (version four, maybe…). I remember the pain involved in setting up a 2D model of the flow over a NACA airfoil and many afternoons spent fighting with boundary conditions.

My next stop took me to the then British Aerospace in Warton to work in the military aircraft and aerostructures department. I learnt a lot about real engineering but really wanted to be a bit closer to the physics. After a spell in the Future Projects Group characterising reusable launch vehicles for space applications (if you spend a little time researching the HOTOL space vehicle concept, you will see where the SABRE engine started), it was back to academia to look at wingtip trailing vortices at Imperial College using CFD.

My Ph.D. was a lot of fun and hard work. My focus was on computationally efficient methods. A lot of my simulations ran on a single core 1.6GHz chip accessing 512MB of RAM. Those were the days! I wrote a quasi-3D solver which was efficient as a result of being able to treat one of the space dimensions as being time-like so you could then march through space in this dimension in the same way as you do through time for unsteady simulations. Essentially, this makes the 3D problem a succession of 2D problems. The prerequisite are cases where you have a dominant flow in one of the spatial coordinate directions so that information can only flow in one direction. This makes the governing equations parabolic rather than elliptic. This work, combined with some details of turbulence modelling of vortices, and a look at vortex methods, made for a rewarding four years.

I spent three years as part of the CFD group at the BAR Honda and then Honda F1 team, which at the time was split into F1 folk and people doing external consultancy work. My main project was working on reducing drag for the British Olympics team in the development cycle for the Beijing Olympics. This was a great project as I got to do the CFD and then validate it in the wind tunnel and see the final designs tested at Manchester Velodrome (more on this later).

I did some further work on sportscars in the American LeMans series in the USA for the group that later went on to do the all-CFD Virgin F1 car. It still frustrates me how inaccurate much of the material in the media is on this subject. Next I went off to do something completely different for a while. I spent a year helping a local company develop their simulation and testing practices, lead their design group in the field of temperature controlled packaging, and then spent three years developing computational methods and tools for a piezoelectric inkjet manufacturer. I’d been tinkering with OpenFOAM for a while and it was here that I got to use and develop it, in anger, in the real world. This year I came back into F1 and am now helping Manor Racing with their OpenFOAM process.

  • Location: I live in Cranfield in Bedfordshire. It’s a nice village in the Home Counties countryside. I live on the other side of the airfield to the University. It’s nice to cycle through the campus and see some of the roads and buildings named after famous academics. I particularly enjoy going past Lanchester Hall, named after the English polymath who developed some of the first theories of lift and trailing vortex formation.
  • Current position: Lead CFD Process Engineer at Manor Racing
  • Current computer: Windows 7 laptop, Intel i7 2.6GHz, 16GB RAM and a Linux workstation (over VNC), Xeon, 32 cores, 512GB RAM
  • One word that best describes how you work: All-or-nothing

How do you know Pointwise?

I’ve known about Pointwise for a long time, but never had the chance to use the software. That’s mostly been due to the places I’ve worked, and it does maybe seem a little underrepresented in the UK. A lot of folk here seem to use ANSA from Beta CAE as a high end pre-processor. It’d be neat to have a go with Pointwise and see how it fares.

What do you see are the biggest challenges facing CFD in the next 5 years?

I’m worried that there aren’t enough people with good CFD domain competence to keep up with the rapid growth of CFD availability and reduction in cost effectiveness through cloud HPC. It’s a great tool that can add so much economic value across a range of applications and I wouldn’t want this to be limited by there not being enough people to support its proper use in industry – people who know which turbulence model to use, when to stop worrying about mesh dependency, etc. – and the potential not reached because of too many otherwise preventable mistakes and inappropriate use.

What are you currently working on?

Obviously, with the industry I’m in, I can’t say too much in detail here. I’m constantly trying to make the CFD process at Manor more efficient and accurate.

What project are you most proud of and why?

The cycling drag reduction project for UK Sport in the development cycle for the Beijing Olympics really stands out for me. From a technical perspective we made some innovative development to the CFD process to capture the effects of transition before specific transitional turbulence models were available. I was also involved in the whole development cycle. This involved performing the CFD, going to the wind tunnel, and then the velodrome, to see the design modifications we were making through each of the testing environments.

Are you reading any interesting technical papers we should know about?

Nothing novel at the moment. I’m mostly looking at papers for turbulence model applications in OpenFOAM.

What software or tools do you use every day?

ANSA, OpenFOAM, ParaView. Text editors gedit and vi for scripting and OpenFOAM dictionaries. I do a little data analysis in Scilab and I spend a lot of my time in a bash terminal. And Google Chrome pretty much goes everywhere I do whether at home or work.

What does your workspace look like?

Simon's current workspace.

Simon’s current workspace.

Do you plan on attending any conferences or workshops this year?

I went to the ESI OpenFOAM conference in Cologne last month. It was great to see a presentation by Professor Spalding on the future of CFD. I was impressed with the diversity covering all relevant aspects from meshing to solving, as well as application and HPC performance. I’m hoping to go to the 12th OpenFOAM Workshop in Exeter next year.

What do you do outside the world of CFD?

I try to spend as much time as I can with my family. Sometimes that’s days out or events. And sometimes it’s just hanging out together doing something or nothing. I also like road cycling having spent much of my teenage years out in the countryside with friends and an OS map. This year I cycled from Land’s End to John o’Groats in 14 days. Bristol was very wet and Scotland was gorgeous.

What is some of the best CFD advice you’ve ever received?

It wasn’t so much direct advice, but I remain indebted to my Ph.D. supervisor who took me down the path of writing my own CFD code when a fair amount of Ph.Ds. were being done with commercial codes. Since then, I’ve always been an advocate of taking some time to understand exactly what the code is doing – it pretty much always pays off later on.

If you had to pick a place to have dinner, where would you go?

The Equinox restaurant at the top of the Raffles tower in Singapore. The food is great and the views are amazing.

Posted in People & Places | Tagged , , , , , , , , , , , , , , | Leave a comment

The Connector Newsletter for 2016 Q4

The 2016 4th Quarter issue of our The Connector newsletter is now available on our website at www.pointwise.com/theconnector/2016-Q4. This issue features articles on

the-connector-2016-q4-social-sharing

Posted in News | Tagged | Leave a comment

This Is How I Glyph – Tcl Namespaces (Part 2)

This is the second in a series of posts about the Tcl namespace command. Each subsequent post will cover more complex uses of namespaces. While this topic is strictly related to Tcl only, it could help you when developing more complex Glyph scripts.

The topics to be covered in this post depend upon a clear understanding of concepts outlined in Tcl Namespaces (Part 1). If you haven’t already, then please review them before continuing.

Subcommands

If you look at the Tcl command manual pages, you will find that many commands support subcommands. One example would be the Tcl string command with its 19 subcommands. A Glyph example would be the pw::Application command and its more than 70 subcommands!

In the example code below equal, map, and range are subcommands of the string command. Similarly, getVersion and getCAESolver are subcommands of the pw::Application command.

A Tcl command with one or more subcommands is also known as a command ensemble. The Tcl namespace command can be used to create your own command ensembles.

package require PWI_Glyph 2.18.0

set s1 "Hello World!"
set s2 "hello world!"
set fromToPairs {Hello Goodbye World Birdie}
puts "string"
puts "  equal          => [string equal $s1 $s2]"
puts "  equal -nocase  => [string equal -nocase $s1 $s2]"
puts "  map            => '[string map $fromToPairs $s1]'"
puts "  range          => '[string range $s2 6 end-1]'"
puts "pw::Application"
puts "  getVersion     => '[pw::Application getVersion]'"
puts "  getCAESolver   => '[pw::Application getCAESolver]'"

# Output:
# string
#   equal          => 0
#   equal -nocase  => 1
#   map            => 'Goodbye Birdie!'
#   range          => 'world'
# pw::Application
#   getVersion     => 'Pointwise V18.0R2C5'
#   getCAESolver   => 'CGNS'

The RangeInt Namespace

Before we get into ensembles, let’s take a look at a namespace called RangeInt. RangeInt supports the creation of named integer values with an associated min and max range. Attempting to assign a value outside this range will result in a Tcl error being triggered. Some example usage of RangeInt is given at the end of the code listing. RangeInt defines a variable named params_ and four procs named add, set, get, and check.

The params_ variable is a Tcl dictionary that is used to store the range and value for each of the named integers.

The add proc is used to create a new named value.

The set, and get procs are used to manipulate the integer values.

The check proc is used to validate values.

Note: The proc implementation details are not important to this discussion. As such, the proc code has been removed for brevity. However, you can view the full, working code by opening the collapsed sections below.

namespace eval RangeInt {
  variable params_ [dict create]

  proc add { name {val 0} {min inf} {max inf} } {
    ...
  }

  proc set { name val } {
    ...
  }

  proc get { name {defaultVal 0} } {
    ...
  }
  
  proc check { name val op key } {
    ...
  }
}

RangeInt::add i1  888       ;# range -infinity ... +infinity
RangeInt::add i2  5 0 20    ;# range         0 ... 20
RangeInt::add i3 -3 -10     ;# range       -10 ... +infinity
RangeInt::add i4 -5 inf -5  ;# range -infinity ... -5
puts "i1  == [RangeInt::get i1]"
puts "i2  == [RangeInt::get i2]"
puts "i3  == [RangeInt::get i3]"
puts "i4  == [RangeInt::get i4]"
puts {}
RangeInt::set i1 500
puts "i1  == [RangeInt::get i1]"
puts {}
catch {RangeInt::set i2 21} msg
puts "error '$msg'"
puts "i2  == [RangeInt::get i2]"

# Output:
# i1  == 888
# i2  == 5
# i3  == -3
# i4  == -5
# 
# i1  == 500
# 
# error 'Invalid value: 0 <= 21 <= 20'
# i2  == 5
namespace eval RangeInt {
  variable params_ [dict create]

  proc add { name {val 0} {min inf} {max inf} } {
    variable params_
    dict set params_ $name MIN $min
    dict set params_ $name MAX $max
    RangeInt::set $name $val
  }

  proc set { name val } {
    variable params_
    if { [check $name $val >= MIN] && [check $name $val <= MAX] } {
      dict set params_ $name VAL $val
      return
    }
    ::set min [dict get $params_ $name MIN]
    ::set max [dict get $params_ $name MAX]
    return -code error "Invalid value: $min <= $val <= $max"
  }

  proc get { name {defaultVal 0} } {
    variable params_
    return [expr {[dict exists $params_ $name VAL] ? \
                  [dict get $params_ $name VAL] : $defaultVal}]
  }
  
  proc check { name val op key } {
    variable params_
    ::set limit [dict get $params_ $name $key]
    return [expr [list "$limit" == "inf" || $val $op $limit]]
  }
}

Namespace Command Ensembles

Converting a namespace into a command ensemble is simple. First, you add a call to the namespace export command for each proc that you want to be an ensemble subcommand. Then, to actually create the ensemble, add a call to the namespace ensemble create command. This call must be made after all the subcommand procs have been exported. The highlighted code fragments below show these changes.

Please notice that the check proc is not exported. It is a helper proc that is only to be used by the namespace itself. Since check was not exported, attempting to call RangeInt check will result in an “unknown or ambiguous subcommand” error.

namespace eval RangeInt {
  variable params_ [dict create]

  namespace export add
  proc add { name {val 0} {min inf} {max inf} } {
    ...
  }

  namespace export set
  proc set { name val } {
    ...
  }

  namespace export get
  proc get { name {defaultVal 0} } {
    ...
  }

  # do not export check - it is for internal use only
  proc check { name val op key } {
    ...
  }

  namespace ensemble create
}

RangeInt add i1  888       ;# range -infinity ... +infinity
RangeInt add i2  5   0 20  ;# range         0 ... 20
RangeInt add i3 -3 -10     ;# range       -10 ... +infinity
RangeInt add i4 -5 inf -5  ;# range -infinity ... -5
puts "i1  == [RangeInt get i1]"
puts "i2  == [RangeInt get i2]"
puts "i3  == [RangeInt get i3]"
puts "i4  == [RangeInt get i4]"
puts {}
RangeInt set i1 500
puts "i1  == [RangeInt get i1]"
puts {}
catch {RangeInt set i2 21} msg
puts "error '$msg'"
puts "i2  == [RangeInt get i2]"
puts {}
puts "check == [RangeInt::check i2 5 <= MAX]" ;# direct call ok
catch {RangeInt check i2 5 <= MAX} msg
puts "error '$msg'"

# Output:
# same as above!
#
# check == 1
# error 'unknown or ambiguous subcommand "check": must be add, get, or set'
namespace eval RangeInt {
  variable params_ [dict create]

  namespace export add
  proc add { name {val 0} {min inf} {max inf} } {
    variable params_
    dict set params_ $name MIN $min
    dict set params_ $name MAX $max
    RangeInt::set $name $val
  }

  namespace export set
  proc set { name val } {
    variable params_
    if { [check $name $val >= MIN] && [check $name $val <= MAX] } {
      dict set params_ $name VAL $val
      return
    }
    ::set min [dict get $params_ $name MIN]
    ::set max [dict get $params_ $name MAX]
    return -code error "Invalid value: $min <= $val <= $max"
  }

  namespace export get
  proc get { name {defaultVal 0} } {
    variable params_
    return [expr {[dict exists $params_ $name VAL] ? \
                  [dict get $params_ $name VAL] : $defaultVal}]
  }
  
  # do not export check - it is for internal use only
  proc check { name val op key } {
    variable params_
    ::set limit [dict get $params_ $name $key]
    return [expr [list "$limit" == "inf" || $val $op $limit]]
  }

  namespace ensemble create
}

Namespace or Ensemble?

There are no hard and fast rules when choosing between plain old namespace procs (RangeInt::add) or going the extra step of exporting procs as ensemble subcommands (RangeInt add). They both achieve the important encapsulation and scoping desired when building a complex Tcl or Glyph library.

I find that the copious use of :: in a Tcl script can be distracting and make the code harder to read. I lean towards using command ensembles for everything except the outer-most namespace. For instance, Glyph uses the pw namespace to protect the other nested, Pointwise specific command ensembles. That is, the pw namespace is not itself an ensemble. However, the nested namespaces such as pw::Grid are implemented as ensembles with subcommands like pw::Grid getAll.

The code below is a simplified implementation of the nested pw::Grid and pw::Database command ensembles inside the plain old pw namespace.

namespace eval pw {

  # The pw::Grid command ensemble
  namespace eval Grid {

    namespace export getAll
    proc getAll { args } {
      ...
    }

    namespace export getCount
    proc getCount { args } {
      ...
    }

    namespace ensemble create
  }

  # The pw::Database command ensemble
  namespace eval Database {

    namespace export getAll
    proc getAll { args } {
      ...
    }

    namespace export getCount
    proc getCount { args } {
      ...
    }

    namespace ensemble create
  }
}

Until Next Time

This post covered the creation of namespace command ensembles. I will be covering additional namespace wizardry in future posts. If you want to learn more about namespaces, then take a look at the full Tcl namespace documentation.

Posted in Applications, Software | Tagged , , | 1 Comment

This Week in CFD

Jobs

  • Engineering.com’s article on Winning Strategies to Land that Great Engineering Job is a worthwhile read, especially the part about follow-up. [50% of our job applicants, especially for internships, never reply to the very first email we send them after receipt of their resume (which we then don’t bother to review).]
  • The University of Cambridge seeks a research assistant in CFD for compressors.

Software

A FloEFD solution performed in Solid Edge. Image from Engineering.com. See link above.

A FloEFD solution performed in Solid Edge. Image from Engineering.com. See link above.

Exascale Computing

  • The Exascale Computing Project from the U.S. Department of Energy awarded $34 million dollars worth of contracts (35 in total) for exascale software development. The one that caught my eye is ExaHDF5: Delivering Efficient Parallel I/O on Exascale Computing Systems.
  • The ExaFLOW project in the E.U. announced €3.3 million of funding for 8 agencies specifically to move CFD to exascale capability.
  • OpenHPC is a community effort to aggregate tools and libraries for HPC on Linux systems.
  • Our friends at Engineering.com specifically directed me to their article on The Democratization of HPC which means cloud computing and new (i.e. “affordable”) license models. [Yes, I have openly mocked the term “democratization” but it’s worth pointing out that I’m a member of the ASSESS Initiative’s working group on Democratization. Karma? Perhaps. I hope to have more to write about that later. (Democratization, not karma.)]

Events

News

  • The article A New File Format for CAD Users was not what I expected. It’s about Pantone’s Total Appearance Capture tool for an object’s color.
  • Mentor Graphics announced Dr. Aihua Wang from Magneti Marelli as first place winner of the inaugural Frontloading CFD Award for work on Integrating Thermal Analysis into Automotive Lighting Product Design. [A picture of Dr. Wang’s winning work sure would’ve been nice.]
  • As reported by Monica Schnitger, our friends at ANSYS earned $246 million in Q3, an increase of 3%.
  • Altair and TotalSim announced a partnership.

Art of the Grid – Classic Edition

I’ve been remiss in not sharing any of Victor Vasarely’s work that fits into the meshing motif. Throughout the 20th century, he produced many paintings that are strongly geometrical and include a grid-type structure that might be appealing to those engineers for whom more abstract works aren’t of interest. (As seen in the Sotheby’s catalog for their contemporary art day auction on 18 November.)

Victor Vasarely, RE-NAB-II-B, 1968

Victor Vasarely, RE-NAB-II-B, 1968. Image from Sotheby’s. See link above.

Bonus: Enjoy particles.js, an online meshy thing on Code Pen.

Posted in Applications, Events, Hardware, News, People & Places, Software | Tagged , , , , , , , , , , , , , , , | 3 Comments