![]() |
OGS
|
|
Manages a pool of independent IPhreeqc instances for thread-safe parallel chemistry calculations.
Each OpenMP thread uses its own PHREEQC instance to avoid thread-safety issues. All instances are initialized with the same thermodynamic database.
Definition at line 18 of file PhreeqcInstancePool.h.
#include <PhreeqcInstancePool.h>
Public Member Functions | |
| PhreeqcInstancePool (std::string const &database, int num_instances) | |
| ~PhreeqcInstancePool () | |
| PhreeqcInstancePool (PhreeqcInstancePool const &)=delete | |
| PhreeqcInstancePool & | operator= (PhreeqcInstancePool const &)=delete |
| int | getInstanceForThread (int thread_id) const |
| int | size () const |
| Returns the number of instances in the pool. | |
Static Public Member Functions | |
| static int | createInstance (std::string const &database) |
| static void | configureForStringIO (int id) |
Private Attributes | |
| std::vector< int > | instance_ids_ |
| ChemistryLib::PhreeqcIOData::PhreeqcInstancePool::PhreeqcInstancePool | ( | std::string const & | database, |
| int | num_instances ) |
Creates a pool of PHREEQC instances.
| database | Path to the thermodynamic database file. |
| num_instances | Number of instances to create (one per thread). |
Definition at line 50 of file PhreeqcInstancePool.cpp.
References configureForStringIO(), createInstance(), INFO(), instance_ids_, and OGS_FATAL.
Referenced by PhreeqcInstancePool(), and operator=().
| ChemistryLib::PhreeqcIOData::PhreeqcInstancePool::~PhreeqcInstancePool | ( | ) |
Definition at line 71 of file PhreeqcInstancePool.cpp.
References instance_ids_.
|
delete |
References PhreeqcInstancePool().
|
static |
Configures an IPhreeqc instance for string-based I/O: disables file output and enables in-memory buffers for selected output and dump.
Definition at line 35 of file PhreeqcInstancePool.cpp.
References OGS_FATAL.
Referenced by PhreeqcInstancePool().
|
static |
Creates a new IPhreeqc instance and loads the thermodynamic database. Returns the instance id. Fatals on failure.
Definition at line 15 of file PhreeqcInstancePool.cpp.
References OGS_FATAL.
Referenced by PhreeqcInstancePool(), and ChemistryLib::PhreeqcIOData::PhreeqcIO::PhreeqcIO().
| int ChemistryLib::PhreeqcIOData::PhreeqcInstancePool::getInstanceForThread | ( | int | thread_id | ) | const |
Returns the PHREEQC instance ID for the given thread.
| thread_id | The OpenMP thread ID (0-based). |
Definition at line 79 of file PhreeqcInstancePool.cpp.
References instance_ids_, and OGS_FATAL.
|
delete |
References PhreeqcInstancePool().
|
inline |
Returns the number of instances in the pool.
Definition at line 38 of file PhreeqcInstancePool.h.
References instance_ids_.
|
private |
Definition at line 49 of file PhreeqcInstancePool.h.
Referenced by PhreeqcInstancePool(), ~PhreeqcInstancePool(), getInstanceForThread(), and size().