<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 id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Dear all,</p>
<p><br>
</p>
<p>First I would like to thank all getdp and gmsh authors/developers for such amazing pieces of software
<br>
</p>
<p>and to make them available open source!</p>
<p><br>
</p>
<p>I am currently working on topology optimization problems in electromagnetism.<br>
</p>
<p>I'll try to keep it simple: I want to maximize square the norm of the electric field in some sub-domain Omega_target,
<br>
</p>
<p>by changing the permittivity value in a design sub-domain Omega_design.<br>
</p>
<p>I defined a formulation<span> "helmoltz_scalar" </span>for a 2D time-harmonic problem (xy plane), TE polarization
<span></span><span></span></p>
<p><span>for the z component of the E-field, which I call u.</span><br>
</p>
<p>In matrix form :</p>
<p>A*u = b (1)</p>
<p>where b is a known source term. <br>
</p>
<p><br>
</p>
<p>Now gradient-based optimization algorithm needs information about the sensitivity of the
<br>
</p>
<p>objective function g with respect to the design variable epsilon. The most efficient way to obtain it
<br>
</p>
<p>is by solving an adjoint problem, namely <br>
</p>
<p>A*uadj = dg/du (2)</p>
<p>In my case g=|u|^2 so the second member of the adjoint equation (2) is dg/du = 2*Re[u]</p>
<p><br>
</p>
<p><span>Since the matrix A is the same for both problems, we do not need to assemble it twice</span><br>
</p>
Is there a way to save time and generate only the right hand side for the adjoint equation?<br>
<p>It looks like the function GenerateRHSGroup might be useful (but it is not documented yet), together with<span> SolveAgain</span>.
<br>
</p>
<p><br>
</p>
<p>This somehow similar to this old thread but maybe there is a more straightforward way to do it?<br>
</p>
<p><a id="LPlnk102804" href="http://onelab.info/pipermail/getdp/2011/001383.html" class="OWAAutoLink">http://onelab.info/pipermail/getdp/2011/001383.html</a><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>Here are the Formulation and Resolution parts of my .pro file:</p>
<p><br>
</p>
<p>#############################################################################<br>
</p>
<p></p>
<div>Formulation{<br>
{Name helmoltz_scalar; Type FemEquation;<br>
Quantity {<br>
{ Name u; Type Local; NameOfSpace Hgradu;}<br>
} <br>
Equation {<br>
Galerkin { [k0^2*CompZZ[epsilonr[]]*Dof{u} , {u}];<br>
In Omega; Jacobian JVol; Integration Int_1; }<br>
Galerkin { [-1/TensorDiag[CompYY[mur[]],CompXX[mur[]],CompXX[mur[]]]*Dof{Grad u} , {Grad u}];<br>
In Omega; Jacobian JVol; Integration Int_1; }<br>
Galerkin { [source[] , {u}];<br>
In Omega; Jacobian JVol; Integration Int_1; }<br>
}<br>
}<br>
{Name adjoint_eq; Type FemEquation;<br>
Quantity {<br>
{ Name u; Type Local; NameOfSpace Hgradu;}<br>
{ Name uadj; Type Local; NameOfSpace Hgraduadj;}<br>
} <br>
Equation {<br>
Galerkin { [ k0^2*CompZZ[epsilonr[]]*Dof{uadj} , {uadj}];<br>
In Omega; Jacobian JVol; Integration Int_1; }<br>
Galerkin { [-1/TensorDiag[CompYY[mur[]],CompXX[mur[]],CompXX[mur[]]]*Dof{Grad uadj} , {Grad uadj}];<br>
In Omega; Jacobian JVol; Integration Int_1; }<br>
Galerkin { [2*Re[{u}], {uadj}]; // <br>
In Omega_target; Jacobian JVol; Integration Int_1; } <br>
}<br>
}<br>
<br>
}</div>
<br>
<br>
<div>Resolution {<br>
{ Name all<br>
System {<br>
{ Name S; NameOfFormulation helmoltz_scalar; Type ComplexValue; Frequency Freq;}<br>
{ Name Sadj; NameOfFormulation adjoint_eq; Type ComplexValue; Frequency Freq;}<br>
}<br>
Operation {<br>
Generate[S] ;Solve[S] ;SaveSolution[S] ;<br>
Generate[Sadj] ;Solve[Sadj] ; SaveSolution[Sadj] ;<br>
}<br>
<br>
}<br>
}</div>
<span id="ms-rterangepaste-start"></span>
<div>
<p><br>
</p>
#############################################################################</div>
<span id="ms-rterangepaste-end"></span><br>
<br>
<br>
<p>Thanks in advance!</p>
<p><br>
</p>
<p>All best</p>
<p><br>
</p>
<p>Benjamin<br>
</p>
<br>
<p></p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
---------------------------------------------------------------------------------------------------<br>
<b>Benjamin Vial</b><br>
Postdoctoral Research Assistant<br>
Antennas and Electromagnetics research group<br>
School of Electronics Engineering and Computer Science<br>
Queen Mary, University of London<br>
<a id="LPNoLP" href="http://benjaminvial.org/">http://benjaminvial.org/</a><br>
<a id="LPNoLP" title="Ctrl+Click or tap to follow the link" href="http://antennas.eecs.qmul.ac.uk/">http://antennas.eecs.qmul.ac.uk/</a><br>
<a id="LPNoLP" title="Ctrl+Click or tap to follow the link" href="http://www.quest-spatial-transformation.org/team/researchers/dr-benjamin-vial/">http://www.quest-spatial-transformation.org/team/researchers/dr-benjamin-vial/</a><br>
<br>
</div>
</div>
</div>
</div>
</body>
</html>