ANSYS R17 Brings Added Tools to Mechanical Licenses

ansys-r17-splashSome of you have probably already noticed, but ANSYS Mechanical licenses have some changes at version 17. First, the license that for years has been known as ANSYS Mechanical is now known as ANSYS Mechanical Enterprise. Further, ANSYS, Inc. has enabled significantly more functionality with this license at version 17 than was available in prior versions. Note that the license task in the ANSYS license files, ‘ansys’ has not changed.

16.2 and Older (task) 17.0 (task)
ANSYS Mechanical (ansys) ANSYS Mechanical Enterprise (ansys)

The 17.0 ANSYS License Manager unlocks additional capability with this license, in addition to the existing Mechanical structural/thermal abilities. Previously, each of these tools used to be an additional cost. The change includes other “Mechanical-” licenses: e.g. Mech-EMAG, Mech CFD. The new tools enabled with ANSYS Mechanical Enterprise licenses at version 17.0 are:

Fatigue Module Rigid Body Dynamics Explicit STR Composite PrepPost (ACP)
SpaceClaim DesignXplorer ANSYS Customization Suite AQWA

Additionally, at version 17.1 these tools are included as well:

AIM Simplorer Entry

These changes do not apply to the lower level licenses, such as ANSYS Structural and Professional. In fact, these licenses are moving to ‘legacy’ mode at version 17. Two newer products now slot below Mechanical Enterprise. These newer products are ANSYS Mechanical Premium and ANSYS Mechanical Pro. We won’t explain those products here, but your local ANSYS provider can give you more information on these two if needed.

Getting back to the additional capabilities with Mechanical Enterprise, these become available once the ANSYS 17.0 and/or the ANSYS 17.1 license manager is installed. This assumes you have a license file that is current on TECS (enhancements and support). Also, a new license task is needed to enable Simplorer Entry.
Ignoring Simplorer Entry for the moment, once the 17.0/17.1 license manager is installed, the single Mechanical Enterprise license task (ansys) now enables several different tools. Note that:

  • Multiple tool windows can be open at once
    • g. ANSYS Mechanical and SpaceClaim
  • Only one can be “active” at a time
    • If solving, can’t edit geometry in SpaceClaim
  • Capabilities are then available in older versions, where applicable, once the 17.0/17.1 license manager is installed

Here is a very brief summary of these newly available capabilities:

Fatigue Module:

  • Runs in the Mechanical window
  • Can calculate fatigue lives for ‘simple’ products (linear static analysis)
    • Stress-life for
      • Constant amplitude, proportional loading
      • Variable amplitude, proportional loading
      • Constant amplitude, non-proportional loading
    • Strain-life
      • Constant amplitude, proportional loading
    • Activated by inserting the Fatigue Tool in the Mechanical Solution branch
    • Postprocess fatigue lives as contour plots, etc.
    • Requires fatigue life data as material properties

ansys-rbd-1Rigid Body Dynamics:

  • Runs in the Mechanical window
  • ANSYS, Inc.-developed solver using explicit time integration, energy conservation
  • Use when only concerned about motion due to joints and contacts
    • To determine forces and moments
  • Activated via Rigid Dynamics analysis system in the Workbench window

drop-test-of-mobile-phoneExplicit STR:

  • Runs in the Mechanical window
  • Utilizes the Autodyn solver
  • For highly nonlinear, short duration structural transient problems
    • Drop test simulations, e.g.
    • Lagrangian-only
  • Activated via Explicit Dynamics analysis system in the Workbench window

simulation-of-3d-compositesComposite PrepPost (ACP):

  • Tools for preparing composites models and postprocessing composites solutions
  • Define composite layup
    • Fiber Directions and Orientations
    • Draping
    • Optimize composite design
  • Results evaluation
    • Layer stresses
    • Failure criteria
    • Delamination
    • Wrinkling
  • Activated via ACP (Pre) and ACP (Post) component systems in the Workbench window

SpaceClaim-Model1bSpaceClaim:

  • Geometry creation/preparation/repair/defeaturing tool
  • Try it, learn it, love it
  • A direct modeler so no history tree
    • Just create/modify on the fly
    • Import from CAD or create in SpaceClaim
    • Can be an incredible time saver in preparing geometry for simulation
  • Activated by right clicking on the Geometry cell in the Workbench project schematic

DesignXplorer:

  • Design of Experiments/Design Optimization/Robust Design Tool
  • Allows for variation of input parameters
    • Geometric dimensions including from external CAD, license permitting
    • Material property values
    • Loads
    • Mesh quantities such as shell thickness, element size specifications
  • Track or optimize on results parameters
    • Max or min stress
    • Max or min temperature
    • Max or min displacement
    • Mass or volume
  • Create design of experiments
  • Fit response surfaces
  • Perform goals driven optimizations
    • Reduce mass
    • Drive toward a desired temperature
  • Understand sensitivities among parameters
  • Perform a Design for Six Sigma study to determine probabilities
  • Activated by inserting Design Exploration components into the Workbench project schematic

ANSYS Customization Suite:

  • Toolkit for customization of ANSYS Workbench tools
  • Includes tools for several ANSYS products
    • Top level Workbench
    • DesignModeler
    • Mechanical
    • DesignXplorer
  • Based on Python and XML
  • Wizards and documentation included

AQWA:

  • Offshore tool for ship, floating platform simulation
  • Uses hydrodynamic defraction for calculations
  • Model up to 50 structures
  • Include effects of moorings, fenders, articulated connectors
  • Solve in static, frequency, and time domains
  • Transfer motion and pressure info to Mechanical
  • Activated via Hydrodynamic Diffraction analysis system in the Workbench window

AIM:

  • New, common user interface for multiphysics simulations
    • Structural
    • Thermal
    • CFD
    • Electromagnetics
  • Capabilities expanding with each ANSYS release (was new at 16.0)
  • Uses SpaceClaim as geometry tool
  • Single window
  • Easy to follow workflow
  • Activated from the ANSYS 17.0/17.1 Start menu

Simplorer Entry:

  • System level simulation tool
  • Simulate interactions such as between
    • Controllers
    • Actuators
    • Sensors
    • Structural Reduced Order Models
    • Simple circuitry
  • Optimize complex system performance
    • Understand interactions and trade offs
  • Entry level tool, limited to 30 models (Simplorer Advanced enables more)
  • Activated from the ANSYS Electromagnetics tools (separate download)
  • Requires an additional license task from ANSYS, Inc.

Where to get more information:

  • Your local ANSYS provider
  • ANSYS Help System
  • ANSYS Customer Portal

Do you have an Internet of Things Strategy? PADT Can Help

thing-1-250w“It is not just a trend, it is a Tsunami. One day you will wake up and see a giant wave headed your way, and that wave will be the Internet of Things!”

This was the opening line from a presentation given by the VP of sales for a major engineering software company. It got my attention because it wasn’t hype or hyperbole.  He was just pointing out the obvious. Over the past two years the signs have been there. Smart devices will connected to the internet, and older devices will be made smart and then connected. Those that don’t, will no longer be competitive.

It is not all about smart thermostats. Far from it.  I went to IoT world in San Jose last week and saw a lot of people scrambling to find their solution. And a few that found them.  The best example was an older letter stamping machine, you can guess at the manufacturer, that plugged a modular device from Electric Imp in to their controller and boom – they were connected.  Some back end programming and they now had a competitive IoT device.

iot-networ-graphic-1 It is time to define and execute on your IoT strategy

When we visit customers, we will often ask them what their IoT Strategy is.  The answers vary from “we don’t really think our products have an IoT play” to existing products on the market.  The focus in the media is on consumer IoT products, but the bigger push right now is for industrial Internet, where machines used in manufacturing, energy generation, raw material extraction, and processing are smart and connected.

Customers from consumers to other companies will be requiring the benefits of IoT devices as they look to replace older hardware.  That is why every company that makes physical products needs to develop an IoT strategy.

PADT Can Help

We have been helping our customers define and implement their approach to IoT well, since before it was called the Internet of Things.  From assisting semiconductor companies that make MEMS sensors to making smart medical devices we are plugged in to what is needed to make IoT work.

iot-landing-page-padt-1A good place to start is our IoT landing page at:

www.padtinc.com/iot

There you can find some basic information about how PADT is a more comprehensive and technically capable solution then most design houses that claim to have IoT solutions.  We are uniquely qualified to make sure the “Thing” in your IoT strategy is designed and manufactured right.

pbj-phoenix-business-journal-logoWe also published a series of articles in the Phoenix Business Journal that provide some fundamental background information on the Internet of Things and how to deal with the challenges it presents:

ansys-iot-wheelSimulation can play a big role in almost every aspect of making your IoT device development faster and more productive.  PADT uses ANSYS, Inc.’s comprehensive Multiphysics simulation tool set to model everything from the chip to the embedded system software.

We highly recommend this white paper, “Engineering the Internet of Things

We also have a recording of a very popular webinar that we did: “Engineering the Internet of Things Devices with ANSYS Simulation

and this video on how ANSYS can drive your IoT Design:

