Treatment of contact between finite deformable bodies using FreeFem++ Pantz Olivier CMAP, Ecole Polytechnique Decembre 2011
Treatment of contact between finitedeformable bodies
using FreeFem++
Pantz Olivier
CMAP, Ecole Polytechnique
Decembre 2011
Plan
Setting of the problem
Formulations of the ProblemThe Master/Slave approachAn alternative formulation
Numerical MethodsInternal Approximation IInternal Approximation II
Setting of the problem
Let M be a set of deformable bodies and J be a functional thatmaps every deformation ψ of M to its enery J(ψ).
M =
ψ
GoalFind ϕ ∈ A such that
J(ϕ) = minψ∈A
J(ψ)
A: Set of admissibledeformations (without(self)intersections)How couls we define A ?
Setting of the problem
Let M be a set of deformable bodies and J be a functional thatmaps every deformation ψ of M to its enery J(ψ).
M =
ψ
GoalFind ϕ ∈ A such that
J(ϕ) = minψ∈A
J(ψ)
A: Set of admissibledeformations (without(self)intersections)How couls we define A ?
The Master/Slave approach
Let us assume that M = {M1,M2} and dim(M1) = dim(M2) = n.For all x ∈ ∂M2, we set
gψ(x) ={
dist(ψ(x), ψ(∂M1)) si ψ(x) /∈ ψ(M1)−dist(ψ(x), ψ(∂M1)) si ψ(x) ∈ ψ(M1)
gψ(x)
ψ(M1)ψ(x)
ψ(M2)
Definition of the constraintsgψ(x) ≥ 0 for every x ∈ ∂M2.M1 =Master body.M2 =Slave body.
Problems linked with the Master/Slave approach
1. Some deformation that satisfies the constraints are NOTintersection free.
2. All deformations are admissible in the case ofI thin structures (dim(M) < n),I self-contacts.
3. The map g is not derivable, leading to technical difficulties(like the “chatter” problem).
Problems linked with the Master/Slave approach
1. Some deformation that satisfies the constraints are NOTintersection free.
2. All deformations are admissible in the case ofI thin structures (dim(M) < n),I self-contacts.
3. The map g is not derivable, leading to technical difficulties(like the “chatter” problem).
Problems linked with the Master/Slave approach
1. Some deformation that satisfies the constraints are NOTintersection free.
2. All deformations are admissible in the case ofI thin structures (dim(M) < n),I self-contacts.
3. The map g is not derivable, leading to technical difficulties(like the “chatter” problem).
An alternative formulation
We define A as the closure of the embeddings.
A = Emb(M;Rn)
where Emb(M;Rn) is the set of embeddings if M into Rn.
ProsI Could be applied whatever the dimension(s) of M is/are.I Take into account contacts and self-contacts in a single
setting.
ConsI Implicit definition of AI Optimality Conditions ?
An alternative formulation
We define A as the closure of the embeddings.
A = Emb(M;Rn)
where Emb(M;Rn) is the set of embeddings if M into Rn.
ProsI Could be applied whatever the dimension(s) of M is/are.I Take into account contacts and self-contacts in a single
setting.
ConsI Implicit definition of AI Optimality Conditions ?
An alternative formulation
We define A as the closure of the embeddings.
A = Emb(M;Rn)
where Emb(M;Rn) is the set of embeddings if M into Rn.
ProsI Could be applied whatever the dimension(s) of M is/are.I Take into account contacts and self-contacts in a single
setting.
ConsI Implicit definition of AI Optimality Conditions ?
Discretization
Admissible set of deformations Ah,ε
Ah,ε is the set of admissible deformations ψ finite elements P1such that
dist(ψ(a), ψ(b)) ≥ ε,
for all elements a and b of Th, mesh of M, such that a ∩ b = ∅.
Discretized ProblemFind ϕh,ε ∈ Ah,ε
J(ϕh,ε) = minψ∈Ah,ε
J(ψ).
I Explicit of the admissible set.I Optimality conditions easy to
derive.I Convergence of ϕh,ε towardsϕ.
Discretization
Admissible set of deformations Ah,ε
Ah,ε is the set of admissible deformations ψ finite elements P1such that
dist(ψ(a), ψ(b)) ≥ ε,
for all elements a and b of Th, mesh of M, such that a ∩ b = ∅.
Discretized ProblemFind ϕh,ε ∈ Ah,ε
J(ϕh,ε) = minψ∈Ah,ε
J(ψ).
I Explicit of the admissible set.I Optimality conditions easy to
derive.I Convergence of ϕh,ε towardsϕ.
Discretization
Admissible set of deformations Ah,ε
Ah,ε is the set of admissible deformations ψ finite elements P1such that
dist(ψ(a), ψ(b)) ≥ ε,
for all elements a and b of Th, mesh of M, such that a ∩ b = ∅.
Discretized ProblemFind ϕh,ε ∈ Ah,ε
J(ϕh,ε) = minψ∈Ah,ε
J(ψ).
I Explicit of the admissible set.I Optimality conditions easy to
derive.I Convergence of ϕh,ε towardsϕ.
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕ jAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Treatment of the non convexes constraints!
DefinitionT (ψ) = Convex close “Neighborhood” of ψ included in Ah,ε.
� � � �� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �� � � �� � �
� � �� � �� � �
� � � �� � � �� � � �� � � �
� � � �� � � �� � � �� � � �
ϕ = ϕnAlgorithm
1. Initialization: ϕ0 = j .2. For every n ≥ 0,
J(ϕn+1) := minψ∈T (ϕn)
J(ψ).
3. STOP whenJ(ϕn+1) ' J(ϕn).
Choosing T (ψ)
An alternativeCan we define T (ψ) by a simple linearization of the constraintsdist(ψ(a), ψ(b)) ≥ ε for all a and b of Th such that a ∩ b = ∅?
T (ψ) is not included in Ah,ε !
An admissible choice (in dimension n = 2)
T (ψ) = {ϕ ∈ Xh such that for every i , j such that xi /∈ aj ,
(ϕ(aj)− ϕ(xi)) · nij ≥ ε}
Xh =set of P1 finite elements,xi = vertices of the mesh,aj = edges of the mesh,nij(ψ) such that ‖nij(ψ)‖ = 1and
miny∈aj
(ψ(y)−ψ(xi))·nij(ψ) = dist(ψ(xi), ψ(aj))
nij
ψ(xi)
ψ(aj)
Choosing T (ψ)
An alternativeNOT WORKINGCan we define T (ψ) by a simple linearization of the constraintsdist(ψ(a), ψ(b)) ≥ ε for all a and b of Th such that a ∩ b = ∅?
T (ψ) is not included in Ah,ε !
An admissible choice (in dimension n = 2)
T (ψ) = {ϕ ∈ Xh such that for every i , j such that xi /∈ aj ,
(ϕ(aj)− ϕ(xi)) · nij ≥ ε}
Xh =set of P1 finite elements,xi = vertices of the mesh,aj = edges of the mesh,nij(ψ) such that ‖nij(ψ)‖ = 1and
miny∈aj
(ψ(y)−ψ(xi))·nij(ψ) = dist(ψ(xi), ψ(aj))
nij
ψ(xi)
ψ(aj)
Choosing T (ψ)
An alternativeNOT WORKINGCan we define T (ψ) by a simple linearization of the constraintsdist(ψ(a), ψ(b)) ≥ ε for all a and b of Th such that a ∩ b = ∅?
T (ψ) is not included in Ah,ε !
An admissible choice (in dimension n = 2)
T (ψ) = {ϕ ∈ Xh such that for every i , j such that xi /∈ aj ,
(ϕ(aj)− ϕ(xi)) · nij ≥ ε}
Xh =set of P1 finite elements,xi = vertices of the mesh,aj = edges of the mesh,nij(ψ) such that ‖nij(ψ)‖ = 1and
miny∈aj
(ψ(y)−ψ(xi))·nij(ψ) = dist(ψ(xi), ψ(aj))
nij
ψ(xi)
ψ(aj)
Optimality Conditions
Question / AnswerAre fix points of the algorithm local minimizers of J over Ah,ε ?NO !But, they satisfy the optimality conditions up to the orderh(Good enough).
Optimality Conditions
Question / AnswerAre fix points of the algorithm local minimizers of J over Ah,ε ?NO !But, they satisfy the optimality conditions up to the orderh(Good enough).
Optimality Conditions
Question / AnswerAre fix points of the algorithm local minimizers of J over Ah,ε ?NO !But, they satisfy the optimality conditions up to the orderh(Good enough).
Abstract1. Initialization: ϕ0 = j .2. For all n ≥ 0,
J(ϕn+1) = minψ∈T (ϕn)
J(ψ).
3. STOP when J(ϕn+1) ' J(ϕn).
T (ψ) = {ϕ ∈ Xh such that for every i , j such that xi /∈ aj ,
F 0ij (ψ) ≤ 0 and F 1
ij (ψ) ≤ 0}
xi = vertices of the mesh, aj = edges of the mesh, ‖nij(ψ)‖ = 1
miny∈aj
(ψ(y)− ψ(xi)) · nij(ψ) = dist(ψ(xi), ψ(aj))
andFα
ij (ψ) = ε− (ψ(aαj )− ψ(xi)) · nij(ψ),
where aαj (α = 0,1) are the nodes of the edge aj .
Numerical Applications
I Application 1 - Contacts between two linear elastic bodies(Blocks.swf).
I Application 2 - Self-Contacts for a non linear elastic beam(Poutre2.swf).
I Application 3 - Balloons in a rotating box (Dynamic.swf enc++).
Time of ComputationNumber of constraintsare of the order N2
dof where (Ndof =number of degrees offreedoms)
Number of iterationsThe size of a convex neighborhood T (ψ) previously defined isapproximately max(h, ε).The number of iteration of the algorithm is of order max(h, ε)−1.
ε
xi
xi
Uzawa not exact...Uzawa does not lead to a solution that satisfies exactly theconstraints. Moreover, the more ε is small, the more is thesystem ill conditioned !!!
Less constraints !
How to ensure non overlapping of the balls located on the leftwith the one located on the right ?
The first method consists to impose for each couple of balls tobe locate at each side of a plane. It leads to N2
dof constraints.The second method of treatment by ”bundles”, that is to imposethat the left balls are located on one side of a plane and theright balls located on the other. Only Ndof constraints.Proceeding recursively, we can ensure non-intersectionbetween the balls with Ndof log(Ndof ) constraints.
Internal Approximation II
1. Initialization: ϕ0 = j .2. For all k ≥ 0
I Partition Pk of M ×M such that there exists nk such that forevery (xi , xj) ∈ Pk
nk .(ϕk (xi)− ϕk (xj)) > ε. (1)
( and Pk is a ”block”)I ϕk+1 obtained after the minimization of J by a sequence of
neighborhoods of the form (1) where Pk is fixed.
3. STOP as soon as J(ϕk+1) ' J(ϕk )
What you don’t want to see.../ / Uzawa stepr e a l eps i l on =0.001; / / Minimal d is tancesr e a l t o l =0 .1 ; / / t o le rance sur l a c o n d i t i o n de contac t ( en t re 0+ et 1)r e a l alpha =0.001; / / Uzawa step/ / r e a l alpha =0.5 ; / / Uzawa stepr e a l de l tamin =1.e−4∗alpha ; / / C r i t e r e d ’ a r r e t Uzawar e a l e r r =0.001;
i n t NbAdapt=1; / / Nombre d ’ adapta t ion de mai l lage ( A t t e n t i o n a l ’ adapta t ion de mai l lage qu i d o i t e t r e compat ib le avec l a d is tance eps i l on minimale . . . i l es t p re fe rab le/ / dans ce cas de ne pas cons iderer les autocontac ts . . . a f a i r e )
/ / Modules de Lame
r e a l E= 1 . ; / / Module de Young ( t ou jou rs p o s i t i f )/ / r e a l E= 5 . ; / / Module de Young ( t ou jou rs p o s i t i f )r e a l nu =0.35;r e a l lambda=E∗nu / ( ( 1 . + nu)∗(1.−2.∗nu ) ) ; / / coef de Lamer e a l mu=E/ (2 .∗ (1 .+ nu ) ) ;
/ / D e f i n i t i o n o f the meshr e a l Lx =0 .1 ;r e a l Ly = 5 . ;
i n t Neumann=1;i n t D i r i c h l e t =2;
macro boundary1 ,2 ,3 ,4 / /
/ / D e f i n i t i o n du mai l lagemesh Sh , Th ;{
/ / Le premier s o l i d eborder bord ( t =0 ,Lx){x= t ; y = 0 . ; l a b e l = D i r i c h l e t ;};border bord1 ( t =0 ,Ly){x=Lx ; y= t ; l a b e l =Neumann;};border bord2 ( t =Lx ,0){x= t ; y=Ly ; l a b e l = D i r i c h l e t ;};border bord3 ( t =Ly ,0){x =0; y= t ; l a b e l =Neumann;};p l o t ( bord ( 5 ) , bord1 ( 5 ) , bord2 ( 5 ) , bord3 ( 5 ) , wa i t =1 ) ;
r e a l dn = 4 0 . ; / / nb de po in t s par un i t e de longueurSh=buildmesh ( bord ( Lx∗dn)+ bord1 ( Ly∗dn)+ bord2 ( Lx∗dn)+ bord3 ( Ly∗dn ) , f i x e b o r d e r =1 ) ;Th=Sh ;
}
/ / Nombre de reg ions
fespace Vh0 (Sh , P0 ) ;
Vh0 reg=reg ion ;i n t regmax= f l o o r ( reg [ ] . max+ 0 . 5 ) ;i n t [ i n t ] Ac t i ve ( regmax +1) ;Ac t i ve =0;f o r ( i n t i =0; i<Vh0 . ndof ; i ++) Ac t i ve [ f l o o r ( reg [ ] [ i ] + 0 . 5 ) ] = 1 ;i n t nbreg=Ac t i ve . sum;cout<<”Nb de reg ions=”<<nbreg<<endl ;i n t [ i n t ] l abe l r eg ( nbreg ) ;i n t k =0;f o r ( i n t i =0; i<regmax+1; i ++) i f ( Ac t i ve [ i ]==1) {l abe l r eg [ k ]= i ; k++;}cout<<”Les reg ions sont ”<<l abe l reg<<endl ;
p l o t (Sh , wa i t =1 ) ;
/ / D e f i n i t i o n des fo rces appl iqueesfespace Vh1 (Sh , P1 ) ;Vh1 f1 , f2 ;{
f1 =0;f2 =0.;//−0.1∗( reg ==0) ;
/ / p l o t ( [ f1 , f2 ] , wa i t =1 ) ;}
/ / D e f i n i t i o n du probleme d ’ e l a s t i c i t ei n t i n i t i a l i z e ;/ / Vh1 u1 , u2 , v1 , v2 ;Vh1 Fc1 , Fc2 ; / / Forces de contac t
/ / Contact fo rces on the deformed meshfespace Wh( Th , P1 ) ;Wh Fcdef1 , Fcdef2 ;/ / Cons t ruc t ion de l a matr ice de Masse sur l e mai l lage deformev a r f Masse2 ( u , v )= i n t 1d ( Th , qfe=qf1pElump ) ( u∗v ) ;
/ / La deformat ions i n i t i a l e sVh1 phi1=x , phi2=y ;Vh1 p h i r e f 1 =phi1 , p h i r e f 2 =phi2 ;
Vh1 dphi1 , dphi2 , Dphi1 , Dphi2 ;
/ / e l a s t i c i t e non l i n e a i r e
macro ph i [ phi1 , phi2 ] / / Deformationmacro p h i r e f [ ph i re f1 , p h i r e f 2 ] / / Deformation precedentemacro dphi [ dphi1 , dphi2 ] / /macro Dphi [ Dphi1 , Dphi2 ] / /
macro Dx( ph i ) [ dx ( ph i [ 0 ] ) , dx ( ph i [ 1 ] ) ] / / Der ivee par rappor t a x d ’ un vecteurmacro Dy( ph i ) [ dy ( ph i [ 0 ] ) , dy ( ph i [ 1 ] ) ] / / Der ivee par rappor t a ymacro E( ph i ) [ ( Dx ( ph i ) ’∗Dx( ph i )−1.) /2 . , (Dx( ph i ) ’∗Dy( ph i ) ) / 2 . , (Dy( ph i ) ’∗Dy( ph i )−1.) /2. ] / / tenseur de de format ionmacro dE( phi , dphi )
[ Dx ( ph i ) ’∗Dx( dphi ) ,(Dx( ph i ) ’∗Dy( dphi )+Dx( dphi ) ’∗Dy( ph i ) ) / 2 . ,Dy( ph i ) ’∗Dy( dphi ) ] / / d e r iv ee du tenseur de de format ion
macro W( ph i )mu∗(E( ph i ) [0]∗E( ph i ) [0 ]+2.∗E( ph i ) [1]∗E( ph i ) [ 1 ] +E( ph i ) [2]∗E( ph i ) [ 2 ] )+lambda /2.∗ (E( ph i ) [ 0 ] +E( ph i ) [ 2 ] )∗ (E( ph i ) [ 0 ] +E( ph i ) [ 2 ] ) / / dens i t e d ’ energ ie
macro dW( phi , dphi )2.∗mu∗(E( ph i ) [0]∗dE( phi , dphi ) [0 ]+2.∗E( ph i ) [1]∗dE( phi , dphi ) [ 1 ] +E( ph i ) [2]∗dE( phi , dphi ) [ 2 ] )+lambda∗(E( ph i ) [ 0 ] +E( ph i ) [ 2 ] )∗ ( dE( phi , dphi ) [ 0 ] + dE( phi , dphi ) [ 2 ] ) / / d e r iv ee de l a dens i t e d ’ energ ie
macro HW( phi , dphi , Dphi )(2.∗mu∗(dE( phi , Dphi ) [0]∗dE( phi , dphi ) [ 0 ]+2.∗dE( phi , Dphi ) [1]∗dE( phi , dphi ) [ 1 ]+dE( phi , Dphi ) [2]∗dE( phi , dphi ) [ 2 ] )+lambda∗(dE( phi , Dphi ) [ 0 ] + dE( phi , Dphi ) [ 2 ] )∗ ( dE( phi , dphi ) [ 0 ] + dE( phi , dphi ) [ 2 ] ) ) / / ” approx imat ion gross ie re ” de l a de r iv ee seconde de l a dens i t e d ’ energ ie
problem e l a s t i c i t e ( dphi1 , dphi2 , Dphi1 , Dphi2 , i n i t = i n i t i a l i z e )=i n t 2d (Sh ) (HW( ph i re f , dphi , Dphi ) )+ i n t 2d (Sh ) (dW( ph i re f , Dphi ) )−i n t 1d (Sh , qfe=qf1pElump ) ( Fc1∗Dphi1+Fc2∗Dphi2 )+on ( D i r i c h l e t , dphi1 =0 , dphi2 =0) ;
/ / Cons t ruc t ion de l a matr ice de Massev a r f Masse ( u , v )= i n t 1d (Sh , qfe=qf1pElump ) ( u∗v ) ;
r e a l J , Jprec ; / / Energiebool newconvex ;ofstream NRJ ( ” NRJ ” ) ;r e a l gammaprev = 1 . ;
/ / We solve minmisat ion problem f o r an inc reas ing compressioni n t igamma=0;f o r ( r e a l gamma= 1 . ;gamma>0.1;gamma−=0.02){
phi2=gamma/ gammaprev∗phi2 ;gammaprev=gamma;f o r ( i n t iAdapt =0; iAdapt<NbAdapt ; iAdapt++){/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / // / I n i t i a l i s a t i o n / // / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
/ / Assemblage de l a matr ice de masser e a l [ i n t ] omega(Vh1 . ndof ) ;{
mat r i x M=Masse (Vh1 , Vh1 ) ;omega=M. diag ;
}newconvex= t rue ;/ / Determinat ion de l a l i s t e des po in t s du bordi n t [ i n t ] subnbpointsbord ( nbreg ) ;i n t nbpointsbord =0;
i n t 1d (Sh , qfe=qf1pE ) (1 .∗ ( nbpointsbord + + ) ) ;
f o r ( k =0;k<nbreg ; k++){i n t nreg= labe l r eg [ k ] ;subnbpointsbord [ k ] = 0 ;i n t 1d (Sh , qfe=qf1pE ) (1 .∗ ( subnbpointsbord [ k ]+=( reg==nreg ) ) ) ;
}nbpointsbord=subnbpointsbord . sum;cout<<”Nb de po in t s du bord=”<<nbpointsbord<<endl ;
/ / Determinat ion des numeros des noeuds sur l e bord/ / e t de l a c o n n e c i t i v i t e du mai l lagei n t [ i n t , i n t ] a (2 , nbpointsbord ) ;i n t [ i n t , i n t ] e (2 , nbpointsbord ) ;i n t [ i n t ] Idv ( nbpointsbord ) ;{
i n t [ i n t ] aa(2∗nbpointsbord ) ;
Vh1 index =0;f o r ( i n t i =0; i<Vh1 . ndof ; i ++) index [ ] [ i ]= i ;
i n t n=0;i n t [ i n t ] f i r s t ( nbreg ) ;f o r ( i n t k =0;k<nbreg ; k++){
i n t m=n ;i n t 1d (Sh , qfe=qf1pElump ) (1 .∗ ( ( reg== labe l r eg [ k ] ) ? ( aa [ n++]=(1∗ index ) ) : 0 . ) ) ;f i r s t [ k ]= aa [m] ;cout<<”n=”<<n<<endl ;
}cout<<”f i r s t=”<<f i r s t<<endl<<”−−−−−−−−−−−−−−”<<endl ;Vh1 next =0;f o r ( i n t i =0; i<nbpointsbord ; i ++) next [ ] [ aa[2∗ i ] ] = aa[2∗ i + 1 ] ;
n=0;f o r ( i n t k =0;k<nbreg ; k++){
Idv [ n ]= f i r s t [ k ] ;f o r ( i n t i =1; i<subnbpointsbord [ k ] ; i ++) Idv [ n+ i ]= next [ ] [ Idv [ n+ i−1]];n+=subnbpointsbord [ k ] ;
}
Vh1 numero=0;f o r ( i n t i =0; i<nbpointsbord ; i ++) {numero [ ] ( Idv ( i ) ) = i ;}
n=0;i n t 1d (Sh , qfe=qf1pElump ) (1 .∗ ( aa ( n++)=(1∗numero ) ) ) ;f o r ( i n t i =0; i<nbpointsbord ; i ++) {a (0 , i )=aa(2∗ i +1 ) ; a (1 , i )=aa(2∗ i ) ; e (0 , aa(2∗ i ) ) = i ; e (1 , aa(2∗ i +1))= i ;}
/∗/ / Determinat ion du max et min de Idv sur chacun des so l i des
maxup=0; maxdown=0;minup=nbpointsbord ; mindown=nbpointsbord ;i n t 1d (Sh , Neumannup , qfe=qf1pElump ) (1 .∗ ( ( minup=1∗min ( minup , numero))∗(maxup=1∗max(maxup , numero ) ) ) ) ;i n t 1d (Sh , Neumanndown , qfe=qf1pElump ) (1 .∗ ( ( mindown=1∗min ( mindown , numero))∗(maxdown=1∗max(maxdown , numero ) ) ) ) ;cout<<”min ,max up=”<<minup<<”;”<<maxup<<endl ;cout<<”min ,max down=”<<mindown<<”;”<<maxdown<<endl ;
∗/ofstream deformat ion ( ” d e f o r m a t i o n I n i t ” ) ;n=0;f o r ( i n t k =0;k<nbreg ; k++){
f o r ( i n t i =n ; i<n+subnbpointsbord [ k ] ; i ++) deformat ion<<Sh( Idv [ i ] ) . x<<” ”<<Sh( Idv [ i ] ) . y<<endl ;n+=subnbpointsbord [ k ] ;deformat ion<<endl ;
}p l o t (Sh ,cmm=” d e f o r m a t i o n I n i t saved ” ) ;
}
/ / La deformat ions i n i t i a l e s ( i n t e r p o l a t i o n )phi1=phi1 ; phi2=phi2 ;p h i r e f 1 = p h i r e f 1 ; p h i r e f 2 = p h i r e f 2 ;i n i t i a l i z e =0;
/ / Les normales are te / noeudr e a l [ i n t , i n t ] n1 ( nbpointsbord , nbpointsbord ) , n2 ( nbpointsbord , nbpointsbord ) ;n1=0;n2=0;
/ / Determinat ion des normales pour tous les couples de po in t s are te / noeud
func i n t computen(){r e a l alpha , sg , sd , tx , ty , nt , t1 ;f o r ( i n t i 1 =0; i1<nbpointsbord ; i 1 ++) / / We l i s t the edges{
nt =( phi1 [ ] [ Idv ( a (0 , i 1 ))]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] ) ˆ 2 + ( phi2 [ ] [ Idv ( a (0 , i 1 ) ) ]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] ) ˆ 2 ;n t= s q r t ( n t ) ; / / longueur de l ’ a re tet x =( phi1 [ ] [ Idv ( a (0 , i 1 ))]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] ) / n t ;t y =( phi2 [ ] [ Idv ( a (0 , i 1 ))]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] ) / n t ;f o r ( i n t i 2 =0; i2<nbpointsbord ; i 2 ++) / / and the v e r t i c e si f ( ! ( ( a (0 , i 1 )== i 2 )| ( a (1 , i 1 )== i 2 ) ) ) {
sg= t x∗(phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (0 , i 1 ) ) ] ) + t y∗(phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (0 , i 1 ) ) ] ) ;sd=−(t x∗(phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] ) + t y∗(phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] ) ) ;i f ( ( sg< 0) && ( sd< 0) ) {
alpha=1.−2∗(((phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] )∗ ty−(phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] )∗ t x )>0);n1 ( i1 , i 2 )= alpha∗t y ;n2 ( i1 , i 2)=−alpha∗t x ;
}else i f ( sg >= 0) {
t1 =( phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (0 , i 1 ) ) ] ) ˆ 2 + ( phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (0 , i 1 ) ) ] ) ˆ 2 ;t1= s q r t ( t1 ) ;n1 ( i1 , i 2)=−(phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (0 , i 1 ) ) ] ) / t1 ;
n2 ( i1 , i 2)=−(phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (0 , i 1 ) ) ] ) / t1 ;}else {
t1 =( phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] ) ˆ 2 + ( phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] ) ˆ 2 ;t1= s q r t ( t1 ) ;n1 ( i1 , i 2)=−(phi1 [ ] [ Idv ( i 2)]−phi1 [ ] [ Idv ( a (1 , i 1 ) ) ] ) / t1 ;n2 ( i1 , i 2)=−(phi2 [ ] [ Idv ( i 2)]−phi2 [ ] [ Idv ( a (1 , i 1 ) ) ] ) / t1 ;
}}
}}
/ / normales redu i t es Remarque : on p o u r r a i t r edu i re l e temps de c a l c u l e t l e stockage en u t i l i s a n t l a symetr ie du problemer e a l [ i n t , i n t ] Mn1( nbpointsbord , nbpointsbord ) ,mn1( nbpointsbord , nbpointsbord ) ,Mn2( nbpointsbord , nbpointsbord ) ,mn2( nbpointsbord , nbpointsbord ) ;
/ / Reduction o f the c o n s t r a i n t sfunc i n t reduc t ion ( ) {
f o r ( i n t i 1 =0; i1<nbpointsbord ; i 1 ++) / / We l i s t the v e r t i c e s . . .f o r ( i n t i 2 =0; i2<nbpointsbord ; i 2 ++) / / . . . and the v e r t i c e si f ( i 1 != i 2 ){
bool F i r s t va lm = t rue ;bool F i r s t va lM = t rue ;r e a l v1=phi1 [ ] ( Idv ( i 1))−phi1 [ ] ( Idv ( i 2 ) ) ;r e a l v2=phi2 [ ] ( Idv ( i 1))−phi2 [ ] ( Idv ( i 2 ) ) ;f o r ( i n t c =0;c<2;c++) / / Normales a t e s t e r = n ( e (0 , i 1 ) , i 2 ) ; n ( e (1 , i 1 ) , i 2 ) ;−n ( e (0 , i 2 ) , i 1 ) ; −n ( e (1 , i 2 ) , i 1 ) ;
i f ( ( n1 ( e ( c , i 1 ) , i 2 ) ! = 0 )| ( n2 ( e ( c , i 1 ) , i 2 ) !=0)){r e a l alpha =n1 ( e ( c , i 1 ) , i 2 )∗v2−n2 ( e ( c , i 1 ) , i 2 )∗v1 ;r e a l Malpha=Mn1( i1 , i 2 )∗v2−Mn2( i1 , i 2 )∗v1 ;r e a l malpha=mn1( i1 , i 2 )∗v2−mn2( i1 , i 2 )∗v1 ;i f ( ( alpha>Malpha )| F i r s t va lM ) {
Mn1( i1 , i 2 )=n1 ( e ( c , i 1 ) , i 2 ) ;Mn2( i1 , i 2 )=n2 ( e ( c , i 1 ) , i 2 ) ;F i r s t va lM = f a l s e ;}
i f ( ( alpha<malpha )| F i r s t va lm ) {mn1( i1 , i 2 )=n1 ( e ( c , i 1 ) , i 2 ) ;mn2( i1 , i 2 )=n2 ( e ( c , i 1 ) , i 2 ) ;F i r s t va lm = f a l s e ;}
}f o r ( i n t c =0;c<2;c++) / / Normales a t e s t e r = n ( e (0 , i 1 ) , i 2 ) ; n ( e (1 , i 1 ) , i 2 ) ;−n ( e (0 , i 2 ) , i 1 ) ; −n ( e (1 , i 2 ) , i 1 ) ;
i f ( ( n1 ( e ( c , i 2 ) , i 1 ) ! = 0 )| ( n2 ( e ( c , i 2 ) , i 1 ) !=0)){r e a l alpha =−n1 ( e ( c , i 2 ) , i 1 )∗v2+n2 ( e ( c , i 2 ) , i 1 )∗v1 ;r e a l Malpha=Mn1( i1 , i 2 )∗v2−Mn2( i1 , i 2 )∗v1 ;r e a l malpha=mn1( i1 , i 2 )∗v2−mn2( i1 , i 2 )∗v1 ;i f ( ( alpha>Malpha )| F i r s t va lM ) {
Mn1( i1 , i 2)=−n1 ( e ( c , i 2 ) , i 1 ) ;
Mn2( i1 , i 2)=−n2 ( e ( c , i 2 ) , i 1 ) ;F i r s t va lM = f a l s e ;
}i f ( ( alpha<malpha )| F i r s t va lm ) {
mn1( i1 , i 2)=−n1 ( e ( c , i 2 ) , i 1 ) ;mn2( i1 , i 2)=−n2 ( e ( c , i 2 ) , i 1 ) ;F i r s t va lm = f a l s e ;
}}
}}
r e a l [ i n t , i n t ] Mlambda ( nbpointsbord , nbpointsbord ) ; / / Lagrange M u l t i p l i e r s f o r the const r a i n t s f o r a l l couple ( ver tex , ve r tex ) f o r the normal Mnr e a l [ i n t , i n t ] mlambda ( nbpointsbord , nbpointsbord ) ; / / . . . and f o r the normal mnr e a l [ i n t , i n t ] MC( nbpointsbord , nbpointsbord ) ; / / Les c o n t r a i n t e sr e a l [ i n t , i n t ] mC( nbpointsbord , nbpointsbord ) ; / /r e a l [ i n t ] nbcons t ra in t s ( nbpointsbord ) ; / / Number o f a c t i v e c o n s t r a i n t sr e a l [ i n t ] nblambda ( nbpointsbord ) ; / / Number o f a c t i v e c o n s t r a i n t s
Mlambda=0; mlambda=0;i n t i t e rconvex =0;i n t i terUzawa =0;Vh1 phiprec1 , phiprec2 ; / / The deformat ions
/ / end of i n i t i a l i s a t i o n / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /wh i le ( ( i terUzawa !=1 ) &(newconvex ) ) / / Convexes loop{
p h i r e f 1 =phi1 ; p h i r e f 2 =phi2 ; / / i l f a u d r a i t a j o u t e r une boucle i c i , jusqu ’ a convergence ent re p h i r e f e t ph ii n i t i a l i z e =0;/ / Computation o f the i n i t i a l normalscomputen ( ) ;reduc t ion ( ) ;
bool nonl inearLoop= t rue ;i terUzawa =0;i n t [ i n t ] I1 ( 0 ) ;i n t [ i n t ] I2 ( 0 ) ;
wh i le ( nonl inearLoop){
p h i r e f 1 =phi1 ; p h i r e f 2 =phi2 ;
i n i t i a l i z e =0;bool notenough= t rue ;wh i le ( notenough){cout<<”−−−−−−−−−−−−−−− Uzawa :”<<I1 . n<<” c o n s t r a i n t s−−−−−−−−−−−−−−−−”<<endl ;
bool admiss ib le= f a l s e ; / / i f admiss ib le= t rue there i s no i n t e r s e c t i o n s
bool pou rsu i t = t rue ; / / Sha l l we s t i l l per forming Uzawa steps ?r e a l a l phae f f =alpha ; / / e f f e c t i v e Uzawa steps .
wh i le ( pou rsu i t ) { / / Uzawa Loopcout<<”Nb−adap : ”+ iAdapt<<” ; I t e r a t i o n s : Convex−>”<<i t e rconvex<<” ; Uzawa−>”<<i terUzawa<<endl ;admiss ib le= t rue ;
/ / Compute contac t fo rces ==========================================================================//Fc1=0;Fc2=0;
f o r ( i n t i =0; i<I1 . n ; i ++){i n t i 1 = I1 [ i ] ; i n t i 2 = I2 [ i ] ;{
i f ( i 1 != i 2 ) {Fc1 [ ] [ Idv ( i 2 )]−=(mlambda ( i1 , i 2 )∗mn1( i1 , i 2 )+Mlambda ( i1 , i 2 )∗Mn1( i1 , i 2 ))∗omega( Idv ( i 1 ) ) ;Fc2 [ ] [ Idv ( i 2 )]−=(mlambda ( i1 , i 2 )∗mn2( i1 , i 2 )+Mlambda ( i1 , i 2 )∗Mn2( i1 , i 2 ))∗omega( Idv ( i 1 ) ) ;Fc1 [ ] [ Idv ( i 1 ) ] + = ( mlambda ( i1 , i 2 )∗mn1( i1 , i 2 )+Mlambda ( i1 , i 2 )∗Mn1( i1 , i 2 ))∗omega( Idv ( i 2 ) ) ;Fc2 [ ] [ Idv ( i 1 ) ] + = ( mlambda ( i1 , i 2 )∗mn2( i1 , i 2 )+Mlambda ( i1 , i 2 )∗Mn2( i1 , i 2 ))∗omega( Idv ( i 2 ) ) ;
}}}/ / So lv ing Pr imal Problem ( l i n e a r e l a s t i c i t y here ) ================================================//v e r b o s i t y =0;phiprec1=phi1 ; phiprec2=phi2 ;Jprec=J ;e l a s t i c i t e ;/ / p l o t ( [ Fc1 , Fc2 ] , coef = 0 . 1 ) ;i n i t i a l i z e =1; / / we do not r e b u i l d the r i g i d i t y mat r i x f o r the next steps .phi1= p h i r e f 1 +dphi1 ; phi2= p h i r e f 2 +dphi2 ;r e a l de l t a = i n t 2d (Sh ) ( ( phiprec1−phi1 ) ˆ 2 + ( phiprec2−phi2 ) ˆ 2 ) ;
/ / Updating the c o n s t r a i n t s ================================================//nbcons t ra in t s =0;i n t n b c o n s t r a i n t s t o t =0;r e a l Cmax=0;f o r ( i n t i =0; i<I1 . n ; i ++){i n t i 1 = I1 [ i ] ; i n t i 2 = I2 [ i ] ;i f ( i 1 != i 2 ) {
mC( i1 , i 2 )= eps i lon−(mn1( i1 , i 2 )∗( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] ) +mn2( i1 , i 2 )∗( phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 ) ] ) ) ;MC( i1 , i 2 )= eps i lon−(Mn1( i1 , i 2 )∗( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] ) +Mn2( i1 , i 2 )∗( phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 ) ] ) ) ;nbcons t ra in t s ( i 2 )+=omega( Idv ( i 1 ) )∗ ( (MC( i1 , i 2 )>0)+(mC( i1 , i 2 )>0));nbcons t ra in t s ( i 1 )+=omega( Idv ( i 2 ) )∗ ( (MC( i1 , i 2 )>0)+(mC( i1 , i 2 )>0));n b c o n s t r a i n t s t o t +=(MC( i1 , i 2 )>0)+(mC( i1 , i 2 )>0);Cmax=max(Cmax,MC( i1 , i 2 ) ) ;Cmax=max(Cmax,mC( i1 , i 2 ) ) ;i f ( ! ( (MC( i1 , i 2)<eps i l on∗t o l )& (mC( i1 , i 2)<eps i l on∗t o l ) ) ) admiss ib le= f a l s e ;
}}
/ / Updating Lagrange M u l t i p l i e r s ================================================//nblambda =0;i n t nblambdatot =0;
r e a l deltalambda =0;f o r ( i n t i =0; i<I1 . n ; i ++){i n t i 1 = I1 [ i ] ; i n t i 2 = I2 [ i ] ;i f ( i 1 != i 2 ) {
r e a l in term=mlambda ( i1 , i 2 ) ;r e a l in terM=Mlambda ( i1 , i 2 ) ;mlambda ( i1 , i 2 )=max ( 0 . , mlambda ( i1 , i 2 )+ a lphae f f / ( nbcons t ra in t s ( i 2 )+ nbcons t ra in t s ( i 1 )+omega( Idv ( i 1 ) )+omega( Idv ( i 2 )))∗mC( i1 , i 2 ) ) ;Mlambda ( i1 , i 2 )=max ( 0 . , Mlambda ( i1 , i 2 )+ a lphae f f / ( nbcons t ra in t s ( i 2 )+ nbcons t ra in t s ( i 1 )+omega( Idv ( i 1 ) )+omega( Idv ( i 2 )))∗MC( i1 , i 2 ) ) ;/ / mlambda ( i1 , i 2 )=max ( 0 . , mlambda ( i1 , i 2 )+ a lphae f f∗mC( i1 , i 2 ) ) ;/ / Mlambda ( i1 , i 2 )=max ( 0 . , Mlambda ( i1 , i 2 )+ a lphae f f∗MC( i1 , i 2 ) ) ;del talambda +=(abs ( mlambda ( i1 , i 2)−i n te rm )+ abs ( Mlambda ( i1 , i 2)−i n te rM ))∗omega( Idv ( i 1 ))∗omega( Idv ( i 2 ) ) ;nblambda ( i 2 )+=(mlambda ( i1 , i 2 )>0)+(Mlambda ( i1 , i 2 )>0);nblambda ( i 1 )+=(mlambda ( i1 , i 2 )>0)+(Mlambda ( i1 , i 2 )>0);nblambdatot +=(mlambda ( i1 , i 2 )>0)+(Mlambda ( i1 , i 2 )>0);
}}
/ / Just to check i f every th ing i s going a l l r i g h tcout<<”; Nb c o n s t r a i n t s v i o l a t e d−>”<<n b c o n s t r a i n t s t o t<<” ; Nb c o n s t r a i n t s a c t i v e−>”<<nblambdatot<<endl ;cout<<”de l t a=”<<de l ta<<endl ;cout<<”del talambda=”<<deltalambda<<endl ;/ / Adapting Uzawa step ==========================================================//a l phae f f =alpha∗max(1. ,0.5∗ log ( de l t a +1.e−10)ˆ2);/ / a l phae f f =alpha ;cout<<”pas e f f e c t i f=”<<a lphae f f<<endl ;cout<<”Cmax=”<<Cmax<<endl ;cout<<”−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−”<<endl ;i terUzawa ++;
/ / Keep on or leave ? ==========================================================//i f ( admiss ib le && ( de l ta<del tamin ) ) pou rsu i t = f a l s e ;/ / pou rsu i t = t r ue ;
}// End of Uzawa loop
/ / Compute new a c t i v a t e d c o n s t r a i n t sr e a l [ i n t , i n t ] a c t i v a t e d ( nbpointsbord , nbpointsbord ) ;f o r ( i n t i 1 =0; i1<nbpointsbord ; i 1 ++) / / We l i s t the v e r t i c e s . . .f o r ( i n t i 2 =0; i2<i 1 ; i 2 ++) / / . . . and the v e r t i c e si f ( i 1 != i 2 ) {
a c t i v a t ed ( i1 , i 2 ) = ( ( eps i lon−(mn1( i1 , i 2 )∗( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] ) +mn2( i1 , i 2 )∗( phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 )])))>0)+( ( eps i lon−(Mn1( i1 , i 2 )∗( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] ) +Mn2( i1 , i 2 )∗( phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 ) ] ) ) ) >0) ;
}f o r ( i n t i =0; i<I1 . n ; i ++) a c t i v a t ed ( I1 ( i ) , I2 ( i ) ) = 1 ;mat r i x I n t e r = a c t i va t e d ;i n t nbprec= I1 . n ;r e a l [ i n t ] C( 0 ) ;[ I1 , I2 ,C]= I n t e r ;i f (C(C. n−1)==0){
I1 . res i ze ( I1 . n−1);
I2 . res i ze ( I2 . n−1);};i n t nbnew=I1 . n ;
cout<<”==========================================”<<endl ;cout<<”NB c o n s t r a i n t s ac t i v a t e d=”<<nbnew<<endl ;cout<<”==========================================”<<endl ;i f ( nbnew==nbprec ) notenough= f a l s e ;
}cout<<”−−−−−−−−−−−−−−−−END OF UZAWA−−−−−−−−−−−−−−−”<<endl ;r e a l d e l t a n o n l i n e a r = s q r t ( i n t 2d (Sh ) ( ( phi−p h i r e f ) ’∗( phi−p h i r e f ) ) ) ;cout<<” de l t a non l i n e a r=”<<de l tanon l i nea r<<endl ;i f ( de l t anon l i nea r<1.e−3) nonl inearLoop= f a l s e ;}
cout<<”−−−−−−−−−−−−−−END OF NON LINEAR LOOP−−−−−−−−−−−−−−”<<endl ;{
r e a l [ i n t ] b1 ( nbpointsbord +1) , b2 ( nbpointsbord +1) ;f o r ( i n t i =0; i<nbpointsbord ; i ++) {b1 ( i )= phi1 [ ] [ Idv ( i ) ] ; b2 ( i )= phi2 [ ] [ Idv ( i ) ] ;} ;b1 ( nbpointsbord )=b1 ( 0 ) ; b2 ( nbpointsbord )=b2 ( 0 ) ;p l o t ( [ b1 , b2 ] , wa i t =1 ,bb=[[−Ly/10−Ly/2.,−Ly / 1 0 ] , [ Ly∗1.1−Ly / 2 . , Ly∗1.1 ] ] ,cmm=”end of non l inea r loop gamma=”+gamma ) ;
}J= in t2d (Sh ) (W( ph i ) ) ;i f ( ( J>Jprec )&( i t e rconvex ! = 0 ) ) {newconvex= f a l s e ;} else {newconvex= t rue ;};NRJ<<J<<endl ;
/ / P lo t the fo rces on the deformed c o n f i g u r a t i o ns t r i n g legende =”Nb−adapta t ion =”+ iAdapt + ” ; I t e r a t i o n convexe ”+ i te rconvex + ” ; J=”+J ;
Th=movemesh(Sh , [ phi1 , phi2 ] ) ;Fcdef1 =0; Fcdef2 =0;Fcdef1 [ ] = Fc1 [ ] ; Fcdef2 [ ] = Fc2 [ ] ;mat r i x M2=Masse2 (Wh,Wh) ;r e a l [ i n t ] omega2(Wh. ndof ) ;omega2=M2. diag ;f o r ( i n t i =0; i<nbpointsbord ; i ++){
Fcdef1 [ ] [ Idv ( i ) ] = Fcdef1 [ ] [ Idv ( i )]∗omega( Idv ( i ) ) / omega2( Idv ( i ) ) ;Fcdef2 [ ] [ Idv ( i ) ] = Fcdef2 [ ] [ Idv ( i )]∗omega( Idv ( i ) ) / omega2( Idv ( i ) ) ;
}p l o t ( [ Fcdef1 , Fcdef2 ] ,cmm=legende , wa i t =1 ) ;
i t e rconvex ++;}// End of convexes loopNRJ<<endl ;/ / save the deformat ion and the contac t fo rces f o r p l o t t i n g{
ofstream deformat ion ( ” deformat ion ”+ iAdapt+”−g”+gamma ) ;ofstream con tac t f o r ce ( ” contactForces ”+ iAdapt+”−g”+gamma ) ;i n t n=0;deformat ion<<nbreg<<endl ;
con tac t fo rce<<nbpointsbord<<endl ;f o r ( i n t k =0;k<nbreg ; k++){
deformat ion<<subnbpointsbord [ k]<<endl ;f o r ( i n t i =n ; i<n+subnbpointsbord [ k ] ; i ++) deformat ion<<phi1 [ ] [ Idv [ i ]]<<” ”<<phi2 [ ] [ Idv [ i]]<<endl ;f o r ( i n t i =n ; i<n+subnbpointsbord [ k ] ; i ++){
/ / con tac t fo rce<<phi1 [ ] [ Idv [ i ]]<<” ”<<phi2 [ ] [ Idv [ i ]]<<” ”<<Fcdef1 [ ] [ Idv [ i ]]<<” ”<<Fcdef2 [ ] [ Idv [ i]]<<endl ;con tac t fo rce<<phi1 [ ] [ Idv [ i ]]<<” ”<<phi2 [ ] [ Idv [ i ]]<<” ”<<Fc1 [ ] [ Idv [ i ]]<<” ”<<Fc2 [ ] [ Idv [ i]]<<endl ;
}n+=subnbpointsbord [ k ] ;
}p l o t ( Th , ps =”Th”+ iAdapt+”−g”+gamma+ ” . eps ” , bb=[[−Ly,−Ly ] , [ Ly , Ly ] ] ) ;savemesh ( Th , ” Th”+igamma + ” .msh ” ) ;
}
/ / Adaptat ion du mai l lagei f ( iAdapt+1<NbAdapt ) {
/ / Er reur sur les cond i t i ons de contac tVh1 e r r o r =0;f o r ( i n t i 1 =0; i1<nbpointsbord ; i 1 ++) / / We l i s t the v e r t i c e s . . .f o r ( i n t i 2 =0; i2<i 1 ; i 2 ++) / / . . . and the v e r t i c e s
/ / f o r ( i n t i 1 =minup ; i1<=maxup ; i 1 ++) / / We l i s t the v e r t i c e s . . ./ / f o r ( i n t i 2 =mindown ; i2<=maxdown ; i 2 ++) / / . . . and the v e r t i c e s
{i f ( ( ( mlambda ( i1 , i 2 ) ! = 0 )| ( Mlambda ( i1 , i 2 ) !=0 ) ) ){
r e a l errm=mlambda ( i1 , i 2 )∗(( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] )∗mn2( i1 , i 2)−(phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 ) ] )∗mn1( i1 , i 2 ) ) ;r e a l errM=Mlambda ( i1 , i 2 )∗(( phi1 [ ] [ Idv ( i 1)]−phi1 [ ] [ Idv ( i 2 ) ] )∗Mn2( i1 , i 2)−(phi2 [ ] [ Idv ( i 1)]−phi2 [ ] [ Idv ( i 2 ) ] )∗Mn1( i1 , i 2 ) ) ;e r r o r [ ] [ Idv ( i 1 ) ]+= errm+errM ;e r r o r [ ] [ Idv ( i 2 )]−=errm+errM ;
}}Vh1 er roex t , der r ;so lve fo rAdap ta t i on ( er roex t , der r )= i n t 2d (Sh)(0.01∗ ( dx ( e r roex t )∗dx ( der r )+ dy ( e r roex t )∗dy ( der r ) ) + e r roex t∗der r )−i n t 1d (Sh ) ( e r r o r∗der r ) ;
p l o t ( e r roex t , wa i t =1 ) ;Sh=adaptmesh (Sh , [ phi1 , phi2 , e r roex t ] , e r r =er r , hmin=2∗eps i l on ) ;p l o t (Sh ,cmm=” adapted ” , wa i t =1 ) ;
}}
igamma++;} / / end of the loop on the parametr ized problems
What remains to be done ...
I Treatment of contacts with the help of a C++ code calledby FreeFem++ !
I Implementation of the method using ”bundles”.I Improve the Uzawa method by translating the Lagrange
Multipliers (and not only by incrementation).I Reduce the conditioning based on a definition of the
admissible set on the non-discretized space.
Thank you for your Attention...