Hello Daniel,
for interpolate I know that it is between two different finite element 
spaces on the same mesh, 
e.g. from Q2 to Q1 elements, or in your case from Q1 to dG0.
What you will need to do is construct a Q1 DoFHandler on each mesh and use 
`interpolate_to_different_mesh` to get a Q1 solution vector on mesh B from 
the one on mesh A.
In a second step you can then use `interpolate` to get a dG0 solution on 
mesh B from the 
temporary solution vector. 
I don't think there is a function to do this in one go as it would be 
difficult to programmatically 
decide which DoFHandler to use as an in-between.
Also note that both meshes have to share the same coarse mesh for this to 
work,
which should not be a problem if one is a refinement of the other.

And if i recall correctly the difference between interpolate and project is 
that interpolate is done locally on the element level,
while project works with the global solution and I think requires a linear 
equation system solve. But other people know more about that specific part 
than I.

Best,
Philipp



On Tuesday, February 11, 2025 at 6:52:06 PM UTC+1 daniel.ri...@gmail.com 
wrote:

> Good morning everyone,
>
>
> I am attempting to write a program which projects a solution vector from 
> mesh A to mesh B. Both meshes are parallel distributed and have different 
> geometries (the first is adaptively refined, the latter has uniform grid 
> size). In addition, the solution uses Q1 elements on mesh A and is to be 
> piecewise constant on mesh B.
>
> I have attempted to use VectorTools::project() for this purpose.
>
> -        -   I create a child of the Function class which takes in a 
> solution vector and its corresponding mesh (both parallel distributed). 
> This function allows the solution vector to be evaluated at any coordinate 
> within the domain (and should also consider ghost elements).
>
> -         -    I insert this as a parameter into the project() function. 
> This is projected onto a non-ghosted vector, which is then assigned to a 
> ghosted vector and is subsequently compressed.
>
> The resulting vector correctly projects to some elements, however other 
> *elements 
> appear to be set to 0* (incorrectly). In addition, the number of elements 
> that are zero and their *locations vary with the number of processors 
> used*. I suspect that it may be something to do with project() not being 
> able to handle ghost elements but I’m not sure. It is very possible that 
> the Function used to evaluate the input vector at any coordinate is 
> incorrect, i have included it in a text file below. I have tried using both 
> FEFieldFunction() and later find_all_active_cells_around_point() but to no 
> avail (the latter appears to return empty for these zeroed elements, even 
> after I perturb the coordinate by a significant amount when no cell is 
> found or use a high tolerance).
>
> I then attempted the following crude workaround:
>
> -            serialize the vector and triangulation
>
> -            project them to a new serial vector using project()
>
> -            scatter them back onto the parallel mesh
>
> Unfortunately, this also failed. I am having difficulty copying the 
> parallel mesh onto a serial one, which appears far more involved than I 
> originally thought.
>
> On a sidenote I have attempted to use interpolate() as well and was still 
> unsuccessful (I encountered the same issue with elements set to 0 at the 
> same locations for a given number of cores used).
>
> Any help would be very, very much appreciated
>
>  
>
> Best wishes,
>
> Daniel Rivlin
>
>  
>

-- 
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 dealii+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/dealii/26785e81-a72e-4c70-a246-160faaad3d0cn%40googlegroups.com.

Reply via email to