Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.
Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
scripting import and interpolation of solution
Posted 06.08.2011, 11:40 GMT-4 Materials, Mesh, Modeling Tools & Definitions, Parameters, Variables, & Functions Version 4.1, Version 4.2 6 Replies
Please login with a confirmed email address before reporting spam
Hi all,
I'm attempting to automate a series of time-dependent 3D simulations, in which the geometry changes from one simulation to the next, but the final distribution of the dependent variable from one simulation should be the initial condition for the next one.
The geometry is set by a matlab script, but due to some memory issues in COMSOL (v 4.1, I haven't rewritten the code sonce 4.2 to try whether they've been solved) the only way to convert the matlab-made geometry to COMSOL is piece by piece, exiting and entering COMSOL after each bit, so as not to encounter the memory problem. Once the geometry is assembled, it is saved as a mphbin file.
Now here's my problem: I'd like to take this saved geometry, mesh it, and interpolate the previous solution onto its mesh. I cannot find a way, however, to import the solution exported by a previous COMSOL simulation. I could perhaps simply read a solution report to a set of matlab variables (coordinates and data) and try write a function using matlab's interp3 to set the initial values from that as f(x,y,z). I'm unclear, however, as to the proper way to set the outputs up so that the they are in the right shape to be used as initial values.
Alternatively, I could try to open up the model with the solution, import the geometry and try mesh it, then interpolate the previous solution to create the initial values with mphinterp (by the way, I have the same issue as with interp3 here: I'm not sure how to reshape the mphinterp outputs so they can be used as initial values), and solve on the new mesh. I'm not sure which of these approaches, if either, works with the way COMSOL is conceived.
Does anyone know of a successful approach to this or a similar problem?
Thanks,
Martin
I'm attempting to automate a series of time-dependent 3D simulations, in which the geometry changes from one simulation to the next, but the final distribution of the dependent variable from one simulation should be the initial condition for the next one.
The geometry is set by a matlab script, but due to some memory issues in COMSOL (v 4.1, I haven't rewritten the code sonce 4.2 to try whether they've been solved) the only way to convert the matlab-made geometry to COMSOL is piece by piece, exiting and entering COMSOL after each bit, so as not to encounter the memory problem. Once the geometry is assembled, it is saved as a mphbin file.
Now here's my problem: I'd like to take this saved geometry, mesh it, and interpolate the previous solution onto its mesh. I cannot find a way, however, to import the solution exported by a previous COMSOL simulation. I could perhaps simply read a solution report to a set of matlab variables (coordinates and data) and try write a function using matlab's interp3 to set the initial values from that as f(x,y,z). I'm unclear, however, as to the proper way to set the outputs up so that the they are in the right shape to be used as initial values.
Alternatively, I could try to open up the model with the solution, import the geometry and try mesh it, then interpolate the previous solution to create the initial values with mphinterp (by the way, I have the same issue as with interp3 here: I'm not sure how to reshape the mphinterp outputs so they can be used as initial values), and solve on the new mesh. I'm not sure which of these approaches, if either, works with the way COMSOL is conceived.
Does anyone know of a successful approach to this or a similar problem?
Thanks,
Martin
6 Replies Last Post 12.05.2012, 15:49 GMT-4