<div dir="ltr"><div dir="ltr">On Thu, Apr 23, 2020 at 12:12 PM Antoine Côté <<a href="mailto:Antoine.Cote3@usherbrooke.ca">Antoine.Cote3@usherbrooke.ca</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">Hi,</span><br>
</div>
<div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div><br>
</div>
<div>I'm using a C++/PETSc program to do Topological Optimization. A finite element analysis is solved at every iteration of the optimization. Displacements U are obtained using KSP solver. U is a Vec created using a 3D DMDA with 3 DOF (ux, uy, uz). Boundary
conditions are stored in Vec N, and forces in Vec RHS. They also have 3 DOF, as they are created using VecDuplicate on U.</div>
<div><br>
</div>
<div>My problem : I have multiple load cases (i.e. different sets of boundary conditions (b.c.) and forces). Displacements U are solved for each load case. I need to extract rapidly the b.c. and forces for each load case before solving.</div>
<div><br>
</div>
<div>One way would be to change the DOF of the DMDA (e.g. for 8 load cases, we could use 3*8=24 DOF). Problem is, prior solving, we would need to loop on nodes to extract the b.c. and forces, for every node, for every load case and for every iteration of the
optimization. This is a waste of time, as b.c. and forces are constant for a given load case.</div>
<div><br>
</div>
<div>A better way would be to assemble b.c. and forces for every load case once, and read them afterwards as needed. This is currently done using a VecDuplicate on U to create multiple vectors N and RHS (N_0, N_1, RHS_0, RHS_1, etc.). Those vectors are hard
coded, and can only solve a set number of load cases.</div>
<div><br>
</div>
<div>I'm looking for a way to allocate dynamically the number of N and RHS vectors. What I would like : </div>
<div>Given nlc, the number of load cases and nn, the number of nodes in the DMDA. Create matrices N and RHS of size (DOF*nn lines, nlc columns). While optimizing : for every load case, use N[all lines, current load case column] and RHS[all lines, current load
case column], solve with KSP, obtain displacement U[all lines, current load case].</div>
<div><br>
</div>
<div>Would that be possible?</div></div></div></div></div></blockquote><div><br></div><div>Why wouldn't you just allocate an array of Vecs, since you only use one at a time?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div>Best regards,</div>
<div><br>
</div>
<div>Antoine Côté</div>
<br>
</div>
</div>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>