dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #26384
Re: [Branch ~dolfin-core/dolfin/trunk] Rev 7446: Expose some more ML options.
On 20 February 2013 09:23, Johannes Ring <johannr@xxxxxxxxx> wrote:
> This commit resulted in the following error when using PETSc 3.2:
>
> [ 0%] Building CXX object
> dolfin/CMakeFiles/dolfin.dir/la/PETScPreconditioner.cpp.o
> /home/johannr/dev/fenics/src/dolfin/trunk/dolfin/la/PETScPreconditioner.cpp:
> In member function ‘virtual void
> dolfin::PETScPreconditioner::set(dolfin::PETScKrylovSolver&)’:
> /home/johannr/dev/fenics/src/dolfin/trunk/dolfin/la/PETScPreconditioner.cpp:573:71:
> error: invalid conversion from ‘std::vector<double>::size_type {aka
> long unsigned int}’ to ‘PetscReal* {aka double*}’ [-fpermissive]
> /home/johannr/dev/fenics/src/dolfin/trunk/dolfin/la/PETScPreconditioner.cpp:573:71:
> error: too many arguments to function ‘PetscErrorCode
> PCSetCoordinates(PC, PetscInt, PetscReal*)’
> In file included from /usr/lib/petscdir/3.2/include/petscksp.h:6:0,
> from
> /home/johannr/dev/fenics/src/dolfin/trunk/dolfin/la/PETScPreconditioner.cpp:27:
> /usr/lib/petscdir/3.2/include/petscpc.h:398:23: note: declared here
>
> The attached patch fixes the problem. Does it look like the correct fix?
>
Looks good.
Garth
> Johannes
>
> On Tue, Feb 19, 2013 at 11:18 PM, <noreply@xxxxxxxxxxxxx> wrote:
>> ------------------------------------------------------------
>> revno: 7446
>> committer: Garth N. Wells <gnw20@xxxxxxxxx>
>> branch nick: petsc-dev
>> timestamp: Tue 2013-02-19 20:46:47 +0000
>> message:
>> Expose some more ML options.
>> modified:
>> dolfin/fem/DofMap.cpp
>> dolfin/la/GenericPreconditioner.h
>> dolfin/la/PETScPreconditioner.cpp
>> dolfin/la/PETScPreconditioner.h
>>
>>
>> --
>> lp:dolfin
>> https://code.launchpad.net/~dolfin-core/dolfin/trunk
>>
>> Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
>> To unsubscribe from this branch go to https://code.launchpad.net/~dolfin-core/dolfin/trunk/+edit-subscription
>>
>> === modified file 'dolfin/fem/DofMap.cpp'
>> --- dolfin/fem/DofMap.cpp 2013-02-19 19:19:30 +0000
>> +++ dolfin/fem/DofMap.cpp 2013-02-19 20:46:47 +0000
>> @@ -311,11 +311,15 @@
>> // Copy dof coordinates into vector
>> for (std::size_t i = 0; i < dofs.size(); ++i)
>> {
>> - const std::size_t local_index = dofs[i] - offset;
>> - for (std::size_t j = 0; j < gdim; ++j)
>> + const std::size_t dof = dofs[i];
>> + if (dof >= _ownership_range.first && dof < _ownership_range.second)
>> {
>> - dolfin_assert(gdim*local_index + j < x.size());
>> - x[gdim*local_index + j] = coordinates[i][j];
>> + const std::size_t local_index = dof - offset;
>> + for (std::size_t j = 0; j < gdim; ++j)
>> + {
>> + dolfin_assert(gdim*local_index + j < x.size());
>> + x[gdim*local_index + j] = coordinates[i][j];
>> + }
>> }
>> }
>> }
>>
>> === modified file 'dolfin/la/GenericPreconditioner.h'
>> --- dolfin/la/GenericPreconditioner.h 2012-11-09 20:57:58 +0000
>> +++ dolfin/la/GenericPreconditioner.h 2013-02-19 20:46:47 +0000
>> @@ -42,7 +42,18 @@
>> virtual void set_nullspace(const std::vector<const GenericVector*> nullspace)
>> {
>> dolfin_error("GenericPreconditioner.h",
>> - "set nullspace for precontioner operator",
>> + "set nullspace for preconditioner operator",
>> + "Not supported by current preconditioner type");
>> + }
>> +
>> + /// Set the coordinates of the operator (matrix) rows. This is
>> + /// can be used by required for certain preconditioners, e.g. ML.
>> + /// The input for this function can be generated using
>> + /// GenericDofMap::tabulate_all_dofs.
>> + virtual void set_coordinates(const std::vector<double>& x)
>> + {
>> + dolfin_error("GenericPreconditioner.h",
>> + "set coordinates for preconditioner operator",
>> "Not supported by current preconditioner type");
>> }
>>
>>
>> === modified file 'dolfin/la/PETScPreconditioner.cpp'
>> --- dolfin/la/PETScPreconditioner.cpp 2013-02-19 12:58:48 +0000
>> +++ dolfin/la/PETScPreconditioner.cpp 2013-02-19 20:46:47 +0000
>> @@ -135,13 +135,10 @@
>> p_ml.add<int>("energy_minimization", -1, 4);
>> p_ml.add<double>("energy_minimization_threshold");
>> p_ml.add<double>("auxiliary_threshold");
>> -
>> - std::set<std::string> aggregation_schemes;
>> - aggregation_schemes.insert("Uncoupled");
>> - aggregation_schemes.insert("Coupled");
>> - aggregation_schemes.insert("MIS");
>> - aggregation_schemes.insert("METIS");
>> - p_ml.add<std::string>("aggregation_scheme", aggregation_schemes);
>> + p_ml.add<bool>("repartition");
>> + p_ml.add<std::string>("repartition_type", boost::assign::list_of("Zoltan")("ParMETIS"));
>> + p_ml.add<std::string>("zoltan_repartition_scheme", boost::assign::list_of("RCB")("hypergraph")("fast_hypergraph"));
>> + p_ml.add<std::string>("aggregation_scheme", boost::assign::list_of("Uncoupled")("Coupled")("MIS")("METIS"));
>> p.add(p_ml);
>>
>> // Hypre/ParaSails parameters
>> @@ -185,7 +182,7 @@
>> // Do nothing
>> }
>> //-----------------------------------------------------------------------------
>> -void PETScPreconditioner::set(PETScKrylovSolver& solver) const
>> +void PETScPreconditioner::set(PETScKrylovSolver& solver)
>> {
>> dolfin_assert(solver.ksp());
>>
>> @@ -341,7 +338,6 @@
>> if (parameters("ml")["energy_minimization"].is_set())
>> {
>> const int method = parameters("ml")["energy_minimization"];
>> - cout << "Setting energy min" << endl;
>> PetscOptionsSetValue("-pc_ml_EnergyMinimization",
>> boost::lexical_cast<std::string>(method).c_str());
>>
>> @@ -355,12 +351,31 @@
>> }
>>
>> // Auxiliary threshold drop tolerance
>> + /*
>> + PetscOptionsSetValue("-pc_ml_Aux", "1");
>> if (parameters("ml")["auxiliary_threshold"].is_set())
>> {
>> const double threshold = parameters("ml")["auxiliary_threshold"];
>> PetscOptionsSetValue("-pc_ml_AuxThreshold",
>> boost::lexical_cast<std::string>(threshold).c_str());
>> }
>> + */
>> +
>> + // Allow ML to re-partition problem
>> + if (parameters("ml")["repartition"].is_set())
>> + {
>> + const bool repartition = parameters("ml")["repartition"];
>> + if (repartition)
>> + {
>> + PetscOptionsSetValue("-pc_ml_repartition", "1");
>> + if (parameters("ml")["repartition_type"].is_set())
>> + PetscOptionsSetValue("-pc_ml_repartitionType", parameters("ml")["repartition_type"].value_str().c_str());
>> + if (parameters("ml")["zoltan_repartition_scheme"].is_set())
>> + PetscOptionsSetValue("-pc_ml_repartitionZoltanScheme", parameters("ml")["zoltan_repartition_scheme"].value_str().c_str());
>> + }
>> + else
>> + PetscOptionsSetValue("-pc_ml_repartition", "0");
>> + }
>>
>> // --- PETSc parameters
>>
>> @@ -553,6 +568,13 @@
>> // Make sure options are set
>> PCSetFromOptions(pc);
>>
>> + // Set physical coordinates for row dofs
>> + if (!_coordinates.empty())
>> + PCSetCoordinates(pc, 3, _coordinates.size()/3, _coordinates.data());
>> +
>> + // Clear memeory
>> + _coordinates.clear();
>> +
>> // Print preconditioner information
>> const bool report = parameters["report"];
>> if (report)
>> @@ -600,6 +622,11 @@
>> #endif
>> }
>> //-----------------------------------------------------------------------------
>> +void PETScPreconditioner::set_coordinates(const std::vector<double>& x)
>> +{
>> + _coordinates = x;
>> +}
>> +//-----------------------------------------------------------------------------
>> std::string PETScPreconditioner::str(bool verbose) const
>> {
>> std::stringstream s;
>>
>> === modified file 'dolfin/la/PETScPreconditioner.h'
>> --- dolfin/la/PETScPreconditioner.h 2012-11-09 20:57:58 +0000
>> +++ dolfin/la/PETScPreconditioner.h 2013-02-19 20:46:47 +0000
>> @@ -58,7 +58,7 @@
>> virtual ~PETScPreconditioner();
>>
>> /// Set the precondtioner type and parameters
>> - virtual void set(PETScKrylovSolver& solver) const;
>> + virtual void set(PETScKrylovSolver& solver);
>>
>> /// Set the (approximate) null space of the preconditioner operator
>> /// (matrix). This is required for certain preconditioner types,
>> @@ -69,6 +69,12 @@
>> boost::shared_ptr<const MatNullSpace> nullspace() const
>> { return petsc_nullspace; }
>>
>> + /// Set the coordinates of the operator (matrix) rows. This is
>> + /// can be used by required for certain preconditioners, e.g. ML.
>> + /// The input for this function can be generated using
>> + /// GenericDofMap::tabulate_all_dofs.
>> + void set_coordinates(const std::vector<double>& x);
>> +
>> /// Return informal string representation (pretty-print)
>> std::string str(bool verbose) const;
>>
>> @@ -99,6 +105,9 @@
>> // the future.
>> boost::shared_ptr<MatNullSpace> petsc_nullspace;
>>
>> + // Operator row coordinates
>> + std::vector<double> _coordinates;
>> +
>> };
>>
>> }
>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
>
References