Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68604107
condat.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 28, 03:41
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Jun 30, 03:41 (2 d)
Engine
blob
Format
Raw Data
Handle
18608195
Attached To
rTAMAAS tamaas
condat.cpp
View Options
/**
* @file
*
* @author Son Pham-Ba <son.phamba@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "condat.hh"
#include <iomanip>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
Condat
::
Condat
(
Model
&
model
,
const
GridBase
<
Real
>&
surface
,
Real
tolerance
,
Real
mu
)
:
Kato
(
model
,
surface
,
tolerance
,
mu
)
{}
/* -------------------------------------------------------------------------- */
Real
Condat
::
solve
(
GridBase
<
Real
>&
g0
)
{
if
(
g0
.
getNbPoints
()
!=
comp
)
{
TAMAAS_EXCEPTION
(
"Target mean gap does not have the right number of components"
);
}
Real
cost
=
0
;
switch
(
model
.
getType
())
{
case
model_type
::
surface_1d:
cost
=
solveTmpl
<
model_type
::
surface_1d
>
(
g0
);
break
;
case
model_type
::
surface_2d:
cost
=
solveTmpl
<
model_type
::
surface_2d
>
(
g0
);
break
;
default
:
break
;
}
return
cost
;
}
template
<
model_type
type
>
Real
Condat
::
solveTmpl
(
GridBase
<
Real
>&
g0
)
{
// Printing column headers
std
::
cout
<<
std
::
setw
(
5
)
<<
"Iter"
<<
" "
<<
std
::
setw
(
15
)
<<
"Cost_f"
<<
" "
<<
std
::
setw
(
15
)
<<
"Error"
<<
'\n'
<<
std
::
fixed
;
constexpr
UInt
comp
=
model_type_traits
<
type
>::
components
;
Real
cost
=
0
;
UInt
n
=
0
;
*
pressure
=
0
;
GridBase
<
Real
>
z
(
*
pressure
);
GridBase
<
Real
>
pressure_old
(
*
pressure
);
Real
t0
=
1
;
Real
t1
=
1
;
Real
m
=
0
;
Real
lipschitz
=
engine
.
getNeumannNorm
();
do
{
engine
.
solveNeumann
(
*
pressure
,
*
gap
);
addUniform
<
comp
>
(
*
gap
,
g0
);
*
gap
-=
surfaceComp
;
z
=
*
gap
;
z
/=
-
lipschitz
;
*
pressure
+=
z
;
enforcePressureCoulomb
<
type
>
();
z
=
*
pressure
;
t1
=
1
+
std
::
sqrt
(
4
*
t0
*
t0
+
1
)
/
2
;
m
=
1
+
(
t0
-
1
)
/
t1
;
z
-=
pressure_old
;
z
*=
m
;
z
+=
pressure_old
;
t0
=
t1
;
pressure_old
=
*
pressure
;
cost
=
computeCost
();
printState
(
n
,
cost
,
cost
);
}
while
(
cost
>
this
->
tolerance
&&
n
++
<
this
->
max_iterations
);
*
gap
+=
surfaceComp
;
model
.
getDisplacement
()
=
*
gap
;
return
cost
;
}
__END_TAMAAS__
/* -------------------------------------------------------------------------- */
Event Timeline
Log In to Comment