15 #if !defined(KRATOS_MPI_COMMUNICATOR_H_INCLUDED )
16 #define KRATOS_MPI_COMMUNICATOR_H_INCLUDED
39 #define KRATOS_TIMER_START(t) Timer::Start(t);
40 #define KRATOS_TIMER_STOP(t) Timer::Stop(t);
42 #define KRATOS_TIMER_START(t)
43 #define KRATOS_TIMER_STOP(t)
69 namespace MPIInternals
78 constexpr
static bool IsFixedSize =
true;
79 constexpr
static std::size_t BlockSize = 1;
86 constexpr
static bool IsFixedSize =
true;
87 constexpr
static std::size_t BlockSize = 1;
94 constexpr
static bool IsFixedSize =
true;
95 constexpr
static std::size_t BlockSize = 1;
102 constexpr
static bool IsFixedSize =
true;
103 constexpr
static std::size_t BlockSize = TDim;
110 constexpr
static bool IsFixedSize =
true;
111 constexpr
static std::size_t BlockSize =
sizeof(
Kratos::Flags)/
sizeof(
double);
118 constexpr
static bool IsFixedSize =
false;
122 return rValue.size();
130 constexpr
static bool IsFixedSize =
false;
134 return rValue.data().size();
142 constexpr
static bool IsFixedSize =
true;
143 constexpr
static std::size_t BlockSize = 4;
150 constexpr
static bool IsFixedSize =
false;
154 return rValue.size()*
sizeof(TVectorValue)/
sizeof(
double);
163 constexpr
static bool IsFixedSize =
false;
167 return (rValue.
TotalSize()+1)*
sizeof(char);
175 constexpr
static bool IsFixedSize =
false;
179 return rValue.size();
189 *(ValueType*)(pBuffer) = rValue;
194 rValue = *(
reinterpret_cast<const ValueType*
>(pBuffer));
204 std::memcpy(pBuffer, &(rValue.data()[0]), rValue.data().size()*
sizeof(
double));
209 std::memcpy(&(rValue.data()[0]), pBuffer, rValue.data().size()*
sizeof(
double));
224 template<std::
size_t TDim>
246 *(pBuffer) = rValue.
X();
247 *(pBuffer + 1) = rValue.
Y();
248 *(pBuffer + 2) = rValue.
Z();
249 *(pBuffer + 3) = rValue.
W();
254 rValue.
SetX(*(pBuffer));
255 rValue.
SetY(*(pBuffer + 1));
256 rValue.
SetZ(*(pBuffer + 2));
257 rValue.
SetW(*(pBuffer + 3));
261 template<
typename TVectorValue>
268 std::memcpy(pBuffer, &(rValue.data()[0]), rValue.size()*
sizeof(TVectorValue));
273 std::size_t position = 0;
274 for (
unsigned int i = 0;
i < rValue.size();
i++)
276 rValue[
i] = *(
reinterpret_cast<const TVectorValue*
>(pBuffer + position));
277 position +=
sizeof(TVectorValue) /
sizeof(
double);
288 std::memcpy(pBuffer, rValue.
Data(), rValue.
TotalSize() *
sizeof(
double));
293 std::memcpy(rValue.
Data(), pBuffer, rValue.
TotalSize() *
sizeof(
double));
304 for (
auto i_dof = rValue.begin(); i_dof != rValue.end(); ++i_dof)
306 *(pBuffer +
i) = (*i_dof)->EquationId();
314 for (
auto i_dof = rValue.begin(); i_dof != rValue.end(); ++i_dof)
316 (*i_dof)->SetEquationId(*(pBuffer +
i));
323 class TDatabaseAccess,
324 bool IsFixedSize = SendTraits<typename TDatabaseAccess::ValueType>::IsFixedSize >
331 template<
class TDatabaseAccess>
336 const auto& r_container = rAccess.GetContainer(rSourceMesh);
337 std::size_t num_objects = r_container.size();
347 template<
class TDatabaseAccess>
352 const auto& r_container = rAccess.GetContainer(rSourceMesh);
353 std::size_t buffer_size = 0;
354 for (
auto iter = r_container.begin(); iter != r_container.end(); ++iter)
377 return rMesh.
Nodes();
382 return rMesh.
Nodes();
415 mrVariable(mrVariable)
420 return iter->FastGetSolutionStepValue(mrVariable);
425 return iter->FastGetSolutionStepValue(mrVariable);
440 mrVariable(mrVariable)
445 return iter->GetValue(mrVariable);
450 return iter->GetValue(mrVariable);
488 return iter->SolutionStepData();
493 return iter->SolutionStepData();
506 return iter->GetDofs();
511 return iter->GetDofs();
526 mrVariable(mrVariable)
531 return iter->GetValue(mrVariable);
536 return iter->GetValue(mrVariable);
571 enum class DistributedType {
577 template<DistributedType TDistributed>
struct MeshAccess
579 constexpr
static DistributedType Value = TDistributed;
582 enum class OperationType {
595 template<OperationType TOperation>
struct Operation
597 constexpr
static OperationType Value = TOperation;
716 , mpVariables_list(pVariablesList)
725 , mpVariables_list(rOther.mpVariables_list)
734 return Kratos::make_shared<MPICommunicator>(mpVariables_list, rDataCommunicator);
764 constexpr MeshAccess<DistributedType::Local> local_meshes;
765 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
766 constexpr Operation<OperationType::Replace> replace;
769 TransferDistributedValuesUnknownSize(local_meshes, ghost_meshes, nodal_solution_step_access, replace);
776 constexpr MeshAccess<DistributedType::Local> local_meshes;
777 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
778 constexpr Operation<OperationType::Replace> replace;
781 TransferDistributedValues(local_meshes, ghost_meshes, dof_id_access, replace);
789 SynchronizeFixedSizeValues(solution_step_value_access);
796 SynchronizeFixedSizeValues(solution_step_value_access);
803 SynchronizeFixedSizeValues(solution_step_value_access);
810 SynchronizeFixedSizeValues(solution_step_value_access);
817 SynchronizeFixedSizeValues(solution_step_value_access);
824 SynchronizeFixedSizeValues(solution_step_value_access);
831 SynchronizeFixedSizeValues(solution_step_value_access);
838 SynchronizeDynamicVectorValues(solution_step_value_access);
845 SynchronizeDynamicMatrixValues(solution_step_value_access);
852 SynchronizeFixedSizeValues(solution_step_value_access);
859 SynchronizeFixedSizeValues(nodal_data_access);
866 SynchronizeFixedSizeValues(nodal_data_access);
873 SynchronizeFixedSizeValues(nodal_data_access);
880 SynchronizeFixedSizeValues(nodal_data_access);
887 SynchronizeFixedSizeValues(nodal_data_access);
894 SynchronizeFixedSizeValues(nodal_data_access);
901 SynchronizeFixedSizeValues(nodal_data_access);
908 SynchronizeDynamicVectorValues(nodal_data_access);
915 SynchronizeDynamicMatrixValues(nodal_data_access);
922 SynchronizeFixedSizeValues(nodal_data_access);
928 constexpr MeshAccess<DistributedType::Local> local_meshes;
929 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
930 constexpr Operation<OperationType::Replace> replace;
931 constexpr Operation<OperationType::MaxValues>
max;
935 TransferDistributedValues(ghost_meshes, local_meshes, nodal_solution_step_access,
max);
938 TransferDistributedValues(local_meshes, ghost_meshes, nodal_solution_step_access, replace);
945 constexpr MeshAccess<DistributedType::Local> local_meshes;
946 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
947 constexpr Operation<OperationType::Replace> replace;
948 constexpr Operation<OperationType::MaxValues>
max;
952 TransferDistributedValues(ghost_meshes, local_meshes, nodal_data_access,
max);
955 TransferDistributedValues(local_meshes, ghost_meshes, nodal_data_access, replace);
962 constexpr MeshAccess<DistributedType::Local> local_meshes;
963 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
964 constexpr Operation<OperationType::Replace> replace;
965 constexpr Operation<OperationType::AbsMaxValues>
max;
969 TransferDistributedValues(ghost_meshes, local_meshes, nodal_solution_step_access,
max);
972 TransferDistributedValues(local_meshes, ghost_meshes, nodal_solution_step_access, replace);
979 constexpr MeshAccess<DistributedType::Local> local_meshes;
980 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
981 constexpr Operation<OperationType::Replace> replace;
982 constexpr Operation<OperationType::AbsMaxValues>
max;
986 TransferDistributedValues(ghost_meshes, local_meshes, nodal_data_access,
max);
989 TransferDistributedValues(local_meshes, ghost_meshes, nodal_data_access, replace);
996 constexpr MeshAccess<DistributedType::Local> local_meshes;
997 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
998 constexpr Operation<OperationType::Replace> replace;
999 constexpr Operation<OperationType::MinValues>
min;
1003 TransferDistributedValues(ghost_meshes, local_meshes, nodal_solution_step_access,
min);
1006 TransferDistributedValues(local_meshes, ghost_meshes, nodal_solution_step_access, replace);
1013 constexpr MeshAccess<DistributedType::Local> local_meshes;
1014 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1015 constexpr Operation<OperationType::Replace> replace;
1016 constexpr Operation<OperationType::MinValues>
min;
1020 TransferDistributedValues(ghost_meshes, local_meshes, nodal_data_access,
min);
1023 TransferDistributedValues(local_meshes, ghost_meshes, nodal_data_access, replace);
1030 constexpr MeshAccess<DistributedType::Local> local_meshes;
1031 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1032 constexpr Operation<OperationType::Replace> replace;
1033 constexpr Operation<OperationType::AbsMinValues>
min;
1037 TransferDistributedValues(ghost_meshes, local_meshes, nodal_solution_step_access,
min);
1040 TransferDistributedValues(local_meshes, ghost_meshes, nodal_solution_step_access, replace);
1047 constexpr MeshAccess<DistributedType::Local> local_meshes;
1048 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1049 constexpr Operation<OperationType::Replace> replace;
1050 constexpr Operation<OperationType::AbsMinValues>
min;
1054 TransferDistributedValues(ghost_meshes, local_meshes, nodal_data_access,
min);
1057 TransferDistributedValues(local_meshes, ghost_meshes, nodal_data_access, replace);
1065 AssembleFixedSizeValues(solution_step_access);
1072 AssembleFixedSizeValues(solution_step_access);
1079 AssembleFixedSizeValues(solution_step_access);
1086 AssembleDynamicVectorValues(solution_step_access);
1093 AssembleDynamicMatrixValues(solution_step_access);
1100 AssembleFixedSizeValues(nodal_data_access);
1107 AssembleFixedSizeValues(nodal_data_access);
1114 AssembleFixedSizeValues(nodal_data_access);
1121 AssembleDynamicVectorValues(nodal_data_access);
1128 AssembleDynamicVectorValues(nodal_data_access);
1135 AssembleDynamicMatrixValues(nodal_data_access);
1144 SynchronizeFixedSizeValues(elemental_data_access);
1151 SynchronizeFixedSizeValues(elemental_data_access);
1158 SynchronizeFixedSizeValues(elemental_data_access);
1165 AssembleDynamicVectorValues(elemental_data_access);
1172 AssembleDynamicVectorValues(elemental_data_access);
1179 SynchronizeDynamicVectorValues(elemental_data_access);
1186 SynchronizeDynamicMatrixValues(elemental_data_access);
1197 bool TransferObjects(std::vector<NodesContainerType>& SendObjects, std::vector<NodesContainerType>& RecvObjects)
override
1199 AsyncSendAndReceiveObjects<NodesContainerType>(SendObjects,RecvObjects);
1208 bool TransferObjects(std::vector<ElementsContainerType>& SendObjects, std::vector<ElementsContainerType>& RecvObjects)
override
1210 AsyncSendAndReceiveObjects<ElementsContainerType>(SendObjects,RecvObjects);
1219 bool TransferObjects(std::vector<ConditionsContainerType>& SendObjects, std::vector<ConditionsContainerType>& RecvObjects)
override
1221 AsyncSendAndReceiveObjects<ConditionsContainerType>(SendObjects,RecvObjects);
1232 AsyncSendAndReceiveObjects<NodesContainerType>(SendObjects,RecvObjects);
1243 AsyncSendAndReceiveObjects<ElementsContainerType>(SendObjects,RecvObjects);
1254 AsyncSendAndReceiveObjects<ConditionsContainerType>(SendObjects,RecvObjects);
1264 constexpr MeshAccess<DistributedType::Local> local_meshes;
1265 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1267 constexpr Operation<OperationType::OrAccessedFlags> or_accessed;
1268 constexpr Operation<OperationType::ReplaceAccessedFlags> replace_accessed;
1270 TransferDistributedValues(ghost_meshes, local_meshes, nodal_flag_access, or_accessed);
1272 TransferDistributedValues(local_meshes, ghost_meshes, nodal_flag_access, replace_accessed);
1282 constexpr MeshAccess<DistributedType::Local> local_meshes;
1283 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1285 constexpr Operation<OperationType::AndAccessedFlags> and_accessed;
1286 constexpr Operation<OperationType::ReplaceAccessedFlags> replace_accessed;
1288 TransferDistributedValues(ghost_meshes, local_meshes, nodal_flag_access, and_accessed);
1290 TransferDistributedValues(local_meshes, ghost_meshes, nodal_flag_access, replace_accessed);
1296 constexpr MeshAccess<DistributedType::Local> local_meshes;
1297 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1299 constexpr Operation<OperationType::Replace> replace;
1301 TransferDistributedValues(local_meshes, ghost_meshes, nodal_flags_access, replace);
1307 constexpr MeshAccess<DistributedType::Local> local_meshes;
1308 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1310 constexpr Operation<OperationType::Replace> replace;
1312 TransferDistributedValues(local_meshes, ghost_meshes, elemental_flags_access, replace);
1336 return "MPICommunicator";
1411 for (
int proc_id = 0; proc_id < nproc; proc_id++)
1413 if (proc_id == rank)
1416 for (
int i_color = 0; i_color < static_cast<int>(neighbours_indices.size()); i_color++)
1418 if ((neighbours_indices[i_color]) >= 0)
1422 std::string
tag =
"Local nodes in rank ";
1423 PrintNodesId(r_local_nodes,
tag, i_color);
1424 tag =
"Ghost nodes in rank ";
1425 PrintNodesId(r_ghost_nodes,
tag, i_color);
1426 tag =
"Interface nodes in rank ";
1436 template<
class TNodesArrayType>
1437 void PrintNodesId(TNodesArrayType& rNodes,
const std::string& Tag,
int color)
1440 std::cout << Tag << rank <<
" with color " <<
color <<
":";
1441 for (
typename TNodesArrayType::iterator i_node = rNodes.begin(); i_node != rNodes.end(); i_node++)
1442 std::cout << i_node->Id() <<
", ";
1444 std::cout << std::endl;
1447 template<
class TObjectType>
1448 bool AsyncSendAndReceiveObjects(std::vector<TObjectType>& SendObjects, std::vector<TObjectType>& RecvObjects)
1455 int * msgSendSize =
new int[mpi_size];
1456 int * msgRecvSize =
new int[mpi_size];
1458 char ** message =
new char * [mpi_size];
1459 char ** mpi_send_buffer =
new char * [mpi_size];
1461 for(
int i = 0;
i < mpi_size;
i++)
1467 for(
int i = 0;
i < mpi_size;
i++)
1473 serializer.
save(
"VariableList",mpVariables_list);
1476 std::stringstream * stream = (std::stringstream *)serializer.
pGetBuffer();
1477 const std::string & stream_str = stream->str();
1478 const char * cstr = stream_str.c_str();
1480 msgSendSize[
i] =
sizeof(char) * (stream_str.size()+1);
1481 mpi_send_buffer[
i] = (
char *)malloc(msgSendSize[
i]);
1482 memcpy(mpi_send_buffer[
i],cstr,msgSendSize[
i]);
1486 MPI_Alltoall(msgSendSize,1,MPI_INT,msgRecvSize,1,MPI_INT,comm);
1488 int NumberOfCommunicationEvents = 0;
1489 int NumberOfCommunicationEventsIndex = 0;
1491 for(
int j = 0;
j < mpi_size;
j++)
1493 if(
j != mpi_rank && msgRecvSize[
j]) NumberOfCommunicationEvents++;
1494 if(
j != mpi_rank && msgSendSize[
j]) NumberOfCommunicationEvents++;
1497 MPI_Request * reqs =
new MPI_Request[NumberOfCommunicationEvents];
1498 MPI_Status * stats =
new MPI_Status[NumberOfCommunicationEvents];
1501 for(
int i = 0;
i < mpi_size;
i++)
1503 if(
i != mpi_rank && msgRecvSize[
i])
1505 message[
i] = (
char *)malloc(
sizeof(
char) * msgRecvSize[
i]);
1507 MPI_Irecv(message[
i],msgRecvSize[
i],MPI_CHAR,
i,0,comm,&reqs[NumberOfCommunicationEventsIndex++]);
1510 if(
i != mpi_rank && msgSendSize[
i])
1512 MPI_Isend(mpi_send_buffer[
i],msgSendSize[
i],MPI_CHAR,
i,0,comm,&reqs[NumberOfCommunicationEventsIndex++]);
1517 int err = MPI_Waitall(NumberOfCommunicationEvents, reqs, stats);
1519 KRATOS_ERROR_IF(err != MPI_SUCCESS) <<
"Error in MPICommunicator asynchronous data transfer" << std::endl;
1523 for(
int i = 0;
i < mpi_size;
i++)
1525 if (
i != mpi_rank && msgRecvSize[
i])
1528 std::stringstream * serializer_buffer;
1530 serializer_buffer = (std::stringstream *)serializer.
pGetBuffer();
1531 serializer_buffer->write(message[
i], msgRecvSize[
i]);
1533 VariablesList* tmp_mpVariables_list = NULL;
1535 serializer.
load(
"VariableList",tmp_mpVariables_list);
1537 if(tmp_mpVariables_list != NULL)
1538 delete tmp_mpVariables_list;
1539 tmp_mpVariables_list = mpVariables_list;
1548 for(
int i = 0;
i < mpi_size;
i++)
1554 free(mpi_send_buffer[
i]);
1561 delete [] mpi_send_buffer;
1563 delete [] msgSendSize;
1564 delete [] msgRecvSize;
1569 template<
class TDatabaseAccess>
1570 void SynchronizeFixedSizeValues(TDatabaseAccess& rVariableAccess)
1572 constexpr MeshAccess<DistributedType::Local> local_meshes;
1573 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1574 constexpr Operation<OperationType::Replace> replace;
1576 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1579 template<
class TDatabaseAccess>
1580 void SynchronizeDynamicVectorValues(TDatabaseAccess& rVariableAccess)
1582 constexpr MeshAccess<DistributedType::Local> local_meshes;
1583 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1584 constexpr Operation<OperationType::Replace> replace;
1587 MatchDynamicVectorSizes(local_meshes, ghost_meshes, rVariableAccess);
1590 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1593 template<
class TDatabaseAccess>
1594 void SynchronizeDynamicMatrixValues(TDatabaseAccess& rVariableAccess)
1596 constexpr MeshAccess<DistributedType::Local> local_meshes;
1597 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1598 constexpr Operation<OperationType::Replace> replace;
1601 MatchDynamicMatrixSizes(local_meshes, ghost_meshes, rVariableAccess);
1604 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1607 template<
class TDatabaseAccess>
1608 void AssembleFixedSizeValues(TDatabaseAccess& rVariableAccess)
1610 constexpr MeshAccess<DistributedType::Local> local_meshes;
1611 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1612 constexpr Operation<OperationType::Replace> replace;
1613 constexpr Operation<OperationType::SumValues>
sum;
1616 TransferDistributedValues(ghost_meshes, local_meshes, rVariableAccess,
sum);
1619 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1622 template<
class TDatabaseAccess>
1623 void AssembleDynamicVectorValues(TDatabaseAccess& rVariableAccess)
1625 constexpr MeshAccess<DistributedType::Local> local_meshes;
1626 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1627 constexpr Operation<OperationType::Replace> replace;
1628 constexpr Operation<OperationType::SumValues>
sum;
1631 MatchDynamicVectorSizes(ghost_meshes, local_meshes, rVariableAccess);
1634 MatchDynamicVectorSizes(local_meshes, ghost_meshes, rVariableAccess);
1639 TransferDistributedValues(ghost_meshes, local_meshes, rVariableAccess,
sum);
1642 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1645 template<
class TDatabaseAccess>
1646 void AssembleDynamicMatrixValues(TDatabaseAccess& rVariableAccess)
1648 constexpr MeshAccess<DistributedType::Local> local_meshes;
1649 constexpr MeshAccess<DistributedType::Ghost> ghost_meshes;
1650 constexpr Operation<OperationType::Replace> replace;
1651 constexpr Operation<OperationType::SumValues>
sum;
1654 MatchDynamicMatrixSizes(ghost_meshes, local_meshes, rVariableAccess);
1657 MatchDynamicMatrixSizes(local_meshes, ghost_meshes, rVariableAccess);
1662 TransferDistributedValues(ghost_meshes, local_meshes, rVariableAccess,
sum);
1665 TransferDistributedValues(local_meshes, ghost_meshes, rVariableAccess, replace);
1678 template<
class TDatabaseAccess>
1679 std::size_t ReduceValues(
1680 const typename TDatabaseAccess::SendType* pBuffer,
1681 TDatabaseAccess& rAccess,
1683 Operation<OperationType::Replace>)
1688 using ValueType =
typename TDatabaseAccess::ValueType;
1689 auto& r_destination = rAccess.GetValue(ContainerIterator);
1690 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, r_destination);
1695 template<
class TDatabaseAccess>
1696 std::size_t ReduceValues(
1697 const typename TDatabaseAccess::SendType* pBuffer,
1698 TDatabaseAccess& rAccess,
1700 Operation<OperationType::SumValues>)
1702 using ValueType =
typename TDatabaseAccess::ValueType;
1703 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1704 ValueType recv_value(r_current);
1705 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1706 r_current += recv_value;
1711 template<
class TDatabaseAccess>
1712 std::size_t ReduceValues(
1713 const typename TDatabaseAccess::SendType* pBuffer,
1714 TDatabaseAccess& rAccess,
1716 Operation<OperationType::MaxValues>)
1718 using ValueType =
typename TDatabaseAccess::ValueType;
1719 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1720 ValueType recv_value(r_current);
1721 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1722 if (recv_value > r_current) r_current = recv_value;
1727 template<
class TDatabaseAccess>
1728 std::size_t ReduceValues(
1729 const typename TDatabaseAccess::SendType* pBuffer,
1730 TDatabaseAccess& rAccess,
1732 Operation<OperationType::AbsMaxValues>)
1734 using ValueType =
typename TDatabaseAccess::ValueType;
1735 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1736 ValueType recv_value(r_current);
1737 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1738 if (std::abs(recv_value) > std::abs(r_current)) r_current = recv_value;
1743 template<
class TDatabaseAccess>
1744 std::size_t ReduceValues(
1745 const typename TDatabaseAccess::SendType* pBuffer,
1746 TDatabaseAccess& rAccess,
1748 Operation<OperationType::MinValues>)
1750 using ValueType =
typename TDatabaseAccess::ValueType;
1751 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1752 ValueType recv_value(r_current);
1753 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1754 if (recv_value < r_current) r_current = recv_value;
1759 template<
class TDatabaseAccess>
1760 std::size_t ReduceValues(
1761 const typename TDatabaseAccess::SendType* pBuffer,
1762 TDatabaseAccess& rAccess,
1764 Operation<OperationType::AbsMinValues>)
1766 using ValueType =
typename TDatabaseAccess::ValueType;
1767 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1768 ValueType recv_value(r_current);
1769 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1770 if (std::abs(recv_value) < std::abs(r_current)) r_current = recv_value;
1775 template<
class TDatabaseAccess>
1776 std::size_t ReduceValues(
1777 const typename TDatabaseAccess::SendType* pBuffer,
1778 TDatabaseAccess& rAccess,
1780 Operation<OperationType::AndAccessedFlags>)
1782 using ValueType =
typename TDatabaseAccess::ValueType;
1783 ValueType recv_value;
1784 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1785 rAccess.GetValue(ContainerIterator) &= recv_value | ~rAccess.mrMask;
1790 template<
class TDatabaseAccess>
1791 std::size_t ReduceValues(
1792 const typename TDatabaseAccess::SendType* pBuffer,
1793 TDatabaseAccess& rAccess,
1795 Operation<OperationType::OrAccessedFlags>)
1797 using ValueType =
typename TDatabaseAccess::ValueType;
1798 ValueType recv_value;
1799 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1800 rAccess.GetValue(ContainerIterator) |= recv_value & rAccess.mrMask;
1805 template<
class TDatabaseAccess>
1806 std::size_t ReduceValues(
1807 const typename TDatabaseAccess::SendType* pBuffer,
1808 TDatabaseAccess& rAccess,
1810 Operation<OperationType::ReplaceAccessedFlags>)
1812 using ValueType =
typename TDatabaseAccess::ValueType;
1813 ValueType recv_value;
1814 MPIInternals::SendTools<ValueType>::ReadBuffer(pBuffer, recv_value);
1816 ValueType& r_current = rAccess.GetValue(ContainerIterator);
1817 r_current.AssignFlags( (recv_value & rAccess.mrMask) | (r_current & ~rAccess.mrMask) );
1823 typename TSourceAccess,
1824 typename TDestinationAccess,
1825 class TDatabaseAccess,
1826 typename TReductionOperation>
1827 void TransferDistributedValues(
1828 TSourceAccess SourceType,
1829 TDestinationAccess DestinationType,
1830 TDatabaseAccess& rAccess,
1831 TReductionOperation Reduction)
1833 using DataType =
typename TDatabaseAccess::ValueType;
1834 using BufferType =
typename MPIInternals::SendTraits<DataType>::BufferType;
1835 int destination = 0;
1839 BufferType send_values;
1840 BufferType recv_values;
1842 for (
unsigned int i_color = 0; i_color < neighbour_indices.size(); i_color++)
1844 if ( (destination = neighbour_indices[i_color]) >= 0)
1846 MeshType& r_source_mesh = GetMesh(i_color, SourceType);
1847 AllocateBuffer(send_values, r_source_mesh, rAccess);
1849 MeshType& r_destination_mesh = GetMesh(i_color, DestinationType);
1850 AllocateBuffer(recv_values, r_destination_mesh, rAccess);
1852 if ( (send_values.size() == 0) && (recv_values.size() == 0) )
1857 FillBuffer(send_values, r_source_mesh, rAccess);
1860 send_values, destination, i_color,
1861 recv_values, destination, i_color);
1863 UpdateValues(recv_values, r_destination_mesh, rAccess, Reduction);
1869 typename TSourceAccess,
1870 typename TDestinationAccess,
1871 class TDatabaseAccess,
1872 typename TReductionOperation>
1873 void TransferDistributedValuesUnknownSize(
1874 TSourceAccess SourceType,
1875 TDestinationAccess DestinationType,
1876 TDatabaseAccess& rAccess,
1877 TReductionOperation Reduction)
1879 using DataType =
typename TDatabaseAccess::ValueType;
1880 using BufferType =
typename MPIInternals::SendTraits<DataType>::BufferType;
1881 int destination = 0;
1885 BufferType send_values;
1886 BufferType recv_values;
1888 for (
unsigned int i_color = 0; i_color < neighbour_indices.size(); i_color++)
1890 if ( (destination = neighbour_indices[i_color]) >= 0)
1892 MeshType& r_source_mesh = GetMesh(i_color, SourceType);
1893 MeshType& r_destination_mesh = GetMesh(i_color, DestinationType);
1895 FillBuffer(send_values, r_source_mesh, rAccess);
1897 std::vector<int> send_size{(
int)send_values.size()};
1898 std::vector<int> recv_size{0};
1901 send_size, destination, i_color,
1902 recv_size, destination, i_color);
1904 recv_values.resize(recv_size[0]);
1906 if ( (send_values.size() == 0) && (recv_values.size() == 0) )
1912 send_values, destination, i_color,
1913 recv_values, destination, i_color);
1915 UpdateValues(recv_values, r_destination_mesh, rAccess, Reduction);
1921 class TDatabaseAccess,
1922 typename TValue =
typename TDatabaseAccess::ValueType,
1923 typename TSendType =
typename MPIInternals::SendTraits<TValue>::SendType>
1924 void AllocateBuffer(std::vector<TSendType>& rBuffer,
const MeshType& rSourceMesh, TDatabaseAccess& rAccess)
1928 if (rBuffer.size() != buffer_size)
1930 rBuffer.resize(buffer_size);
1935 class TDatabaseAccess,
1936 typename TValue =
typename TDatabaseAccess::ValueType,
1937 typename TSendType =
typename MPIInternals::SendTraits<TValue>::SendType>
1938 void FillBuffer(std::vector<TSendType>& rBuffer,
MeshType& rSourceMesh, TDatabaseAccess& rAccess)
1940 auto& r_container = rAccess.GetContainer(rSourceMesh);
1941 TSendType* p_buffer = rBuffer.data();
1942 std::size_t position = 0;
1943 for (
auto iter = r_container.begin(); iter != r_container.end(); ++iter)
1945 TValue& r_value = rAccess.GetValue(iter);
1946 MPIInternals::SendTools<TValue>::WriteBuffer(r_value, p_buffer + position);
1952 class TDatabaseAccess,
1953 typename TValue =
typename TDatabaseAccess::ValueType>
1954 void FillBuffer(std::string& rBuffer,
MeshType& rSourceMesh, TDatabaseAccess& rAccess)
1956 StreamSerializer serializer;
1957 auto& r_container = rAccess.GetContainer(rSourceMesh);
1959 for (
auto iter = r_container.begin(); iter != r_container.end(); ++iter)
1961 TValue& r_value = rAccess.GetValue(iter);
1962 serializer.
save(
"Value", r_value);
1965 rBuffer = serializer.GetStringRepresentation();
1969 class TDatabaseAccess,
1970 typename TReductionOperation,
1971 typename TValue =
typename TDatabaseAccess::ValueType,
1972 typename TSendType =
typename MPIInternals::SendTraits<TValue>::SendType>
1974 const std::vector<TSendType>& rBuffer,
1976 TDatabaseAccess& rAccess,
1977 TReductionOperation Operation)
1979 auto& r_container = rAccess.GetContainer(rSourceMesh);
1980 const TSendType* p_buffer = rBuffer.data();
1981 std::size_t position = 0;
1983 for (
auto iter = r_container.begin(); iter != r_container.end(); ++iter)
1985 position += ReduceValues(p_buffer + position, rAccess, iter, Operation);
1990 <<
"Error in estimating receive buffer size." << std::endl;
1994 class TDatabaseAccess,
1995 typename TValue =
typename TDatabaseAccess::ValueType>
1997 const std::string& rBuffer,
1999 TDatabaseAccess& rAccess,
2000 Operation<OperationType::Replace>)
2002 StreamSerializer serializer;
2003 std::stringstream* serializer_buffer = (std::stringstream *)serializer.pGetBuffer();
2004 serializer_buffer->write(rBuffer.data(), rBuffer.size());
2006 auto& r_container = rAccess.GetContainer(rSourceMesh);
2007 for (
auto iter = r_container.begin(); iter != r_container.end(); ++iter)
2009 serializer.load(
"Value", rAccess.GetValue(iter));
2014 typename TSourceAccess,
2015 typename TDestinationAccess,
2016 class TDatabaseAccess>
2017 void MatchDynamicVectorSizes(
2018 TSourceAccess SourceType,
2019 TDestinationAccess DestinationType,
2020 TDatabaseAccess& rAccess)
2022 using TVectorType =
typename TDatabaseAccess::ValueType;
2023 int destination = 0;
2027 std::vector<int> send_sizes;
2028 std::vector<int> recv_sizes;
2030 bool resize_error =
false;
2031 std::stringstream error_detail;
2033 for (
unsigned int i_color = 0; i_color < neighbour_indices.size(); i_color++)
2035 if ( (destination = neighbour_indices[i_color]) >= 0)
2037 MeshType& r_source_mesh = GetMesh(i_color, SourceType);
2038 const auto& r_source_container = rAccess.GetContainer(r_source_mesh);
2039 const std::size_t num_values_to_send = r_source_container.size();
2041 MeshType& r_destination_mesh = GetMesh(i_color, DestinationType);
2042 auto& r_destination_container = rAccess.GetContainer(r_destination_mesh);
2043 const std::size_t num_values_to_recv = r_destination_container.size();
2045 if ( (num_values_to_send == 0) && (num_values_to_recv == 0) )
2050 if (send_sizes.size() != num_values_to_send)
2052 send_sizes.resize(num_values_to_send);
2055 if (recv_sizes.size() != num_values_to_recv)
2057 recv_sizes.resize(num_values_to_recv);
2061 for (
auto iter = r_source_container.begin(); iter != r_source_container.end(); ++iter)
2063 const TVectorType& r_value = rAccess.GetValue(iter);
2064 send_sizes[position++] = r_value.size();
2068 send_sizes, destination, i_color,
2069 recv_sizes, destination, i_color);
2072 for (
auto iter = r_destination_container.begin(); iter != r_destination_container.end(); ++iter)
2074 std::size_t source_size = recv_sizes[position++];
2075 if (source_size != 0)
2077 TVectorType& r_value = rAccess.GetValue(iter);
2078 if (r_value.size() == source_size)
2082 else if (r_value.size() == 0)
2084 r_value.resize(source_size,
false);
2088 resize_error =
true;
2091 <<
"local size: " << r_value.size() <<
" "
2092 <<
"source size: " << source_size <<
"." << std::endl;
2100 <<
"Size mismatch in Vector size synchronization." << std::endl
2101 << error_detail.str();
2105 typename TSourceAccess,
2106 typename TDestinationAccess,
2107 class TDatabaseAccess>
2108 void MatchDynamicMatrixSizes(
2109 TSourceAccess SourceType,
2110 TDestinationAccess DestinationType,
2111 TDatabaseAccess& rAccess)
2113 using TMatrixType =
typename TDatabaseAccess::ValueType;
2114 int destination = 0;
2118 std::vector<int> send_sizes;
2119 std::vector<int> recv_sizes;
2121 bool resize_error =
false;
2122 std::stringstream error_detail;
2124 for (
unsigned int i_color = 0; i_color < neighbour_indices.size(); i_color++)
2126 if ( (destination = neighbour_indices[i_color]) >= 0)
2128 MeshType& r_source_mesh = GetMesh(i_color, SourceType);
2129 const auto& r_source_container = rAccess.GetContainer(r_source_mesh);
2130 const std::size_t num_values_to_send = 2*r_source_container.size();
2132 MeshType& r_destination_mesh = GetMesh(i_color, DestinationType);
2133 auto& r_destination_container = rAccess.GetContainer(r_destination_mesh);
2134 const std::size_t num_values_to_recv = 2*r_destination_container.size();
2136 if ( (num_values_to_send == 0) && (num_values_to_recv == 0) )
2141 if (send_sizes.size() != num_values_to_send)
2143 send_sizes.resize(num_values_to_send);
2146 if (recv_sizes.size() != num_values_to_recv)
2148 recv_sizes.resize(num_values_to_recv);
2152 for (
auto iter = r_source_container.begin(); iter != r_source_container.end(); ++iter)
2154 const TMatrixType& r_value = rAccess.GetValue(iter);
2155 send_sizes[position++] = r_value.size1();
2156 send_sizes[position++] = r_value.size2();
2160 send_sizes, destination, i_color,
2161 recv_sizes, destination, i_color);
2164 for (
auto iter = r_destination_container.begin(); iter != r_destination_container.end(); ++iter)
2166 std::size_t source_size_1 = recv_sizes[position++];
2167 std::size_t source_size_2 = recv_sizes[position++];
2168 if (source_size_1 != 0 && source_size_2 != 0)
2170 TMatrixType& r_value = rAccess.GetValue(iter);
2171 if (r_value.size1() == source_size_1 && r_value.size2() == source_size_2)
2175 else if (r_value.size1() == 0 && r_value.size2() == 0)
2177 r_value.resize(source_size_1, source_size_2,
false);
2181 resize_error =
true;
2184 <<
"local size: (" << r_value.size1() <<
"," << r_value.size2() <<
") "
2185 <<
"source size: (" << source_size_1 <<
"," << source_size_2 <<
")." << std::endl;
2193 <<
"Size mismatch in Matrix size synchronization." << std::endl
2194 << error_detail.str();
2237 rOStream << std::endl;
The Commmunicator class manages communication for distributed ModelPart instances.
Definition: communicator.h:67
Communicator::Pointer Create() const
Definition: communicator.cpp:79
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: communicator.cpp:657
NeighbourIndicesContainerType & NeighbourIndices()
Definition: communicator.cpp:162
const DataCommunicator & mrDataCommunicator
Definition: communicator.h:513
MeshType & GhostMesh()
Returns the reference to the mesh storing all ghost entities.
Definition: communicator.cpp:251
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
MeshType & InterfaceMesh()
Returns the reference to the mesh storing all interface entities.
Definition: communicator.cpp:257
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
unsigned int IndexType
Definition: communicator.h:80
virtual void PrintData(std::ostream &rOStream, std::string const &rPrefixString="") const
Print object's data.
Definition: communicator.cpp:662
unsigned int SizeType
Definition: communicator.h:82
Base class for all Conditions.
Definition: condition.h:59
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
virtual bool ErrorIfTrueOnAnyRank(bool Condition) const
This function throws an error on ranks where Condition evaluates to false, if it evaluated to true on...
Definition: data_communicator.h:729
virtual void Barrier() const
Pause program execution until all threads reach this call.
Definition: data_communicator.h:386
virtual int Size() const
Get the parallel size of this DataCommunicator.
Definition: data_communicator.h:597
TObject SendRecv(const TObject &rSendObject, const int SendDestination, const int SendTag, const int RecvSource, const int RecvTag) const
Exchange data with other ranks.
Definition: data_communicator.h:492
virtual int Rank() const
Get the parallel rank for this DataCommunicator.
Definition: data_communicator.h:587
virtual bool IsDistributed() const
Check whether this DataCommunicator is aware of parallelism.
Definition: data_communicator.h:606
Base class for all Elements.
Definition: element.h:60
static const Flags AllDefined()
Definition: flags.h:252
MPICommunicator manages the transfer of ModelPart data in MPI distributed memory environment.
Definition: mpi_communicator.h:569
bool AssembleNonHistoricalData(Variable< DenseVector< array_1d< double, 3 > > > const &ThisVariable) override
Definition: mpi_communicator.h:1118
bool SynchronizeNodalFlags() override
Definition: mpi_communicator.h:1294
Communicator::Pointer Create(const DataCommunicator &rDataCommunicator) const override
Definition: mpi_communicator.h:730
bool SynchronizeVariable(Variable< array_1d< double, 6 > > const &rThisVariable) override
Definition: mpi_communicator.h:821
MPICommunicator & operator=(MPICommunicator const &rOther)=delete
Assignment operator.
bool SynchronizeNonHistoricalVariable(Variable< array_1d< double, 3 > > const &rThisVariable) override
Definition: mpi_communicator.h:877
bool SynchronizeVariable(Variable< array_1d< double, 3 > > const &rThisVariable) override
Definition: mpi_communicator.h:807
bool TransferObjects(std::vector< NodesContainerType > &SendObjects, std::vector< NodesContainerType > &RecvObjects) override
Definition: mpi_communicator.h:1197
BaseType::SizeType SizeType
Definition: mpi_communicator.h:616
bool SynchronizeNonHistoricalVariable(Variable< int > const &rThisVariable) override
Definition: mpi_communicator.h:856
bool SynchronizeNonHistoricalDataToMin(Variable< double > const &ThisVariable) override
Synchronize variable in nodal data to the minimum value across all processes.
Definition: mpi_communicator.h:1011
bool SynchronizeVariable(Variable< int > const &rThisVariable) override
Definition: mpi_communicator.h:786
bool SynchronizeElementalNonHistoricalVariable(Variable< Matrix > const &ThisVariable) override
Definition: mpi_communicator.h:1183
BaseType::ElementType ElementType
Definition: mpi_communicator.h:622
BaseType::PropertiesType PropertiesType
Definition: mpi_communicator.h:620
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: mpi_communicator.h:633
bool SynchronizeNonHistoricalDataToAbsMax(Variable< double > const &ThisVariable) override
Synchronize variable in nodal data to the absolute maximum value across all processes.
Definition: mpi_communicator.h:977
~MPICommunicator() override=default
Destructor.
bool TransferObjects(std::vector< NodesContainerType > &SendObjects, std::vector< NodesContainerType > &RecvObjects, Kratos::Serializer &particleSerializer) override
Definition: mpi_communicator.h:1230
bool AssembleCurrentData(Variable< array_1d< double, 3 > > const &ThisVariable) override
Definition: mpi_communicator.h:1076
std::string Info() const override
Turn back information as a string.
Definition: mpi_communicator.h:1334
bool SynchronizeVariable(Variable< array_1d< double, 4 > > const &rThisVariable) override
Definition: mpi_communicator.h:814
bool SynchronizeElementalNonHistoricalVariable(Variable< DenseVector< array_1d< double, 3 > > > const &ThisVariable) override
Definition: mpi_communicator.h:1162
KRATOS_DEPRECATED_MESSAGE("This constructor is deprecated, please use the one that accepts a DataCommunicator") MPICommunicator(VariablesList *Variables_list)
Constructor using the VariablesList of the ModelPart that will use this communicator.
Definition: mpi_communicator.h:707
bool SynchronizeElementalNonHistoricalVariable(Variable< int > const &ThisVariable) override
Definition: mpi_communicator.h:1141
bool TransferObjects(std::vector< ConditionsContainerType > &SendObjects, std::vector< ConditionsContainerType > &RecvObjects) override
Definition: mpi_communicator.h:1219
bool SynchronizeCurrentDataToAbsMax(Variable< double > const &ThisVariable) override
Synchronize variable in nodal solution step data to the absolute maximum value across all processes.
Definition: mpi_communicator.h:960
bool SynchronizeNonHistoricalDataToAbsMin(Variable< double > const &ThisVariable) override
Synchronize variable in nodal data to the absolute minimum value across all processes.
Definition: mpi_communicator.h:1045
bool TransferObjects(std::vector< ConditionsContainerType > &SendObjects, std::vector< ConditionsContainerType > &RecvObjects, Kratos::Serializer &particleSerializer) override
Definition: mpi_communicator.h:1252
bool SynchronizeVariable(Variable< bool > const &rThisVariable) override
Definition: mpi_communicator.h:800
bool SynchronizeDofs() override
Definition: mpi_communicator.h:774
bool IsDistributed() const override
Definition: mpi_communicator.h:753
bool AssembleCurrentData(Variable< Matrix > const &ThisVariable) override
Definition: mpi_communicator.h:1090
bool SynchronizeCurrentDataToMax(Variable< double > const &ThisVariable) override
Synchronize variable in nodal solution step data to the maximum value across all processes.
Definition: mpi_communicator.h:926
Communicator BaseType
Definition: mpi_communicator.h:612
bool SynchronizeVariable(Variable< Matrix > const &rThisVariable) override
Definition: mpi_communicator.h:842
MPICommunicator(MPICommunicator const &rOther)
Copy constructor.
Definition: mpi_communicator.h:723
MeshType::ElementConstantIterator ElementConstantIterator
Definition: mpi_communicator.h:685
bool SynchronizeNonHistoricalDataToMax(Variable< double > const &ThisVariable) override
Synchronize variable in nodal data to the maximum value across all processes.
Definition: mpi_communicator.h:943
bool AssembleNonHistoricalData(Variable< Matrix > const &ThisVariable) override
Definition: mpi_communicator.h:1132
bool SynchronizeNonHistoricalVariable(Variable< bool > const &rThisVariable) override
Definition: mpi_communicator.h:870
MeshType::ConditionIterator ConditionIterator
Definition: mpi_communicator.h:694
bool SynchronizeElementalNonHistoricalVariable(Variable< array_1d< double, 3 > > const &ThisVariable) override
Definition: mpi_communicator.h:1155
bool SynchronizeElementalFlags() override
Definition: mpi_communicator.h:1305
BaseType::NodeType NodeType
Definition: mpi_communicator.h:618
bool SynchronizeNonHistoricalVariable(Variable< double > const &rThisVariable) override
Definition: mpi_communicator.h:863
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: mpi_communicator.h:688
bool AssembleCurrentData(Variable< Vector > const &ThisVariable) override
Definition: mpi_communicator.h:1083
bool SynchronizeCurrentDataToAbsMin(Variable< double > const &ThisVariable) override
Synchronize variable in nodal solution step data to the absolute minimum value across all processes.
Definition: mpi_communicator.h:1028
MPICommunicator(VariablesList *pVariablesList, const DataCommunicator &rDataCommunicator)
Constructor using the VariablesList and a custom DataCommunicator.
Definition: mpi_communicator.h:714
MeshType::PropertiesContainerType PropertiesContainerType
Properties container. Which is a vector set of Properties with their Id's as key.
Definition: mpi_communicator.h:653
BaseType::ConditionType ConditionType
Definition: mpi_communicator.h:624
bool AssembleNonHistoricalData(Variable< int > const &ThisVariable) override
Definition: mpi_communicator.h:1097
bool AssembleNonHistoricalData(Variable< Vector > const &ThisVariable) override
Definition: mpi_communicator.h:1125
bool AssembleCurrentData(Variable< double > const &ThisVariable) override
Definition: mpi_communicator.h:1069
bool SynchronizeNonHistoricalVariable(Variable< array_1d< double, 4 > > const &rThisVariable) override
Definition: mpi_communicator.h:884
bool SynchronizeVariable(Variable< Quaternion< double >> const &rThisVariable) override
Definition: mpi_communicator.h:849
MeshType::NodeIterator NodeIterator
Definition: mpi_communicator.h:639
bool AssembleCurrentData(Variable< int > const &ThisVariable) override
Definition: mpi_communicator.h:1062
bool SynchronizeVariable(Variable< Vector > const &rThisVariable) override
Definition: mpi_communicator.h:835
bool SynchronizeNonHistoricalVariable(Variable< array_1d< double, 6 > > const &rThisVariable) override
Definition: mpi_communicator.h:891
bool SynchronizeCurrentDataToMin(Variable< double > const &ThisVariable) override
Synchronize variable in nodal solution step data to the minimum value across all processes.
Definition: mpi_communicator.h:994
BaseType::IndexType IndexType
Definition: mpi_communicator.h:614
bool SynchronizeElementalNonHistoricalVariable(Variable< double > const &ThisVariable) override
Definition: mpi_communicator.h:1148
MeshType::PropertiesIterator PropertiesIterator
Definition: mpi_communicator.h:659
MeshType::NodeConstantIterator NodeConstantIterator
Definition: mpi_communicator.h:645
BaseType::MeshesContainerType MeshesContainerType
Definition: mpi_communicator.h:630
BaseType::NeighbourIndicesContainerType NeighbourIndicesContainerType
Definition: mpi_communicator.h:626
bool SynchronizeNonHistoricalVariable(Variable< Quaternion< double >> const &rThisVariable) override
Definition: mpi_communicator.h:919
bool SynchronizeAndNodalFlags(const Flags &TheFlags) override
Definition: mpi_communicator.h:1280
MeshType::ElementIterator ElementIterator
Definition: mpi_communicator.h:679
bool AssembleNonHistoricalData(Variable< double > const &ThisVariable) override
Definition: mpi_communicator.h:1104
bool TransferObjects(std::vector< ElementsContainerType > &SendObjects, std::vector< ElementsContainerType > &RecvObjects, Kratos::Serializer &particleSerializer) override
Definition: mpi_communicator.h:1241
bool SynchronizeNonHistoricalVariable(Variable< Matrix > const &rThisVariable) override
Definition: mpi_communicator.h:912
KRATOS_CLASS_POINTER_DEFINITION(MPICommunicator)
Pointer definition of MPICommunicator.
bool SynchronizeNonHistoricalVariable(Variable< array_1d< double, 9 > > const &rThisVariable) override
Definition: mpi_communicator.h:898
bool SynchronizeOrNodalFlags(const Flags &TheFlags) override
Definition: mpi_communicator.h:1262
bool SynchronizeElementalNonHistoricalVariable(Variable< DenseVector< int > > const &ThisVariable) override
Definition: mpi_communicator.h:1169
bool SynchronizeVariable(Variable< double > const &rThisVariable) override
Definition: mpi_communicator.h:793
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: mpi_communicator.h:673
bool SynchronizeElementalNonHistoricalVariable(Variable< Vector > const &ThisVariable) override
Definition: mpi_communicator.h:1176
MeshType::PropertiesConstantIterator PropertiesConstantIterator
Definition: mpi_communicator.h:665
BaseType::MeshType MeshType
Definition: mpi_communicator.h:628
bool TransferObjects(std::vector< ElementsContainerType > &SendObjects, std::vector< ElementsContainerType > &RecvObjects) override
Definition: mpi_communicator.h:1208
bool AssembleNonHistoricalData(Variable< array_1d< double, 3 > > const &ThisVariable) override
Definition: mpi_communicator.h:1111
bool SynchronizeNodalSolutionStepsData() override
Definition: mpi_communicator.h:762
bool SynchronizeVariable(Variable< array_1d< double, 9 > > const &rThisVariable) override
Definition: mpi_communicator.h:828
bool SynchronizeNonHistoricalVariable(Variable< Vector > const &rThisVariable) override
Definition: mpi_communicator.h:905
MeshType::ConditionConstantIterator ConditionConstantIterator
Definition: mpi_communicator.h:700
static MPI_Comm GetMPICommunicator(const DataCommunicator &rDataCommunicator)
Get the underlying MPI_Comm instance.
Definition: mpi_data_communicator.cpp:431
Definition: mpi_communicator.h:498
Node::DofsContainerType ValueType
Definition: mpi_communicator.h:501
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:502
const ValueType & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:509
ValueType & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:504
Definition: mpi_communicator.h:386
const ContainerType & GetContainer(const Communicator::MeshType &rMesh)
Definition: mpi_communicator.h:398
ContainerType & GetContainer(Communicator::MeshType &rMesh)
Definition: mpi_communicator.h:393
Communicator::MeshType::ElementsContainerType::iterator IteratorType
Definition: mpi_communicator.h:390
Communicator::MeshType::ElementsContainerType::const_iterator ConstIteratorType
Definition: mpi_communicator.h:391
Definition: mpi_communicator.h:516
ElementalDataAccess(const Variable< TValue > &mrVariable)
Definition: mpi_communicator.h:524
typename SendTraits< TValue >::SendType SendType
Definition: mpi_communicator.h:522
const TValue & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:534
TValue & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:529
TValue ValueType
Definition: mpi_communicator.h:521
Definition: mpi_communicator.h:541
ElementalFlagsAccess(const Kratos::Flags &rMask)
Definition: mpi_communicator.h:549
Kratos::Flags & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:554
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:547
const Kratos::Flags & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:559
const Kratos::Flags & mrMask
Definition: mpi_communicator.h:544
Definition: mpi_communicator.h:368
Communicator::MeshType::NodesContainerType::const_iterator ConstIteratorType
Definition: mpi_communicator.h:373
ContainerType & GetContainer(Communicator::MeshType &rMesh)
Definition: mpi_communicator.h:375
Communicator::MeshType::NodesContainerType::iterator IteratorType
Definition: mpi_communicator.h:372
const ContainerType & GetContainer(const Communicator::MeshType &rMesh)
Definition: mpi_communicator.h:380
Definition: mpi_communicator.h:430
NodalDataAccess(const Variable< TValue > &mrVariable)
Definition: mpi_communicator.h:438
const TValue & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:448
TValue ValueType
Definition: mpi_communicator.h:435
typename SendTraits< TValue >::SendType SendType
Definition: mpi_communicator.h:436
TValue & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:443
Definition: mpi_communicator.h:455
const Kratos::Flags & mrMask
Definition: mpi_communicator.h:458
Kratos::Flags & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:468
NodalFlagsAccess(const Kratos::Flags &rMask)
Definition: mpi_communicator.h:463
const Kratos::Flags & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:473
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:461
Definition: mpi_communicator.h:480
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:484
ValueType & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:486
const ValueType & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:491
Definition: mpi_communicator.h:405
typename SendTraits< TValue >::SendType SendType
Definition: mpi_communicator.h:411
TValue ValueType
Definition: mpi_communicator.h:410
const TValue & GetValue(const ConstIteratorType &iter)
Definition: mpi_communicator.h:423
NodalSolutionStepValueAccess(const Variable< TValue > &mrVariable)
Definition: mpi_communicator.h:413
TValue & GetValue(IteratorType &iter)
Definition: mpi_communicator.h:418
NodesContainerType & Nodes()
Definition: mesh.h:346
typename NodesContainerType::const_iterator NodeConstantIterator
Const iterator for nodes in the container. Provides direct references to nodes.
Definition: mesh.h:117
typename PropertiesContainerType::iterator PropertiesIterator
Iterator for properties in the container. Provides direct references to properties.
Definition: mesh.h:123
typename ConditionsContainerType::iterator ConditionIterator
Iterator for conditions in the container. Provides direct references to conditions.
Definition: mesh.h:153
PointerVectorSet< ElementType, IndexedObject, std::less< typename IndexedObject::result_type >, std::equal_to< typename IndexedObject::result_type >, typename ElementType::Pointer, std::vector< typename ElementType::Pointer > > ElementsContainerType
Type alias for the container of elements.
Definition: mesh.h:135
typename NodesContainerType::iterator NodeIterator
Iterator for nodes in the container. Provides direct references to nodes.
Definition: mesh.h:114
PointerVectorSet< NodeType, IndexedObject, std::less< typename IndexedObject::result_type >, std::equal_to< typename IndexedObject::result_type >, typename NodeType::Pointer, std::vector< typename NodeType::Pointer > > NodesContainerType
Type alias for the container of nodes.
Definition: mesh.h:111
typename ConditionsContainerType::const_iterator ConditionConstantIterator
Const iterator for conditions in the container. Provides direct references to conditions.
Definition: mesh.h:156
typename ElementsContainerType::const_iterator ElementConstantIterator
Const iterator for elements in the container. Provides direct references to elements.
Definition: mesh.h:141
typename ElementsContainerType::iterator ElementIterator
Iterator for elements in the container. Provides direct references to elements.
Definition: mesh.h:138
typename PropertiesContainerType::const_iterator PropertiesConstantIterator
Const iterator for properties in the container. Provides direct references to properties.
Definition: mesh.h:126
ElementsContainerType & Elements()
Definition: mesh.h:568
Definition: mpi_serializer.h:33
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
boost::indirect_iterator< typename TContainerType::const_iterator > const_iterator
Definition: pointer_vector_set.h:96
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Quaternion A simple class that implements the main features of quaternion algebra.
Definition: quaternion.h:28
void SetX(const T &value)
Definition: quaternion.h:122
void SetZ(const T &value)
Definition: quaternion.h:138
void SetW(const T &value)
Definition: quaternion.h:146
const T W() const
Definition: quaternion.h:145
void SetY(const T &value)
Definition: quaternion.h:130
const T Y() const
Definition: quaternion.h:129
const T X() const
Definition: quaternion.h:121
const T Z() const
Definition: quaternion.h:137
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
BufferType * pGetBuffer()
Definition: serializer.h:903
A shared variable list gives the position of each variable in the containers sharing it.
Definition: variables_list_data_value_container.h:61
SizeType TotalSize() const
Definition: variables_list_data_value_container.h:392
BlockType * Data()
Definition: variables_list_data_value_container.h:592
Holds a list of variables and their position in VariablesListDataValueContainer.
Definition: variables_list.h:50
Short class definition.
Definition: array_1d.h:61
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_WARNING_IF_ALL_RANKS(label, conditional)
Definition: logger.h:276
TContainerType & GetContainer(ModelPart::MeshType &rMesh)
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
REACTION_CHECK_STIFFNESS_FACTOR INNER_LOOP_ITERATION DISTANCE_THRESHOLD ACTIVE_CHECK_FACTOR AUXILIAR_COORDINATES NORMAL_GAP WEIGHTED_GAP WEIGHTED_SCALAR_RESIDUAL bool
Definition: contact_structural_mechanics_application_variables.h:93
@ Local
Definition: traits.h:20
@ Ghost
Definition: traits.h:21
TExpressionType::data_type sum(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:675
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
color
Definition: all_t_win_vs_m_fixed_error.py:230
int j
Definition: quadrature.py:648
string tag
Definition: regular_mesher.py:14
integer i
Definition: TensorModule.f:17
static std::size_t GetSendSize(const ValueType &rValue)
Definition: mpi_communicator.h:362
static std::size_t GetSendSize(TDatabaseAccess &rAccess, const Communicator::MeshType &rSourceMesh)
Definition: mpi_communicator.h:350
typename TDatabaseAccess::ValueType ValueType
Definition: mpi_communicator.h:349
static std::size_t GetSendSize(TDatabaseAccess &rAccess, const Communicator::MeshType &rSourceMesh)
Definition: mpi_communicator.h:334
typename TDatabaseAccess::ValueType ValueType
Definition: mpi_communicator.h:333
static std::size_t GetSendSize(const ValueType &)
Definition: mpi_communicator.h:341
Definition: mpi_communicator.h:325
static std::size_t GetSendSize(const ValueType &rValue)
static std::size_t GetSendSize(TDatabaseAccess &rAccess, const Communicator::MeshType &rSourceMesh)
typename TDatabaseAccess::ValueType ValueType
Definition: mpi_communicator.h:326
Definition: mpi_communicator.h:184
static void WriteBuffer(const ValueType &rValue, SendType *pBuffer)
Definition: mpi_communicator.h:187
static void ReadBuffer(const SendType *pBuffer, ValueType &rValue)
Definition: mpi_communicator.h:192
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:185
Definition: mpi_communicator.h:199
static void ReadBuffer(const SendType *pBuffer, ValueType &rValue)
Definition: mpi_communicator.h:207
static void WriteBuffer(const ValueType &rValue, SendType *pBuffer)
Definition: mpi_communicator.h:202
typename SendTraits< ValueType >::SendType SendType
Definition: mpi_communicator.h:200
std::vector< SendType > BufferType
Definition: mpi_communicator.h:149
static std::size_t GetMessageSize(const DenseVector< TVectorValue > &rValue)
Definition: mpi_communicator.h:152
double SendType
Definition: mpi_communicator.h:148
double SendType
Definition: mpi_communicator.h:108
std::vector< SendType > BufferType
Definition: mpi_communicator.h:109
double SendType
Definition: mpi_communicator.h:161
std::string BufferType
Definition: mpi_communicator.h:162
static std::size_t GetMessageSize(const Kratos::VariablesListDataValueContainer &rValue)
Definition: mpi_communicator.h:165
double SendType
Definition: mpi_communicator.h:128
static std::size_t GetMessageSize(const Matrix &rValue)
Definition: mpi_communicator.h:132
std::vector< SendType > BufferType
Definition: mpi_communicator.h:129
std::vector< SendType > BufferType
Definition: mpi_communicator.h:174
static std::size_t GetMessageSize(const Node::DofsContainerType &rValue)
Definition: mpi_communicator.h:177
int SendType
Definition: mpi_communicator.h:173
std::vector< SendType > BufferType
Definition: mpi_communicator.h:141
double SendType
Definition: mpi_communicator.h:140
double SendType
Definition: mpi_communicator.h:116
std::vector< SendType > BufferType
Definition: mpi_communicator.h:117
static std::size_t GetMessageSize(const Vector &rValue)
Definition: mpi_communicator.h:120
double SendType
Definition: mpi_communicator.h:100
std::vector< SendType > BufferType
Definition: mpi_communicator.h:101
std::vector< SendType > BufferType
Definition: mpi_communicator.h:85
int SendType
Definition: mpi_communicator.h:84
std::vector< SendType > BufferType
Definition: mpi_communicator.h:93
double SendType
Definition: mpi_communicator.h:92
int SendType
Definition: mpi_communicator.h:76
std::vector< SendType > BufferType
Definition: mpi_communicator.h:77
Definition: mpi_communicator.h:72
Configure::IteratorType IteratorType
Definition: transfer_utility.h:249