For detailed examples, check out the ANSYS IoT Landing page to get a feel for why so many companies are driving their design with ANSYS simulation software:  www.ansys.com/iot

PADT-Webinar-Logo

Engineering the Internet of Things Devices with ANSYS Simulation

June 21, 2016 (Tue)
1:00 PM AZ & PDT / 2:00 pm MDT

REGISTER

Make sure you subscribe to PADT’s email list so you don’t miss future Events

Talking is the Best Approach

We hope that you find all of the material above, and the information we will provide in the coming months useful. But they are no substitute for giving us a call or sending us an email and setting up a face-to-face to talk about your IoT strategy and device development needs.  If you are doing the work in-house, we have the hardware and software tools you need to be successful. If you need outside help, you won’t find engineers with more applicable experience.

Give us a call at 1-800-293-PADT or email info@padtinc.com.

shutterstock_321231902

Just One CUBE With Just One Click! A 1.3x Speedup For ANSYS® Mechanical™

Greetings from the HPC numerical simulation proving grounds of PADT, Inc. in Tempe, Arizona. While bench marking the very latest version of ANSYS® Mechanical™ I learned something very significant and I need to share this information with you right now.As I gazed down on the data outputs from the new solve.out files, I began to notice something. Yes change indeed, something was different, something had changed.

A brief pause for emphasis, in regards in overall ANSYS® productivity and amazing improvements please read this post.

However, pertaining to this blog post, I am focusing on one very important HPC performance metric to me. It is one of the many HPC performance metrics that I have used when creating a balanced HPC server for engineering simulation.. But wait there is more! so please wait just a little bit longer, for very soon I will post even more juicy pieces of data garnered from taken from these new ANSYS® benchmark solver files.

To recap in all of its bullets points & glories:

  • For today and just for today, we are focusing on just one of the performance metrics.
    • The Time Spent Computing The Solution!
  • This 1.3x speedup in solve times was achieved using just one CUBE workstation and with just one click!
    • Open ANSYS®and while you are creating your solve.
    • Select, withjust one click either the INTEL MPI or IBM Platform MPI.
    • Next, run your test repeat as necessary using whichever MPI version that you did not start your test with.

The ANSYS® Mechanical™ Benchmark Description:

  • V15sp-5
    • Sparse solver, symmetric matrix, 6000k DOFs, transient, nonlinear, structural analysis with 1 iteration
    • GPU Accelerator or Co-Processor enabled for: NVIDIA and Intel Phi
    • A large sized job for direct solvers, should run incore on machines with 128 GB or more of memory, good test of processor flop speed if running incore and I/O if running out-of-core

CUBE ANSYS Numerical Simulation Appliance Used:

The ANSYS® Mechanical™ Benchmark Results:


TIME SPENT COMPUTING THE SOLUTION TIME SPENT COMPUTING THE SOLUTION
IBM Platform MPI INTEL MPI
Cores 2016 CUBE w16i-v4 2016 CUBE w16i-v4 This Speedup is…X faster!
2 396.1 380.9 1.04
4 239.7 229.6 1.04
6 210.1 196.7 1.07
8 182.9 168.7 1.08
10 167.2 161.4 1.04
12 167.1 160.7 1.04
14 196.1 151.3 1.30
16 184.7 161.7 1.14

justonecubejustoneclickspeedup

Wow! using these latest 14nm INTEL® XEON®  CPU’s, phew, I have been forever changed! As you can see from the data above, in just one simple click, changing from the IBM Platform MPI to using INTEL MPI and look! the benchmark time spent computing times are faster! A 1.3x Speedup!

Now in this specific benchmark example along with the use of the latest  ANSYS® Mechanical achieving a 1.3x speedup without spending another penny is very wise and not so foolish.

Disclaimer: Please check with your ANSYS Software Sales Representative for the very latest on solver updates and information. Because some of the models and compatibility can very on the . You may need to use the MS-MPI, INTEL-MPI or IBM Platform MPI for your distributed solving. If you are not sure please contact your local ANSYS® Corporate Software Sales or ANSYS® Software Channel Partner that was assigned specifically to you and/or your company.

References:

http://www.ansys.com/Solutions/Solutions-by-Role/IT-Professionals/Platform-Support/Benchmarks-Overview/ANSYS-Mechanical-Benchmarks

Webinars: Overview of Add-On Products that Work with ANSYS Mechanical

PADT-Webinar-LogoWith the introduction of the new ANSYS Mechanical Enterprise, many add-on products that had to be purchased separate, are now included. In these webinars PADT’s engineers will provide an overview of the key applications that users now have easy access to.

Each product will be reviewed by one of PADT’s engineers. The will share the functionality of each tool, discuss some lessons we have learned in using and supporting each tool, and provide a short demonstration. Each session will have time for Questions and Answers.

ANSYS-Footer-RBD-STR-ACT

Sign up for the one you want, or all three. Everyone that registers will receive a link to the recording and to a copy of the slides. So register even if you can not make the specific dates.

Here are the times and links to register:

Overview of ANSYS Rigid Body Dynamics (RBD) and ANSYS Explicit STR
May 19, 2016 (Thu)
11:00 am MST & PDT / 12:00 pm MDT

      REGISTER

Overview of ANSYS SpaceClaim and ANSYS AIM
May 24, 2016 (Tue)
11:00 am MST & PDT / 12:00 pm MDT

    REGISTER

Overview of ANSYS Customization Toolkit (ACT) and ANSYS DesignXplorer (DX)
May 26, 2016 (Thu)
11:00 am MST & PDT / 12:00 pm MDT

     REGISTER

We hope to see you online.  If you have any questions, contact us at support@padtinc.com or call 480.813.4884.

ANSYS_Mechanical_Header

Phoenix Business Journal: ​What is numerical simulation? And why should I care?

pbj-phoenix-business-journal-logoNumerical simulation has been the bulk of my career for 30 years now. I love simulation. It has had a huge positive impact on product development as well as many other industries.  In “What is numerical simulation? And why should I care?” I evangelize a bit about my professional passion.

Helpful New Meshing Feature in ANSYS Mechanical 17.0 – Nonlinear Mechanical Shape Checking

ansys=new-mesh-r17Meshing for Nonlinear Structural Problems

Overcoming convergence difficulties in nonlinear structural problems can be a challenge. I’ve written a couple of times previously about tools that can help us overcome those difficulties:

I’m pleased to announce a new tool in the ANSYS Mechanical tool belt in version 17.0.
With version 17.0 of ANSYS we get a new meshing option for structural simulations: Nonlinear Mechanical Shape Checking. This option has been added to the previously available Standard Mechanical Shape Checking and Aggressive Mechanical Shape Checking. For a nonlinear solution in which elements can become significantly distorted, if we start with better-shaped elements they can undergo larger deformations without encountering errors in element formulation we may encounter fewer difficulties as the nodes deflect and the elements become distorted. The nonlinear mechanical setting is more restrictive on the element shapes than the other two settings.

We’ve been recommending the aggressive mechanical setting for nonlinear solutions for quite a while. The new nonlinear mechanical setting is looking even better. Anecdotally, I have one highly nonlinear customer model that reached 95% of the applied load before a convergence failure in version 16.2. That was with the aggressive mechanical shape checking. With 17.0, it reached 99% simply by remeshing with the same aggressive setting and solving. That tells you that work has been going on under the hood with the ANSYS meshing and nonlinear technology. By switching to the new nonlinear mechanical shape checking and solving again, the solution now converges for the full 100% of the applied load.
Here are some statistics using just one measure of the ‘goodness’ of our mesh, element quality. You can read about the definition of element quality in the ANSYS Help, but in summary better shaped elements have a quality value close to 1.0, while poorly shaped elements have a value closer to zero. The following stats are for tetrahedral meshes of a simple turbomachinery blade/rotor sector model (this is not a real part, just something made up) comparing two of the options for element shape checking. The table shows that the new nonlinear mechanical setting produces significantly fewer elements with a quality value of 0.5 or less. Keep in mind this is just one way to look at element quality – other methods or a different cutoff might put things in a somewhat different perspective. However, we can conclude that the Nonlinear Mechanical setting is giving us fewer ‘lower quality’ elements in this case.

Shape Checking Setting Total Elements Elements w/Quality <0.5 % of elements w/Quality <0.5
Aggressive Mechanical 31683 1831 5.8
Nonlinear Mechanical 31865 1249 3.9

Here are images of a portion of the two meshes mentioned above. This is the mesh with the Aggressive Mechanical Shape Checking option set:ansys-new-meshing-17-01
The eyeball test on these two meshes confirms fewer elements at the lower quality contour levels.

And this is the mesh with the Nonlinear Mechanical Shape Checking option set:

ansys-new-meshing-17-02

So, if you are running nonlinear structural models, we urge you to test out the new Nonlinear Mechanical mesh setting. Since it is more restrictive on element shapes, you may see longer meshing times or encounter some difficulties in meshing complex geometry. You may see a benefit in easier to converge nonlinear solutions, however. Give it a try!

Driving the Design of Small Modular Nuclear Reactors with Flownex

