1. C3PO documentation

1.1. Introduction

C3PO (Collaborative Code Coupling PlatfOrm) is a Python library offering generic services for the definition of coupled calculations with codes meeting a certain framework. This framework is defined by:

  • Use of Python. Codes have to be wrapped into a Python class, which allows to coordinate them in a homogeneous way regardless of their native programming language.

  • Use of MEDCoupling for data exchanges. MEDCoupling is the common format choosen for the exchanges of space-dependent variables. MEDCoupling is a C++ library, with Python binding, provided by the open-source SALOME platform [1].

  • If needed, use of MPI as distributed memory parallelization standard. MPI is by far the dominant distributed memory parallelization standard. C3PO is compatible with the use of MPI, but does not support other distributed memory parallelization standards. On the other hand, full flexibility is given for the intra-code shared memory parallelization.

  • Implementation of an ICoCo API [2]. ICoCo (V2) is the code API used by C3PO. It includes all required capabilities for multiphysics simulations such as initialization, termination, time-step control, solving, exchange of variables etc. It is defined by c3po.PhysicsDriver.PhysicsDriver.

For more information about code integration, see How to use a code with C3PO.

The main objective of C3PO is to facilitate and standardize the writing of coupling scripts, in particular in HPC (High Performance Computing) environment. It also provides generic (and HPC-compatible) implementations of the main coupling algorithms (Picard iteration, Anderson acceleration, JFNK), and allows pooling of efforts in the development and verification of multi-physics calculation schemes.

C3PO is code- and physics-agnostic, and therefore constitutes a kernel of generic methods that can be shared by different multi-physics applications. For this reason, it has been made open-source under the (highly permissive) 3-Clause BSD License here: https://sourceforge.net/projects/cea-c3po/.

1.2. Source overview

The sources directory contains:

  • The directory c3po with all C3PO sources. It can be imported without any MPI dependency.

  • The file setup.py that can be used to install C3PO via pip: “pip install path –user” (with path the path to the setup.py file)

  • The file .pylintrc that define coding standards to be followed in C3PO. Install pylint (python3 module available with pip) and run “pylint c3po” from the sources directory to check your code. You must get the grade 10/10!

The directory sources/c3po contains the definition of the following classes:

Basic couplings can be made only with these classes.

The directory sources/c3po also contains six directories:

  • couplers with specific implementations of c3po.Coupler.Coupler for the main coupling algorithms. See below.

  • exchangeMethods with specific implementations of exchange methods (to be used with a c3po.LocalExchanger.LocalExchanger). See below.

  • medcouplingCompat which deals with various versions of MEDCoupling. Import this module to use all versions of MEDCoupling in an identical way (following the last version API).

  • physicsDrivers with specific implementations of c3po.PhysicsDriver.PhysicsDriver for some codes.

  • services with some optionnal services (mainly for monitoring of coupled calculations). See below.

  • raises for optionnal error handling services. See below.

  • multi1D with sources related to the use of a set of 1D models in a 3D coupling. See below.

  • mpi with sources related to MPI. See below.

Note

When “import c3po” is made, the classes and functions defined in c3po/couplers, c3po/exchangeMethods and c3po/services are imported and made available directly in c3po module.

“import c3po.medcouplingCompat” must be done if one wants to use directly MEDCoupling (using this helper).

“import c3po.raises” must be done to access raises functionalities. icoco package must be available.

“import c3po.multi1D” (and if needed “import c3po.multi1D.mpi”) must be done to access multi1D functionalities.

“import c3po.mpi” must be done to get access to MPI classes of C3PO (the classes and functions defined in c3po/mpi/mpiExchangeMethods are imported and made available directly in c3po.mpi module). mpi4py must be available.

Each class of c3po/physicsDrivers must be imported separately.

“import c3po.services.checkScope” must be done, as it uses an additionnal prerequisite “icoco”.

1.2.1. c3po/couplers directory

This directory contains the definition of the following classes (coupling algorithms, they all inherit from c3po.Coupler.Coupler):

1.2.2. c3po/exchangeMethods directory

This directory contains the definition of the following classes (exchange methods to be used with a c3po.LocalExchanger.LocalExchanger):

1.2.3. c3po/services directory

This directory contains the definition of the following elements:

1.2.4. c3po/raises directory

This directory contains the definition of the following elements:

1.2.5. c3po/multi1D directory

This directory contains the definition of the following classes:

When c3po.multi1D is imported, the above-mentioned classes are imported and made available in c3po.multi1D.

c3po/multi1D also contains one directory:

  • mpi with specializations of c3po.multi1D for MPI couplings. See below.

1.2.5.1. c3po/multi1D/mpi directory

1.2.6. c3po/mpi directory

This directory contains the definition of C3PO sources related to MPI.

Two parallelization modes are available (and can be mixed):

  • Collaborative: all the processes run the same instructions. Instructions that do not concern a process (because it does not host a code for example) are ignored.

  • Master-workers: a master process executes the highest-level instructions. It controls the execution of calculation codes and the data exchanges between worker processes.

These two parallelization modes share a common base of concepts.

1.2.6.1. Common base

1.2.6.2. Collaborative mode

1.2.6.3. Master/workers mode

The directory sources/c3po/mpi also contains one directories:

  • mpiExchangeMethods with specific implementations of MPI exchange methods. See below.

1.2.6.4. c3po/mpi/mpiExchangeMethods directory

1.3. Contacts

cyril.patricot@cea.fr

1.4. References

[1] “Salomé: The Open Source Integration Platform for Numerical Simulation”, http://www.salome-platform.org.

[2] E. Deville, F. Perdu, “Documentation of the Interface for Code Coupling : ICoCo”, NURISP technical report D3.3.1.2 (2012).