Functions
mmc_host.h File Reference

OpenMP host code for CPU-based MMC simulations. More...

#include "mmc_mesh.h"
#include "mmc_raytrace.h"
#include "mmc_utils.h"
Include dependency graph for mmc_host.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mmc_init_from_cmd (mcconfig *cfg, tetmesh *mesh, raytracer *tracer, int argc, char **argv)
 Initialize simulation configuration structure cfg using command line options. More...
 
int mmc_init_from_json (mcconfig *cfg, tetmesh *mesh, raytracer *tracer, char *jcfg, char *jmesh)
 Initialize simulation configuration structure cfg using a JSON input file. More...
 
int mmc_reset (mcconfig *cfg, tetmesh *mesh, raytracer *tracer)
 Rest simulation related data structures. More...
 
int mmc_cleanup (mcconfig *cfg, tetmesh *mesh, raytracer *tracer)
 Clear simulation related data structures. More...
 
int mmc_prep (mcconfig *cfg, tetmesh *mesh, raytracer *tracer)
 Peprocessing simulation settings and data for simulation. More...
 
int mmc_run_mp (mcconfig *cfg, tetmesh *mesh, raytracer *tracer)
 Main function to launch CPU based MMC photon simulation. More...
 

Detailed Description

OpenMP host code for CPU-based MMC simulations.

Function Documentation

◆ mmc_cleanup()

int mmc_cleanup ( mcconfig cfg,
tetmesh mesh,
raytracer tracer 
)

Clear simulation related data structures.

Parameters
[out]cfgthe simulation configuration structure
[out]meshthe mesh data structure
[out]tracerthe ray-tracer data structure
Here is the call graph for this function:

◆ mmc_init_from_cmd()

int mmc_init_from_cmd ( mcconfig cfg,
tetmesh mesh,
raytracer tracer,
int  argc,
char **  argv 
)

Initialize simulation configuration structure cfg using command line options.

In this unit, we first launch a master thread and initialize the necessary data structures. This include the command line options (cfg), tetrahedral mesh (mesh) and the ray-tracer precomputed data (tracer).

Parameters
[out]cfgthe simulation configuration structure
[in]meshthe mesh data structure
[in]tracerthe ray-tracer data structure
[in]argctotal number of command line option strings
[in]argvcommand line option string array
Here is the call graph for this function:

◆ mmc_init_from_json()

int mmc_init_from_json ( mcconfig cfg,
tetmesh mesh,
raytracer tracer,
char *  jcfg,
char *  jmesh 
)

Initialize simulation configuration structure cfg using a JSON input file.

Parameters
[out]cfgthe simulation configuration structure
[in]meshthe mesh data structure
[in]tracerthe ray-tracer data structure
[in]jcfgJSON data structure parsed from the input file
[in]jmeshJSON data structure parsed from the mesh data
Here is the call graph for this function:

◆ mmc_prep()

int mmc_prep ( mcconfig cfg,
tetmesh mesh,
raytracer tracer 
)

Peprocessing simulation settings and data for simulation.

Parameters
[out]cfgthe simulation configuration structure
[out]meshthe mesh data structure
[out]tracerthe ray-tracer data structure
Here is the call graph for this function:

◆ mmc_reset()

int mmc_reset ( mcconfig cfg,
tetmesh mesh,
raytracer tracer 
)

Rest simulation related data structures.

Parameters
[out]cfgthe simulation configuration structure
[out]meshthe mesh data structure
[out]tracerthe ray-tracer data structure
Here is the call graph for this function:

◆ mmc_run_mp()

int mmc_run_mp ( mcconfig cfg,
tetmesh mesh,
raytracer tracer 
)

Main function to launch CPU based MMC photon simulation.

This is the main loop of the Monte Carlo photon simulation. This function run a complete photon simulation session based on one set of user input.

Parameters
[out]cfgthe simulation configuration structure
[out]meshthe mesh data structure
[out]tracerthe ray-tracer data structure

The master thread then spawn multiple work-threads depending on your OpenMP settings. By default, the total thread number (master + work) is your total CPU core number. For example, if you have a dual-core CPU, the total thread number is 2; if you have two quad-core CPUs, the total thread number is 8. If you want to set the total thread number manually, you need to set the OMP_NUM_THREADS environment variable. For example, OMP_NUM_THREADS=3 sets the total thread number to 3.