Parfor with COMSOL object
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
christober
am 4 Nov. 2015
Kommentiert: christober
am 5 Nov. 2015
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 Kommentare
Akzeptierte Antwort
Edric Ellis
am 4 Nov. 2015
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
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!