Let us define a function F(z) penalizing the deviation of z from 0 and taking into account the insensitivity zone:
$$\begin{aligned} F(z) = {\left\{ \begin{array}{ll} (z + s)^2, &{}\quad z < -s, \\ 0, &{}\quad - s \le z \le s,\\ (z - s)^2, &{}\quad z > s. \end{array}\right. } \end{aligned}$$
(25)
Using this function, we replace the heuristic strategy by minimization of the functional
$$\begin{aligned} J_{\lambda }(\varOmega ) = \int _{\varGamma _v} F( \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2) ) \, \mathrm{d}s, \end{aligned}$$
(26)
where for Problem 1a,
$$\begin{aligned} \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2)=\frac{1}{2} \varvec{\sigma }({\mathbf {u}}_1):\varvec{\varepsilon }({\mathbf {u}}_1) + \frac{1}{2} \varvec{\sigma }({\mathbf {u}}_2):\varvec{\varepsilon }({\mathbf {u}}_2) - \lambda _0, \end{aligned}$$
while for Problem 2,
$$\begin{aligned} \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2)= \alpha _1 \varvec{\sigma }({\mathbf {u}}_1):\varvec{\varepsilon }({\mathbf {u}}_1) + \alpha _2 \varvec{\sigma }({\mathbf {u}}_2):\varvec{\varepsilon }({\mathbf {u}}_2) - \lambda _0. \end{aligned}$$
For simplicity, we shall consider Problem 1a. After taking the shape derivative of the functional (observe that \(F'=\hbox {d}F/\hbox {d}z\)), we have
$$\begin{aligned} J_{\lambda }(\varOmega ) ' = \int _{\varGamma _v} F'( \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2)) \varrho '({\mathbf {u}}_1,{\mathbf {u}}_2) \, \mathrm{d}s+ \int _{\varGamma _v}\bigg [ \frac{\partial F}{\partial n} + \kappa F\bigg ] {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s, \end{aligned}$$
(27)
where
$$\begin{aligned} \varrho '({\mathbf {u}}_1,{\mathbf {u}}_2)=\varvec{\sigma }({\mathbf {u}}_1'):\varvec{\varepsilon }({\mathbf {u}}_1) +\varvec{\sigma }({\mathbf {u}}_2'):\varvec{\varepsilon }({\mathbf {u}}_2). \end{aligned}$$
Here, \(\kappa \) is the average curvature at the given point on \(\varGamma _v\) and
$$\begin{aligned} \frac{\partial F}{\partial n} = F'( \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2)) \frac{\partial }{\partial n}( \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2) ). \end{aligned}$$
(28)
In order to get rid of \({\mathbf {u}}_1'\) and \({\mathbf {u}}_2'\), we introduce adjoint equations for \({\mathbf {p}}_1\) and \({\mathbf {p}}_2\) in the weak form
$$\begin{aligned} - \int _{\varOmega } \varvec{\sigma }({\mathbf {p}}_1 ): \varvec{\varepsilon }(\varvec{\varphi })\, \mathrm{d}x-\int _{\varGamma _v} F'(\varrho ({\mathbf {u}}_1,{\mathbf {u}}_2) ) \varvec{\sigma }({\mathbf {u}}_1 ):\varvec{\varepsilon }(\varvec{\varphi }) \, \mathrm{d}s= 0 \end{aligned}$$
(29)
and
$$\begin{aligned} - \int _{\varOmega } \varvec{\sigma }({\mathbf {p}}_2 ): \varvec{\varepsilon }(\varvec{\varphi })\, \mathrm{d}x-\int _{\varGamma _v} F'(\varrho ({\mathbf {u}}_1,{\mathbf {u}}_2) ) \varvec{\sigma }({\mathbf {u}}_2 ):\varvec{\varepsilon }(\varvec{\varphi }) \, \mathrm{d}s= 0 \end{aligned}$$
(30)
where \({\mathbf {p}}_1,\, {\mathbf {p}}_2,\, \varvec{\varphi }\, \in {\mathbf {H}}^1_{\varGamma _0}(\varOmega )\). Then, substituting again \(\varvec{\varphi }:= {\mathbf {p}}_1\) or \(\varvec{\varphi }:= {\mathbf {p}}_2\) in the shape derivative of the weak state equations and \(\varvec{\varphi }:= {\mathbf {u}}_1 ' \) or \(\varvec{\varphi }:= {\mathbf {u}}_2 ' \) in the adjoint equations, we obtain
$$\begin{aligned}&\int _{\varGamma _v} F'( \varrho ({\mathbf {u}}_1,{\mathbf {u}}_2) ) \varrho '({\mathbf {u}}_1,{\mathbf {u}}_2) \, \mathrm{d}s\nonumber \\&\quad =\int _{\varGamma _v} [\varvec{\sigma }({\mathbf {u}}_1 ):\varvec{\varepsilon }({\mathbf {p}}_1)+ \varvec{\sigma }({\mathbf {u}}_2 ):\varvec{\varepsilon }({\mathbf {p}}_2)] {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s. \end{aligned}$$
(31)
As a result,
$$\begin{aligned} J_{\lambda }(\varOmega ) ' = \int _{\varGamma _v} \bigg [\varvec{\sigma }({\mathbf {u}}_1 ):\varvec{\varepsilon }({\mathbf {p}}_1)+ \varvec{\sigma }({\mathbf {u}}_2 ):\varvec{\varepsilon }({\mathbf {p}}_2) + \frac{\partial F}{\partial n} + \kappa F \bigg ] {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s. \end{aligned}$$
(32)
When the expression in square brackets is negative, we should add material (\( {\mathbf {V}}\cdot {\mathbf {n}}> 0 \)); otherwise, material has to be removed (\( {\mathbf {V}}\cdot {\mathbf {n}}< 0 \)).
Nevertheless, in such a form the algorithm may have a tendency to liquidate the variable part of the boundary \(\varGamma _v\) altogether. To control this unwanted behavior, we introduce the averaged versions of \(J_{\lambda }\) and F:
$$\begin{aligned} {\bar{J}}_{\lambda }&=\frac{J_{\lambda }}{\int _{\varGamma _v} \, \mathrm{d}s}, \end{aligned}$$
(33)
$$\begin{aligned} {\bar{F}}&=\frac{\int _{\varGamma _v} F \, \mathrm{d}s}{\int _{\varGamma _v} \, \mathrm{d}s}. \end{aligned}$$
(34)
Observe that for \(| \varGamma _v|=\int _{\varGamma _v} \, \mathrm{d}s\) we have
$$\begin{aligned} | \varGamma _v|' =\int _{\varGamma _v} \kappa {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s. \end{aligned}$$
Hence, the shape derivative of the averaged functional may be expressed as
$$\begin{aligned} \begin{aligned} {\bar{J}}'_{\lambda }&= \frac{1}{| \varGamma _v|^2}\big [J'_{\lambda }(\varOmega ) | \varGamma _v| - J_{\lambda }(\varOmega )| \varGamma _v|' \big ]\\&=\frac{1}{| \varGamma _v|}\int _{\varGamma _v}\bigg [\varvec{\sigma }({\mathbf {u}}_1 ):\varvec{\varepsilon }({\mathbf {p}}_1)+ \varvec{\sigma }({\mathbf {u}}_2 ):\varvec{\varepsilon }({\mathbf {p}}_2) + \frac{\partial F}{\partial n} + \kappa F \bigg ] {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s\\&\qquad - \frac{1}{| \varGamma _v|} {\bar{F}}\int _{\varGamma _v} \kappa {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s. \end{aligned} \end{aligned}$$
As a result, the final formula has the form
$$\begin{aligned} {\bar{J}}'_{\lambda }=\frac{1}{| \varGamma _v|}\int _{\varGamma _v} \bigg [\varvec{\sigma }({\mathbf {u}}_1 ):\varvec{\varepsilon }({\mathbf {p}}_1)+ \varvec{\sigma }({\mathbf {u}}_2 ):\varvec{\varepsilon }({\mathbf {p}}_2) + \frac{\partial F}{\partial n} + \kappa (F-{\bar{F}}) \bigg ] {\mathbf {V}}\cdot {\mathbf {n}}\, \mathrm{d}s. \end{aligned}$$
(35)
We assume that the heuristic algorithm for Problem 1a is realized as follows, taking into account the first three terms in (35):
it is assumed that the energy density \(\varvec{\sigma }({\mathbf {u}}): \varvec{\varepsilon }({\mathbf {u}})\) has a constant value \(\lambda _0\) on \(\varGamma _v\);
the energy densities \(\varvec{\sigma }({\mathbf {u}}_1): \varvec{\varepsilon }({\mathbf {u}}_1)\) and \(\varvec{\sigma }({\mathbf {u}}_2): \varvec{\varepsilon }({\mathbf {u}}_2)\) are computed for loads \({\mathbf {t}}_1\) and \({\mathbf {t}}_2\) acting on the same boundary \(\varGamma _1\);
the average energy density is \(\frac{1}{2} \varvec{\sigma }({\mathbf {u}}_1):\varvec{\varepsilon }({\mathbf {u}}_1) + \frac{1}{2} \varvec{\sigma }({\mathbf {u}}_2):\varvec{\varepsilon }({\mathbf {u}}_2) \) for loads \({\mathbf {t}}_1\) and \({\mathbf {t}}_2\);
if at a given point on \(\varGamma _v\) this density is greater than \(\lambda _0+s\), the boundary is moved outside;
if at a given point on \(\varGamma _v\) this density is smaller than \(\lambda _0-s\), the boundary is moved inside;
these steps are repeated until equilibrium is achieved;
the value of \(\lambda _0\) is modified if the final design is unsatisfactory.
The last term in (35), involving the curvature \(\kappa \), is incorporated into the procedure in the following way:
If \(\kappa > 0\) and \(F > {\bar{F}}\), then after a biomimetic modification the boundary is additionally moved inside \(\varOmega \) by 50% of the biomimetic step.
If \(\kappa < 0\) and \(F > {\bar{F}}\), then after a biomimetic modification the boundary is additionally moved outside \(\varOmega \) by 50% of the biomimetic step.
The insensitivity range parametrized by s is needed to ensure existence of equilibrium.
For Problem 2 the algorithm will be the same, with \(\frac{1}{2} \varvec{\sigma }({\mathbf {u}}_1):\varvec{\varepsilon }({\mathbf {u}}_1) + \frac{1}{2} \varvec{\sigma }({\mathbf {u}}_2):\varvec{\varepsilon }({\mathbf {u}}_2) \) replaced by \(\alpha _1 \varvec{\sigma }({\mathbf {u}}_1):\varvec{\varepsilon }({\mathbf {u}}_1) + \alpha _2 \varvec{\sigma }({\mathbf {u}}_2):\varvec{\varepsilon }({\mathbf {u}}_2)\).