3.1.4.1.2. c3po.mpi.mpiExchangeMethods.MPISharedRemapping module
Contain the class SharedRemapping.
- class c3po.mpi.mpiExchangeMethods.MPISharedRemapping.MPIRemapper(meshAlignment=False, offset=None, rescaling=1.0, rotation=0.0, outsideCellsScreening=False, reverseTransformations=True)
Bases:
objectAllow to share the mesh projection for different
MPISharedRemappingobjects by building them with the same instance of this class.- __init__(meshAlignment=False, offset=None, rescaling=1.0, rotation=0.0, outsideCellsScreening=False, reverseTransformations=True)
Build a
MPIRemapperobject.Warning
It is mandatory to call the
terminate()method after use, otherwise MPI may be badly ended.Warning
The option
outsideCellsScreeningis not ready to use yet.There seems to be a bug in MEDCoupling that may cause wrong results when rescaling is used with a source mesh of nature IntensiveConservation. In this case, it is necessary to use
reverseTransformations=Falseand to never perform a remapping on a field whose underling mesh has not been rescaled.- Parameters:
meshAlignment (bool) – If set to True, at the initialization phase of the
MPIRemapperobject, meshes are translated such as their “bounding box” are radially centred on(x = 0., y = 0.)and, if the meshes are 3D, havezmin = 0.offset – Value of the offset between the source and the target meshes (>0 on z means that the source mesh is above the target one). The given vector is used to translate the source mesh (after the mesh alignment, if any). The dimension of offset must be >= the dimension of the meshes (we use only the first components).
rescaling – Value of a rescaling factor to be applied between the source and the target meshes (>1 means that the source mesh is initially larger than the target one). The scaling is centered on
[0., 0.(, 0.)]and is applied to the source mesh after mesh alignment or translation, if any.rotation – Value of the rotation between the source and the target meshes. The rotation is centered on
[0., 0.(, 0.)]and is about the vertical axis. >0 means that the source mesh is rotated of the given angle compared to the target one. The inverse rotation is applied to the source mesh, after mesh alignment or translation, if any. pi means half turn.outsideCellsScreening (bool) – If set to True, target (and source) cells whose barycentre is outside of source (or target) mesh are screen out (defaultValue is assigned to them). It can be useful to screen out cells that are in contact with the other mesh, but that should not be intersected by it. On the other hand, it will screen out cells actually intersected if their barycenter is outside of the other mesh ! Be careful with this option.
reverseTransformations (bool) – If set to True, all the transformations (translation, rescaling and rotation) applied in
initialize()on the provided meshes are reversed at the end ofinitialize().
- initialize(ranksToGet, ranksToSet, mpiComm, field)
INTERNAL
- recvField(fieldTemplate)
INTERNAL
- sendField(field)
INTERNAL
- terminate()
Release all allocated resources.
Warning
This method must be called once the object is no more needed in order to properly release MPI resources.
- class c3po.mpi.mpiExchangeMethods.MPISharedRemapping.MPISharedRemapping(remapper, reverse=False, defaultValue=0.0, linearTransform=(1.0, 0.0))
Bases:
MPIExchangeMethodMPISharedRemappingis the MPI version ofc3po.exchangeMethods.SharedRemapping.SharedRemapping.MPI features of MEDCoupling must be available. It allows to use MEDCoupling projections between codes using domain decomposition methods.
- __call__(fieldsToGet, fieldsToSet, valuesToGet)
Project the input fields one by one before returning them as outputs, in the same order.
- __init__(remapper, reverse=False, defaultValue=0.0, linearTransform=(1.0, 0.0))
Build an
MPISharedRemappingobject, to be given to anc3po.mpi.MPIExchanger.MPIExchanger.Warning
At the present time,
defaultValuehas to be 0.- Parameters:
remapper (MPIRemapper) – A
MPIRemapperobject (defined in C3PO) performing the projection. It can thus be shared with other instances ofMPISharedRemapping(its initialization will always be done only once).reverse (bool) – Allows the
MPIRemapperto be shared with an instance ofMPISharedRemappingperforming the reverse exchange (the projection will be done in the reverse direction if reverse is set to True).defaultValue – This is the default value to be assigned, during the projection, in the meshes of the target mesh that are not intersected by the source mesh.
linearTransform (tuple) – Tuple
(a,b): apply a linear function to all output fieldsfsuch as they becomea * f + b. The transformation is applied after the mesh projection.
- clean()
- getPatterns()
- initialize(field)
INTERNAL
- setRanks(ranksToGet, ranksToSet, mpiComm)