Flownex-Logo-2015-250wThe development of small modular nuclear reactors, or SMR’s, is a complex task that involves balancing the thermodynamic performance of the entire system. Flownex is the ideal tool for modeling  pressure drop [flow] and heat transfer [temperature] for the connected components of a complete system in steady state and transient, sizing and optimizing pumps or compressors, pipes, valves, tanks, and heat exchangers.

To highlight this power and capability,  PADT and Flownex will be exhibiting at the 2016 SMR conference in Atlanta where we will be available to discuss exciting new Flownex developments in system and subsystem simulations of SMRs.  If you are attending this year’s event, please stop by the Flownex booth and say hello to experts from M-Tech and PADT.

If you are not able to make the conference or if you want to know more now, you can view more information from the new Flownex SMR brochure or this video:

Why is Flownex a Great Tool for SMR Design and Simulation?

These developments offer greatly reduced times for performing typical design tasks required for Small Modular Nuclear Reactor (SMR) projects including sizing of major components, calculating overall plant efficiency, and design for controllability

This task involves typical components like the reactor primary loop, intermediate loops, heat exchangers or steam generators and the power generation cycle. Flownex provides for various reactor fuel geometries, various reactor coolant types and various types of power cycles.

Flownex can also be used for determining plant control philosophy. By using a plant simulation model, users can determine the transient response of sensed parameters to changes in input parameters and based on that, set up appropriate pairings for control loops.

For passive safety system design Flownex can be used to optimize the natural circulation loops.  The program can calculate the dynamic plant-wide temperatures and pressures in response to various accident scenarios, taking into account decay heat generation, multiple natural circulation loops, transient energy storage and rejection to ambient conditions.

flownex-smr-model-1

Learn more at www.padtinc.com/flownex, give us a call at 480.813.4884 or email brian.duncan@padtinc.com.

 

New Tricks for an Old Dog: Eric Learns ANSYS SpaceClaim – Post 3

Adding Complexity and Moving

ANSYS-SpaceClaim-Learning-00-00
This post is the third in a series on learning ANSYS SpaceClaim. After over 31 years of CAD use, it has become difficult for me to learn new tools. In this series I will share my experience as I explore and learn how to use this fantastic tool.
If you have not read the previous post, start here.  A table of contents is here.

After playing with that block it seems like it may be time to try a more complex geometry.  For business banking, I’ve got this key fob that generates a number every thirty seconds that I use for security when I log in.  Might as well sort of model that.

keyfob

So the first thing I do is start up a new model and orient myself on to the sketch plane:

ANSYS-SpaceClaim-Learning-03-01

Then I use the line and arc tools to create the basic shape. Play around a bit. I found that a lot of things I had to constrain in other packages are just assumed when you define the geometry.  A nice thing is that as you create geometry, it locks to the grid and to other geometry. ANSYS-SpaceClaim-Learning-03-02

I dragged around and typed in values for dimensions to get the shape I wanted. As I was doing it I realized I was in metric. I’m old, I don’t do metric. So I went in to File and selected SpaceClaim options from the bottom of the window.  I used the Units screen to set things to Imperial.

ANSYS-SpaceClaim-Learning-03-03

This is the shape I ended up with:

ANSYS-SpaceClaim-Learning-03-04

I took this and pulled it up and added a couple of radii:

ANSYS-SpaceClaim-Learning-03-05

But if I look at the real object, the flat end needs to be round.  In another tool, I’d go back to the sketch, modify that line to be an arc, and regen.  Well in SpaceClaim you don’t have the sketch, it is gone.    Ahhh. Panic. I’ve been doing it that way for 25 some years.  OK. Deep breath, just sketch the geometry I need. Click on the three point arc tool, drag over the surface, then click on the first corner, the second, and a third point to define the arc:

ANSYS-SpaceClaim-Learning-03-06

Then us pull to drag it down, using the Up to icon to lock it to the bottom of the object.

ANSYS-SpaceClaim-Learning-03-07

Then I clicked on the edges and pulled some rounds on there:

ANSYS-SpaceClaim-Learning-03-08

OK, so the next step in SolidEdge would be to do a thin wall.  I don’t see a thin wall right off the top, but shell looks like what I want, under the Create group on the Design tab.  So I spinned my model around, clicked on the bottom surface I want to have open and I have a shell.  A thickness of 0.035″ looks good:

ANSYS-SpaceClaim-Learning-03-09

My next feature will be the cutout for the view window.   What I have not figured out yet is how to lock an object to be symmetrical. Here is why. I sketch my cutout as such, not really paying attention to where it is located.  Now I want to move it so that it is centred on the circle.

ANSYS-SpaceClaim-Learning-03-10

Instead of specifying constraints, you move the rectangle to be centered.  To do that I drag to select the rectangle then click Move. By default it puts the nice Move tool in the middle of the geometry.  If I drag on the X direction (Red) you can see it shows the distance from my start.

ANSYS-SpaceClaim-Learning-03-11

So I have a couple of options, to center it. The easiest is to use Up To and click the X axis for the model and it will snap right there.  The key thing I learned was I had to select the red move arrow or it would also center horizontally where I clicked.

If I want to specify how far away the edge is from the center of the circle, the way I did it is kind of cool.  I selected my rectangle, then clicked move. Then I clicked on the yellow move ball followed by a click on the left line, this snapped the move tool to that line. Next I clicked the little dimension Icon to get a ruller, and a small yellow ball showed up. I clicked on this and dragged it to the center of my circle, now I had a dimension from the circle specified that I could type in.ANSYS-SpaceClaim-Learning-03-13

After playing around a bit, if found a second, maybe more general way to do this.  I clicked on the line I want to position.  One of the icons over on the left of my screen is the Move Dimension Base Point icon. If you click on that you get another one of those small yellow balls you can move. I dragged it over to the center of the circle and clicked. then I can specify the distance as 0.75″

ANSYS-SpaceClaim-Learning-03-14

I’ve got the shape I want, so I pull, using the minus icon to subtract, and I get my cutout:

ANSYS-SpaceClaim-Learning-03-15

If you look closely,you will notice I put rounds on the corners of the cutout as well, I used Pull again.

The last thing I want to do is create the cutout for where the bank logo goes. It is a concentric circle with an arc on the right side.  Saddly, this is the most complex thing I’ve ever sketched in SpaceClaim so I was a bit afraid. It was actually easy.  I made a circle, clicking on the center of the outside arc to make them concentric. The diameter was 1″. Then I made another circle of 2″ centered on the right.  To get the shape I wanted, I used the Trim Away command and clicked on the curves I don’t want. The final image is my cutout.

ANSYS-SpaceClaim-Learning-03-16

Now I can do the same thing, subtract it out, put in some rounds, and whalla:

untitled.3

Oh, and I used the built in rendering tool to quickly make this image. I’ll have to dedicate a whole posting to that.

But now that I have my part, it is time to play with move in 3D.

Moving in 3D

Tyler, who is one of our in-house SpaceClaim experts (and younger) pointed out that I need to start thinking about editing the 3D geometry instead of being obsessed with controlling my sketches. So here goes.

If I wanted to change the size of the rectangular cutout in a traditional CAD tool, I’d go edit the sketch. There is no sketch to edit! Fear. Unknown. Change.

So the first thing I’ll do is just move it around. Grab one of the faces and see happens.

ANSYS-SpaceClaim-Learning-03-17

It moves back and forth, pretty simple.  The same tools for specifying the start and stop points are available. Now, if I ctrl-click on all four surfaces the whole thing moves. That is pretty cool.

ANSYS-SpaceClaim-Learning-03-18

Note: I’m using the undo all the time to go back to my un-moved geometry.

Another Note:  As you select faces, you have to spin the model around a lot. I use the middle mouse button to do this rather than clicking on the spin Icon and then having to unclick it.

Play with it some more. I was able to put draft by using the arcs on the Move gizmo, and if you pull far enough it adds material.ANSYS-SpaceClaim-Learning-03-19

That is enough for this post. More soon.

 

 

 

New Tricks for an Old Dog: Eric Learns ANSYS SpaceClaim – Post 2

Learning More About Pulling

ANSYS-SpaceClaim-Learning-00-00
This post is the second in a series on learning ANSYS SpaceClaim. After over 31 years of CAD use, it has become difficult for me to learn new tools. In this series I will share my experience as I explore and learn how to use this fantastic tool.
If you have not read the previous post, start here.  A table of contents is here.

As I explored ANSYS SpaceClaim in my first try, it became obvious that a lot of capabilities that are in multiple operations in most CAD systems, are all combined in Pull for SpaceClaim.  In this posting I feel like it would be a really good idea for me to really understand all the things Pull can do.

Start with the Manual

Not very exciting or adventurous. But there is so much in this operation that I feel like I will miss something critical if I don’t read up first.   It states:

“Use the Pull tool to offset, extrude, revolve, sweep, and draft faces; use it to round, chamfer, extrude, copy, or pivot edges. You can also drag a point with the Pull tool to draw a line on a sketch plane.”

Let’s think about that for a second.  What it is basically saying is if I pull on an object of a given dimension, it creates an object that is one higher dimension. Point pulls to a curve, a curve pulls to a face, and a face pulls to a solid. Kind of cool. The big surprise for me is that there is no round or fillet command. To make a round you pull on an edge. This is change.

Pull some Stuff

I started by reading my block with a hole back in.

ANSYS-SpaceClaim-Learning-02-01

This fillet pull thing scares me so I thought I’d confront it first. So selecte Pull, and selected an edge:

ANSYS-SpaceClaim-Learning-02-02

Then I dragged it away from the block. Nothing. You can’t create a surface that way. Then I dragged in towards the center. A round was created.

ANSYS-SpaceClaim-Learning-02-03

If anything, too simple. Back in my day, adding a round to an edge took skill and experience!

So next I think I want to try and change the size of something. Maybe the diameter of the hole. So I select the cylinder’s face. Is shows the current radius. I could just change that value:

ANSYS-SpaceClaim-Learning-02-04

Instead I drag, and while I do that I noticed that there are two numbers, the current radius and the change to the radius!  Kind of cool. No, really useful.

ANSYS-SpaceClaim-Learning-02-05

You use tab to go between them. So I hit tab once, typed 3 then tab again (or return) and I get a 8 mm diameter.  I like the visual feedback as well as the ability to enter a specific change number.

Next thing that I felt like doing was rounding a corner. Put a 5mm round on the corner facing out:

ANSYS-SpaceClaim-Learning-02-07

So I grabbed the point and dragged, and got a line.

ANSYS-SpaceClaim-Learning-02-07a

 

Remember, it only goes up one entity type – point to curve. Not point to surface. So I ctrl-clicked (that is how you select multiple entities) on the three curves that intersect at the corner:

ANSYS-SpaceClaim-Learning-02-08

Then I dragged and got my round.

ANSYS-SpaceClaim-Learning-02-09

Pulling Along or Around Something

This are all sort of dragging straight. After looking at the manual text it seems I can revolve and sweep as well with the Pull operation.  Cool. But what do I revolve or sweep around and along?  Looking at the manual (and it turns out the prompt on the screen) I use Alt-Clicking to define these control curves.  Let’s try it out by revolving something about that line I mistakenly made.

I click on one of the curves on the round. then Alt-Click the line – It turns blue. So there is a nice visual clue that it is different than the source curve.  Now I’ve also got spinny icons around the curve rather than pull icons.

ANSYS-SpaceClaim-Learning-02-10

So I drag and… funky revolved surface shows up. I had to spin the model to see it clearly:

ANSYS-SpaceClaim-Learning-02-11

Let me stop and share something special about this. In most other CAD tools, this would have involved multiple clicks, maybe even multiple windows. In SpaceClaim, it was Click, Alt-Click, Drag.  Nice.

Using the Pop=up Icons

As you play with the model you may start seeing some popup icons near the mouse when you select geometry while using pull. The compound round on the block is complicated, so I spun it around and grabbed just one edge and pulled it in to be a round.  Then I clicked on it and got this:

ANSYS-SpaceClaim-Learning-02-12

Not only can I put a value in there, I can drop ones I use a lot. I can also change my round to a chamfer, or I can change it to a variable radius. This is worth noting. In most other CAD tools you pick what type of thing you want to do to the edge. Here we start by dragging a round, then specify if it is a chamfer or a variable.

The variable radius is worth digging more in to.  I clicked on it and it was not intuitive as to what I should do. Let’s try help. Search on Variable Radius… duh. Click on the arrow that shows up and drag that. There are three arrows. The one in the middle scales both ends the same, the one on either end, well it sets the radius for either end.

ANSYS-SpaceClaim-Learning-02-13Reading more I see if I hold down the CTRL key and click on the arrow, I can drag a new control point along the edge. I can type in a percentage as well.  Very useful.

ANSYS-SpaceClaim-Learning-02-14

Clicking on a control point and hitting delete, gets rid of them.

That’s just one icon that pops up.  Playing some more it seems the other icons control how it handles corners and multiple fillets merging… something to look at as I do more complex parts.

The other popup I want to look at is the Up To one.  It looks like an arrow on a surface.  In other tools I extrude, cut, revolve all the time to some other piece of geometry.  This is the way to do it in Space Claim.  Let’s say I want to pull a feature to the middle of my hole. First I sketch the outline on a face:ANSYS-SpaceClaim-Learning-02-15

Then I select the outline, and get a popup. First thing I want to do is click on the + sign, because I want to add, not cut, then I click on the Up To and then select the axis of the hole:  ANSYS-SpaceClaim-Learning-02-16

That is enough for pulling and for today.  In the next session it may be time to explore the Move command.

 

 

 

 

 

 

 

 

 

New Tricks for an Old Dog: Eric Learns ANSYS SpaceClaim – Table of Contents

ANSYS-SpaceClaim-Learning-00-00This post is a table of contents to a series about ANSYS SpaceClaim. After over 31 years of CAD use, it has become difficult for me to learn new tools. In this series I will share my experience as I explore and learn how to use this fantastic tool.

  1. Introduction, Getting Started, The Interface, A Block with a Hole in It
  2. Learning More About Pulling
  3. Adding Complexity and Moving

Phoenix Business Journal: 5 reasons why nerds celebrate Pi Day

pbj-phoenix-business-journal-logo

Have you heard? It’s Pi Day! This post, “5 reasons why nerds celebrate Pi Day” shares the reasons why those of us in the know like Pi day so much.
pie-pi

New Tricks for an Old Dog: Eric Learns ANSYS SpaceClaim – Post 1

ANSYS-SpaceClaim-Learning-00-00Thirty-one.  That is the number of years that I have been using CAD software. CADAM was the tool, 1985 was the year.  As some of our engineers like to point out, they were not even born then.

Twenty-one. that is the number of years that I have been using SolidEdge.  This classifies me as an old dog, a very old dog. As PADT has grown the amount of CAD I do has gone way down, but every once in a while I need to get in there and make some geometry happen. I’m usually in a hurry so I just pop in to SolidEdge and without really thinking, I get things done.

Then ANSYS, Inc. had to go and buy SpaceClaim. It rocks.  It is not just another solid modeler, it is a better way to create, repair, and modify CAD.  I watch our engineers and customers do some amazing things with it. I’m still faster in SolidEdge because I have more years of practice than they have been adults. But this voice in my head has been whispering “think how fast you would be in SpaceClaim if you took the time to learn it.” Then that other voice (I have several) would say “you’re too old to learn something new, stick with what you know. You might break your hip”

I had used SpaceClaim a bit when they created a version that worked with ANSYS Mechanical four or five years ago, but nothing serious.  Last month I attended some webinars on R17 and saw how great the tool is, and had to accept that it was time.  That other voice be damned – this old dog needs to get comfortable and learn this tool.  And while I’m at it, it seemed like a good idea to bring some others along with me.

These posts will be a tutorial for others who want to learn SpaceClaim.  Unlike those older tools, it does not require five days of structured training with workshops.  The program comes with teaching material and tutorials.  The goal is to guide the reader through the process, pointing out things I learned along the way, as I learn them.

A link to the table of contents is here.

Getting Started

The product I’m learning is ANSYS SpaceClaim Direct Modeler, a version of SpaceClaim that is built into the ANSYS simulation product suite. There is a stand alone SpaceClaim product but since most of our readers are ANSYS users, I’m going to stick with this version of the tool.

This is what you see when you start it up:

ANSYS-SpaceClaim-Learning-01-01

I’ve been using the same basic layout for 20 years, so this is a bit daunting for me. I like to start on a new program by getting to know what different areas of the user interface do. The “Welcome to ANSYS SCDM” kind of anticipates that and gives me some options.

Under “Getting Started” you will see a Quick Reference Card, Introduction, and Tutorials. Open up the Quick Reference and print it out. Don’t bother with it right now, but it will come in handy, especially if you are not going to use SpaceClaim every day.

The Introduction button is a video that gets you oriented with the GUI. Just what we need. It is a lot of information presented fast, so you are not going to learn everything the first viewing, but it will get you familiar with things.

File Mar 11, 3 53 54 PM

Here I am watching the video.  Notice how attentive I am.

Once that is done you should sort of know the basic lay of the land. Kind of like walking into a room and looking around. You know where the couch is, the window, and the shelf on one wall.  Now it is time to explore the room.

It is kind of old school, but I like user guides.  You can open the SpaceClaim User Guide from the Help line in the “Welcome” window.  I leave it open and use it as a reference.

The Interface

The best place to learn where things are in the interface is to look at the interface section in the manual. It has this great graphic:

ANSYS-SpaceClaim-Learning-01-03

The top bit is pretty standard, MS office like. You have your application menu, quick access toolbar, and Ribbon Bar.  The Ribbon Bar is where all the operations sit.  We used to call these commands but in an object oriented world, they are more properly referred to as operations – do something to objects, operate on them.  I’ll come back and explore those later. Over on the left there are panels, the thing we need to explore first because they are a view into our model just like the graphics window.

