Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77575498
parallel_2d.cc
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
Thu, Aug 15, 06:48
Size
3 KB
Mime Type
text/x-c
Expires
Sat, Aug 17, 06:48 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
19883146
Attached To
rAKA akantu
parallel_2d.cc
View Options
/**
* @file parallel_2d.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 22 2010
* @date last modification: Tue Jun 24 2014
*
* @brief Parallel example
*
* @section LICENSE
*
* Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu 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.
*
* Akantu 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 Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include <limits>
#include <fstream>
/* -------------------------------------------------------------------------- */
#include "mesh_io.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using
namespace
akantu
;
int
main
(
int
argc
,
char
*
argv
[])
{
initialize
(
"material.dat"
,
argc
,
argv
);
debug
::
setDebugLevel
(
dblError
);
UInt
spatial_dimension
=
2
;
UInt
max_steps
=
10000
;
Real
time_factor
=
0.8
;
Real
max_disp
=
1e-6
;
Mesh
mesh
(
spatial_dimension
);
StaticCommunicator
&
comm
=
StaticCommunicator
::
getStaticCommunicator
();
Int
psize
=
comm
.
getNbProc
();
Int
prank
=
comm
.
whoAmI
();
akantu
::
MeshPartition
*
partition
=
NULL
;
if
(
prank
==
0
)
{
// Read the mesh
mesh
.
read
(
"square_2d.msh"
);
partition
=
new
MeshPartitionScotch
(
mesh
,
spatial_dimension
);
partition
->
partitionate
(
psize
);
}
SolidMechanicsModel
model
(
mesh
);
/// model initialization
model
.
initParallel
(
partition
);
delete
partition
;
model
.
initFull
();
if
(
prank
==
0
)
std
::
cout
<<
model
.
getMaterial
(
0
)
<<
std
::
endl
;
model
.
setBaseName
(
"multi"
);
model
.
addDumpFieldVector
(
"displacement"
);
model
.
addDumpFieldVector
(
"velocity"
);
model
.
addDumpFieldVector
(
"acceleration"
);
model
.
addDumpFieldTensor
(
"stress"
);
model
.
addDumpFieldTensor
(
"grad_u"
);
/// boundary conditions
Real
eps
=
1e-16
;
const
Array
<
Real
>
&
pos
=
mesh
.
getNodes
();
Array
<
Real
>
&
disp
=
model
.
getDisplacement
();
Array
<
bool
>
&
boun
=
model
.
getBlockedDOFs
();
mesh
.
computeBoundingBox
();
Real
left_side
=
mesh
.
getLowerBounds
()(
0
);
Real
right_side
=
mesh
.
getUpperBounds
()(
0
);
for
(
UInt
i
=
0
;
i
<
mesh
.
getNbNodes
();
++
i
)
{
if
(
std
::
abs
(
pos
(
i
,
0
)
-
left_side
)
<
eps
)
{
disp
(
i
,
0
)
=
max_disp
;
boun
(
i
,
0
)
=
true
;
}
if
(
std
::
abs
(
pos
(
i
,
0
)
-
right_side
)
<
eps
)
{
disp
(
i
,
0
)
=
-
max_disp
;
boun
(
i
,
0
)
=
true
;
}
}
Real
time_step
=
model
.
getStableTimeStep
()
*
time_factor
;
std
::
cout
<<
"Time Step = "
<<
time_step
<<
"s"
<<
std
::
endl
;
model
.
setTimeStep
(
time_step
);
model
.
dump
();
for
(
UInt
s
=
1
;
s
<=
max_steps
;
++
s
)
{
model
.
explicitPred
();
model
.
updateResidual
();
model
.
updateAcceleration
();
model
.
explicitCorr
();
if
(
s
%
200
==
0
)
model
.
dump
();
if
(
prank
==
0
&&
s
%
100
==
0
)
std
::
cout
<<
"passing step "
<<
s
<<
"/"
<<
max_steps
<<
std
::
endl
;
}
finalize
();
return
EXIT_SUCCESS
;
}
Event Timeline
Log In to Comment