Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87367082
dumper_paraview_mesh.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, Oct 12, 06:18
Size
16 KB
Mime Type
text/x-c++
Expires
Mon, Oct 14, 06:18 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21572100
Attached To
rLIBMULTISCALE LibMultiScale
dumper_paraview_mesh.cc
View Options
/**
* @file dumper_paraview_mesh.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
*
* @date Tue Jul 22 14:47:56 2014
*
* @brief This dumper allows to generate paraview files for vizualization
*
* @section LICENSE
*
* Copyright INRIA and CEA
*
* The LibMultiScale is a C++ parallel framework for the multiscale
* coupling methods dedicated to material simulations. This framework
* provides an API which makes it possible to program coupled simulations
* and integration of already existing codes.
*
* This Project was initiated in a collaboration between INRIA Futurs Bordeaux
* within ScAlApplix team and CEA/DPTA Ile de France.
* The project is now continued at the Ecole Polytechnique Fédérale de Lausanne
* within the LSMS/ENAC laboratory.
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/
#include "lm_common.hh"
#include "lib_continuum.hh"
#include "dumper_paraview.hh"
#include "compute.hh"
#include "filter.hh"
#include "filter_manager.hh"
#include "communicator.hh"
#include "units_converter.hh"
/* -------------------------------------------------------------------------- */
#include <sys/stat.h>
#include <sys/types.h>
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template
<
typename
Cont
>
void
DumperParaview
<
Cont
>::
dump
(
Cont
&
cont
){
static
const
UInt
Dim
=
Cont
::
Dim
;
Communicator
&
comm
=
Communicator
::
getCommunicator
();
CommGroup
group
=
cont
.
getCommGroup
();
UInt
my_rank
=
comm
.
groupRank
(
lm_my_proc_id
,
group
);
UInt
group_size
=
comm
.
getNBprocsOnGroup
(
group
);
if
(
my_rank
==
0
){
openPVTU
();
file
.
printf
(
"<VTKFile type=
\"
PUnstructuredGrid
\"
version=
\"
0.1
\"
"
);
// #ifdef BIG_ENDIAN
// file.printf("byte_order=\"BigEndian\">\n");
// #else
file
.
printf
(
"byte_order=
\"
LittleEndian
\"
>
\n
"
);
// #endif
file
.
printf
(
"<PUnstructuredGrid GhostLevel=
\"
1
\"
>
\n
"
);
file
.
printf
(
"<PPointData>
\n
"
);
if
(
dep_serie
)
paraHelper
.
PDataArray
(
"displacements"
,
3
);
if
(
p0_serie
)
paraHelper
.
PDataArray
(
"P0"
,
3
);
if
(
vel_serie
)
paraHelper
.
PDataArray
(
"velocities"
,
3
);
if
(
force_serie
)
paraHelper
.
PDataArray
(
"force"
,
3
);
if
(
applied_force_serie
)
paraHelper
.
PDataArray
(
"applied_force"
,
3
);
if
(
temperature_serie
)
paraHelper
.
PDataArray
(
"temperature"
,
1
);
if
(
temperatureVar_serie
)
paraHelper
.
PDataArray
(
"temperatureVariation"
,
1
);
if
(
heatCapacity_serie
)
paraHelper
.
PDataArray
(
"heatCapacity"
,
1
);
if
(
heatRate_serie
)
paraHelper
.
PDataArray
(
"heatRate"
,
1
);
if
(
external_heatRate_serie
)
paraHelper
.
PDataArray
(
"externalHeatRate"
,
1
);
if
(
id_serie
)
paraHelper
.
PDataArray
(
"id"
,
1
);
if
(
mass_serie
)
paraHelper
.
PDataArray
(
"mass"
,
1
);
if
(
flag_boundary
)
paraHelper
.
PDataArray
(
"blocked_dof"
,
3
);
if
(
barycenters_serie
)
paraHelper
.
PDataArray
(
"barycenters"
,
3
);
if
(
proc_serie
)
paraHelper
.
PDataArray
(
"procs"
,
1
);
if
(
alpha_serie
)
paraHelper
.
PDataArray
(
"alpha"
,
1
);
for
(
UInt
i
=
0
;
i
<
additional_fields
.
size
();
++
i
)
{
FilterID
additional_field
=
additional_fields
[
i
];
if
(
additional_field
!=
invalidFilter
){
ComputeInterface
*
ptr
=
dynamic_cast
<
ComputeInterface
*>
(
FilterManager
::
getManager
().
getObject
(
additional_field
));
if
(
ptr
)
{
ptr
->
build
();
paraHelper
.
PDataArray
(
additional_field
,
ptr
->
getDim
());
}
}
}
file
.
printf
(
"</PPointData>"
);
if
(
stress_serie
||
strain_serie
){
file
.
printf
(
"<PCellData>
\n
"
);
}
if
(
stress_serie
&&
Dim
==
3
)
paraHelper
.
PDataArray
(
"stress"
,
6
);
if
(
strain_serie
&&
Dim
==
3
)
paraHelper
.
PDataArray
(
"strain"
,
6
);
if
(
stress_serie
&&
Dim
==
2
)
paraHelper
.
PDataArray
(
"stress"
,
3
);
if
(
strain_serie
&&
Dim
==
2
)
paraHelper
.
PDataArray
(
"strain"
,
3
);
if
(
stress_serie
||
strain_serie
){
file
.
printf
(
"</PCellData>
\n
"
);
}
file
.
printf
(
"<PPoints><PDataArray type=
\"
Float64
\"
NumberOfComponents=
\"
3
\"
format=
\"
ascii
\"
/></PPoints>"
);
if
(
group_size
>
1
)
for
(
UInt
l
=
0
;
l
<
group_size
;
++
l
){
file
.
printf
(
"<Piece Source=
\"
%s-VTUs/%s_pvf%.4d.proc%.4d.vtu
\"
/>
\n
"
,
this
->
getID
().
c_str
(),
this
->
getID
().
c_str
(),
this
->
action_step
,
l
);
}
else
file
.
printf
(
"<Piece Source=
\"
%s-VTUs/%s_pvf%.4d.proc%.4d.vtu
\"
/>
\n
"
,
this
->
getID
().
c_str
(),
this
->
getID
().
c_str
(),
this
->
action_step
,
lm_my_proc_id
);
file
.
printf
(
"</PUnstructuredGrid></VTKFile>"
);
file
.
close
();
}
openVTU
();
typename
Cont
::
ContainerElems
&
contElems
=
cont
.
getContainerElems
();
typename
Cont
::
ContainerNodes
&
contNodes
=
cont
.
getContainerNodes
();
UInt
nb
=
contNodes
.
nbElem
(
dt_all
);
UInt
nbElems
=
contElems
.
nbElem
();
std
::
vector
<
UInt
>
nodes
;
UInt
compteur
;
/* start */
paraHelper
.
write_header
(
nb
,
nbElems
);
UnitsConverter
unit
;
unit
.
setInUnits
(
code_unit_system
);
unit
.
setOutUnits
(
this
->
dump_unit_system
);
unit
.
computeConversions
();
paraHelper
.
startDofList
();
typedef
typename
Cont
::
ContainerNodes
::
Ref
RefNd
;
typedef
typename
Cont
::
ContainerElems
::
Ref
RefElt
;
typename
Cont
::
ContainerNodes
::
iterator
itNodes
=
contNodes
.
getIterator
(
dt_all
);
typename
Cont
::
ContainerElems
::
iterator
itElems
=
contElems
.
getIterator
();
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
X
[
Dim
];
n
.
getPositions0
(
X
);
for
(
UInt
i
=
0
;
i
<
Dim
;
++
i
)
paraHelper
.
pushReal
(
X
[
i
]
*
unit
.
getConversion
<
Length
>
());
for
(
UInt
i
=
Dim
;
i
<
3
;
++
i
)
paraHelper
.
pushReal
(
0.0
);
}
paraHelper
.
endDofList
();
paraHelper
.
startCellsConnectivityList
();
for
(
RefElt
el
=
itElems
.
getFirst
();
!
itElems
.
end
();
el
=
itElems
.
getNext
())
{
if
(
el
.
isAltered
())
nodes
=
el
.
getAlteredConnectivity
();
else
el
.
localIndexes
(
nodes
);
UInt
nd_sz
=
nodes
.
size
();
if
(
nd_sz
==
10
)
nd_sz
=
4
;
for
(
UInt
j
=
0
;
j
<
nd_sz
;
++
j
)
{
paraHelper
.
pushInteger
(
nodes
[
j
]);
}
}
paraHelper
.
endCellsConnectivityList
();
paraHelper
.
startCellsoffsetsList
();
compteur
=
0
;
for
(
RefElt
el
=
itElems
.
getFirst
();
!
itElems
.
end
();
el
=
itElems
.
getNext
())
{
el
.
localIndexes
(
nodes
);
if
(
nodes
.
size
()
==
10
)
compteur
+=
4
;
else
compteur
+=
nodes
.
size
();
paraHelper
.
pushInteger
(
compteur
);
}
paraHelper
.
endCellsoffsetsList
();
paraHelper
.
startCellstypesList
();
UInt
code_type
=
UINT_MAX
;
for
(
RefElt
el
=
itElems
.
getFirst
();
!
itElems
.
end
();
el
=
itElems
.
getNext
())
{
el
.
localIndexes
(
nodes
);
switch
(
nodes
.
size
())
{
case
2
:
code_type
=
3
;
break
;
case
3
:
code_type
=
5
;
break
;
case
8
:
code_type
=
12
;
break
;
case
4
:
code_type
=
10
;
break
;
case
10
:
code_type
=
10
;
break
;
default
:
LM_FATAL
(
"unable to dump for VTK : "
<<
nodes
.
size
());
}
paraHelper
.
pushInteger
(
code_type
);
}
paraHelper
.
endCellstypesList
();
paraHelper
.
startPointDataList
();
if
(
dep_serie
){
paraHelper
.
startData
(
"displacements"
,
3
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
x
=
n
.
displacement
(
0
)
*
unit
.
getConversion
<
Length
>
();
Real
y
=
0
;
Real
z
=
0
;
if
(
Dim
>
1
)
y
=
n
.
displacement
(
1
)
*
unit
.
getConversion
<
Length
>
();
if
(
Dim
>
2
)
z
=
n
.
displacement
(
2
)
*
unit
.
getConversion
<
Length
>
();
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
}
paraHelper
.
endData
();
}
if
(
p0_serie
){
paraHelper
.
startData
(
"P0"
,
3
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
x
=
n
.
position0
(
0
)
*
unit
.
getConversion
<
Length
>
();
Real
y
=
0
;
Real
z
=
0
;
if
(
Dim
>
1
)
y
=
n
.
position0
(
1
)
*
unit
.
getConversion
<
Length
>
();
if
(
Dim
>
2
)
z
=
n
.
position0
(
2
)
*
unit
.
getConversion
<
Length
>
();
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
}
paraHelper
.
endData
();
}
if
(
vel_serie
){
paraHelper
.
startData
(
"velocities"
,
3
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
x
=
n
.
velocity
(
0
);
Real
y
=
0
;
Real
z
=
0
;
if
(
Dim
>
1
)
y
=
n
.
velocity
(
1
);
if
(
Dim
>
2
)
z
=
n
.
velocity
(
2
);
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
}
paraHelper
.
endData
();
}
if
(
force_serie
){
paraHelper
.
startData
(
"force"
,
3
);
UInt
cpt
=
0
;
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
x
=
n
.
force
(
0
);
Real
y
=
0
;
Real
z
=
0
;
if
(
Dim
>
1
)
y
=
n
.
force
(
1
);
if
(
Dim
>
2
)
z
=
n
.
force
(
2
);
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
++
cpt
;
}
paraHelper
.
endData
();
}
if
(
applied_force_serie
){
paraHelper
.
startData
(
"applied_force"
,
3
);
UInt
cpt
=
0
;
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
x
=
n
.
appliedForce
(
0
);
Real
y
=
0
;
Real
z
=
0
;
if
(
Dim
>
1
)
y
=
n
.
appliedForce
(
1
);
if
(
Dim
>
2
)
z
=
n
.
appliedForce
(
2
);
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
++
cpt
;
}
paraHelper
.
endData
();
}
if
(
temperature_serie
){
paraHelper
.
startData
(
"temperature"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
t
=
n
.
temperature
();
paraHelper
.
pushReal
(
t
);
}
paraHelper
.
endData
();
}
if
(
temperatureVar_serie
){
paraHelper
.
startData
(
"temperatureVariation"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
t
=
n
.
temperatureVar
();
paraHelper
.
pushReal
(
t
);
}
paraHelper
.
endData
();
}
if
(
heatCapacity_serie
){
paraHelper
.
startData
(
"heatCapacity"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
()){
Real
t
=
n
.
capacity
();
paraHelper
.
pushReal
(
t
);
}
paraHelper
.
endData
();
}
if
(
heatRate_serie
){
paraHelper
.
startData
(
"heatRate"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
()){
Real
t
=
n
.
heatRate
();
paraHelper
.
pushReal
(
t
);
}
paraHelper
.
endData
();
}
if
(
external_heatRate_serie
){
paraHelper
.
startData
(
"externalHeatRate"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
()){
Real
t
=
n
.
externalHeatRate
();
paraHelper
.
pushReal
(
t
);
}
paraHelper
.
endData
();
}
if
(
id_serie
){
paraHelper
.
startData
(
"id"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
paraHelper
.
pushReal
(
n
.
id
());
}
paraHelper
.
endData
();
}
if
(
mass_serie
){
paraHelper
.
startData
(
"mass"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
Real
mass
=
n
.
mass
()
*
unit
.
getConversion
<
Mass
>
();
paraHelper
.
pushReal
(
mass
);
}
paraHelper
.
endData
();
}
if
(
flag_boundary
){
paraHelper
.
startData
(
"blocked_dof"
,
3
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
for
(
UInt
i
=
0
;
i
<
Dim
;
++
i
)
{
Real
is_blocked
=
n
.
boundary
(
i
);
paraHelper
.
pushReal
(
is_blocked
);
}
}
paraHelper
.
endData
();
}
if
(
barycenters_serie
){
paraHelper
.
startData
(
"barycenters"
,
3
);
Real
x
=
0
,
y
=
0
,
z
=
0
;
UInt
cpt
=
0
;
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
x
+=
n
.
position0
(
0
);
y
+=
n
.
position0
(
1
);
z
+=
n
.
position0
(
2
);
++
cpt
;
}
x
/=
cpt
;
y
/=
cpt
;
z
/=
cpt
;
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
paraHelper
.
pushReal
(
x
);
paraHelper
.
pushReal
(
y
);
paraHelper
.
pushReal
(
z
);
}
paraHelper
.
endData
();
}
if
(
proc_serie
){
paraHelper
.
startData
(
"procs"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
paraHelper
.
pushReal
(
lm_my_proc_id
);
}
paraHelper
.
endData
();
}
if
(
alpha_serie
){
paraHelper
.
startData
(
"alpha"
,
1
);
for
(
RefNd
n
=
itNodes
.
getFirst
();
!
itNodes
.
end
();
n
=
itNodes
.
getNext
())
{
paraHelper
.
pushReal
(
n
.
alpha
());
}
paraHelper
.
endData
();
}
for
(
UInt
i
=
0
;
i
<
additional_fields
.
size
();
++
i
)
{
FilterID
additional_field
=
additional_fields
[
i
];
if
(
additional_field
!=
invalidFilter
){
ComputeInterface
*
ptr
=
dynamic_cast
<
ComputeInterface
*>
(
FilterManager
::
getManager
().
getObject
(
additional_field
));
if
(
ptr
)
{
dumpField
(
additional_field
,
cont
,
*
ptr
,
ptr
->
getDim
());
}
}
}
paraHelper
.
endPointDataList
();
if
(
stress_serie
||
strain_serie
)
paraHelper
.
startCellDataList
();
if
(
stress_serie
){
if
(
Dim
==
3
)
paraHelper
.
startData
(
"stress"
,
6
);
if
(
Dim
==
2
)
paraHelper
.
startData
(
"stress"
,
3
);
for
(
RefElt
el
=
itElems
.
getFirst
();
!
itElems
.
end
();
el
=
itElems
.
getNext
()){
// order of dimensions for paraview: xx, yy, zz, xy yz xz
// order of dimensions for libmultiscale : akantu COLmajor
paraHelper
.
pushReal
(
el
.
stress
(
0
+
0
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
if
(
Dim
==
2
)
{
paraHelper
.
pushReal
(
el
.
stress
(
1
+
1
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
paraHelper
.
pushReal
(
el
.
stress
(
0
+
1
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
}
else
if
(
Dim
==
3
){
paraHelper
.
pushReal
(
el
.
stress
(
1
+
1
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
paraHelper
.
pushReal
(
el
.
stress
(
2
+
2
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
paraHelper
.
pushReal
(
el
.
stress
(
0
+
1
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
paraHelper
.
pushReal
(
el
.
stress
(
1
+
2
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
paraHelper
.
pushReal
(
el
.
stress
(
0
+
2
*
Dim
)
*
unit
.
getConversion
<
Pressure
>
());
}
}
paraHelper
.
endData
();
}
if
(
strain_serie
){
if
(
Dim
==
3
)
paraHelper
.
startData
(
"strain"
,
6
);
if
(
Dim
==
2
)
paraHelper
.
startData
(
"strain"
,
3
);
for
(
RefElt
el
=
itElems
.
getFirst
();
!
itElems
.
end
();
el
=
itElems
.
getNext
()){
// order of dimensions for paraview: xx, yy, zz, xy yz xz,
// order of dimensions for libmultiscale : akantu COLmajor
paraHelper
.
pushReal
(
el
.
strain
(
0
+
0
*
Dim
));
if
(
Dim
==
2
)
{
paraHelper
.
pushReal
(
el
.
strain
(
1
+
1
*
Dim
));
paraHelper
.
pushReal
(
el
.
strain
(
0
+
1
*
Dim
));
}
else
if
(
Dim
==
3
){
paraHelper
.
pushReal
(
el
.
strain
(
1
+
1
*
Dim
));
paraHelper
.
pushReal
(
el
.
strain
(
2
+
2
*
Dim
));
paraHelper
.
pushReal
(
el
.
strain
(
0
+
1
*
Dim
));
paraHelper
.
pushReal
(
el
.
strain
(
1
+
2
*
Dim
));
paraHelper
.
pushReal
(
el
.
strain
(
0
+
2
*
Dim
));
}
}
paraHelper
.
endData
();
}
if
(
stress_serie
||
strain_serie
)
paraHelper
.
endCellDataList
();
// paraHelper.startData(file,"deformation",3);
// for (RefElt el = itNodes.GetFirstElem();!itNodes.endElem();el = itNodes.getNextElem()) {
// file.printf("%.15e",el.GetDeformations(0));
// if (Dim > 1)
// file.printf(" %.15e",el.GetDeformations(1));
// else
// file.printf(" %.15e",0.0);
// if (Dim > 2)
// file.printf(" %.15e",el.GetDeformations(2));
// else
// file.printf(" %.15e",0.0);
// file.printf("\n");
// }
// paraHelper.endData(file);
// paraHelper.endCellDataList(file);
paraHelper
.
write_conclusion
();
file
.
close
();
}
/* -------------------------------------------------------------------------- */
DECLARE_DUMPER_REF
(
DumperParaview
,
LIST_CONTINUUM_MODEL
);
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment