The assignment of initial values by user-defined initialValues<dim>

48 views
Skip to first unread message

Toddy Liu

unread,
Oct 2, 2021, 4:31:49 AM10/2/21
to deal.II User Group
Dear Deal.II community,

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: 
screenshot.png
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.

Any advice or suggestions will be appreciated!
Thank you.

Best,
Toddy


--------------------------------------------------------
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



Wolfgang Bangerth

unread,
Oct 4, 2021, 12:37:01 AM10/4/21
to dea...@googlegroups.com
On 10/2/21 2:31 AM, Toddy Liu wrote:
>
> 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.

Toddy: It would be interesting to know whether the error is also in the latest
deal.II release, 9.3. But regardless of this, for parallel computations it is
often simpler to use interpolation (via VectorTools::interpolate()) rather
than projection because the former does not require solving a linear system.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Praveen C

unread,
Oct 4, 2021, 1:16:36 AM10/4/21
to Deal. II Googlegroup
But VectorTools::project needs a vector without ghosts, right ?

And thats what the error is saying.

In step-40 solve function, we already use a vector without ghosts when we solve the linear system. Similar thing has to be done for project.

best
praveen

Toddy Liu

unread,
Oct 4, 2021, 4:37:30 AM10/4/21
to dea...@googlegroups.com
Professor Wolfgang,

Thanks for your reply. I use VectorTools::interpolate instead of project then get even better results. Thank you again.

Best,
Toddy  
Reply all
Reply to author
Forward
0 new messages