Parfor with COMSOL object
19 次查看(过去 30 天)
显示 更早的评论
Dear Concerned,
I have been reading through parallel processing toolbox lately to integrate COMSOL with matlab parallel processing and i am new to parallel processing with matlab aswell.
However i am struggling with the below problem.
In a parfor loop in am forced to load a COMSOL model object like the one below: "model = mphload('LIB_9AH_1D.mph');"
parfor i = 1:2
comsolPort=[2036 2037];
t = getCurrentTask();
labit=t.ID;
mphstart(comsolPort(labit))
import('com.comsol.model.*');
import('com.comsol.model.util.*');
model = mphload('LIB_9AH_1D.mph');
end
Later i want to refer the 'model' object outside the parfor loop. I am doing this to invoke two COMSOL process in parallel to work with matlab.
However i get an error saying "Temporary variable model is used after the parfor loop,but its value is not available after the loop"
How to make a object value available after the parfor loop?. Any ways to approach this problem will be really helpful.
Matlab version and details:
MATLAB Version: 8.2.0.701 (R2013b) MATLAB License Number: 595731 Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
0 个评论
采纳的回答
Edric Ellis
2015-11-4
Outputs from a parfor loop need to be either sliced outputs, or reductions. In this case, a sliced output is probably most appropriate. You could put the model into a cell array:
parfor i = 1:2
...
model{i} = ...;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!