ANSYS-SpaceClaim-Learning-01-04

The Structure Panel is key.  This is where your model is shown in tree form, just like in most ANSYS products.  In SpaceClaim your model is collection of objects, and they are shown in the tree in the order you added them. You can turn visibility on and off, select objects, and act on objects (using the right mouse button) using the tree. At this point I just had one solid, so pretty boring.  I’m sure it will do more later.

Take a look at the bottom of the Structure Panel and you will find some tabs. These give access to Layers, Selection, Groups, and Views.  All handy ways to organize and interact with your model.  I felt like I needed to come back to these later when I had something to interact with.

TIP: If you are like me, you probably tried to drag these panels around and hosed up your interface. Go to File > SpaceClaim Options (button at the bottom) > Appearance and click the “Reset Docking Layout” button in the upper right of the window.  Back to normal. 

The options panel changes dynamically as you choose things from the ribbon. If you click on the Design > Line you get this:

ANSYS-SpaceClaim-Learning-01-05

And if you click on Pull you get this:

ANSYS-SpaceClaim-Learning-01-06

Keeps the clutter down and makes the commands much more capable.

Below that is the Properties Panel.  If the Options panel is how you control an operation, then the Properties panel is how you view and control an object in your model.  No point in exploring that till we have objects to play with.  It does have an appearance tab as well, and this controls your graphics window.

At the bottom is the Status Bar. Now I’m a big believer in status bars, and SpaceClaim uses theirs well.  It tells you what is going on and/or what to do next.  It also has info on what you have selected and short cut icons for selection and graphics tools. Force yourself to read and use the status bar, big time saver.

The last area of the interface is the graphics window. It of course shows you your geometry, your model.  In addition there are floating tools that show up in the graphics window based upon what you are doing.  Grrr. #olddogproblem_1.  I’m not a fan of these, cluttering up my graphics. But almost all modern interfaces work this way now and I will have to overcome my anger and learn to deal.

Make Something

For most of the 30+ years that I’ve been doing this CAD thing, I’ve always started with the same object: A block with a hole in it.  So that is what we will do next.  I have to admit I’m a little nervous.

I’m nervous because I’m a history based guy.  If you have used most CAD tools like SolidWorks or ANSYS DesignModeler you know what history based modeling is like. You make a sketch then you add or subtract material and it keeps track of your operations. SpaceClaim is not history based. You operate on objects and it doesn’t track the steps, it just modifies your objects.  SolidEdge has done this for over ten years, but I never got up the nerve to learn how to use it.  So here goes, new territory.

Things start the same way. But instead of a sketch you make some curves.  The screen looks like this when you start:

ANSYS-SpaceClaim-Learning-01-07

The default plane is good enough, so I’ll make my curves on that. Under Design>Sketch click on the Rectangle icon then move your mouse on to the grid. You will notice it snaps to the grid. Click in the Upper Left and the Lower Right to make a rectangle then enter 25mm in to each text box, making a 25 x 25 square:

ANSYS-SpaceClaim-Learning-01-08

Next we want to make our block.  In most tools you would find an extrude operation. But in SpaceClaim they have combined the huge multitude of operations into a few operation types, and then use context or options to give you the functionality you want. That is why the next thing we want to do is click on Pull on the Edit group.

But first, notice something important. If you look at the model tree you will notice that you have only one object in your design, Curves. When you click Pull it gets out of sketch mode and into 3D mode. It also automatically turns your curves into a surface. Look at the tree again.

ANSYS-SpaceClaim-Learning-01-09    ANSYS-SpaceClaim-Learning-01-10

This is typical of SpaceClaim and why it can be so efficient. It knows what you need to do and does it for you.

Move you mouse over your newly created surface and notice that it will show arrows. Move around and put it over a line, it shows what object will be selected if you click.  Go to the inside of your surface and click. It selects the surface and shows you some options right there.

ANSYS-SpaceClaim-Learning-01-11

Drag your mouse over the popup menu and you can see that you can set options like add material, subtract material, turn off merging (it will make a separate solid instead of combining with any existing ones), pull both directions, get a ruler, or specify that you are going to pull up to something.  For now, we are just going to take the default and pull up.

As you do this the program tells you how far you are pulling. You can type in a value if you want.  I decided to be boring and I put in 25 mm.  Geometry has been created, no one has been hurt, and I have not lost feeling in any limbs. Yay.

ANSYS-SpaceClaim-Learning-01-12

On the status bar, click on the little menu next to the magnifying glass and choose Zoom Extents.  That centers the block. Whew. That makes me feel better.

Now for the hole. It is the same process except simpler than in most tools.  Click on the circle tool in Sketch. The grid comes back and you can use that to sketch, or you can just click on the top of the block. Let’s do that. The grid snaps up there.  To make the circle click in the middle of the grid and drag it out.  Put 10 in for the diameter. A circle is born.

Take a look at your tree. You have a solid and a set of curves.  ANSYS-SpaceClaim-Learning-01-13

Now choose Pull from the Edit section. There is only a Solid now?

ANSYS-SpaceClaim-Learning-01-14

SpaceClaim went ahead and split that top surface into two surfaces. Saving a step again.

Click on the circle surface and drag it up and down. If you go up, it adds a cylinder, if you go down, it automatically subtracts.  Go ahead and pull it down and through the block and let go. Done.  Standard first part created. Use the File>Save command to save your awesome geometry.

ANSYS-SpaceClaim-Learning-01-15

That is it for the getting started part.  In the next post we will use this geometry to explore SpaceClaim more, now that we have an object to work on.  As you were building this you probably saw lots of options and input and maybe even played with some of it. This is just a first look at the power inside SpaceClaim.

Click here for Post 2 where the Pull command is explored.

Reading ANSYS Mechanical Result Files (.RST) from C/C++ (Part 3)

ansys-fortran-to-c-cpp-1-00In the last post of this series I illustrated how I handled the nested call structure of the procedural interface to ANSYS’ BinLib routines.  If you recall, any time you need to extract some information from an ANSYS result file, you have to bracket the function call that extracts the information with a *Begin and *End set of function calls.  These two functions setup and tear down internal structures needed by the FORTRAN library.  I showed how I used RAII principles in C++ along with a stack data structure to manage this pairing implicitly.  However, I have yet to actually read anything truly useful off of the result file!  This post centers on the design of a set of C++ iterators that are responsible for actually reading data off of the file.  By taking the time to write iterators, we expose the ANSYS RST library to many of the algorithms available within the standard template library (STL), and we also make our own job of writing custom algorithms that consume result file data much easier.  So, I think the investment is worthwhile.

If you’ve programmed in C++ within the last 10 years, you’ve undoubtedly been exposed to the standard template library.  The design of the library is really rather profound.  This image represents the high level design of the library in a pictorial fashion:

ansys-fortran-to-c-cpp-3-01

On one hand, the library provides a set of generic container objects that provide a robust implementation of many of the classic data structures available within the field of computer science.  The collection of containers includes things like arbitrarily sized contiguous arrays (vectors), linked lists, associative arrays, which are implemented as either binary trees or as a hash container, as well as many more.  The set of containers alone make the STL quite valuable for most programmers.

On the other hand, the library provides a set of generic algorithms that encompass a whole suite of functionality defined in classic computer science.  Sorting, searching, rearranging, merging, etc… are just a handful of the algorithms provided by the library.  Furthermore, extreme care has been taken within the implementation of these algorithms such that an average programmer would hard pressed to produce something safer and more efficient on their own.

However, the real gem of the standard library are iterators.  Iterators bridge the gap between generic containers on one side and the generic algorithms on the other side.  Need to sort a vector of integers, or a double ended queue of strings?  If so, you just call the same sort function and pass it a set of iterators.  These iterators “know” how to traverse their parent container.  (Remember containers are the data structures.)

So, what if we could write a series of iterators to access data from within an ANSYS result file?  What would that buy us?  Well, depending upon which concepts our iterators model, having them available would open up access to at least some of the STL suite of algorithms.  That’s good.  Furthermore, having iterators defined would open up the possibility of providing range objects.  If we can provide range objects, then all of the sudden range based for loops are possible.  These types of loops are more than just syntactic sugar.  By encapsulating the bounds of iteration within a range, and by using iterators in general to perform the iteration, the burden of a correct implementation is placed on the iterators themselves.  If you spend the time to get the iterator implementation correct, then any loop you write after that using either the iterators or better yet the range object will implicitly be correct from a loop construct standpoint.  Range based for loops also make your code cleaner and easier to reason about locally.

Now for the downside…  Iterators are kind of hard to write.  The price for the flexibility they offer is paid for in the amount of code it takes to write them.  Again, though, the idea is that you (or, better yet somebody else) writes these iterators once and then you have them available to use from that point forward.

Because of their flexibility, standard conformant iterators come in a number of different flavors.  In fact, they are very much like an ice cream Sunday where you can pick and choose what features to mix in or add on top.  This is great, but again it makes implementing them a bit of a chore.  Here are some of the design decisions you have to answer when implementing an iterator:

