<head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBannerh21b6s7 { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButtonh21b6s7:hover, .pfptPrimaryButtonh21b6s7:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButtonh21b6s7:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
</head><!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">
Hello, The following code returns a different answer depending on how many processors I use. With one processor, the last MPIAIJ matrix is correctly formed: row 0: (0, 1. ) (1, 2. ) (2, 3. ) (3, 4. ) (4, -1. ) row 1: (0, 5. ) (1, 6. ) (2, 7. )
</div>
<!-- Preheader Text : END -->
<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerStart</div>
<!--[if ((ie)|(mso))]>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" ><tr><td>
<table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #90a4ae;background-color:#D0D8DC;"><tr><td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px">
<tr><td style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr">
This Message Is From an External Sender
</td></tr>
<tr><td style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr">
This message came from outside your organization.
</td></tr>
</table>
</td></tr></table>
</td></tr></table>
<![endif]-->
<![if !((ie)|(mso))]>
<div dir="ltr" id="pfptBannerh21b6s7" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #D0D8DC !important; background-color: #D0D8DC; border-top: 4px solid #90a4ae !important; border-top: 4px solid #90a4ae;">
<div id="pfptBannerh21b6s7" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBannerh21b6s7" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px">
This Message Is From an External Sender
</div>
<div id="pfptBannerh21b6s7" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;">
This message came from outside your organization.
</div>
</div>
<div style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"> </div>
</div>
<![endif]>
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerEnd</div>
<!-- Email Banner : END -->
<!-- BaNnErBlUrFlE-BoDy-end -->
<div dir="ltr">Hello,<div><br></div><div>The following code returns a different answer depending on how many processors I use. With one processor, the last MPIAIJ matrix is correctly formed:<br><br>row 0: (0, 1.) (1, 2.) (2, 3.) (3, 4.) (4, -1.)<br>row 1: (0, 5.) (1, 6.) (2, 7.) (3, 8.) (4, -2.)<br>row 2: (0, 9.) (1, 10.) (2, 11.) (3, 12.) (4, -3.)<br>row 3: (0, 13.) (1, 14.) (2, 15.) (3, 16.) (4, -4.)<br>row 4: (0, 17.) (1, 18.) (2, 19.) (3, 20.) (4, -5.)<br>row 5: (0, 21.) (1, 22.) (2, 23.) (3, 24.) (4, -6.)<br>row 6: (0, 25.) (1, 26.) (2, 27.) (3, 28.) (4, -7.)<br></div><div><br></div><div>With two processors though, the column matrix is placed in between:<br><br>row 0: (0, 1.) (1, 2.) (2, -1.) (3, 3.) (4, 4.)<br>row 1: (0, 5.) (1, 6.) (2, -2.) (3, 7.) (4, 8.)<br>row 2: (0, 9.) (1, 10.) (2, -3.) (3, 11.) (4, 12.)<br>row 3: (0, 13.) (1, 14.) (2, -4.) (3, 15.) (4, 16.)<br>row 4: (0, 17.) (1, 18.) (2, -5.) (3, 19.) (4, 20.)<br>row 5: (0, 21.) (1, 22.) (2, -6.) (3, 23.) (4, 24.)<br>row 6: (0, 25.) (1, 26.) (2, -7.) (3, 27.) (4, 28.)<br></div><div><br></div><div>Am I not building the nested matrix correctly, perhaps? I am using the Firedrake PETSc fork. Can you reproduce it?</div><div><br></div><div>Thanks,</div><div>Miguel</div><div><br></div><div><br>```python<br>import numpy as np<br>from petsc4py import PETSc<br>from petsc4py.PETSc import COMM_WORLD<br><br><br>input_array = np.array(<br> [<br> [1, 2, 3, 4],<br> [5, 6, 7, 8],<br> [9, 10, 11, 12],<br> [13, 14, 15, 16],<br> [17, 18, 19, 20],<br> [21, 22, 23, 24],<br> [25, 26, 27, 28],<br> ],<br> dtype=np.float64,<br>)<br><br><br>n_11_global_rows, n_11_global_cols = input_array.shape<br>size = ((None, n_11_global_rows), (None, n_11_global_cols))<br>mat = PETSc.Mat().createAIJ(size=size, comm=COMM_WORLD)<br>mat.setUp()<br>mat.setValues(range(n_11_global_rows), range(n_11_global_cols), input_array)<br>mat.assemblyBegin()<br>mat.assemblyEnd()<br>mat.view()<br><br>input_array = np.array([[-1, -2, -3, -4, -5, -6, -7]], dtype=np.float64)<br>global_rows, global_cols = input_array.T.shape<br>size = ((None, global_rows), (None, global_cols))<br>mat_2 = PETSc.Mat().createAIJ(size=size, comm=COMM_WORLD)<br>mat_2.setUp()<br>mat_2.setValues(range(global_rows), range(global_cols), input_array)<br>mat_2.assemblyBegin()<br>mat_2.assemblyEnd()<br><br>N = PETSc.Mat().createNest([[mat, mat_2]], comm=COMM_WORLD)<br>N.assemblyBegin()<br>N.assemblyEnd()<br><br>PETSc.Sys.Print(f"N sizes: {N.getSize()}")<br><br>N.convert("mpiaij").view()<br>```<br><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%" dir="ltr"><tbody><tr> <td dir="ltr" style="font-family:sans-serif,sans-serif;font-size:12px;color:#626262;text-align:left"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td style="line-height:18px"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"><tbody><tr> <td height="25" width="100%" style="font-size:25px;line-height:25px"> </td> </tr></tbody></table> </td></tr><tr> </tr></tbody></table><table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td align="left" style="line-height:21px"> <b style="color:#626262;font-family:sans-serif"> Miguel Angel Salazar de Troya </b> <br> <div style="color:#a4a4a4;font-family:sans-serif"> Head of Software Engineering </div> </td> </tr></tbody></table> </td></tr> <tr><td><div cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"></div></td></tr><tr> <td height="18" width="100%" style="font-size:18px;line-height:18px"> </td> </tr></tbody></table> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse;max-width:550px"><tbody><tr> <td valign="middle" style="line-height:1;width:250px"> <img src="https://cdn.signite.io/a5017/121058/conversions/corintis-thumb.png" border="0" alt="" width="250" style="display:block"> </td> <td width="20"></td> <td width="2" bgcolor="#EAEAEA"></td> <td width="20"></td> <td valign="middle"> <div style="font-size:12px"> <div> <div style="line-height:1;white-space:normal"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td valign="middle" height="20" style="font-size:12px;line-height:15px"> <span style="font-family:sans-serif"> EPFL Innovation Park Building C </span> </td> </tr></tbody></table> </div> </div> <div> <div style="line-height:1;white-space:normal"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td valign="middle" height="20" style="font-size:12px;line-height:15px"> <span style="font-family:sans-serif"> 1015 Lausanne </span> </td> </tr></tbody></table> </div> </div> <div> <div style="line-height:1;white-space:normal"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td valign="middle" height="20" style="font-size:12px;line-height:15px"> <span style="font-family:sans-serif">Email:</span> <a href="mailto:miguel.salazar@corintis.com" style="color:#626262;text-decoration:none;font-family:sans-serif" dir="ltr" target="_blank"> miguel.salazar@corintis.com </a> </td> </tr></tbody></table> </div> </div> <div> <div style="line-height:1;white-space:normal"> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse" width="100%"><tbody><tr> <td valign="middle" height="20" style="font-size:12px;line-height:15px"> <span style="font-family:sans-serif">Website:</span> <a href="https://urldefense.us/v3/__https://www.corintis.com__;!!G_uCfscf7eWS!bC7zvBxQx0RuDXxzlOgxr_PdSp5N9ZdzjgTPmjG_ZU5WbNvHboZHFBhZksYgyDF2nO1IRXABTx5zmJLaL2NK_EYg2SnKUCzq$" style="color:#626262;text-decoration:none;font-family:sans-serif" dir="ltr" target="_blank">www.corintis.com</a> </td> </tr></tbody></table> </div> </div> <div> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"><tbody><tr> <td height="15" width="100%" style="font-size:15px;line-height:15px"> </td> </tr></tbody></table> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"><tbody><tr> </tr></tbody></table> </div> </div> </td> </tr></tbody></table> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"><tbody><tr> <td height="5" width="100%" style="font-size:5px;line-height:5px"> </td> </tr></tbody></table> <table><tbody><tr> <td height="1" width="500" style="line-height:1px"> <img src="https://cdn.signite.io/static/spacer.gif" width="500" height="1" border="0" style="display:block" alt=""> </td> </tr></tbody></table> <table cellpadding="0" cellspacing="0" border="0" style="float:none;font-size:12px;font-family:sans-serif;color:#626262;border-collapse:collapse"><tbody><tr> <td height="5" width="100%" style="font-size:5px;line-height:5px"> </td> </tr></tbody></table> <table><tbody><tr> <td height="1" width="500" style="line-height:1px"> <img src="https://cdn.signite.io/static/spacer.gif" width="500" height="1" border="0" style="display:block" alt=""> </td> </tr> </tbody></table></div></div></div>