i wrote a shallow water equation code on MATLAB but it is solving sequentially and takes a lot of time so i was wondering how can i transform my code to a parallel one so that it can utilize multiple cores.
I try to understand your problem that you have non-linear Navier-stokes equations for AUV in shallow water environment. while running your code, you want to solve these equations instantly.
1. First, you should solve equations (you may use fluent for example), then construct a coefficient list covering all parameters.
2. Coefficient list is a table that includes all hydrodynamics, hydrostatic etc. coefficients obtained for different swimming conditions.
3. Your code parses this table depending on the dynamics of the vehicle.
You can use the toolbox provided by Matlab (https://www.mathworks.com/products/parallel-computing.html), however an efficient parallelization requires a correct definition of the algorithms.
Actually, it was ... years ago the KAP prepocressor for Fortran did that, if the code were written with no dependencies it was able to parallelize the sequential into a parallel one. I used that many times and it provided also the transformed source code with the OpenMP directives. Then it was acquired by Intel and becomes part of the Intel compiler. At present I don't know if it is developed....
I did this work on a 3D Poisson equation discretized with standard second order equation, using a "coloured" SOR method and I got an efficient parallelized source code that scaled up to 8 CPU correctly. Also for parabolic equation it worked fine. Of course, the main issue is that works only on shared-memory architecture. A more extensive parallelization requires to structure ad hoc the algorithm.
I agree, the starting point is to write efficiently the code.
It would be interesting to see the capability of Matlab in doing that ... however, my interest in numerical simulation of turbulence requires nowdays a larger computational power, I doubt that can be done in Matlab. Even if it seems it works also on GPU...
Well, I have both didactic reasons and some useful statistical tool I developed in Matlab for post-processing. I never really explored the CFD potentialities for research task but there are some books addressing that.