Decision Options Choice for RST Reader Iterators
Dereference Data Type Anything you want Special structs for each type of iterator.
Iteration Category 1.       Forward iterator
2.       Single pass iterator
3.       Bidirectional iterator
4.       Random access iterator
Forward, Single Pass

Iterators syntactically function much like pointers in C or C++.  That is, like a pointer you can increment an iterator with the ++ operator, you can dereference an iterator with the * operator and you can compare two iterators for equality.  We will talk more about incrementing and comparisons in a minute, but first let’s focus on dereferencing.  One thing we have to decide is what type of data the client of our iterator will receive when they dereference it.  My choice is to return a simple C++ structure with data members for each piece of data.  For example, when we are iterating over the nodal geometry, the RST file contains the node number, the nodal coordinates and the nodal rotations.  To represent this data, I create a structure like this:ansys-fortran-to-c-cpp-3-02

I think this is pretty self-explanatory.  Likewise, if we are iterating over the element geometry section of an RST file, there is quite a bit of useful information for each element.  The structure I use in that case looks like this:

ansys-fortran-to-c-cpp-3-03

 

Again, pretty self-explanatory.  So, when I’m building a node geometry iterator, I’m going to choose the NodalCoordinateData structure as my dereference type.

The next decision I have to make is what “kind” of iterator I’m going to create.  That is, what types of “iteration” will it support?  The C++ standard supports a variety of iterator categories.  You may be wondering why anyone would ever care about an “iteration category”?  Well, the reason is fundamental to the design of the STL.   Remember that the primary reason iterators exist is to provide a bridge between generic containers and generic algorithms.  However, any one particular algorithm may impose certain requirements on the underlying iterator for the algorithm to function appropriately.

Take the algorithm “sort” for example.  There are, in fact, lots of different “sort” algorithms.  The most efficient versions of the “sort” algorithm require that an iterator be able to jump around randomly in constant time within the container.  If the iterator supports jumping around (a.k.a. random access) then you can use it within the most efficient sort algorithm.   However, there are certain kinds of iterators that don’t support jumping around.  Take a linked list container as an example.  You cannot randomly jump around in a linked list in constant time.  To get to item B from item A you have to follow the links, which means you have to jump from link to link to link, where each jump takes some amount of processing time.  This means, for example, there is no easy way to cut a linked list exactly in half even if you know how many items in total are in the list.  To cut it in half you have to start at the beginning and follow the links until you’ve followed size/2 number of links.  At that point you are at the “center” of the list.  However, with an array, you simply choose an index equal to size/2 and you automatically get to the center of the array in one step.  Many sort algorithms, as an example, obtain their efficiency by effectively chopping the container into two equal pieces and recursively sorting the two pieces.  You lose all that efficiency if you have to walk out to the center.

If you look at the “types” of iterators in the table above you will see that they build upon one another.  That is, at the lowest level, I have to answer the question, can I just move forward one step?  If I can’t even do that, then I’m not an iterator at all.  After that, assuming I can move forward one step, can I only go through the range once, or can I go over the range multiple times?  If I can only go over the range once, I’m a single pass iterator.  Truthfully, the forward iterator concept and the single pass iterator concept form level 1A and 1B of the iterator hierarchy.  The next higher level of functionality is a bidirectional iterator.  This type of iterator can go forward and backwards one step in constant time.  Think of a doubly linked list.  With forward and backward links, I can go either direction one step in constant time.  Finally, the most flexible iterator is the random access iterator.  These are iterators that really are like raw pointers.  With a pointer you can perform pointer arithmetic such that you can add an arbitrary offset to a base pointer and end up at some random location in a range.  It’s up to you to make sure that you stay within bounds.  Certain classes of iterators provide this level of functionality, namely those associated with vectors and deques.

So, the question is what type of iterator should we support?  Perusing through the FORTRAN code shipped with ANSYS, there doesn’t appear to be an inherent limitation within the functions themselves that would preclude random access.  But, my assumption is that the routines were designed to access the data sequentially.  (At least, if I were the author of the functions that is what I would expect clients to do.)  So, I don’t know how well they would be tested regarding jumping around.  Furthermore, disk controllers and disk subsystems are most likely going to buffer the data as it is read, and they very likely perform best if the data access is sequential.  So, even if it is possible to randomly jump around on the result file, I’m not sold on it being a good idea from a performance standpoint.  Lastly, I explicitly want to keep all of the data on the disk, and not buffer large chunks of it into RAM within my library.  So, I settled on expressing my iterators as single pass, forward iterators.  These are fairly restrictive in nature, but I think they will serve the purpose of reading data off of the file quite nicely.

Regarding my choice to not buffer the data, let me pause for a minute and explain why I want to keep the data on the disk. First, in order to buffer the data from disk into RAM you have to read the data off of the disk one time to fill the buffer.  So, that process automatically incurs one disk read.  Therefore, if you only ever need to iterate over the data once, perhaps to load it into a more specialized data structure, buffering it first into an intermediate RAM storage will actually slow you down, and consume more RAM.  The reason for this is that you would first iterate over the data stored on the disk and read it into an intermediate buffer.  Then, you would let your client know the data is ready and they would iterate over your internal buffer to access the data.  They might as well just read the data off the disk themselves! If the end user really wants to buffer the data, that’s totally fine.  They can choose to do that themselves, but they shouldn’t have to pay for it if they don’t need it.

Finally, we are ready to implement the iterators themselves.  To do this I rely on a very high quality open source library called Boost.  Boost has within it a library called iterator_facade that takes care of supplying most all of the boilerplate code needed to create a conformant iterator.  Using it has proven to be a real time saver.  To define the actual iterator, you derive your iterator class from iterator_facade and pass it a few template parameters.  One is the category defining the type of iterator you are creating.  Here is the definition for the nodal geometry iterator:

ansys-fortran-to-c-cpp-3-04

You can see that there are a few private functions here that actually do all of the work.  The function “increment” is responsible for moving the iterator forward one spot.  The function “equal” is responsible for determining if two different iterators are in fact equal.  And the function “dereference” is used to return the data associated with the current iteration spot.  You will also notice that I locally buffer the single piece of data associated with the current location in the iteration space inside the iterator.  This is stored in the pData member function.  I also locally store the current index.   Here are the implementations of the functions just mentioned:

ansys-fortran-to-c-cpp-3-05

First you can see that testing iterator equality is easy.  All we do is just look to see if the two iterators are pointing to the same index.  If they are, we define them as equal. (Note, an important nuance of this is that we don’t test to see if their buffered data is equal, just their index.  This is important later on.)  Likewise, increment is easy to understand as well.  We just increase the index by one, and then buffer the new data off of disk into our local storage.  Finally, dereference is easy too.  All we do here is just return a reference to the local data store that holds this one node’s data.  The only real work occurs in the readData() function.  Inside that function you will see the actual call to the CResRdNode() function.  We pass that function our current index and it populates an array of 6 doubles with data and returns the actual node number.  After we have that, we simply parse out of that array of 6 doubles the coordinates and rotations, storing them in our local storage.  That’s all there is to it.  A little more work, but not bad.

With these handful of operations, the boost iterator_facade class can actually build up a fully conformant iterator will all the proper operator overloads, etc… It just works.  Now that we have iterators, we need to provide a “begin” and “end” function just like the standard containers do.  These functions should return iterators that point to the beginning of our data set and to one past the end of our data set.  You may be thinking to yourself, wait a minute, how to we provide an “end” iterator without reading the whole set of nodes?  The reality is, we just need to provide an iterator that “equality tests” to be equal to the end of our iteration space?  What does that mean?  Well, what it means is that we just need to provide an iterator that, when compared to another iterator which has walked all the way to the end, it passes the “equal” test.  Look at the “equal” function above.  What do two iterators need to have in common to be considered equal?  They need to have the same index.  So, the “end” iterator simply has an index equal to one past the end of the iteration space.  We know how big our iteration space is because that is one of the pieces of metadata supplied by those ResRd*Begin functions.  So, here are our begin/end functions to give us a pair of conformant iterators.

ansys-fortran-to-c-cpp-3-06

Notice, that the nodes_end() function creates a NodeIterator and passes it an index that is one past the maximum number of nodes that have coordinate data stored on file.  You will also notice, that it does not have a second Boolean argument associated with it.  I use that second argument to determine if I should immediately read data off of the disk when the iterator is constructed.  For the begin iterator, I need to do that.  For the end iterator, I don’t actually need to cache any data.  In fact, no data for that node is defined on disk.  I just need a sentinel iterator that is one past the iteration space.

So, there you have it.  Iterators are defined that implicitly walk over the rst file pulling data off as needed and locally buffering one piece of it.  These iterators are standard conformant and thus can be used with any STL algorithm that accepts a single pass, read only, forward iterator.  They are efficient in time and storage.  There is, though, one last thing that would be nice.  That is to provide a range object so that we can have our cake and eat it too.  That is, so we can write these C++11 range based for loops.  Like this:ansys-fortran-to-c-cpp-3-07

To do that we need a bit of template magic.  Consider this template and type definition:

