Ce Qin,

Removing the assertion works, but it will cause a problem. Since the 
> ConstraintMatrix internally uses local_lines to determine the position of 
> a ConstraintLine, we can not insert new line or query an existing line 
> anymore.
>
The attached examples works for me as far as I can tell. There a IndexSet 
is created, copied, shifted and merged with the original one.
Similarly, a ConstraintMatrix is created, copied, shifted and merged with 
the original one. Furthermore, in the resulting ConstraintMatrix
another constraint is added. What kind of error do you observe when 
inserting a new line? 

Best,
Daniel

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2016 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------


// test shift ConstraintMatrix

#include <iomanip>
#include <fstream>
#include <cmath>
#include <stdlib.h>

#include <deal.II/base/index_set.h>
#include <deal.II/lac/constraint_matrix.h>

int main()
{
  const int size = 20;

  dealii::IndexSet set2(size);
  dealii::IndexSet set1(size);
  std::cout << "Create index set with entries 2,5,8" << std::endl;
  set1.add_index(2);
  set1.add_index(5);
  set1.add_index(8);
  set2 = set1;
  std::cout << "Shift indices by 10 and merge" << std::endl;
  set2.add_indices(set1, 10);
  set2.print(std::cout);

  std::cout << "Create ConstraintMatrix with constraints u(2)+.5u(5)=0, u(5)+.7u(8)=0" << std::endl;
  dealii::ConstraintMatrix constraints1(set2);
  constraints1.add_line(2);
  constraints1.add_entry(2, 5, .5);
  constraints1.add_line(5);
  constraints1.add_entry(5, 8, .7);
  dealii::ConstraintMatrix constraints2(constraints1);
  constraints1.print(std::cout);
  constraints1.shift(10);
  std::cout << "Shifted constraints" << std::endl; 
  constraints1.print(std::cout);
  constraints2.merge(constraints1);
  std::cout << "Shifted and merged constraints" << std::endl;
  constraints2.print(std::cout);
  std::cout << "Add constraint u(8)+u(18)=0" << std::endl;
  constraints2.add_line(8);
  constraints2.add_entry(8,18,1.);
  constraints2.print(std::cout);
  constraints2.close();
  std::cout << "Close" << std::endl;
  constraints2.print(std::cout);

  return 0;
}
[ 50%] Built target test_shift
[100%] Run test_shift with Debug configuration
Create index set with entries 2,5,8
Shift indices by 10 and merge
{2, 5, 8, 12, 15, 18}
Create ConstraintMatrix with constraints u(2)+.5u(5)=0, u(5)+.7u(8)=0
    2 5:  0.5
    5 8:  0.7
Shifted constraints
    12 15:  0.5
    15 18:  0.7
Shifted and merged constraints
    2 5:  0.5
    5 8:  0.7
    12 15:  0.5
    15 18:  0.7
Add constraint u(8)+u(18)=0
    2 5:  0.5
    5 8:  0.7
    12 15:  0.5
    15 18:  0.7
    8 18:  1
Close
    2 18:  0.35
    5 18:  0.7
    8 18:  1
    12 18:  0.35
    15 18:  0.7
[100%] Built target run

Reply via email to