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!