Esempio n. 1
0
 static void processModel(const JSONNode & nd, MatModel& model) {
     bool nlayset = false;
     bool rangeset = false;
     bool lengthset = false;
     bool heightset = false;
     bool atomsset = false;
     for (auto i = nd.begin(); i != nd.end(); i++) {
         if (i->name() == JsonNames::numlayers) {
             model.mNumLayers = i->as_int();
             nlayset = true;
         } else if (i->name() == JsonNames::range) {
             model.mRadius = i->as_float();
             rangeset = true;
         } else if (i->name() == JsonNames::length) {
             model.mLength = i->as_float();
             lengthset = true;
         } else if (i->name() == JsonNames::height) {
             model.mHeight = i->as_float();
             heightset = true;
         } else if (i->name() == JsonNames::atoms) {
             BNB_ASSERT(nlayset);
             readIntVector(*i, model.mNumLayers, model.mLayersAtoms);
             atomsset = true;
         } else {
             BNB_ERROR_REPORT("Illegal name on parsing model data");
         }
     }
     BNB_ASSERT(nlayset && rangeset && lengthset && heightset && atomsset);
 }
Esempio n. 2
0
TEST(TestISTLMatrix, AssembleMPI)
{
  InspectMatrixSIM sim(1);
  sim.read("src/LinAlg/Test/refdata/petsc_test.xinp");
  sim.opt.solver = SystemMatrix::ISTL;
  sim.preprocess();
  sim.initSystem(SystemMatrix::ISTL);

  Matrix stencil(4,4);
  stencil(1,1) = stencil(2,2) = stencil(3,3) = stencil(4,4) = 1.0;

  for (int iel = 1; iel <= sim.getSAM()->getNoElms(); ++iel)
    sim.getMatrix()->assemble(stencil, *sim.getSAM(), iel);

  sim.getMatrix()->beginAssembly();
  sim.getMatrix()->endAssembly();

  // now inspect the matrix
  const ProcessAdm& adm = sim.getProcessAdm();
  ISTL::Mat& mat = static_cast<ISTLMatrix*>(sim.getMatrix())->getMatrix();
  ISTL::Vec b(mat.N()), b2(mat.N());

  try {
    Dune::OwnerOverlapCopyCommunication<int,int> comm(*adm.getCommunicator());
    comm.indexSet().beginResize();
    typedef Dune::ParallelLocalIndex<Dune::OwnerOverlapCopyAttributeSet::AttributeSet> LI;
    for (size_t i = 0; i < adm.dd.getMLGEQ().size(); ++i) {
      int gid = adm.dd.getGlobalEq(i+1);
      comm.indexSet().add(gid-1, LI(i, gid >= adm.dd.getMinEq() ?
                                       Dune::OwnerOverlapCopyAttributeSet::owner :
                                       Dune::OwnerOverlapCopyAttributeSet::overlap));
    }
    comm.indexSet().endResize();
    comm.remoteIndices().setIncludeSelf(true);
    comm.remoteIndices().template rebuild<false>();

    ISTL::ParMatrixAdapter op(mat, comm);

    b = 1.0;
    op.apply(b, b2);
  } catch (Dune::ISTLError& e) {
    std::cerr << e << std::endl;
    ASSERT_TRUE(false);
  }

  IntVec v = readIntVector("src/LinAlg/Test/refdata/petsc_matrix_diagonal.ref");
  for (size_t i = 1; i <= adm.dd.getMLGEQ().size(); ++i)
    ASSERT_FLOAT_EQ(v[adm.dd.getGlobalEq(i)-1], b2[i-1]);
}