Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91996883
stimulation_linearmomentum.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
Sat, Nov 16, 11:48
Size
3 KB
Mime Type
text/x-c++
Expires
Mon, Nov 18, 11:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22360776
Attached To
rLIBMULTISCALE LibMultiScale
stimulation_linearmomentum.cc
View Options
/**
* @file stimulation_linearmomentum.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Jul 09 21:59:47 2014
*
* @brief This stimulator zeros the linear momentum of a group of atoms
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale 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.
*
* LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "stimulation_linearmomentum.hh"
#include "lib_md.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "filter.hh"
#include "ref_point_data.hh"
#include <mpi.h>
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template
<
typename
Cont
>
void
StimulationLinearMomentum
<
Cont
>::
stimulate
(
Cont
&
cont
,
UInt
stage
)
{
static
const
UInt
Dim
=
Cont
::
Dim
;
UInt
cpt
=
cont
.
nbElem
(),
cpt_tot
=
0
;
Real
local_mean_v
[
3
]
=
{
0.0
,
0.0
,
0.0
};
//, local_mean_vy = 0.0, local_mean_vz = 0.0;
Real
mean_v
[
3
]
=
{
0.0
,
0.0
,
0.0
};
//, mean_vy = 0.0, mean_vz = 0.0;
typedef
typename
Cont
::
Ref
RefDof
;
typename
Cont
::
iterator
it
=
cont
.
getIterator
();
for
(
RefDof
at
=
it
.
getFirst
()
;
!
it
.
end
()
;
at
=
it
.
getNext
())
{
Real
vel
[
Dim
];
at
.
getVelocities
(
vel
);
for
(
UInt
i
=
0
;
i
<
Dim
;
++
i
)
{
local_mean_v
[
i
]
+=
vel
[
i
];
}
}
MPI_Allreduce
(
&
local_mean_v
,
&
mean_v
,
3
,
MPI_DOUBLE
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
&
cpt
,
&
cpt_tot
,
1
,
MPI_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
mean_v
[
0
]
/=
cpt_tot
;
mean_v
[
1
]
/=
cpt_tot
;
mean_v
[
2
]
/=
cpt_tot
;
//DUMP(" T " << mean_v[0]<< " T " << mean_v[1] << " T " << mean_v[2], DBG_MESSAGE);
//UInt i=0;
for
(
RefDof
at
=
it
.
getFirst
()
;
!
it
.
end
()
;
at
=
it
.
getNext
())
{
for
(
UInt
i
=
0
;
i
<
Dim
;
++
i
)
{
at
.
velocity
(
i
)
-=
mean_v
[
i
];
}
}
}
/* -------------------------------------------------------------------------- */
/* LMDESC LINEAR_MOMENTUM
This stimulator zeros the linear momentum of a group of atoms
*/
/* LMHERITATE action_interface */
/* LMEXAMPLE STIMULATION lm LINEAR_MOMENTUM INPUT md FREQ 1 */
template
<
typename
Cont
>
void
StimulationLinearMomentum
<
Cont
>::
declareParams
(){
Stimulation
<
Cont
>::
declareParams
();
}
/* -------------------------------------------------------------------------- */
DECLARE_STIMULATION
(
StimulationLinearMomentum
,
LIST_ATOM_MODEL
)
DECLARE_STIMULATION
(
StimulationLinearMomentum
,
LIST_CONTINUUM_MODEL
)
DECLARE_STIMULATION
(
StimulationLinearMomentum
,
LIST_DD_MODEL
)
DECLARE_STIMULATION_REFPOINT
(
StimulationLinearMomentum
)
DECLARE_STIMULATION_GENERIC_MESH
(
StimulationLinearMomentum
)
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment