Please login with a confirmed email address before reporting spam
Hi,
I am not exactly sure what you mean by parallel code. It is possible to set up external functions and external material models. For this you need to make a DLL in your preferred development system and COMSOL will call the DLL at each solver call, e.g. at each time step. You can run any code in such a DLL. This is for Windows, I think the Linux version has similar mechanisms. The model builder allows model methods in JAVA, but I don't think they can be called during computation. I am sometimes using them to set parameters and for post processing. Check the documentation.
Cheers, Edgar
HI Edgar, thanks for answer. There is way to use methods during computatin but basically I use JAVA methods for post processing.
The example I provided is legit JAVA code which works but not in Comsol. Thanks for the idea with external DLL. It's great and useful tool but it does not fit what I want to try.
For example we have parametric sweep with 3 steps, where 1, 2, 3 are indeces of those steps. In postprocessing we need to performGlobal Evaluation
for each step independently. I will omit imports, class name andexecute
method of the classmethod11
and show simple example:
int[] indeces = new int[]{1, 2, 3}; for (int i: indeces) { with(model.result().numerical("sol2")); set("outersolnumindices", i); endwith(); model.result().numerical("gev1").setIndex("expr", "2+" + toString(i), 0); model.result().numerical("gev1").setResult(); } double[][] table = model.result().table("tbl1").getReal();
Previous code is a sequence. Next example suppose to be legit equivalent of previous.
int[] indeces = new int[]{1, 2, 3}; List mylist = Arrays.asList(indeces); mylist.parallelStream().map(i-> { with(model.result().numerical("sol2")); set("outersolnumindices", i); endwith(); model.result().numerical("gev1").setIndex("expr", "2+" + toString(i), 0); model.result().numerical("gev1").setResult(); }); double[][] table = model.result().table("tbl1").getReal(); // 'i' cannot be resolved to a variable.
But this code should run for each indexi
an independent subprogram in the same time.
I suspect that it's impossible to do in the way I want but at least to have an option to run parallel JAVA code would be nice.
Best Regards, Kostiantyn Vasko
>Hi, > >I am not exactly sure what you mean by parallel code. It is possible to set up external functions and external material models. For this you need to make a DLL in your preferred development system and COMSOL will call the DLL at each solver call, e.g. at each time step. You can run any code in such a DLL. This is for Windows, I think the Linux version has similar mechanisms. >The model builder allows model methods in JAVA, but I don't think they can be called during computation. I am sometimes using them to set parameters and for post processing. >Check the documentation. > >Cheers, >Edgar HI Edgar, thanks for answer. There is way to use methods during computatin but basically I use JAVA methods for post processing. The example I provided is legit JAVA code which works but not in Comsol. Thanks for the idea with external DLL. It's great and useful tool but it does not fit what I want to try. For example we have parametric sweep with 3 steps, where 1, 2, 3 are indeces of those steps. In postprocessing we need to perform `Global Evaluation` for each step independently. I will omit imports, class name and `execute` method of the class `method11` and show simple example: int[] indeces = new int[]{1, 2, 3}; for (int i: indeces) { with(model.result().numerical("sol2")); set("outersolnumindices", i); endwith(); model.result().numerical("gev1").setIndex("expr", "2+" + toString(i), 0); model.result().numerical("gev1").setResult(); } double[][] table = model.result().table("tbl1").getReal(); Previous code is a sequence. Next example suppose to be legit equivalent of previous. int[] indeces = new int[]{1, 2, 3}; List mylist = Arrays.asList(indeces); mylist.parallelStream().map(i-> { with(model.result().numerical("sol2")); set("outersolnumindices", i); endwith(); model.result().numerical("gev1").setIndex("expr", "2+" + toString(i), 0); model.result().numerical("gev1").setResult(); }); double[][] table = model.result().table("tbl1").getReal(); // 'i' cannot be resolved to a variable. But this code should run for each index `i` an independent subprogram in the same time. I suspect that it's impossible to do in the way I want but at least to have an option to run parallel JAVA code would be nice. Best Regards, Kostiantyn Vasko