1 #ifndef SMOMPI_NoMasterMacroCellsDemagnetizedField_H
2 #define SMOMPI_NoMasterMacroCellsDemagnetizedField_H
5 #include "SM_MacroCellsDemagnetizedField.h"
9 #include "MPI_CoreToCoreIMessage.h"
12 #include "SMOMPI_NoMasterMacroCellsNetwork.h"
32 static constexpr tMPITag TAG_P=99;
34 static constexpr tMPITag TAG_M=98;
39 std::valarray<tMPIRequest> mReceiveRequests;
40 std::valarray<tMPIRequest> mSendRequests;
43 tMPIInteger mIsAvaliable;
44 tMPICount mValuesNumber;
46 std::map<tMPICoreId,tBoolean> mIsDataReceivedFromCore;
49 tInteger mNeighborCoresNumber;
52 std::valarray<tReal> mMp_values;
55 std::valarray<tReal> mP_values;
63 mNeighborCoresNumber=0;
82 inline static CORE_UniquePointer<SelfClass>
New() {
83 return CORE_UniquePointer<SelfClass>(
new SelfClass(),
90 virtual CORE_UniquePointer<SM_MacroCellsDemagnetizedField>
newInstance()
const override {
91 CORE_UniquePointer<SelfClass> p=
New();
123 mem+=mReceiveRequests.size()*
sizeof(tMPIRequest);
124 mem+=mSendRequests.size()*
sizeof(tMPIRequest);
125 mem+=mMp_values.size()*
sizeof(tReal);
126 mem+=mP_values.size()*
sizeof(tReal);
127 mem+=mIsDataReceivedFromCore.size()*(
sizeof(tMPICoreId)+
sizeof(tBoolean));
159 mNeighborCoresNumber=coresNumber;
160 mNeighborCoresNumber--;
163 mSendRequests.resize(2*mNeighborCoresNumber);
164 mReceiveRequests.resize(2);
176 "SMOMPI_NoMasterMacroCellsDemagnetizedField::computeMatrix()",
177 "method not valid for no master core ");
200 const tReal *vP=
null,*vM=
null;
210 const tMPICoreId& coreId=mpiEnv.
getCoreId();
218 tMPIRequest *iSRequest=&mSendRequests[0];
219 for (c=0;c<coreId;c++) {
228 for (c=coreId+1;c<coresNumber;c++) {
238 mIsDataReceivedFromCore.clear();
249 inline tBoolean waitForDataFromNeighborCores(tMPICoreId& c,tMPICount& nValues,std::valarray<tReal>& Pvalues,std::valarray<tReal>& Mvalues) {
251 if (mIsDataReceivedFromCore.size()==mNeighborCoresNumber)
return false;
262 (mIsDataReceivedFromCore.find(c)==mIsDataReceivedFromCore.end())) {
266 MPI_Environment::GetCount<tReal>(mStatus,nValues);
269 if (((tMPICount)Pvalues.size())<nValues) {
270 Pvalues.resize(nValues);
272 if (((tMPICount)Mvalues.size())<nValues) {
273 Mvalues.resize(nValues);
281 mIsDataReceivedFromCore[c]=
true;
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
tIndex getSize() const
return the number values of the container
Definition: CORE_Field.h:161
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
static void Send(const MPI_Environment &env, const tMPICoreId &dstCore, const T &data, const tMPITag &tag, tMPIRequest &request)
none blocking of sending a data with flag to dstCore
Definition: MPI_CoreToCoreIMessage.h:99
static tBoolean Receive(const MPI_Environment &env, const tMPICoreId &srcCore, T &data, const tMPITag &tag, tMPIRequest &request)
blocking receive a data with tag from source core
Definition: MPI_CoreToCoreIMessage.h:196
This class is a Environment class to define MPI world.
Definition: MPI_Environment.h:36
static tBoolean IsTagMessageAvaliable(const MPI_Environment &env, const tMPITag &tag, tMPICoreId &source, tMPIBoolean &isAvailable, tMPIStatus &status)
test if the message with tag is avalaible
Definition: MPI_Environment.h:437
const tMPICoreId & getCoreId() const
get the id of the current process of this environment
Definition: MPI_Environment.h:200
const tMPICoreId & getCoresNumber() const
get the number of cores of this environment of common environment
Definition: MPI_Environment.h:180
static tBoolean WaitAll(const tMPICount &nRequests, tMPIRequest requests[], tMPIStatus statuses[])
wait the end the the communication by blocking
Definition: MPI_Environment.h:308
static tBoolean IsMessageAvaliable(const MPI_Environment &env, tMPICoreId &source, tMPITag &tag, tMPIBoolean &isAvailable, tMPIStatus &status)
test if a message is available form any tag and any source
Definition: MPI_Environment.h:401
static MPI_Environment & GetEnvironment()
get the environment
Definition: MPI_Run.h:114
This class describes an MPI implementation of the demagnetized field based on no master core.
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:24
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:121
virtual void discretize(const SM_Material &material, const SM_MacroCellsNetwork &network) final
discretize the field
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:144
static CORE_UniquePointer< SelfClass > New()
build a new instance of the operator
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:82
SMOMPI_NoMasterMacroCellsDemagnetizedField(void)
create a network class
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:61
virtual void computeField(const SM_MacroCellsNetwork &network, const SM_MacroCellsMagnetizationField &M) final
compute the demagnetized field on macro cells network
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.cpp:21
virtual ~SMOMPI_NoMasterMacroCellsDemagnetizedField(void)
destroy
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:69
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:109
virtual void computeMatrix(const SM_Material &material, const SM_MacroCellsNetwork &network) final
compute the matrix
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:171
virtual CORE_UniquePointer< SM_MacroCellsDemagnetizedField > newInstance() const override
create a New instance of this
Definition: SMOMPI_NoMasterMacroCellsDemagnetizedField.h:90
This class is describes a demagnetized operator.
Definition: SM_MacroCellsDemagnetizedField.h:50
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_MacroCellsDemagnetizedField.h:141
const tFlag & getStorage() const
yet storage type in {NO_STORAGE,PACKED_STORAGE}
Definition: SM_MacroCellsDemagnetizedField.h:162
virtual void discretize(const SM_Material &material, const SM_MacroCellsNetwork &network)
discretize the field
Definition: SM_MacroCellsDemagnetizedField.cpp:12
This class is describes a Magnetization field.
Definition: SM_MacroCellsMagnetizationField.h:23
This class is describes a macro cell network.
Definition: SM_MacroCellsNetwork.h:25
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61