mutationpp / Mutationpp

The MUlticomponent Thermodynamic And Transport library for IONized gases in C++
GNU Lesser General Public License v3.0
106 stars 57 forks source link

How shou I use mutation++ with OpenMP Correctly and Efficiently? #220

Closed tu-97 closed 1 year ago

tu-97 commented 1 year ago
My OS is ubuntu:

My OS Version:20.04

HELLO,I am a rookie CFD coder ,I want to Parallelize my code with OpenMP. I am using structured grid. For two-dimensional calculations,there are two for loop. In each mesh point,I need to use mutation++ to calculate mixture properties,T 、P...

My serial code works well,I can pass mixture using C + + Reference. //---------------------------------------------------------C++ code---------------------- void Icondition(variable Q, conser TS, Mutation::Mixture &gas){...} //---------------------------------------------------------C++ code----------------------

If I creat a new mixture class in each mesh point ,it is very slow,because it need read text file form Local memory.How shou I use mutation++ with OpenMP Correctly and Efficiently?

//---------------------------------------------------------C++ code---------------------- void Redi(variable *Q, Mutation::MixtureOptions &gas) { Mutation::MixtureOptions opt(gas);

pragma omp parallel for default(shared) private(opt) num_threads(NCORES)

for (int i = 0; i <= MX; i++)
    for (int j = 0; j <= MY; j++)
    {
        Mutation::Mixture local_gas(gas);
            }

} //---------------------------------------------------------C++ code----------------------