← Back to team overview

dolfin team mailing list archive

Re: dolfin mailing list

 

This has been fixed in dolfin-stable.

Garth

Alessio Quaglino wrote:
Send the simplest possible C++ program that leads to the problem and
I'll take a look.

Garth

Ok thanks. Put this into /src/demo/pde/poisson:

#include <dolfin.h>
#include "Poisson.h"

using namespace dolfin;

void solvePoissonBug(Mesh& mesh)
{
  // Linear system and solver
  Matrix A;
  Vector b;

  // Create forms
  Function f = 0.0;
  Function g = 0.0;
  Poisson::BilinearForm a;
  Poisson::LinearForm L(f,g);

  // Assemble
  FEM::assemble(a, A, mesh);
  FEM::assemble(L, b, mesh);

  int rows[1];
  int cols[1];
  real block[1];

  rows[0] = 1;
  cols[0] = 1;
  block[0] = 1.0;

  A.add(block, rows, 0, cols, 0);
}

int main()
{
  Mesh mesh("../../../../data/meshes/dolfin-2.xml.gz");
  solvePoissonBug(mesh);
}

Regards,
Alessio


Alessio Quaglino wrote:
Alessio Quaglino wrote:
Anyway, I just have a small (but important) bug with uBlas and dolfin
0.6.3 that Johan Jansson couldnt solve so if you (or someone else if
you
don't have time) could help me I would really appreciate.

Is the bug present in the later release (0.6.4)?

Garth

Yes. Gbd gives the following output:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1209726752 (LWP 3498)]
0xb7cd53dc in
boost::numeric::ublas::matrix_assign<boost::numeric::ublas::scalar_assign,
boost::numeric::ublas::basic_full<unsigned int>,
boost::numeric::ublas::generalized_vector_of_vector<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>,
boost::numeric::ublas::vector<boost::numeric::ublas::compressed_vector<double,
0u, boost::numeric::ublas::unbounded_array<unsigned int,
std::allocator<unsigned int> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
,
boost::numeric::ublas::unbounded_array<boost::numeric::ublas::compressed_vector<double,
0u, boost::numeric::ublas::unbounded_array<unsigned int,
std::allocator<unsigned int> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
,
std::allocator<boost::numeric::ublas::compressed_vector<double, 0u,
boost::numeric::ublas::unbounded_array<unsigned int,
std::allocator<unsigned int> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
, boost::numeric::ublas::compressed_matrix<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>, 0u,
boost::numeric::ublas::unbounded_array<unsigned int,
std::allocator<unsigned int> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
(m=@0x8242b7c, e=@0x8242b44) at vector_sparse.hpp:957
957                 *it = k_based (i);

The simple example uses the Python interface and the Poisson equation.
I've inserted inside uBlasMatrix.h the following function, which does
exactly what add() does, but with different arguments.

   template <class Mat>
   inline void uBlasMatrix<Mat>::diagSum(const uBlasVector& x)
   {
     if( assembled )
     {
       Assembly_matrix.assign(*this);
       assembled = false;
     }
     else
       dolfin_error("Matrix has not been assembled. Did you forget to
 call
 A.apply()?");

     uint s = Assembly_matrix.size1();
     uint r = Assembly_matrix.size2();

     if( s != r )
       dolfin_error("Matrix is not square!");

     for( uint i = 0; i < s; i++ )
     {
       Assembly_matrix(i , i) += x[i];
     }
   }

My simple test case just import the form file already defined for
Poisson
euqation, uses dolfin mesh generator and then assemble the matrix A:

    # Create a mesh of the unit square
    mesh = UnitSquare(100, 100)

    # Import forms (compiled just-in-time with FFC)
    forms = import_formfile("Poisson.form")
    import poisson as forms

    # Assemble linear system
    a = forms.PoissonBilinearForm()
    A = Matrix()
    FEM_assemble(a, A, mesh)

    # Sum a vector
    b = Vector(A.size(0))
    b.operator=(2.0)
    A.diagSum(b)

I've also already tried to call A.apply() before but it does not help.
The
segmentation fault comes from the following line (inside uBlasMatrix.h):

Assembly_matrix.assign(*this);

However, there is no segmentation fault if I call A.zero() after
FEM_assemble(), so my guess is that this depends on the matrix
representation. Thank you for the help.

Regards,
Alessio Quaglino


Best regards,
Alessio Quaglino







References