Commit d1bbe0bf authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

itaComsolModel: Now also allows to directly be created using a filename and a model tag

parent 54cf6b5a
......@@ -119,10 +119,24 @@ classdef itaComsolModel < handle
%% Constructor
methods
function obj = itaComsolModel(comsolModel)
if ~isa(comsolModel, 'com.comsol.clientapi.impl.ModelClient')
error('Input must be a comsol model (com.comsol.clientapi.impl.ModelClient)')
function obj = itaComsolModel(varargin)
% Creates an itaComsolModel either using a comsol model (com.comsol.clientapi.impl.ModelClient)
% or a filepath and a model tag
assert(nargin > 0, 'Invalid number of input arguments: 1 or 2 expected.');
if nargin == 1
comsolModel = varargin{1};
assert(isa(comsolModel, 'com.comsol.clientapi.impl.ModelClient'),...
'Single input must be a comsol model (com.comsol.clientapi.impl.ModelClient)')
else
filepath = varargin{1};
modelTag = varargin{2};
assert(ischar(filepath) && contains(filepath, '.mph') && ischar(modelTag),...
'For two input expecting a model filepath and a modeltag');
comsolModel = mphload(filepath, modelTag);
end
obj.mModel = comsolModel;
obj.mParameterNode = itaComsolParameters(obj);
obj.mSelectionNode = itaComsolSelection(obj);
......
......@@ -35,7 +35,8 @@ comsolServer.Connect();
%multiple models at once
modelTag = 'itaDemoModel';
demofolder = fileparts(mfilename('fullpath'));
comsolModelObj = mphload(fullfile(demofolder, 'ita_comsol_demo_model.mph'), modelTag);
modelFilepath = fullfile(demofolder, 'ita_comsol_demo_model.mph');
comsolModelObj = mphload(modelFilepath, modelTag);
%% Connect COMSOL client to server
%To visualize the changes we are going to apply to the model later on, it
......@@ -48,6 +49,10 @@ comsolModelObj = mphload(fullfile(demofolder, 'ita_comsol_demo_model.mph'), mode
%% --- ITA initialization ---
%% Create an itaComsolModel
% From a comsol model object
itaComsolModelObj = itaComsolModel(comsolModelObj);
%Alternatively:
%Directly use the filepath and a user-defined model tag
%itaComsolModelObj = itaComsolModel(modelFilepath, modelTag);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment