On Fri, Jan 24, 2020 at 1:33 PM Prashant K. Jha <pjha....@gmail.com> wrote:

> Hi All,
>
> <https://prashjha.github.io/>I am building a network of 1-d EDGE2 elements
> embedded in 2-d or 3-d. At any given node of the network, it may have more
> than 2 elements intersecting. To enforce continuity of flux at such nodes,
> I have to add a constraint relating the dofs of intersecting elements. I am
> using Penalty method to enforce the continuity.
>
> When I am adding value to (i,j) element of the matrix where i and j are
> dofs related by constraint, I get Petsc malloc error and it suggests to use
> MatSetOption on the matrix. I do that as follows:
>
>
>
>
> *auto &pres =
> net_sys.add_system<TransientLinearImplicitSystem>("Pressure_1D");
> pres.add_variable("pressure_1d", FIRST);*
>
>
> *net_sys.init();*
>
>
>
> *PetscMatrix<Number> *pet_mat =
> dynamic_cast<PetscMatrix<Number>*>(pres.matrix);*
>
> *MatSetOption( pet_mat.mat(), MAT_NEW_NONZERO_ALLOCATION_ERR,
> PETSC_FALSE);*
>
> Casting matrix associated to pres system into Petsc matrix gives following
> error:
>
>
> *model.cpp:1163:53: error: cannot dynamic_cast ‘(&
>
> pres)->libMesh::TransientSystem<libMesh::LinearImplicitSystem>::<anonymous>.libMesh::LinearImplicitSystem::<anonymous>.libMesh::ImplicitSystem::matrix’
> (of type ‘class libMesh::SparseMatrix<double>*’) to type ‘class
> libMesh::PetscMatrix<double>*’ (target is not pointer or reference to
> complete type)       dynamic_cast<PetscMatrix<Number>*>(pres.matrix);*
>
> There is not much available online. If someone know how to resolve this,
> please share the information. My final goal is to constrain the dofs and
> would not mind applying an alternative approach.
>

I think the issue here is you need to

#include "libmesh/petsc_matrix.h"

since otherwise PetscMatrix is not a complete type.

-- 
John

_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to