Changeset 177495 for src/comm/mpi


Ignore:
Timestamp:
Apr 17, 2013, 6:35:40 PM (13 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
4f3474
Parents:
d6a338
Message:

Implemented boundary values derived from continious problem.

Location:
src/comm/mpi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/comm/mpi/settings.cpp

    rd6a338 r177495  
    4444#include <string>
    4545
     46#include "base/index.hpp"
    4647#include "comm/comm.hpp"
    4748#include "comm/mpi/settings.hpp"
     49#include "discretization/boundary_value_setter.hpp"
    4850#include "grid/multigrid.hpp"
    4951#include "grid/tempgrid.hpp"
     
    218220    AddDatatypeGlobal(FinerGrid(sol(i-1)), sol(i), 1);
    219221  }
     222
     223  InitializeBoundaryValues();
    220224}
    221225
     
    428432}
    429433
     434void VMG::MPI::Settings::InitializeBoundaryValues()
     435{
     436  assert(bv_ranks.size() == 0);
     437
     438  if (MG::GetFactory().TestObject("BOUNDARY_VALUE_SETTER")) {
     439
     440    Index coord;
     441
     442    const int level_index = MG::GetRhs()->MaxLevel() - MG::GetRhs()->GlobalMaxLevel();
     443    const std::vector<BoundaryValue>& bvs = MG::GetBoundaryValueSetter()->BoundaryValues();
     444    const std::map<Index, std::vector<GlobalIndices> >& global = MG::GetComm()->DecomposedGlobal();
     445
     446    assert(global.find(0)->second[level_index].BoundaryType() == GlobalMax);
     447
     448    MPI_Comm comm = CommunicatorLocal((*MG::GetRhs())(MG::GetRhs()->GlobalMaxLevel()));
     449
     450    bv_ranks.reserve(bvs.size());
     451
     452    for (std::vector<BoundaryValue>::const_iterator iter_b = bvs.begin(); iter_b != bvs.end(); ++iter_b) {
     453      for (std::map<Index, std::vector<GlobalIndices> >::const_iterator iter_g = global.begin(); iter_g != global.end(); ++iter_g) {
     454        if (iter_b->GetIndex().IsComponentwiseGreaterOrEqual(iter_g->second[level_index].LocalBegin()) &&
     455            iter_b->GetIndex().IsComponentwiseLess(iter_g->second[level_index].LocalEnd())) {
     456            bv_ranks.push_back(0);
     457            coord = iter_g->first;
     458            MPI_Cart_rank(comm, coord.vec(), &bv_ranks.back());
     459          break;
     460        }
     461      }
     462    }
     463  }
     464}
     465
    430466std::string VMG::MPI::Settings::ToString() const
    431467{
  • src/comm/mpi/settings.hpp

    rd6a338 r177495  
    7070  VMG::MPI::DatatypesLocal& DatatypesLocal(const Grid& grid);
    7171
     72  const std::vector<int>& BoundaryRanks() const {return bv_ranks;}
     73
    7274  std::string ToString() const;
    7375
     
    7981  void CreateLocalCommunicator(MPI_Comm& comm_global, const Grid& grid);
    8082
     83  void InitializeBoundaryValues();
     84
    8185  std::map<int, MPI_Comm> communicators_global;
    8286  std::map<KeyUnsorted, MPI_Comm> communicators_local;
     
    8690  std::map<KeyUnsorted, VMG::MPI::DatatypesGlobal> datatypes_global;
    8791  std::map<KeyUnsorted, VMG::MPI::DatatypesLocal> datatypes_local;
     92
     93  std::vector<int> bv_ranks;
     94
    8895};
    8996
Note: See TracChangeset for help on using the changeset viewer.