Hi David,
Alternative approach which avoids copying matrices and calling apply_boundary_values() (both are not very fast opeations) is as follows: Switch to applying constraints locally. Keep your constraints as (a) hanging nodes + zero dirichlet and (b) non-zero dirichlet. 1. Assemble system matrix with (a) constraints. While doing so mark cells which are on the boundary and put them into a list. 2. Every time you need to update you BC, updated the (b) constraint object. Then loop over boundary cells, assemble local matrix and use distribute_local_to_global ( const Vector< LocalType > & local_vector, const std::vector< size_type > & local_dof_indices, VectorType & global_vector, const FullMatrix< LocalType > & local_matrix ) with zero local_vector and constraints (b). Regards, Denis. On Saturday, August 20, 2016 at 12:27:55 AM UTC+2, David F wrote: > > Hello everyone, I looked in the forum, in the documentation and in the > tutorials but I couldn't find a way to solve this problem in the way I > need. I would appreciate a lot any help you could provide me. > > > I would like to have Dirichlet BCs applied to faces with some boundary id. > This id is not changing (i.e., the constrained faces are always the same), > and the mesh, elastic properties etc. are also constant throughout the > program. The function used to define these BCs has always the same shape, > the only thing that is changing is the value of the Dirichlet BCs (e.g., > imagine that first you constrain the displacement of a face with a > spatially-constant value of 1.0 through the face, and in the next solution > step to 2.0 and so on). I need to solve this system many times, each time > with a different value of the Dirichlet BCs. To do this efficiently, I > would like to precalculate as much as possible, for example, assembling the > system matrix only once etc. > > Now my question is, given that the sparsity pattern is not changing (as > the constrained nodes are the same), is there a way to solve this in a > manner such that only the solution and rhs are changing from one step to > the next? If the answer is that the system matrix must necessarily change, > which should be the strategy to reassemble only the changing cells (and > avoiding thus reassembling the whole matrix)? In summary, what's the most > efficient way to repeatedly solve a system in which the only changes from > step to step are the value (not the region over which they are applied) of > the Dirichlet BCs? > > > > About my current implementation: > > I don't have hanging nodes, and I'm using PETScWrappers::MPI:: > SparseMatrix and PETScWrappers::MPI::Vector. > > I assemble the matrix with > > void distribute_local_to_global > <https://dealii.org/8.4.1/doxygen/deal.II/classConstraintMatrix.html#aaa155d7c8fcd10b7c417bfabd2698744> > > (const FullMatrix > <https://dealii.org/8.4.1/doxygen/deal.II/classFullMatrix.html>< typename > MatrixType::value_type > &local_matrix, const std::vector< size_type > <https://dealii.org/8.4.1/doxygen/deal.II/classConstraintMatrix.html#a71b13eb29cd43c9e87abebf2bf78b2a3> > > > &local_dof_indices, MatrixType &global_matrix) const > and apply the BCs with > > void interpolate_boundary_values > <https://dealii.org/8.4.1/doxygen/deal.II/namespaceVectorTools.html#a0e84d0721e3780394e7d854b7ec878cf> > > (const DoFHandlerType &dof, const types::boundary_id > <https://dealii.org/8.4.1/doxygen/deal.II/namespacetypes.html#a685c06c8ba84120df596d9e56f5510e2> > > boundary_component, const Function > <https://dealii.org/8.4.1/doxygen/deal.II/classFunction.html>< > DoFHandlerType::space_dimension, double > &boundary_function, std::map< > types::global_dof_index > <https://dealii.org/8.4.1/doxygen/deal.II/namespacetypes.html#a3bf9e493f1aab00b04933b81856144c4>, > > double > &boundary_values, const ComponentMask > <https://dealii.org/8.4.1/doxygen/deal.II/classComponentMask.html> > &component_mask=ComponentMask > <https://dealii.org/8.4.1/doxygen/deal.II/classComponentMask.html>()) > > void apply_boundary_values > <https://dealii.org/8.4.1/doxygen/deal.II/namespaceMatrixTools.html#a26b81352fcf862218943831dbb38f0a0> > > (const std::map< types::global_dof_index > <https://dealii.org/8.4.1/doxygen/deal.II/namespacetypes.html#a3bf9e493f1aab00b04933b81856144c4>, > > double > &boundary_values, PETScWrappers::MPI::SparseMatrix > <https://dealii.org/8.4.1/doxygen/deal.II/classPETScWrappers_1_1MPI_1_1SparseMatrix.html> > > &matrix, PETScWrappers::MPI::Vector > <https://dealii.org/8.4.1/doxygen/deal.II/classPETScWrappers_1_1MPI_1_1Vector.html> > > &solution, PETScWrappers::MPI::Vector > <https://dealii.org/8.4.1/doxygen/deal.II/classPETScWrappers_1_1MPI_1_1Vector.html> > > &right_hand_side, const bool eliminate_columns=true) > > > > > P.S.: I tried to simply repeat the process to re-apply the BCs with a new > value using the same matrix, but I get always the first BCs I apply (I > think because once I apply it, the matrix knows it has been already > condensed and ignores the next calls). > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
