Could we please change the PETSc option to allow setting matrix entries that have not been preallocated?

Asked by Mikael Mortensen on 2012-10-26

I would really like to change line 224 in PETScMatrix.cpp from

MatSetOption(*A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);

to

MatSetOption(*A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);

to allow setting entries in a matrix that have not been preallocated by the sparsitypatternbuilder.

I know it's not an optimal solution, but this would make PeriodicBCs work again. It could be set back to True when PeriodicBCs have been migrated to the dofmaps. As of now PeriodicBCs only works using the solve(a == L) formalism and many of my applications are broken with trunk.

It could perhaps be made optional through a parameter? Not sure there is such an option for Epetra or other backends though?

Best regards

Mikael

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Patrick Farrell (pefarrell) said : #1

I second this. I've had to make this change locally for quite a while.

Garth Wells (garth-wells) said : #2

It's easy to make the change locally.

Proper fixes for periodic bcs are welcome!

Den Oct 26, 2012 kl. 4:55 PM skrev Garth Wells:

> Your question #212407 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/212407
>
> Status: Open => Answered
>
> Garth Wells proposed the following answer:
> It's easy to make the change locally.

Obviously, but applications may have users that don't compile dolfin themselves.

Hans Petter has a keynote lecture today about computational turbulence (Fenics and cbc.pdesys) at the 25th Nordic seminar on computational mechanics. It is great PR for Fenics, but unfortunate that the applications he talks about don't work with binaries.

>
> Proper fixes for periodic bcs are welcome!

They certainly are. Meanwhile...

Mikael

>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/dolfin/+question/212407/+confirm?answer_id=1
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/dolfin/+question/212407
>
> You received this question notification because you asked the question.

Anders Logg (logg) said : #4

On Fri, Oct 26, 2012 at 03:26:14PM -0000, Mikael Mortensen wrote:
> Question #212407 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/212407
>
> Status: Answered => Open
>
> Mikael Mortensen is still having a problem:
>
> Den Oct 26, 2012 kl. 4:55 PM skrev Garth Wells:
>
> > Your question #212407 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/212407
> >
> > Status: Open => Answered
> >
> > Garth Wells proposed the following answer:
> > It's easy to make the change locally.
>
> Obviously, but applications may have users that don't compile dolfin
> themselves.
>
> Hans Petter has a keynote lecture today about computational turbulence
> (Fenics and cbc.pdesys) at the 25th Nordic seminar on computational
> mechanics. It is great PR for Fenics, but unfortunate that the
> applications he talks about don't work with binaries.
>
> >
> > Proper fixes for periodic bcs are welcome!
>
> They certainly are. Meanwhile...

Is it possible to call

  MatSetOption(*A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);

to change the parameter after the matrix has been created?

Then PeriodicBC.cpp could call that function as a temporary fix on the
PETSc Mat pointer.

--
Anders

Patrick Farrell (pefarrell) said : #5

From my reading of http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetOption.html, it seems that Anders' suggestion could be implemented. How would you check that a given GenericMatrix is actually a PETScMatrix?

Anders Logg (logg) said : #6

On Mon, Oct 29, 2012 at 03:35:44PM -0000, Patrick Farrell wrote:
> Question #212407 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/212407
>
> Patrick Farrell posted a new comment:
> >From my reading of http://www.mcs.anl.gov/petsc/petsc-
> current/docs/manualpages/Mat/MatSetOption.html, it seems that Anders'
> suggestion could be implemented. How would you check that a given
> GenericMatrix is actually a PETScMatrix?

if (has_type<Foo>(A))

where Foo is something like PETScMatrix or boost::shared_ptr<PETScMatrix>.

--
Anders

Patrick Farrell (pefarrell) said : #7

Can you help with this problem?

Provide an answer of your own, or ask Mikael Mortensen for more information if necessary.

To post a message you must log in.