<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body 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);">
Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks for the fast response! An array of Vec would indeed solve my problem. I just don't know how to allocate it. Say I have a Vec U of the right size (created with a DMDA), and nlc = 4 load cases. How should I allocate and initialize the array?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Best regards</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt;" data-ogsc=""><b>De :</b> Matthew Knepley <knepley@gmail.com><br>
<b>Envoyé :</b> 23 avril 2020 15:23<br>
<b>À :</b> Antoine Côté <Antoine.Cote3@USherbrooke.ca><br>
<b>Cc :</b> petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Objet :</b> Re: [petsc-users] Vec sizing using DMDA</font>
<div> </div>
</div>
<div>
<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" style="">Antoine.Cote3@usherbrooke.ca</a>> wrote:<br>
</div>
<div class="x_gmail_quote">
<blockquote class="x_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="x_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="x_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="https://can01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cse.buffalo.edu%2F~knepley%2F&data=02%7C01%7CAntoine.Cote3%40usherbrooke.ca%7C888ff916feb548abb37f08d7e7bbd0e7%7C3a5a8744593545f99423b32c3a5de082%7C0%7C0%7C637232666159880350&sdata=BrPOJDPKhyf74tJ7y%2B4q8euV3P7YwzK%2BDGZxZr1xZ10%3D&reserved=0" originalsrc="http://www.cse.buffalo.edu/~knepley/" shash="TnqL6hNHLMLLRwh3Gy3VMy9wFcfQy9RaobNSg001dwaFANZunJt8DYEFq2ZFsnfy/Tb/tH4wiyZN9V6o1wBFPYgMDFjRZ2gTq7ULqA0T9sJxgPjsc07EOI1Xg/A04azhx9KvxGPR367AIKVpsCNcx04GwTLT+d4EFzKm6jAWMDA=" target="_blank" style="">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>