Hi
I am trying to couple openFOAM solver reactingFOAM with Cantera, an open source code used for solving chemical kinetics, thermodynamics, and transport processes. The idea is that Cantera provide species’ properties as viscosity, sensible enthalpy and diffusion coefficient, based on its own implemented methods and data bases. However, reviewing the capabilities of the OF adapter, I found that there is no ability to read or to write in any of these properties that I mentioned above. Before continuing in this task, I would like to know if there an alternative of coupling both codes using preCICE, or if I should try another way to do it.
Thank you,
Juan.
Makis
July 31, 2024, 2:55pm
2
I assume that this is the Cantera you mean:
and I assume that you want to get new properties in every step of the time loop.
Is this information based on a mesh, or are they uniform properties for the complete domain? While with preCICE you could of course provide a dummy, single-point mesh to just exchange such uniform properties, we are currently working on a feature to exchange quantities not associated with a mesh:
opened 09:19AM - 22 Nov 18 UTC
enhancement
For several applications users asked about sending global data, meaning data tha… t is not associated to a mesh. Examples:
* Angles between coordinate systems (CAMRAD-CFD)
* Global background pressure (fluid-acoustic coupling)
* Others that I forgot
Note: We have previously referred to this kind of data as meta data. In the end, I am not too happy with this expression as it let to confusion (exchanging strings, integers etc.). What I had in mind are physical values, thus floating point values only.
# User perspective
## Configuration
```xml
<solver-interface dimensions="2">
<data:scalar name="ClassicalMeshData"/>
<global-data:scalar name="GlobalData1"/>
<global-data:vector name="GlobalData2"/>
<mesh name="MeshName">
<use-data name="ClassicalMeshData"/>
</mesh>
<participant name="SolverName">
<use-mesh name="MeshName" provide="yes"/>
<write-data name="ClassicalMeshData" mesh="MeshName"/>
<write-data name="GlobalData1"/>
<read-data name="GlobalData2"/>
</participant>
<coupling-scheme:parallel-implicit>
<participants first="SolverName" second="..."/>
...
<exchange data="ClassicalMeshData" mesh="MeshName" from="SolverName" to="..."/>
<exchange data="GlobalData1" from="SolverName" to="..."/>
<exchange data="GlobalData2" from="..." to="SolverName"/>
...
<post-processing:IQN-ILS>
<data name="ClassicalMeshData" mesh="MeshName"/>
<data name="GlobalData1"/>
...
</post-processing:IQN-ILS>
</coupling-scheme:parallel-implicit>
```
## API
```c++
int getDataID ( const std::string& dataName ); // use same function name if possible
void setGlobalDataSize (
int dataID,
int size,
int* globalDataIDs );
// similar functions for reading and for scalar data
void writeGlobalVectorData (
int dataID,
int size,
int* globalDataIDs,
double* values );
```
I am not sure if we can avoid having sth like the above `setGlobalDataSize`. If we make this data structure completely dynamic, undefined behavior can appear. For instance, what happens if within one subcycled timestep two different sizes are given? Which one will be used? I currently also don't see a use-case where a completely dynamic size would be necessary (which does not mean that there isn't).
## Communication behavior
* Writing should be allowed on any rank. If data is written on multiple ranks, preCICE checks for consistency.
* On every reading rank, the same data is available
# Developer perspective
## Communication
* Gather on all writing ranks to master and check for consistency. This cannot be a debug-only feature, since we need to figure out either way on which rank data was written
* Send from master to master and broadcast
## WIP: Data structures and random thoughts
* New class `GlobalData` (in which package?? `mesh` would obviously lead to misunderstandings, probably a new package is needed)
* Do we need a `GlobalDataContext`? Maybe not
* Participant gets `_writeGlobalDataContexts` and `_readGlobalDataContexts` (or directly `_readGlobalDatas` or similar)
* How do we treat global data in `CouplingData`? New similar data structure? This has consequences in `_sendData` in `BaseCouplingScheme`
* How do we distinguish between the two send operations, normal m2n send and global data send in `M2N`, compare how sending the timestep size is currently handled
If this is information based on a mesh, you can extend the OpenFOAM adapter to read it as you wish: