Simulation Apps: How to Add a File Menu with Save Options

Andrew Griesmer August 25, 2015
Share this on Facebook Share this on Twitter Share this on Google+ Share this on LinkedIn

When a user running your COMSOL app finds a particularly interesting set of results, they might need to save their app so they can come back to it later. Without save options, you’d have to re-run the simulation later with the input parameters they gave you. That would be very inefficient and defeat the purpose of creating simulation apps. Today, we’ll show you how to add a file menu with save options in your app.

Including Save Options in Your Simulation App’s Interface

Adding a menu bar to include save options in the external app interface may not carry the glitz and glamour of some of the other Application Builder features, but it can help you immensely with debugging an app or remembering particularly interesting results.

Whenever you or an app user runs a simulation app, there is a chance of unexpected results. This could go one of two ways:

  1. Either your app user has found the spectacular results that need to be shared with the world, or
  2. The app and underlying model flat out didn’t work

In both cases, the user would need to save the running app to show later.

Whenever a running app is saved, the entire underlying model is saved with it. That way, when it is reopened, it contains the model, app, and input data from the last save point. This saves you from having to re-run the simulation to inspect the results further.

Learn how to add save options to your app in the video below and empower your app users to help you improve your simulation apps. The video featured here is Part 2 of a series of videos created to give you a basic introduction to using the Application Builder and meeting best practices when building apps.

Video Tutorial: How to Add Save Options to a COMSOL App

 

Further Reading

Video Transcription

In the previous video in this series, we built an app from a COMSOL Multiphysics model. For best practices, the next step, shown in this video, is adding Save Options to your app. These are important in case you encounter input parameters that give an interesting result. This could include valuable results to reference later on, or unexpected results to use for debugging purposes.

Here is my basic app that I have created from the busbar model, and to add save options, I can do this one of two ways: the first is in the Main Window. I can right-click to add a Menu bar. However, I’m going to use the Application Builder ribbon and this Main Window section. So, here I can add a Menu bar and then add a Menu. This will be my File menu and then I can create Items such as the ‘Save As…’ item. For an icon, I’m going to use a save_as image that has been preloaded. And for keyboard shortcut, I will press CTRL+SHIFT+S. For Commands to Run, this is the exact same thing as with the buttons for updating geometry and computing. I could go into the Model and add those. However, I want to add the GUI Command>File Commands>Save Application As. Now I can click Run, which runs the operation, Save Application As, that I clicked on, and then I’m actually going to create another item, just to show you, and I’m going to do this a little bit quicker, and it will be my Save item. So, there we go!

Now I will test the application to show you how these work. Using the Test Application button, within the Application Builder, you can see that these have two different names: the original ‘busbar_v2.mph’ and this ‘Untitled.mph’. This is because these are two separate apps; we have the editable app in the background and our test app here. So, I can click File, go to Save As, and on my Desktop I will save this as ‘busbar_v2_copy’. Click save, and you can see that the name is changed to ‘busbar_v2_copy’ and now these are two different files. To demonstrate how these files are different, I will re-enter the width as 8 and update the geometry. I will save this using the keyboard shortcut, CTRL+S, exit out of the app.

Now when I go to the Model Builder, in this ‘busbar_v2′ app, and go to the Parameters, you can see that the Width is still 5 cm. However, if I open the ‘busbar_v2_copy’ app, when I go to the Parameters node, you can see that the Width is now 8 cm. So, when I save this app using Test Application, I created an entirely new app. This is different than running an app from the file menu, where you have the app running, but you don’t have the background editable app running as well.

Now that we have finished building our File menu, I would like to point out a subtle difference here in the Main Window, I actually have two types of Menus: the Menu bar we used, and a Ribbon. You could actually create your own ribbon for your apps that works the same way as a Menu bar. Most of the apps that are included with the Application Library use the Ribbon, however, some use the Menu bar as well. Stay tuned for our next video on Subforms.


Categories

Loading Comments...

Categories


Tags