I'm programming on solving a time-dependent PDE using multiple processors using distributed memory, based on step-40. At the beginning step, I need to assign initial values to solution variable. What I have done is:
Where InitialValues<dim> is a user-defined function which is related to Cartesian coordinates and it will set the values of "old_locally_relevant_solution" only once at the first time step. And the next-step solution "locally_relevant_solution" will be solved based on "old_locally_relevant_solution".
When running my code, the error occurred(the details are as follows) and I think the errors might result from the VectorTools::project. So what is the feasible way to set the values of my "old_locally_relevant_solution" using my "InitialValues" function.
Thank you.
--------------------------------------------------------
An error occurred in line <866> of file </home/toddyliu/deal.ii-candi/tmp/unpack/deal.II-v9.2.0/include/deal.II/lac/petsc_vector_base.h> in function
const dealii::PETScWrappers::internal::VectorReference& dealii::PETScWrappers::internal::VectorReference::operator=(const PetscScalar&) const
The violated condition was:
!vector.has_ghost_elements()
Additional information:
You are trying an operation on a vector that is only allowed if the vector has no ghost elements, but the vector you are operating on does have ghost elements. Specifically, vectors with ghost elements are read-only and cannot appear in operations that write into these vectors.
See the glossary entry on 'Ghosted vectors' for more information.
Stacktrace:
-----------
#0 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: dealii::PETScWrappers::internal::VectorReference::operator=(double const&) const
#1 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: dealii::internal::ElementAccess<dealii::PETScWrappers::MPI::Vector>::set(double, unsigned int, dealii::PETScWrappers::MPI::Vector&)
#2 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: void dealii::VectorTools::internal::project_matrix_free_copy_vector<2, dealii::PETScWrappers::MPI::Vector, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::PETScWrappers::MPI::Vector&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
#3 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: void dealii::VectorTools::internal::project<dealii::PETScWrappers::MPI::Vector, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::PETScWrappers::MPI::Vector&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
#4 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: void dealii::VectorTools::project<2, dealii::PETScWrappers::MPI::Vector, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::PETScWrappers::MPI::Vector&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
#5 /home/toddyliu/deal.ii-candi/deal.II-v9.2.0/lib/libdeal_II.g.so.9.2.0: void dealii::VectorTools::project<2, dealii::PETScWrappers::MPI::Vector, 2>(dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::PETScWrappers::MPI::Vector::value_type> const&, dealii::PETScWrappers::MPI::Vector&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
#6 ./dendriticSolidification-4: DenSolid::DendriticSolidification<2>::run()
#7 ./dendriticSolidification-4: main