<div dir="ltr">Just note, GAMG uses these near null space vectors but hypre does not as far as I know.<div>Hypre does do elasticity so I would just stick with hypre if you just want to solve your problem (and move on)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 31, 2024 at 1:01 AM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">There is MatSetNearNullSpace, which is used to ensure an approximation property in coarse levels of multigrid. That should always be set when dealing with problems like this, regardless of boundary conditions. Separately, there is MatSetNullSpace, which you should only use if you are solving a singular system with that null space.<br>
<br>
Note that you need at least three non-colinear points to constrain the null space so if you, for example, have a Dirichlet condition at only one point or along one straight line, there will still be a null space.<br>
<br>
Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a>> writes:<br>
<br>
> I think Mark mentioned this earlier, but I want to make sure that the rigid<br>
> body null vectors should be specified only when Neumann boundary conditions<br>
> are used on all boundaries of the domain, correct? Alternatively, if a<br>
> Dirichlet boundary condition is used (on any part of the domain boundary)<br>
> then there is no null space, i.e., the operator is a full rank matrix?<br>
><br>
> If the above is true, then I think I do not need to specify the rigid body<br>
> null modes because I am using Dirichlet boundary conditions for the<br>
> velocity solver.<br>
><br>
> On Wed, Oct 30, 2024 at 12:28 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br>
><br>
>> Yes to 6 null vectors in 3D, 3 null vectors in 2D. The center of mass does<br>
>> not need to be identified because you can algebraically orthogonalize<br>
>> (lines 411-420 here).<br>
>><br>
>><br>
>> <a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/plexfem.c?ref_type=heads*L377-425__;Iw!!G_uCfscf7eWS!b0T54ExhpyMjL9O-B63FmKcfUHpYoH0-ixjUnroOoB0PZPSEVH2-LEMb_Yw57sybhA0rknBisFM2erfwfjN2syg$" rel="noreferrer" target="_blank">https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/plexfem.c?ref_type=heads#L377-425</a><br>
>><br>
>> See also this implementation with raw coordinates. GAMG orthogonalizes<br>
>> within each aggregate (in a later phase of the algorithm) so global<br>
>> orthogonalization is not necessary.<br>
>><br>
>><br>
>> <a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/pc/impls/gamg/agg.c?ref_type=heads*L387__;Iw!!G_uCfscf7eWS!b0T54ExhpyMjL9O-B63FmKcfUHpYoH0-ixjUnroOoB0PZPSEVH2-LEMb_Yw57sybhA0rknBisFM2erfw3-yhJ68$" rel="noreferrer" target="_blank">https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/pc/impls/gamg/agg.c?ref_type=heads#L387</a><br>
>><br>
>> Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a>> writes:<br>
>><br>
>> > I think the nullspace for the velocity operator is of the form<br>
>> ><br>
>> > vnull = U + ω × r<br>
>> > in which U is a rigid body velocity and ω is the rigid body rotational<br>
>> > velocity, and r is the radius vector from the center of mass. I believe I<br>
>> > need to construct 6 nullspace vectors in 3D and 3 nullspace vectors in<br>
>> 2D.<br>
>> > Sounds correct? Also does the center of mass coordinates matter when<br>
>> > defining r?<br>
>> ><br>
>> > On Wed, Oct 30, 2024 at 7:53 AM Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a>><br>
>> wrote:<br>
>> ><br>
>> >> @Mark: Is there some document/paper that I can follow to check the<br>
>> algebra<br>
>> >> of these zero eigenvectors/null space modes?<br>
>> >><br>
>> >> @Jed : We use a projection method preconditioner to solve the coupled<br>
>> >> velocity pressure system as described here (<br>
>> >> <a href="https://urldefense.us/v3/__https://www.sciencedirect.com/science/article/pii/S0021999123004205__;!!G_uCfscf7eWS!b0T54ExhpyMjL9O-B63FmKcfUHpYoH0-ixjUnroOoB0PZPSEVH2-LEMb_Yw57sybhA0rknBisFM2erfwvAPghoI$" rel="noreferrer" target="_blank">https://www.sciencedirect.com/science/article/pii/S0021999123004205</a>).<br>
>> It<br>
>> >> is an approximation of the Schur complement. As a part of projection<br>
>> >> preconditioner, we need to solve just the momentum equation separately<br>
>> >> without considering the pressure part.<br>
>> >><br>
>> >> On Tue, Oct 29, 2024 at 8:03 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br>
>> >><br>
>> >>> And to be clear, we recommend using fieldsplit Schur to separate the<br>
>> >>> pressure and velocity part (there are many examples). Applying AMG<br>
>> directly<br>
>> >>> to the saddle point problem will not be a good solver because the<br>
>> >>> heuristics assume positivity and do not preserve inf-sup stability<br>
>> (nor do<br>
>> >>> standard smoothers).<br>
>> >>><br>
>> >>> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> writes:<br>
>> >>><br>
>> >>> > This is linear elasticity and there are 6 "null" vectors (if you<br>
>> removed<br>
>> >>> > Dirichlet boundary conditions these are eigenvectors with zero<br>
>> >>> eigenvalue):<br>
>> >>> > 3 translations, x, y, z, and three rotatiions xx, yy ,zz.<br>
>> >>> > x = (1,0,0,1,0,0,1,0 ...)<br>
>> >>> > and xx is something like (0, z_1, -y_1, 0, z_2, -y_2, ...) where z_1<br>
>> is<br>
>> >>> the<br>
>> >>> > z coordinate of the first vertex, etc.<br>
>> >>> ><br>
>> >>> > Mark<br>
>> >>> ><br>
>> >>> > On Tue, Oct 29, 2024 at 3:47 PM Amneet Bhalla <<a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a><br>
>> ><br>
>> >>> wrote:<br>
>> >>> ><br>
>> >>> >> Hi Mark,<br>
>> >>> >><br>
>> >>> >> Thanks! I am not sure how to construct null space and zero energy<br>
>> modes<br>
>> >>> >> manually for this operator. Is there some theory or documentation I<br>
>> can<br>
>> >>> >> follow to figure out what the null space and zero energy modes look<br>
>> >>> like<br>
>> >>> >> for this operator? Once I know what these are in symbolic form, I<br>
>> >>> think I<br>
>> >>> >> should be able to construct them manually.<br>
>> >>> >><br>
>> >>> >> Best,<br>
>> >>> >> --Amneet<br>
>> >>> >><br>
>> >>> >> On Tue, Oct 29, 2024 at 7:35 AM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br>
>> >>> >><br>
>> >>> >>> Oh my mistake. You are using staggered grids. So you don't have a<br>
>> >>> block<br>
>> >>> >>> size that hypre would use for the "nodal" methods.<br>
>> >>> >>> I'm not sure what you are doing exactly, but try hypre and you<br>
>> could<br>
>> >>> >>> create the null space, zero energy modes, manually, attach to the<br>
>> >>> matrix<br>
>> >>> >>> and try GAMG.<br>
>> >>> >>> You can run with '-info :pc' and grep on GAMG to see if GAMG is<br>
>> >>> picking<br>
>> >>> >>> the null space up (send this output if you can't figure it out).<br>
>> >>> >>><br>
>> >>> >>> Thanks,<br>
>> >>> >>> Mark<br>
>> >>> >>><br>
>> >>> >>> On Tue, Oct 29, 2024 at 9:28 AM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
>> wrote:<br>
>> >>> >>><br>
>> >>> >>>> This coordinate interface is just a shortcut for vertex based<br>
>> >>> >>>> discretizations with 3 dof per vertex, etc. (maybe works in 2D).<br>
>> >>> >>>> You will need to construct the null space vectors manually and<br>
>> >>> attach it<br>
>> >>> >>>> to the matrix. Used by GAMG.<br>
>> >>> >>>><br>
>> >>> >>>> Note, for hypre you want to use the "nodal" options and it does<br>
>> not<br>
>> >>> use<br>
>> >>> >>>> these null space vectors. That is probably the way you want to go.<br>
>> >>> >>>> eg: -pc_hypre_boomeramg_nodal_coarsen<br>
>> >>> >>>><br>
>> >>> >>>> I would run with hypre boomerang and -help and grep on nodal to<br>
>> see<br>
>> >>> all<br>
>> >>> >>>> the "nodal" options and use them.<br>
>> >>> >>>><br>
>> >>> >>>> Thanks,<br>
>> >>> >>>> Mark<br>
>> >>> >>>><br>
>> >>> >>>><br>
>> >>> >>>> On Mon, Oct 28, 2024 at 8:06 PM Amneet Bhalla <<br>
>> <a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a><br>
>> >>> ><br>
>> >>> >>>> wrote:<br>
>> >>> >>>><br>
>> >>> >>>>> Hi Folks,<br>
>> >>> >>>>><br>
>> >>> >>>>> I am trying to solve the momentum equation in a projection<br>
>> >>> >>>>> preconditioner using GAMG or Hypre solver. The equation looks<br>
>> like<br>
>> >>> for<br>
>> >>> >>>>> velocity variable *v* looks like:<br>
>> >>> >>>>><br>
>> >>> >>>>><br>
>> >>> >>>>> [image: Screenshot 2024-10-28 at 4.15.17 PM.png]<br>
>> >>> >>>>><br>
>> >>> >>>>> Here, μ is spatially varying dynamic viscosity and λ is spatially<br>
>> >>> >>>>> varying bulk viscosity. I understand that I need to specify rigid<br>
>> >>> body<br>
>> >>> >>>>> nullspace modes to the multigrid solver in order to accelerate<br>
>> its<br>
>> >>> >>>>> convergence. Looking into this routine<br>
>> >>> MatNullSpaceCreateRigidBody() (<br>
>> >>> >>>>><br>
>> >>><br>
>> <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Mat/MatNullSpaceCreateRigidBody/__;!!G_uCfscf7eWS!bVR6duCoDqPhZrWS-sm1c5qxsFPjZMhdT86AqLpPzWgVy5qoRhd4_Jue2LJOIS6LRrtV2cHGrqger1Yvb-Y5f-0$" rel="noreferrer" target="_blank">https://urldefense.us/v3/__https://petsc.org/release/manualpages/Mat/MatNullSpaceCreateRigidBody/__;!!G_uCfscf7eWS!bVR6duCoDqPhZrWS-sm1c5qxsFPjZMhdT86AqLpPzWgVy5qoRhd4_Jue2LJOIS6LRrtV2cHGrqger1Yvb-Y5f-0$</a><br>
>> >>> >>>>> <<br>
>> >>><br>
>> <a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Mat/MatNullSpaceCreateRigidBody/__;!!G_uCfscf7eWS!eKqgIJjCdMzIU76f7X65AmGxrU_-lC7W02BMWafJ77DNf_IuQk6O1X3qU1x9Ez8NJ20vZEL-mF6T1yNmDnwv0eWa2w$" rel="noreferrer" target="_blank">https://urldefense.us/v3/__https://petsc.org/release/manualpages/Mat/MatNullSpaceCreateRigidBody/__;!!G_uCfscf7eWS!eKqgIJjCdMzIU76f7X65AmGxrU_-lC7W02BMWafJ77DNf_IuQk6O1X3qU1x9Ez8NJ20vZEL-mF6T1yNmDnwv0eWa2w$</a><br>
>> >>> >),<br>
>> >>> >>>>> I see that I need to provide the coordinates of each node. I am<br>
>> >>> using<br>
>> >>> >>>>> staggered grid discretization. Do I need to provide coordinates<br>
>> of<br>
>> >>> >>>>> staggered grid locations?<br>
>> >>> >>>>><br>
>> >>> >>>>> Thanks,<br>
>> >>> >>>>> --<br>
>> >>> >>>>> --Amneet<br>
>> >>> >>>>><br>
>> >>> >>>>><br>
>> >>> >>>>><br>
>> >>> >>>>><br>
>> >>> >><br>
>> >>> >> --<br>
>> >>> >> --Amneet<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >><br>
>> >>> >><br>
>> >>><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> --Amneet<br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> ><br>
>> > --<br>
>> > --Amneet<br>
>><br>
><br>
><br>
> -- <br>
> --Amneet<br>
</blockquote></div>