ansys-fortran-to-c-cpp-3-08

There is a bit of machinery that is going on here, but the concept is simple.  I just want the compiler to stamp out a new type that has a “begin()” and “end()” member function that actually call my “nodes_begin()” and “nodes_end()” functions.  That is what this template will do.  I can also create a type that will call my “elements_begin()” and “elements_end()” function.  Once I have those types, creating range objects suitable for C++11 range based for loops is a snap.  You just make a function like this:

ansys-fortran-to-c-cpp-3-09

 

This function creates one of these special range types and passes in a pointer to our RST reader.  When the compiler then sees this code:

ansys-fortran-to-c-cpp-3-10

It sees a range object as the return type of the “nodes()” function.  That range object is compatible with the semantics of range based for loops, and therefore the compiler happily generates code for this construction.

Now, after all of this work, the client of the RST reader library can open a result file, select something of interest, and start looping over the items in that category; all in three lines of code.  There is no need to understand the nuances of the binlib functions.  But best of all, there is no appreciable performance hit for this abstraction.  At the end of the day, we’re not computationally doing anything more than what a raw use of the binlib functions would perform.  But, we’re adding a great deal of type safety, and, in my opinion, readability to the code.  But, then again, I’m only slightly partial to C++.  Your mileage may vary…

Reading ANSYS Mechanical Result Files (.RST) from C/C++ (Part 2)

ansys-fortran-to-c-cpp-1-00In the last post in this series I illustrated how you can interface C code with FORTRAN code so that it is possible to use the ANSYS, Inc. BinLib routines to read data off of an ANSYS result file within a C or C++ program.  If you recall, the routines in BinLib are written in FORTRAN, and my solution was to use the interoperability features of the Intel FORTRAN compiler to create a shim library that sits between my C++ code and the BinLib code. In essence, I replicated all of the functions in the original BinLib library, but gave them a C interface. I call this library CBinLib.

You may remember from the last post that I wanted to add a more C++ friendly interface on top of the CBinLib functions.  In particular, I showed this piece of code, and alluded to an explanation of how I made this happen.  This post covers the first half of what it takes to make the code below possible.

ansys-fortran-to-c-cpp-2-01

What you see in the code above is the use of C++11 range based “for loops” to iterate over the nodes and elements stored on the result file.  To accomplish this we need to create conformant STL style iterators and ranges that iterate over some space.  I’ll describe the creation of those in a subsequent post.  In this post, however, we have to tackle a different problem.  The solution to the problem is hidden behind the “select” function call shown in the code above.  In order to provide some context for the problem, let me first show you the calling sequence for the procedural interface to BinLib.  This is how you would use BinLib if you were programming in FORTRAN or if you were directly using the CBinLib library described in the previous post.  Here is the recommended calling sequence:

ansys-fortran-to-c-cpp-2-02

You can see the design pattern clearly in this skeleton code.  You start by calling ResRdBegin, which gives you a bunch of useful data about the contents of the file in general.  Then, if you want to read geometric data, you need to call ResRdGeomBegin, which gives you a little more useful metadata.  After that, if you want to read the nodal coordinate data you call ResRdNodeBegin followed by a loop over nodes calling ResRdNode, which gives you the actual data about individual nodes, and then finally call ResRdNodeEnd.  If at that point you are done with reading geometric data, you then call ResRdGeomEnd.  And, if you are done with the file you call ResRdEnd.

Now, one thing jumps off the page immediately.  It looks like it is important to pair up the *Begin and*End calls.  In fact, if you peruse the ResRd.F FORTRAN file included with the ANSYS distribution you will see that in many of the *End functions, they release resources that were allocated and setup in the corresponding *Begin function.

So, if you forget to call the appropriate *End, you might leak resources.  And, if you forget to call the appropriate *Begin, things might not be setup properly for you to iterate.  Therefore, in either case, if you fail to call the right function, things are going to go badly for you.

This type of design pattern where you “construct” some scaffolding, do some work, and then “destruct” the scaffolding is ripe for abstracting away in a C++ type.  In fact, one of the design principles of C++ known as RAII (Resource Acquisition Is Initialization) maps directly to this problem.  Imagine that we create a class in which in the constructor of the class we call the corresponding *Begin function.  Likewise, in the destructor of the class we call the corresponding *End function.  Now, as long as we create an instance of the class before we begin iterating, and then hang onto that instance until we are done iterating, we will properly match up the *Begin, *End calls.  All we have to do is create classes for each of these function pairs and then create an instance of that class before we start iterating.  As long as that instance is still alive until we are finished iterating, we are good.

Ok, so abstracting the *Begin and *End function pairs away into classes is nice, but how does that actually help us?  You would still have to create an instance of the class, hold onto it while you are iterating, and then destroy it when you are done.  That sounds like more work than just calling the *Begin, *End directly.  Well, at first glance it is, but let’s see if we can use the paradigm more intelligently.  For the rest of this article, I’ll refer to these types of classes as BeginEnd classes, though I call them something different in the code.

First, what we really want is to fire and forget with these classes.  That is, we want to eliminate the need to manually manage the lifetime of these BeginEnd classes.  If I don’t accomplish this, then I’ve failed to reduce the complexity of the *Begin and *End requirements.  So, what I would like to do is to create the appropriate BeginEnd class when I’m ready to extract a certain type of data off of the file, and then later on have it magically delete itself (and thus call the appropriate *End function) at the right time.  Now, one more complication.  You will notice that these *Begin and*End function pairs are nested.  That is, I need to call ResRdGeomBegin before I call ResRdNodeBegin.  So, not only do I want a solution that allows me to fire and forget, but I want a solution that manages this nesting.

Whenever you see nesting, you should think of a stack data structure.  To increase the nesting level, you push an item onto the stack.  To decrease the nesting level, you pop and item off of the stack.  So, we’re going to maintain a stack of these BeginEnd classes.  As an added benefit, when we introduce a container into the design space, we’ve introduced something that will control object lifetime for us.  So, this stack is going to serve two functions for us.  It’s going to ensure we call the *Begin’s and *End’s in the right nested order, and second, it’s going to maintain the BeginEnd object lifetimes for us implicitly.

To show some code, here is the prototype for my pure virtual class that serves as a base class for all of the BeginEnd classes.  (In my code, I call these classes FileSection classes)

ansys-fortran-to-c-cpp-2-03

You can see that it is an interface class by noting the pure virtual function getLevel.  You will also notice that this function returns a ResultFileSectionLevel.  This is just an enum over file section types.  I like to use an enum as opposed to relying on RTTI.  Now, for each BeginEnd pair, I create an appropriate derived class from this base ResultFileSection class.  Within the destructor of each of the derived classes I call the appropriate *End function.  Finally, here is my stack data structure definition:

ansys-fortran-to-c-cpp-2-03p5

 

You can see that it is just a std::stack holding objects of the type SectionPtrT.  A SectionPtrT is a std::unique_ptr for objects convertible to my base section class.  This will enable the stack to hold polymorphic data, and the std::unique_ptr will manage the lifetime of the objects appropriately.   That is, when we pop and object off of the stack, the std::unique_ptr will make sure to call delete, which will call the destructor.  The destructor calls the appropriate *End function as we’ve mentioned before.

At this point, we’ve reduced our problem to managing items on a stack.  We’re getting closer to making our lives easier, trust me!  Let’s look at a couple of different functions to show how we pull these pieces together.  The first function is called reduceToLevelOrBegin(level).  See the code below:ansys-fortran-to-c-cpp-2-04

The operation of this function is fairly straightforward, yet it serves an integral role in our BeginEnd management infrastructure.   What this function does is it iteratively pops items off of our section stack until it either reaches the specified level, or it reaches the topmost ResRdBegin level.  Again, through the magic of C++ polymorphism, when an item gets popped off of the stack, eventually its destructor is called and that in turn calls the appropriate *End function.  So, what this function accomplishes is it puts us at a known level in the nested section hierarchy and, while doing so, ensures that any necessary *End functions are called appropriately to free resources on the FORTRAN side of things.  Notice that all of that happens automatically because of the type system in C++.  By popping items off of the stack, I implicitly clean up after myself.

The second function to consider is one of a family of similar functions.  We will look at the function that prepares the result file reader to read element geometry data off of the file.  Here it is:

ansys-fortran-to-c-cpp-2-05

You will notice that we start by reducing the nested level to either the “Geometry” level or the “Begin” level.  Effectively what this does is unwind any nesting we have done previously.  This is the machinery that makes “fire and forget” possible.  That is, whenever in ages past that we requested something to be read off of the result file, we would have pushed onto the stack a series of objects to represent the level needed to read the data in question.  Now that we wish to read something else, we unwind any previously existing nested Begin calls before doing so.   That is, we clean up after ourselves only when we ask to read a different set of data.  By waiting until we ask to read some new set of data to unwind the stack, we implicitly allow the lifetime of our BeginEnd classes to live beyond iteration.

