One way I was thinking about to avoid this issue is to directly initialize
a sparse matrix and use an explicit system, without creating an implicit
system.

Sorry about the dumb question, but I couldn't find a way to initialize a
sparse matrix with given size. The closest one I can find is in
implicit_system.C and seems more complicated than what I needed (simply an
empty matrix of certain size). Could anyone please help?

Best,
Shawn

On Mon, Feb 25, 2019 at 6:07 PM Yuxiang Wang <yw...@virginia.edu> wrote:

> Dear all,
>
> In solving for linear elasticity, I would need to know the reaction
> forces. This should be relatively easy - just use the stiffness matrix *
> solution vector and we can get the reaction forces.
>
> I used a new system to store the unpenalized stiffness matrix as well as
> the force values:
>
> // Initialize another system to store forces
> LinearImplicitSystem & force_system =
> equation_systems.add_system<LinearImplicitSystem> ("ForceSystem");
>
> force_system.add_variable("fx");
> force_system.add_variable("fy");
> force_system.add_variable("fz");
>
> I used `system` being the main equation system. During the assembly, I
> just assembled two copies of the stiffness matrix, so I can leave one
> unpenalized:
> force_system.matrix->add_matrix (Ke, dof_indices);
> dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
> system.matrix->add_matrix (Ke, dof_indices);
> system.rhs->add_vector (Fe, dof_indices);
>
> Lastly, I just used a vector_mult to get the actual reaction force:
>
> force_system.matrix->vector_mult(*force_system.solution, *system.solution
> );
>
> It worked quite conveniently, because I can also export the nodal forces
> that are already associated with the mesh. However, I did see a warning:
>
> Matrix A must be assembled before calling PetscVector::add_vector(v, A).
> Please update your code, as this warning will become an error in a future
> release.src/numerics/petsc_vector.C, line 235, compiled Sep 19 2018 at
> 23:21:53 ***
> *** Warning, This code is deprecated, and likely to be removed in future
> library versions! src/numerics/petsc_vector.C, line 236, compiled Sep 19
> 2018 at 23:21:53 ***
>
> Any ideas in how I can get around this issue?
>
> Best,
> Shawn
>
> --
> Yuxiang "Shawn" Wang, PhD
> yw...@virginia.edu
> +1 (434) 284-0836
>


-- 
Yuxiang "Shawn" Wang, PhD
yw...@virginia.edu
+1 (434) 284-0836

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

Reply via email to