Comparing Models and Applications
It can be useful to compare two versions of the same model or application to get an overview of the differences between the two versions. To do so, click the Compare button () in the Compare section of the Developer toolbar. A Select Application window then opens, where you can select the Model MPH-file (the remote file) to which you want to compare the current model in the COMSOL Desktop (the local file). A comparison then starts, and the results, if there are any differences, appear as a tree in the Comparison Result window. The comparison tool compares all the settings in the entire model, including visible and invisible settings in the Model Builder and the Application Builder. For comparing versions of a model or application in the Model Manager, see The Versions Window in this book and Comparing Models Saved in Databases in the Model Manager Reference Manual for more information.
The Comparison Result Window
At the top of the Comparison Result window there is a toolbar with the following buttons:
New Comparison (), to make a new comparison. A New Comparison dialog box opens, where the default is that the Use open file check box is selected. Clear it to specify another Local file. Specify a Remote file and then click OK to perform a new comparison.
Update (), to update the comparison.
Collapse () and Expand (), where you can click to choose Collapse Selected or Expand Selected to collapse or expand the selected tree branches (or use the divide and multiply keypad keys, respectively), Collapse Other to collapse all tree branches except the selected ones, or Collapse All or Expand All to collapse or expand all branches in the comparison tree.
Show Table View (), to toggle between the view with the comparisons in a tree and a view with a list of the differences.
Load Comparison from File (), to load the results from another comparison from an XML-file.
Save Comparison to File (), to save the results from the current comparison to an XML-file.
Show Next Difference (), to move to the next difference in the tree with nodes that differ under Differences.
Show Previous Difference (), to move to the previous difference in the tree with nodes that differ under Differences.
Under Comparing files, you find the file paths to the local model and the remote model. The local model is typically the model open in the COMSOL Desktop, and it can have been modified after the last save. The left column is called Local file (Saved application) when the local model is the opened model or application. When the local model is a new model that has not yet been saved, the left column is called Open application. The right column is called Remote file. Both columns contain a path to the selected files, unless the Local file column contains the file that is open in the COMSOL Desktop.
If you compare two versions of a model or application in a database, this section is instead called Compare versions, and the left column and right column are called Older version and Newer version, respectively.
Under Differences, you can use the Filter results list to control filtering with the options No filter, Exclude all matching labels (the default), and Include only matching labels. The entries in the Regular expression field define what node labels to filter. You can make the filtering case sensitive by selecting the Case Sensitive button () box next to the list. The filter matching is done with regular expressions, and any label that contains a matching text will be either included or excluded. Filtering can be disabled by choosing No filter from the Filter results list. Click the Show Only Active Settings button () next to the list to exclude inactive settings from the comparison. Such settings are not actively used in the current model state and do not typically appear in the COMSOL Desktop. Select or clear the Include Only Outgoing Changes (), Include Only Incoming Changes (), and Include Only Conflicting Changes () buttons as desired to change the view to include one of those types of changes. Incoming changes here are changes that someone has made to the remote file since the last update of the local file. Such incoming changes will be merged to the local file during an update of that file. Outgoing changes are changes that someone has made to the local file and that has not been committed to the remote file yet. Such outgoing changes will be merged to the remote file during a commit of the file. The categorization of incoming and outgoing changes requires version information (available for models that use version control in the Model Manager). For models without version information the categorization have little meaning, and they both just represent a general difference.
The tree of nodes with differences has a structure according the structure of the underlying model object, not the Model Builder or Application Builder trees. This means that the hierarchy can be somewhat different compared to the hierarchy seen in the Model Builder and Application Builder windows. The comparison includes all nonbinary differences in the model object that can be saved to disk, with some exceptions. For nodes that correspond to a node in the Model Builder or Application Builder trees, double-click the node (or right-click and choose Go to Source) in the tree of nodes with differences to display the corresponding node in one of those trees in the local file.
Below is a list of consequences of this design:
Selecting a node in the tree will update the table under Comparing values below the tree. This table shows the attributes of the selected node, both in the local or older model (Local value or Value in older column) and the remote or newer model (Remote value or Value in newer column). This table is particularly interesting for the nodes labeled Properties differ, Variables differ, or Selections differ because they show the settings where there are differences. Parent nodes can also show the same differences but typically with a larger number of attributes that have the same local and remote or older and newer values. For differences that contain long entries or large arrays, there is an option to show a more detailed difference in a separate window for a selected table. Either double-click the table row or click the Detailed Comparison of Selected Attribute button () below the table to open the Compare Attribute window. When applicable, you can also right-click a node and choose Go to Remote Source, Go to Older Version, or Go to Newer Version to display the corresponding node in one of those trees. For nodes where values differ, right-click and choose Go to Node in Local File, Go to Node in Remote File, Override Difference in Local File, or Override Difference in Remote File, where you can use the last two options to discard the local changes or to transfer them to the remote file, respectively.
Comparing Two Selected Nodes
When you select two nodes with settings in the Model Builder tree or Application Builder tree, right-click and choose Compare Selected Nodes to compare the contents of the two nodes. The comparison appears in the Comparison Results window just like other comparisons, with similar functionality as described above.
Merging Differences
There are two ways to merge differences in the Comparison Results window:
For nodes that correspond to a node in the Model Builder tree, right-click the node and choose Override Difference in Opened () to overwrite that difference in the open model. After this operation, the open model will be altered so it as close as possible matches the other model. When comparing two models that both can be altered (for example, two models saved on your file system), you can also right-click and choose Override Difference in Remote File () to overwrite the difference in the other model instead.
When the comparison has version information (for models that use version control in the Model Manager) and the node corresponds to the root node in the Model Builder, you can right-click and choose Merge Changes to Opened. This operation only merges the changes that has been done in the other version after you started editing your version. An example is when you edit a model in a Model Manager database and another user has edited the same model after you opened your version. For this merge operation, there is only one possible target that can be altered.
Some differences can be impossible to transfer when the models differ significantly, so a setting is not applicable in the target. For example, when a material link refers to a material that does not exist in the target. The merge is typically most successful when there are isolated changes that do not depend on other parts of the model. If there are large structural differences with a lot of removed and added nodes, the merge will have more difficulties to achieve a good result. Sometimes it can be necessary to update the comparison result and do several merge operations. Also, pay attention to cases when merging differences for nodes that are automatically generated, such as the solver sequence. Many models have an automatically generated solver sequence that depends on settings in the study steps and physics interfaces.