At this point we have the stack in a known state; either it is at the Begin level or the Geometry level.  So, we simply call the appropriate *Begin functions depending on what level we are at, and push the appropriate type of BeginEnd objects onto the stack to record our traversal for later cleanup.  At this point, we are ready to begin iterating.  I’ll describe the process of creating iterators in the next post.  Clearly, there are lots of different select*** functions within my class.  I have chosen to make all of them private and have a single select function that takes an enum descriptor of what to select and some additional information for specifying result data.

One last thing to note with this design.  Closing the result file is easy. All that is required is that we simply fully unwind the stack.  That will ensure all of the appropriate FORTRAN cleanup code is called in the right order.  Here is the close function:

ansys-fortran-to-c-cpp-2-06

As you can see, cleanup is handled automatically.  So, to summarize, we use a stack of polymorphic data to manage the BeginEnd function calls that are necessary in the FORTRAN interface.  By doing this we ensure a level of safety in our class design.  Also, this moves us one step closer to this code:

ansys-fortran-to-c-cpp-2-07

In the next post I will show how I created iterators and range objects to enable clean for loops like the ones shown above.

How To Install And Configure xRDP and Same Session xRDP on CentOS 6.7 / RHEL 6.7

Introduction

What s xRDP? Taking directly from the xRDP website.

“Xrdp is the main server accepting connections from RDP clients. Xrdp contains the RDP, security, MCS, ISO, and TCP layers, a simple window manager and a few controls. Its a multi threaded single process server. It is in this process were the central management of the sessions are maintained. Central management includes shadowing a session and administrating pop ups to users. Xrdp is control by the configuration file xrdp.ini.

RDP has 3 security levels between the RDP server and RDP client. Low, medium and high. Low is 40 bit, data from the client to server is encrypted, medium is 40 bit encryption both ways and high is 128 bit encryption both ways. Xrdp currently supports all 3 encryption levels via the xrdp.ini file. RSA key exchange is used with both client and server randoms to establish the RC4 keys before the client connect.

Modules are loaded at runtime to provide the real functionality. Many different modules can be created to present one of many different desktops to the user. The modules are loadable to conserve memory and support both GPL and non GPL modules.

Multi threaded to provide optimal user performance. One client can’t slow them all down. One multi threaded process is also required for session shadowing with any module. The module doesn’t have to consider shadowing, the xrdp server does it. For example, you could shadow a VNC, RDP or a custom module session all from the same shadowing tool.

Build in window manager for sending pop ups to any user running any module. Also can be user to provide connection errors or prompts.

libvnc

Libvnc, a VNC module for xrdp. Libvnc provides a connection to VNC servers. Its a simple client only supporting a few VNC encodings(raw, cursor, copyrect). Emphasis on being small and fast. Normally, the xrdp server and the Xvnc server are the same machine so bitmap compression encodings would only slow down the session.

librdp

Librdp, an RDP module for xrdp. Librdp provides a connection to RDP servers. It only supports RDP4 connections currently.

sesman

Sesman, the session manager. Sesman is xrdp’s session manager. Xrdp connect to sesman to verify the user name / password, and also starts the user session if credentials are ok. This is a multi process / Linux only session manager. Sessions can be started or viewed from the command line via sesrun.”

STEP 1 – Setup xRDP Same on your CUBE Linux Compute Server:

  1. Add the following repository for the needed extra packages for enterprise linux
    • rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
      I am using the platform CentOS release 6.7 – 64 Bit for this installation of xRDP
  2. Install xRDP
    • yum install xrdp tigervnc-server -y
  3. Start xRDP
    • service xrdp start
  4. Enter the following commands to ensure that the xRDP services restart on a reboot
    • chkconfig xrdp on
    • chkconfig vncserver on
  5. Add the ANSYS linux users into the following groups:
    • users & video
  6. Now try it out!

mstsc

STEP 2.0.0 (optional) – How To Setup xRDP Same Session Remote Desktop on your CUBE Linux Compute Server:

2.0.1) Login as root via SSH

2.0.2) cd /etc/xrdp/

2.0.3) Edit the xrdp.ini file as the root user. Open and edit the xrdp.ini file. For same session sharing, locate and modify the last line of the xrdp.ini configuration file.

  • Change from port=-1 to port=ask-1

vi /etc/X11/Xrdp.ini
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=high
channel_code=1
max_bpp=24
#black=000000
#grey=d6d3ce
#dark_grey=808080
#blue=08246b
#dark_blue=08246b
#white=ffffff
#red=ff0000
#green=00ff00
#background=626c72
[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=ask-1

xrdp-1

2.0.4) Save the xrdp.ini and restart the xrdp service (command is below)

  • service xrdp restart

2.0.5) Next, For you MPI local or distributed Users, edit the following files

  • cd /etc/pam.d/
  • edit the file xrdp-sesman
  • add –> session required pam_limits.so

2.0.6) For users of xRDP same session management.

  • cd /etc/pam.d/
  • edit the common-session file
  • add –> session required pam_limits.so

STEP 2.1.0 – Open the Microsoft Remote Desktop client on your Windows Machine.

  • Try logging in from two machines or two sessions of Microsoft Remote Desktop
  • Enter the hostname or IP address of your CUBE Linux Compute Server
  • Login

(see screen capture below)

xrdp-login-presentation-graphic

STEP 2.2.0 – Pay Attention to a few things while logging in.

  • For you the originator of the RDP desktop session:
  • AS You are logging into the linux machine note the port number used for your login as the login window script executes.
  • PORT 5910

(see screen capture below)

xrdp-port-num

  •  Login! The new xRDP console session has been created on the Linux machine.
    • This session is the remote desktop session that you created so that you can share the same desktop with another user.

STEP 2.3.0 – Login process for you the secondary RDP user:

  • As you begin the remote desktop login process. Enter the port provided or that was created for the primary user. Our primary user noted and informed you that the port number for his RDP session was 5910.
  • Enter this port number into your session window when entering your login information via RDP:

(see screen capture below)

xrdp-port-num-5910

  •  Click OK to login to the desktop
  • Success! You are now both logged into the same RDP session. Both users will see the same screen and cursor move being controlled by the one or other user.

(see screen capture below)

xrdp-same-session-login

Final Thoughts pertaining to xRDP/remote desktop connections and screen sharing on 64-bit Linux.

Other/Secondary users who do not need to login to an already running/existing remote desktop session. Do not enter the port number the server, leave the port setting as -1. Logging in this way ensure you will have a unique NONSHARED remote desktop experience.

The Primary or the originator of the xRDP session. Do not use SYSTEM –> LOGOUT to close the RDP session.Simply minimize the session or click the X to close your window out.

(see screen capture below)

click-the-x

Are you aware that ANSYS recently released ANSYS 17.0? Well for you ANSYS CFD users check out the beautiful ANSYS FLUENT 17.0 GUI for Linux. If you look close enough at the screen capture you will notice that I was running one of the ANSYS fluent benchmarks.

The External Flow Over a Truck Body with a Polyhedral Mesh (truck_poly_14m) an ANSYS FLUENT benchmark.

(see screen capture below)

fluent-17.0-picture4

References/Notes/Performance Tuning for xRDP:

xRDP website – xRDP

Nvidia’s website reference: NVIDIA Graphics Cards: NVIDIA How To

Performance Tuning:

Verify that you have the latest Nvidia graphics card driver and/or you are having openGL issues:

  1. Not sure what Nvidia graphics card you have?
    1. Try running this command –> lspci -k | grep -A 2 -E “(VGA|3D)”
  2. If you already have the Nvidia graphics card driver installed but you are unsure what driver version is currently installed.
    1. Try running this command –> nvidia-smi
  3. Direct rendering –> Yes or No
    1. glxinfo|head -n 25
    2. glxinfo | grep OpenGL

Uh Oh! If the output of these commands look something like what you see below:

$ glxinfo|head -n 25
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Error: couldn’t find RGB GLX visual or fbconfig
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
Xlib: extension “GLX” missing on display “:11.0”.
name of display: :11.0

Then please add this information to the end of the xorg.conf file and reboot the server.

  • The xorg.conf file is located in: /etc/X11
  • Section “Module”
    Load “extmod”
    Load “dbe”
    Load “type1”
    Load “freetype”
    Load “glx”
    EndSection

Other Features of the NVIDIA Installer

Without options, the .run file executes the installer after unpacking it. The installer can be run as a separate step in the process, or can be run at a later time to get updates, etc. Some of the more important commandline options of nvidia-installer are:

nvidia-installer options

–uninstall
During installation, the installer will make backups of any conflicting files and record the installation of new files. The uninstall option undoes an install, restoring the system to its pre-install state.

–latest
Connect to NVIDIA’s FTP site, and report the latest driver version and the url to the latest driver file.

–update
Connect to NVIDIA’s FTP site, download the most recent driver file, and install it.

–ui=none
The installer uses an ncurses-based user interface if it is able to locate the correct ncurses library. Otherwise, it will fall back to a simple commandline user interface. This option disables the use of the ncurses library.

This how to install for xRDP was installed onto a CentOS release 6.7 (Final) Linux using PADT, Inc. – CUBE engineering simulation compute servers.