CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   Automatic integration COMSOL (

Diego November 19, 2012 14:33

Automatic integration COMSOL

I have a COMSOL 3.5 3D simulation in which I would like to calculate the integral of a specific variable over just a portion of a boundary, not over the whole boundary. I know that I can do this by simply specifying the x and y coordinates that define the region I want to deal with as follows:


My problem is that I want to divide this boundary in 100 portions and to calculate the integral of the function f(x,y) in all of them. Doing the same thing (only changing the coordinates) 100 times and for many different files seems really irksome to me, so I was wondering if there is a way to do this automatically. I had thought about writing the necessary commands in a *.m file and executing it, but I don't see how I can export the values of the integrals to a *.txt file or similar.

Does anybody have a clue?

Diego November 20, 2012 07:04

Well, I could figure it out. With the command xlswrite('filename.xls', data), I can get a xls file with the data resulting from the integration. That would be:

vJ=postint(fem,'f(x,y)*(x>J)*(y>J)', ...
'unit','units', ...
'recover','off', ...

xlswrite('filename.xls', vJ)

My problem now is that J takes 100 different values, so I would like to define a counter variable in order to use something similar to a "" instruction.

Anybody knows how to do it??

All times are GMT -4. The time now is 15:04.