5#ifndef RUN_LOCALSTIFFNESSMATRICESFIXEDDISTRIBUTION_H
6#define RUN_LOCALSTIFFNESSMATRICESFIXEDDISTRIBUTION_H
11#include "LocalStiffnessMatrices.h"
13class LocalStiffnessMatricesFixedDistribution :
public LocalStiffnessMatrices{
17 LocalStiffnessMatricesFixedDistribution(
AdaptiveSparseGrid &sg, StencilTemplate& stencilClass,
int number_processes_, DistributedDepthsHashtable distributedDepthsHashtable_ )
18 :LocalStiffnessMatrices(sg, stencilClass, number_processes_){
19 distributedDepthsHashtable = distributedDepthsHashtable_;
20 for (
auto it = depthList.begin_all(); it != depthList.end_all(); ++it) {
23 int node = distributedDepthsHashtable.getNodeForDepth(T);
24 int node_vergleich = distributedDepthsHashtable_.getNodeForDepth(T);
25 if (node != node_vergleich) {
26 cout <<
" err " << endl;
35 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
36 MPI_Comm_size(MPI_COMM_WORLD, &num_tasks);
38 cout <<
"USE LOCALSTIFFNESSMATRICES ONLY WITH MPI" << endl;
42 for (
auto it = depthList.begin_all(); it != depthList.end_all(); ++it){
45 int node = distributedDepthsHashtable.getNodeForDepth(T);
46 int node_vergleich = distributedDepthsHashtable_.getNodeForDepth(T);
47 if (node != node_vergleich) {
48 cout <<
" err " << endl;
54 stencilClass.initialize(T);
62 const SingleDepthHashCellStructure &depthGrid = cellData.getGridForDepth(Tcell);
63 const auto &map = depthGrid._map;
64 const auto end = depthGrid.getNumberOfEntries();
68 std::vector<LocalStiffnessMatrixFixedDepthSymmetric> vector;
70#pragma omp parallel for schedule(dynamic)
71 for (
size_t i = 0; i < end; i++) {
72 CellDimension cellDimension = map.getIndexOfTable(i);
73 LocalStiffnessMatrixFixedDepthSymmetric localStiffnessMatrixFixedDepthSymmetric(cellDimension, sg, stencilClass);
78 vector.push_back(localStiffnessMatrixFixedDepthSymmetric);
80 pairedDepthsLocalStiffnessMatrices.push_back(std::make_pair(T, vector));
89 void operator+=(LocalStiffnessMatrices& localStiffnessMatrices){
90 for(
auto& item : pairedDepthsLocalStiffnessMatrices){
93 auto it = std::find_if(
94 localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->begin(),
95 localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->end(),
96 [&T](
const std::pair<Depth,std::vector<LocalStiffnessMatrices::LocalStiffnessMatrixFixedDepthSymmetric>>& pair) {
97 return pair.first == T;
101 if (it != localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->end()) {
103 std::vector<LocalStiffnessMatrices::LocalStiffnessMatrixFixedDepthSymmetric> &matrices_add = it->second;
105 for(
auto& matrix : item.second){
106 for (
auto &matrix_add: matrices_add){
107 CellDimension cellCompare=*matrix.getCell();
108 if(cellCompare==*matrix_add.getCell()){
117 LocalStiffnessMatrices& operator+(LocalStiffnessMatrices& localStiffnessMatrices){
118 for(
auto& item : pairedDepthsLocalStiffnessMatrices){
119 Depth T = item.first;
121 auto it = std::find_if(
122 localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->begin(),
123 localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->end(),
124 [&T](
const std::pair<Depth,std::vector<LocalStiffnessMatrices::LocalStiffnessMatrixFixedDepthSymmetric>>& pair) {
125 return pair.first == T;
129 if (it != localStiffnessMatrices.getPairedDepthsLocalStiffnessMatrices()->end()) {
131 std::vector<LocalStiffnessMatrices::LocalStiffnessMatrixFixedDepthSymmetric> &matrices_add = it->second;
133 for(
auto& matrix : item.second) {
134 for (
auto &matrix_add: matrices_add){
135 CellDimension cellCompare=*matrix.getCell();
136 if(cellCompare==*matrix_add.getCell()){
Definition sparseGrid.h:277