<div dir="ltr">Yes, that's right.<div><br><div>Also, it is best to send this to the list, like petsc-users, for a few reasons. </div><div><br></div><div>It is useful for the core developers, as well as any lurkers really, to casually see what people are doing. And the threads are archived and are a good source of deep documentation. eg, one could search for these methods to see any discussion on them if you want to go beyond the documentation. Your question is a good question. Could be a FAQ (even if not that frequent).</div></div><div><br></div><div>Mark</div><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 20, 2018 at 10:32 PM Sanjay Govindjee <<a href="mailto:s_g@berkeley.edu">s_g@berkeley.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
Thanks. I will give this a try and see what makes best sense. In
the Thermo-Elastic case I think it should be easy.<br>
The vectors are the 3 translations, the 3 rotations (all on the
first 3 dofs), then a 'translation' on the 4th dof.<br>
<br>
I'll let you know if it works or not.<br>
<br>
-sanjay<br>
<pre class="m_8377073067395826505moz-signature" cols="72">-------------------------------------------------------------------
Sanjay Govindjee, PhD, PE
Horace, Dorothy, and Katherine Johnson Professor in Engineering
779 Davis Hall
University of California
Berkeley, CA 94720-1710
Voice: +1 510 642 6060
FAX: +1 510 643 5264
<a class="m_8377073067395826505moz-txt-link-abbreviated" href="mailto:s_g@berkeley.edu" target="_blank">s_g@berkeley.edu</a>
<a class="m_8377073067395826505moz-txt-link-freetext" href="http://faculty.ce.berkeley.edu/sanjay" target="_blank">http://faculty.ce.berkeley.edu/sanjay</a>
-------------------------------------------------------------------
Books:
Engineering Mechanics of Deformable Solids
<a class="m_8377073067395826505moz-txt-link-freetext" href="http://amzn.com/0199651647" target="_blank">http://amzn.com/0199651647</a>
Engineering Mechanics 3 (Dynamics) 2nd Edition
<a class="m_8377073067395826505moz-txt-link-freetext" href="http://amzn.com/3642537111" target="_blank">http://amzn.com/3642537111</a>
Engineering Mechanics 3, Supplementary Problems: Dynamics
<a class="m_8377073067395826505moz-txt-link-freetext" href="http://www.amzn.com/B00SOXN8JU" target="_blank">http://www.amzn.com/B00SOXN8JU</a>
NSF NHERI SimCenter
<a class="m_8377073067395826505moz-txt-link-freetext" href="https://simcenter.designsafe-ci.org/" target="_blank">https://simcenter.designsafe-ci.org/</a>
-------------------------------------------------------------------
</pre>
<div class="m_8377073067395826505moz-cite-prefix">On 11/20/18 10:39 AM, Mark Adams wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">PCSetCoordinates is essentially
deprecated for this reason. Fragile.
<div><br>
</div>
<div>The recommended way is to use
MatSetNearNullSpace. There is a helper function
MatNullSpaceCreateRigidBody that takes coordinates
that is a reroll of PCSetCoordinates basically, but
you can not use that.</div>
<div><br>
</div>
<div>1) You can create the null space yourself and
give it to the matrix. Here is a sample code:<br>
</div>
<div>
<pre style="color:rgb(0,0,0);white-space:pre-wrap"> if (nearnulldim) {
MatNullSpace nullsp;
Vec *nullvecs;
PetscInt i;
ierr = PetscMalloc1(nearnulldim,&nullvecs);CHKERRQ(ierr);
for (i=0; i<nearnulldim; i++) {
ierr = VecCreate(PETSC_COMM_WORLD,&nullvecs[i]);CHKERRQ(ierr);
ierr = VecLoad(nullvecs[i],viewer);CHKERRQ(ierr);
}
ierr = MatNullSpaceCreate(PETSC_COMM_WORLD,PETSC_FALSE,nearnulldim,nullvecs,&nullsp);CHKERRQ(ierr);
ierr = MatSetNearNullSpace(A,nullsp);CHKERRQ(ierr);
for (i=0; i<nearnulldim; i++) {ierr = VecDestroy(&nullvecs[i]);CHKERRQ(ierr);}
ierr = PetscFree(nullvecs);CHKERRQ(ierr);
ierr = MatNullSpaceDestroy(&nullsp);CHKERRQ(ierr);
}</pre>
</div>
<div>You have <span style="color:rgb(0,0,0);white-space:pre-wrap">nearnulldim = 2*D + 1. You need to replace VecLoad here with code that sets the null space explicitly.</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">
</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">2) Here is another way that would use PETSc's RBM constructor. Here is the recommended way to set the null space now with PETSc's RBMs:</span></div>
<div><span style="color:rgb(0,0,0);white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"><font color="#000000"> if (use_nearnullspace) {
MatNullSpace matnull;
Vec vec_coords;
PetscScalar *c;
ierr = VecCreate(MPI_COMM_WORLD,&vec_coords);CHKERRQ(ierr);
ierr = VecSetBlockSize(vec_coords,3);CHKERRQ(ierr);
ierr = VecSetSizes(vec_coords,m,PETSC_DECIDE);CHKERRQ(ierr);
ierr = VecSetUp(vec_coords);CHKERRQ(ierr);
ierr = VecGetArray(vec_coords,&c);CHKERRQ(ierr);
for (i=0; i<m; i++) c[i] = coords[i]; /* Copy since Scalar type might be Complex */
ierr = VecRestoreArray(vec_coords,&c);CHKERRQ(ierr);
ierr = MatNullSpaceCreateRigidBody(vec_coords,&matnull);CHKERRQ(ierr);
</font><font color="#999999"> ierr = MatSetNearNullSpace(Amat,matnull);CHKERRQ(ierr);
</font><font color="#000000"> ierr = MatNullSpaceDestroy(&matnull);CHKERRQ(ierr);
ierr = VecDestroy(&vec_coords);CHKERRQ(ierr);
} else {</font></span><br>
</div>
<div><font color="#000000"><span style="white-space:pre-wrap">
</span></font></div>
<div><font color="#000000"><span style="white-space:pre-wrap">Now there is a method to get the vectors out of the null space: <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceGetVecs.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceGetVecs.html</a></span></font></div>
<div>
<div><br>
</div>
<div>Now you can create the RBMs (6) with thus
second code and the get the vectors with <span style="color:rgb(0,0,0);white-space:pre-wrap">MatNullSpaceGetVecs -- giving </span><span style="color:rgb(0,0,0);white-space:pre-wrap">MatNullSpaceGetVecs</span><span style="color:rgb(0,0,0);white-space:pre-wrap"> a vector array of size 7. This will give you the 6 RBMs. Now you just need to manually create and set the 7th vector with a basis vector for your thermal dof. I assume that this is the correct null space mathematically. Then use that in </span><span style="color:rgb(0,0,0);white-space:pre-wrap">MatNullSpaceCreate.</span></div>
<div><br>
</div>
<div>You could use either approach.</div>
<div><br>
</div>
<div>Note, I don't know if all this has been tested
well with > 6 null vectors, so we may need to
fix bug(s).</div>
<div><br>
</div>
<div>Mark</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Nov 20, 2018 at 1:03 PM Sanjay Govindjee
<<a href="mailto:s_g@berkeley.edu" target="_blank">s_g@berkeley.edu</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> Mark,<br>
In parFEAP we have been using GAMG together with
PCSetCoordinates. This works fine for mechanical problems,
but<br>
one of our users wants to solve thermo-elastic problems (4 -
dofs per node). The matrix now has a block size of 4<br>
and GAMG is complaining:<br>
<br>
<pre style="margin:0;padding:0"><code class="m_8377073067395826505m_2196643734492311132bbc_code">[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Don't know how to create null space for ndm=3, ndf=4. Use MatSetNearNullSpace.
[0]PETSC ERROR: #1 PCSetCoordinates_AGG() line 196 in /home/user/Software/petsc-3.9.2/src/ksp/pc/impls/gamg/agg.c
[0]PETSC ERROR: #2 PCSetCoordinates() line 1876 in /home/user/Software/petsc-3.9.2/src/ksp/pc/interface/precon.c
I looked at the docs for how to try to set the null space but it was not fully clear to me what is the best way
to do this. Can you give me some hints here?
-sanjay
</code></pre>
<pre class="m_8377073067395826505m_2196643734492311132moz-signature" cols="72">--
-------------------------------------------------------------------
Sanjay Govindjee, PhD, PE
Horace, Dorothy, and Katherine Johnson Professor in Engineering
779 Davis Hall
University of California
Berkeley, CA 94720-1710
Voice: +1 510 642 6060
FAX: +1 510 643 5264
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-abbreviated" href="mailto:s_g@berkeley.edu" target="_blank">s_g@berkeley.edu</a>
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-freetext" href="http://faculty.ce.berkeley.edu/sanjay" target="_blank">http://faculty.ce.berkeley.edu/sanjay</a>
-------------------------------------------------------------------
Books:
Engineering Mechanics of Deformable Solids
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-freetext" href="http://amzn.com/0199651647" target="_blank">http://amzn.com/0199651647</a>
Engineering Mechanics 3 (Dynamics) 2nd Edition
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-freetext" href="http://amzn.com/3642537111" target="_blank">http://amzn.com/3642537111</a>
Engineering Mechanics 3, Supplementary Problems: Dynamics
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-freetext" href="http://www.amzn.com/B00SOXN8JU" target="_blank">http://www.amzn.com/B00SOXN8JU</a>
NSF NHERI SimCenter
<a class="m_8377073067395826505m_2196643734492311132moz-txt-link-freetext" href="https://simcenter.designsafe-ci.org/" target="_blank">https://simcenter.designsafe-ci.org/</a>
-------------------------------------------------------------------
</pre>
</div>
</blockquote>
</div>
</blockquote>
<br>
</div>
</blockquote></div></div>