# Elastic structure analysis with two different material constants depending on region (can't [region] be specified in [buildmesh]?)

Hello, FF++ developers!

I would like to do structural analysis of elastic bodies with different material constants in different regions.
When creating a mesh with the square command, the [region] can be set, but this is not possible with the [buildmesh] command.
How can I do it?

I am considering the analysis of an elastic body with a region (A, B) having two different material constants, with the description of the equation as shown below.

## solve Elasticity ([uu, vv], [w, s]) = int2d(th,regionA)( lambda*div(w,s)*div(uu,vv) + 2.mu( epsilon(w,s)'epsilon(uu,vv) ) ) +int2d(th,regionB)( lambdadiv(w,s)*div(uu,vv) + 2.mu( epsilon(w,s)'epsilon(uu,vv) ) ) + int2d(th)( - gravitys ) + on(1, uu=0, vv=0) ;

See if this helps. IIRC, It makes a mesh with a line in the middle creating two regions
which can then be used to determine material properties etc.

innerline.edp (1.4 KB)

`````` cat drill.edp
macro buildouter()
border left(t=0, 1){x=-szx/2; y=szy*(t-.5);label=1; }
border top(t=0, 1){x=szx*(t-.5);y=szy/2; label=2; }
border right(t=0, 1){x=szx/2; y=-szy*(t-.5);label=3; }
border bottom(t=0, 1){x=-szx*(t-.5);y=-szy/2; label=4; }
// EOM
real szx=2;
real szy=1;
int nx=20;
int ny=20;
buildouter
border middle(t=0, 1){x=0; y=-szy*(t-.5);label=5; }

mesh Th = buildmesh(left(-ny)+top(-nx)+right(-ny)+bottom(-nx)
+ middle(ny));
//medit("Th",Th);
//plot(Th,wait=1,fill=1);
//medit("Th",Th);
macro Op(xx,vxx) (dx(xx)*dx(vxx)+dy(xx)*dy(vxx)) //
fespace Vh1(Th,P1);
fespace Vh2(Th,P2);
Vh1 a1,va1,b1=0;
Vh2 a2,va2,b2=0;
// https://doc.freefem.org/examples/mesh-generation.html
int rl=Th(-szx/2,0).region;
int rr=Th(szx/2,0).region;;
cout<<" rl="<<rl<<" rr="<<rr<<endl; cout.flush;
problem both([a1,a2],[va1,va2],solver=sparsesolver,tgv=-1)
//problem both([a1,a2],[va1,va2],solver=CG)
= int2d(Th,rl)(Op(a1,va1))+int2d(Th,rl)(b1*va1)
+ int2d(Th,rr)(Op(a2,va2))+int2d(Th,rr)(b2*va2)
// otherwise use CG
+int2d(Th,rr)(a1*va1)+int2d(Th,rl)(a2*va2)
// a1 to a2 boundary
+int1d(Th,5)(a2*va2)-int1d(Th,5)(a1*2.0*va2)
+int1d(Th,5)(a2*va1)-int1d(Th,5)(a1*2.0*va1)
+on(1,a1=2*y)+on(3,a2=-3*y)
;

both;
Vh1 net=a1+a2;
plot(a1,cmm="a1",wait=1,fill=true,value=1);
plot(a2,cmm="a2",wait=1,fill=true,value=1);
plot(net,cmm="net",wait=1,fill=true,value=1);
medit("net",Th,net);

marchywka@happy:/home/documents/cpp/proj/freefem/forum\$

``````

Hi Keita,

Please, take a look at Chapter 2, Section 2.15 Optimal Control (https://doc.freefem.org/pdf/FreeFEM-documentation.pdf). In such a problem, the reference domain is a circle with three smaller circles within. Each circle has a different material property. The mesh is created from the buildmesh command.

;D I hope it is useful.

Dear marchywka

When setting the area with [buildmesh], I was able to do what I wanted by using [border] to delimit the area around the area I wanted to distinguish.
I see that different region labels change the color of the mesh (sorry, amateur).

・Create a region mesh with [buildmesh] (use only the minimum necessary [border])
・Add [border] to delimit the area

Thank you for your continued support.
Keita Kambayashi

Dear lucassfernandez