Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82106464
dumper_dd_paraview.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
Mon, Sep 9, 15:20
Size
5 KB
Mime Type
text/x-c++
Expires
Wed, Sep 11, 15:20 (2 d)
Engine
blob
Format
Raw Data
Handle
20648626
Attached To
rLIBMULTISCALE LibMultiScale
dumper_dd_paraview.cc
View Options
/**
* @file dumper_dd_paraview.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Fri Jul 11 15:47:44 2014
*
* @brief This dumper allows to generate paraview files for vizualization
*
* @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 "dumper_paraview.hh"
#include "filter.hh"
#include "lib_dd.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;
typedef typename Cont::Ref RefNode;
typename Cont::ContainerNodes & cNodes = cont.getContainerNodes();
if (lm_my_proc_id == 0){
openPVTU();
file.printf("<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" ");
file.printf("byte_order=\"LittleEndian\">\n");
file.printf("<PUnstructuredGrid GhostLevel=\"0\">\n");
file.printf("<PPointData>\n");
if (force_serie) paraHelper.PDataArray("force",3);
if (stress_serie) paraHelper.PDataArray("stress",6);
paraHelper.PDataArray("kind", 1);
file.printf("</PPointData>");
file.printf("<PPoints><PDataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"/></PPoints>");
if (lm_world_size > 1)
for (UInt l=0 ; l < lm_world_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();
UInt nb = 0;
typename Cont::iterator it = cNodes.getIterator();
for (RefNode nd = it.getFirst(); !it.end(); nd = it.getNext())
++nb;
if(nb) paraHelper.write_header(nb,1);
else paraHelper.write_header(nb,0);
UnitsConverter unit;
unit.setInUnits(code_unit_system);
unit.setOutUnits(code_unit_system);
unit.computeConversions();
paraHelper.startDofList();
typename Cont::iterator itNodes = cNodes.getIterator();
for (RefNode nd = itNodes.getFirst();!itNodes.end();nd = itNodes.getNext()) {
Real X[3] = {0,0,0};
for (UInt i = 0; i < Dim; ++i)
X[i] = nd.position(i)*unit.getConversion<Length>();
for (UInt i = 0; i < 3; ++i)
paraHelper.pushReal(X[i]);
}
paraHelper.endDofList();
paraHelper.startCellsConnectivityList();
for (UInt i=0;i < nb;++i)
{
paraHelper.pushInteger(i);
}
paraHelper.endCellsConnectivityList();
paraHelper.startCellsoffsetsList();
paraHelper.pushInteger(nb);
paraHelper.endCellsoffsetsList();
paraHelper.startCellstypesList();
if(nb){
paraHelper.pushInteger(2);
}
paraHelper.endCellstypesList();
paraHelper.startPointDataList();
if (force_serie){
paraHelper.startData("force",3);
for (RefNode nd = itNodes.getFirst();!itNodes.end();nd = itNodes.getNext()) {
double fx=0,fy=0,fz=0;
fx = nd.force(0);
if (Dim > 1)
fy = nd.force(1);
if (Dim == 3)
fz = nd.force(2);
paraHelper.pushReal(fx);
paraHelper.pushReal(fy);
paraHelper.pushReal(fz);
}
paraHelper.endData();
}
if (stress_serie){
paraHelper.startData("stress",6);
for (RefNode nd = itNodes.getFirst();!itNodes.end();nd = itNodes.getNext()) {
Real x = nd.stress(0);
Real y = nd.stress(1);
Real z = nd.stress(2);
paraHelper.pushReal(x);
paraHelper.pushReal(y);
paraHelper.pushReal(z);
x = nd.stress(3);
y = nd.stress(4);
z = nd.stress(5);
paraHelper.pushReal(x);
paraHelper.pushReal(y);
paraHelper.pushReal(z);
}
paraHelper.endData();
}
paraHelper.startData("kind",1);
for (RefNode nd = itNodes.getFirst();!itNodes.end();nd = itNodes.getNext()) {
paraHelper.pushReal(0);
}
paraHelper.endData();
paraHelper.endPointDataList();
paraHelper.write_conclusion();
file.close();
}
/* -------------------------------------------------------------------------- */
DECLARE_DUMPER_REF(DumperParaview,LIST_DD_MODEL)
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment