← Back to team overview

dolfin team mailing list archive

Re: Fwd: [Branch ~dolfin-core/dolfin/main] Rev 4695: Add parameter "use_ident" in DirichletBC. Default value is true (same

 

On Fri, Apr 23, 2010 at 09:34:16AM +0100, Garth N. Wells wrote:
> This sounds very PETSc-speecific. Should it be a parameter of
> PETScMatrix only?
>
> Garth

Yes, perhaps. I find it a bit strange that MatZeroRows breaks for
rows without elements.

The problem with making it a PETScMatrix-specific option is it would
be very inconvenient to set the option. One would need to cast the
Matrix to a PETScMatrix and then set the option, or just work with
PETScMatrix in which case the code breaks when changing backend.

How about making it a global PETSc option?

  dolfin::parameters["petsc"]["use_mat_zero_rows"]

--
Anders


> -------- Original Message --------
> Subject: [Branch ~dolfin-core/dolfin/main] Rev 4695: Add parameter
> "use_ident"	in DirichletBC. Default value is true (same
> Date: Thu, 22 Apr 2010 15:17:22 -0000
> From: noreply@xxxxxxxxxxxxx
> Reply-To: noreply@xxxxxxxxxxxxx
> To: Garth Wells <gnw20@xxxxxxxxx>
>
> ------------------------------------------------------------
> revno: 4695
> committer: Anders Logg <logg@xxxxxxxxx>
> branch nick: dolfin-dev
> timestamp: Thu 2010-04-22 17:14:50 +0200
> message:
>   Add parameter "use_ident" in DirichletBC. Default value is true (same
>   behavior as earlie). If set to false, the matrix will be manipulated
>   using setitem instead (useful when PETSc complains about missing entries
>   in row).
> modified:
>   ChangeLog
>   dolfin/fem/BoundaryCondition.h
>   dolfin/fem/DirichletBC.cpp
>   dolfin/fem/DirichletBC.h
>   dolfin/la/GenericMatrix.cpp
>   dolfin/la/KrylovSolver.cpp
>   dolfin/la/KrylovSolver.h
>   dolfin/nls/NewtonSolver.cpp
>
>

> === modified file 'ChangeLog'
> --- ChangeLog	2010-04-15 18:57:43 +0000
> +++ ChangeLog	2010-04-22 15:14:50 +0000
> @@ -1,3 +1,4 @@
> + - Add parameter "use_ident" in DirichletBC
>   - Issue error by default when solvers don't converge (parameter "error_on_convergence")
>   - Add option to print matrix/vector for a VariationalProblem
>   - Trilinos backend now works in parallel
>
> === modified file 'dolfin/fem/BoundaryCondition.h'
> --- dolfin/fem/BoundaryCondition.h	2010-03-09 20:01:43 +0000
> +++ dolfin/fem/BoundaryCondition.h	2010-04-22 15:14:50 +0000
> @@ -5,7 +5,7 @@
>  // Modified by Johan Hake 2009.
>  //
>  // First added:  2008-06-18
> -// Last changed: 2009-11-12
> +// Last changed: 2010-04-22
>
>  #ifndef __BOUNDARY_CONDITION_H
>  #define __BOUNDARY_CONDITION_H
> @@ -13,6 +13,7 @@
>  #include <vector>
>  #include <boost/shared_ptr.hpp>
>  #include <dolfin/common/types.h>
> +#include <dolfin/common/Variable.h>
>
>  namespace dolfin
>  {
> @@ -24,7 +25,7 @@
>
>    /// Common base class for boundary conditions
>
> -  class BoundaryCondition
> +  class BoundaryCondition : public Variable
>    {
>    public:
>
>
> === modified file 'dolfin/fem/DirichletBC.cpp'
> --- dolfin/fem/DirichletBC.cpp	2010-04-05 17:22:50 +0000
> +++ dolfin/fem/DirichletBC.cpp	2010-04-22 15:14:50 +0000
> @@ -6,7 +6,7 @@
>  // Modified by Johan Hake, 2009
>  //
>  // First added:  2007-04-10
> -// Last changed: 2009-12-03
> +// Last changed: 2010-04-22
>
>  #include <boost/scoped_ptr.hpp>
>  #include <boost/assign/list_of.hpp>
> @@ -48,6 +48,7 @@
>      method(method), user_sub_domain(reference_to_no_delete_pointer(sub_domain))
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_sub_domain(user_sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -60,6 +61,7 @@
>      method(method), user_sub_domain(sub_domain)
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_sub_domain(user_sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -73,6 +75,7 @@
>      method(method), user_sub_domain(static_cast<SubDomain*>(0))
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_mesh_function(sub_domains, sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -86,6 +89,7 @@
>      method(method), user_sub_domain(static_cast<SubDomain*>(0))
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_mesh_function(sub_domains, sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -98,6 +102,7 @@
>      method(method), user_sub_domain(static_cast<SubDomain*>(0))
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_mesh(sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -110,6 +115,7 @@
>      method(method), user_sub_domain(static_cast<SubDomain*>(0))
>  {
>    check();
> +  parameters = default_parameters();
>    init_from_mesh(sub_domain);
>  }
>  //-----------------------------------------------------------------------------
> @@ -123,6 +129,7 @@
>      facets(markers)
>  {
>    check();
> +  parameters = default_parameters();
>  }
>  //-----------------------------------------------------------------------------
>  DirichletBC::DirichletBC(boost::shared_ptr<const FunctionSpace> V,
> @@ -135,11 +142,15 @@
>      facets(markers)
>  {
>    check();
> +  parameters = default_parameters();
>  }
>  //-----------------------------------------------------------------------------
>  DirichletBC::DirichletBC(const DirichletBC& bc)
>    : BoundaryCondition(bc._function_space)
>  {
> +  // Set default parameters
> +  parameters = default_parameters();
> +
>    *this = bc;
>  }
>  //-----------------------------------------------------------------------------
> @@ -356,7 +367,19 @@
>    // Modify linear system (A_ii = 1) and apply changes
>    if (A)
>    {
> -    A->ident(size, &dofs[0]);
> +    const bool use_ident = parameters["use_ident"];
> +    if (use_ident)
> +    {
> +      A->ident(size, &dofs[0]);
> +    }
> +    else
> +    {
> +      for (uint i = 0; i < size; i++)
> +      {
> +        std::pair<uint, uint> ij(dofs[i], dofs[i]);
> +        A->setitem(ij, 1.0);
> +      }
> +    }
>      A->apply("insert");
>    }
>  }
>
> === modified file 'dolfin/fem/DirichletBC.h'
> --- dolfin/fem/DirichletBC.h	2009-11-12 10:18:53 +0000
> +++ dolfin/fem/DirichletBC.h	2010-04-22 15:14:50 +0000
> @@ -5,7 +5,7 @@
>  // Modified by Johan Hake, 2009
>  //
>  // First added:  2007-04-10
> -// Last changed: 2009-11-12
> +// Last changed: 2010-04-22
>  //
>  // FIXME: This class needs some cleanup, in particular collecting
>  // FIXME: all data from different representations into a common
> @@ -176,6 +176,14 @@
>      /// Set value g for boundary condition, domain remains unchanged
>      void set_value(boost::shared_ptr<const GenericFunction> g);
>
> +    /// Default parameter values
> +    static Parameters default_parameters()
> +    {
> +      Parameters p("dirichlet_bc");
> +      p.add("use_ident", true);
> +      return p;
> +    }
> +
>    private:
>
>      // Friends
>
> === modified file 'dolfin/la/GenericMatrix.cpp'
> --- dolfin/la/GenericMatrix.cpp	2010-04-21 17:48:42 +0000
> +++ dolfin/la/GenericMatrix.cpp	2010-04-22 15:14:50 +0000
> @@ -2,7 +2,7 @@
>  // Licensed under the GNU LGPL Version 2.1.
>  //
>  // First added:  2010-02-23
> -// Last changed: 2010-04-21
> +// Last changed: 2010-04-22
>
>  #include <boost/scoped_array.hpp>
>  #include <dolfin/common/constants.h>
>
> === modified file 'dolfin/la/KrylovSolver.cpp'
> --- dolfin/la/KrylovSolver.cpp	2010-04-19 19:47:09 +0000
> +++ dolfin/la/KrylovSolver.cpp	2010-04-22 15:14:50 +0000
> @@ -5,7 +5,7 @@
>  // Modified by Anders Logg, 2008.
>  //
>  // First added:  2007-07-03
> -// Last changed: 2010-04-19
> +// Last changed: 2010-04-22
>
>  #include <dolfin/common/Timer.h>
>  #include <dolfin/parameter/Parameters.h>
>
> === modified file 'dolfin/la/KrylovSolver.h'
> --- dolfin/la/KrylovSolver.h	2009-07-09 12:13:49 +0000
> +++ dolfin/la/KrylovSolver.h	2010-04-22 15:14:50 +0000
> @@ -5,7 +5,7 @@
>  // Modified by Anders Logg, 2008.
>  //
>  // First added:  2007-07-03
> -// Last changed: 2009-06-30
> +// Last changed: 2010-04-22
>
>  #ifndef __KRYLOV_SOLVER_H
>  #define __KRYLOV_SOLVER_H
> @@ -31,7 +31,7 @@
>    public:
>
>      /// Create Krylov solver
> -    KrylovSolver(std::string solver_type = "default",
> +    KrylovSolver(std::string solver_type = "default",
>                   std::string pc_type = "default");
>
>      /// Destructor
>
> === modified file 'dolfin/nls/NewtonSolver.cpp'
> --- dolfin/nls/NewtonSolver.cpp	2010-04-19 19:47:09 +0000
> +++ dolfin/nls/NewtonSolver.cpp	2010-04-22 15:14:50 +0000
> @@ -6,7 +6,7 @@
>  // Modified by Johan Hake, 2010.
>  //
>  // First added:  2005-10-23
> -// Last changed: 2010-04-19
> +// Last changed: 2010-04-22
>
>  #include <iostream>
>  #include <dolfin/common/NoDeleter.h>
>
>

> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp

Attachment: signature.asc
Description: Digital signature


Follow ups

References