Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78071857
dumper_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
Sun, Aug 18, 06:16
Size
29 KB
Mime Type
text/x-c
Expires
Tue, Aug 20, 06:16 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
19978205
Attached To
rLIBMULTISCALE LibMultiScale
dumper_paraview.cc
View Options
/**
* @file dumper_paraview.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Wed Jul 09 21:59:47 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 "dumper_paraview.hh"
#include "compute_interface.hh"
#include "factory_multiscale.hh"
#include "field.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "lib_md.hh"
#include "lm_common.hh"
#include "ref_point_data.hh"
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <communicator.hh>
#include <iomanip>
#include <sys/stat.h>
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
DumperParaview::DumperParaview(const std::string &name)
: LMObject(name), dep_field(false), p0_field(false), vel_field(false),
force_field(false), proc_field(false), stress_field(false),
strain_field(false), epot_field(false), mass_field(false),
charge_field(false), id_field(false), flag_compressed(false),
flag_text(false), flag_base64(false), alpha_field(false),
e_density_field(false), barycenters_field(false),
temperature_field(false), temperatureVar_field(false),
heatCapacity_field(false), heatRate_field(false),
external_heatRate_field(false), tag_field(false) {}
/* -------------------------------------------------------------------------- */
DumperParaview::~DumperParaview() {}
/* -------------------------------------------------------------------------- */
void DumperParaview::init() {
DumperInterface::init();
if (flag_compressed)
paraHelper.setMode(ParaviewHelper::COMPRESSED);
if (flag_text)
paraHelper.setMode(ParaviewHelper::TEXT);
if (flag_base64)
paraHelper.setMode(ParaviewHelper::BASE64);
}
/* -------------------------------------------------------------------------- */
/* LMDESC PARAVIEW
This dumper ouputs paraview files from any domain description.
It admits several options that could be model dependent.
*/
/* LMEXAMPLE DUMPER para PARAVIEW INPUT md PROC DISP PREFIX /home/titeuf */
/* LMHERITANCE dumper */
void DumperParaview::declareParams() {
DumperInterface::declareParams();
/* LMKEYWORD PROC
Flag to request processor number to each DOF
*/
this->parseTag("PROC", proc_field, false);
/* LMKEYWORD DISP
Flag to request displacements stored at each DOF
*/
this->parseTag("DISP", dep_field, false);
/* LMKEYWORD ELECTRONIC_DENSITY
Flag to request electronic density (for EAM systems) stored at each atom
*/
this->parseTag("ELECTRONIC_DENSITY", e_density_field, false);
/* LMKEYWORD ALPHA
Flag to request output of alpha line (for Arlequin testing)
*/
this->parseTag("ALPHA", alpha_field, false);
/* LMKEYWORD P0
Flag to request output of initial position stored at each DOFs
*/
this->parseTag("P0", p0_field, false);
/* LMKEYWORD TEMPERATURE
Only for continuum domains.
Flag to request output of temperature stored at each DOFs.
*/
this->parseTag("TEMPERATURE", temperature_field, false);
/* LMKEYWORD TEMPERATURE_VARIATION
Only for continuum domains. Flag to request the output of the temperature
variation
at each DOFs.
*/
this->parseTag("TEMPERATURE_VARIATION", temperatureVar_field, false);
/* LMKEYWORD HEAT_CAPACITY
return the heat capacity associated with nodal DOF. This
is applicable only for FE domains.
*/
this->parseTag("HEAT_CAPACITY", heatCapacity_field, false);
/* LMKEYWORD HEAT_RATE
return the heat rate (residual) associated with nodal DOF. This
is applicable only for FE domains.
*/
this->parseTag("HEAT_RATE", heatRate_field, false);
/* LMKEYWORD EXTERNAL_HEAT_RATE
return the external applied heat rate associated with nodal DOF. This
is applicable only for FE domains.
*/
this->parseTag("EXTERNAL_HEAT_RATE", external_heatRate_field, false);
/* LMKEYWORD VEL
Flag to request output of velocity stored at each DOFs
*/
this->parseTag("VEL", vel_field, false);
/* LMKEYWORD FORCE
Flag to request output of force stored at each DOFs
*/
this->parseTag("FORCE", force_field, false);
/* LMKEYWORD APPLIED_FORCE
Flag to request output of applied force stored at each DOFs
*/
this->parseTag("APPLIED_FORCE", applied_force_field, false);
/* LMKEYWORD STRESS
Flag to request output of stress field. This is implemented only for atomic
systems where the stress is computed using LAMMPS compute\_stress object.
*/
this->parseTag("STRESS", stress_field, false);
/* LMKEYWORD STRAIN
Flag to request output of strain field. This is implemented only for FE
systems.
*/
this->parseTag("STRAIN", strain_field, false);
/* LMKEYWORD EPOT
Flag to request the output of the potential energy associated to each
degree of freedom. Only for MD domains.
*/
this->parseTag("EPOT", epot_field, false);
/* LMKEYWORD MASS
Flag to request output of mass stored to each degree of freedom. Only
applicable
to MD and FE systems.
*/
this->parseTag("MASS", mass_field, false);
/* LMKEYWORD CHARGE
Flag to request the output of the charge associated to each degree of
freedom.
Only for MD domains
*/
this->parseTag("CHARGE", charge_field, false);
/* LMKEYWORD ID
Flag to request output of internal id associated to each degree of freedom.
*/
this->parseTag("ID", id_field, false);
/* LMKEYWORD COMPRESSED
Flag to request output in compressed mode.
*/
this->parseTag("COMPRESSED", flag_compressed, false);
/* LMKEYWORD TEXT
The sections in XML paraview files are set to be written in simple TEXT
encoding.
*/
this->parseTag("TEXT", flag_text, false);
/* LMKEYWORD BASE64
The sections in XML paraview files are set to be written in base64
encoding.
*/
this->parseTag("BASE64", flag_base64, false);
/* LMKEYWORD TAG
provide the tag of the degree of freedom (for usage with lammps)
*/
this->parseTag("TAG", tag_field, false);
/* LMKEYWORD ADDFIELD
provide the id of compute as an additional field
*/
this->parseKeyword("ADDFIELD", additional_fields, std::vector<LMID>{});
/* LMKEYWORD BOUNDARY
flag to request output of nodal blockage
*/
this->parseKeyword("BOUNDARY", flag_boundary, false);
}
/* -------------------------------------------------------------------------- */
void DumperParaview::openPVTU() {
std::stringstream fname;
fname << this->getBaseName() << "_pvf" << std::setfill('0') << std::setw(4)
<< this->action_step << ".pvtu";
/* ouverture du fichier parallele vtk */
file.open(fname.str());
paraHelper.setOutputFile(file);
}
/* -------------------------------------------------------------------------- */
void DumperParaview::openVTU() {
std::string dirname;
dirname += this->prefix + "/" + this->getID() + "-VTUs";
mkdir(dirname.c_str(), 0755);
std::stringstream fname;
fname << dirname << "/" << this->getID() << "_pvf" << std::setfill('0')
<< std::setw(4) << this->action_step << ".proc" << std::setfill('0')
<< std::setw(4) << lm_my_proc_id << ".vtu";
file.open(fname.str(), "wb+", flag_compressed);
paraHelper.setOutputFile(file);
}
/* -------------------------------------------------------------------------- */
#define SERIES_LIST \
((dep_field, _displacement))((p0_field, _position0))( \
(vel_field, _velocity))((force_field, _force))((stress_field, _stress))( \
(proc_field, _proc))((id_field, _id))((mass_field, _mass))( \
(epot_field, _epot))((charge_field, _charge))((tag_field, _tag))
#define APPLY_ON_ACTIVATED_FIELD(r, functor, field) \
{ \
auto var_flag = BOOST_PP_TUPLE_ELEM(2, 0, field); \
constexpr auto _type = BOOST_PP_TUPLE_ELEM(2, 1, field); \
if (var_flag) { \
auto f = make_field<_type>(cont); \
functor(f); \
} \
}
#define APPLY_FUNCTOR_ON_ACTIVATED_FIELDS(functor) \
BOOST_PP_SEQ_FOR_EACH(APPLY_ON_ACTIVATED_FIELD, functor, SERIES_LIST);
/* -------------------------------------------------------------------------- */
template <typename Cont> enable_if_md<Cont> DumperParaview::dump(Cont &cont) {
constexpr UInt Dim = Cont::Dim;
UInt nb = cont.size();
CommGroup &group = cont.getCommGroup();
UInt my_rank = group.getMyRank();
UInt group_size = group.size();
if (my_rank == 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");
APPLY_FUNCTOR_ON_ACTIVATED_FIELDS([&](auto field) {
paraHelper.PDataArray(field.getName(), field.getDim());
});
for (UInt i = 0; i < additional_fields.size(); ++i) {
LMID additional_field = additional_fields[i];
if (additional_field != invalidFilter) {
auto *ptr = dynamic_cast<ComputeInterface *>(
&FilterManager::getManager().getObject(additional_field));
if (ptr) {
ptr->build();
paraHelper.PDataArray(additional_field, ptr->getDim());
}
}
}
file.printf("</PPointData>");
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, group[l].getAbsoluteRank());
}
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();
if (nb)
paraHelper.write_header(nb, 1);
else
paraHelper.write_header(nb, 0);
UnitsConverter unit;
unit.setInUnits(code_unit_system);
unit.setOutUnits(this->dump_unit_system);
unit.computeConversions();
paraHelper.startDofList();
for (auto &&at : cont) {
auto X = at.position0();
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 (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();
APPLY_FUNCTOR_ON_ACTIVATED_FIELDS([&](auto field) {
auto dim = field.getDim();
auto name = field.getName();
paraHelper.startData(name, dim);
for (auto &&v : field) {
paraHelper.push(v, dim);
}
paraHelper.endData();
});
for (UInt i = 0; i < additional_fields.size(); ++i) {
LMID additional_field = additional_fields[i];
if (additional_field != invalidFilter) {
ComputeInterface *ptr = dynamic_cast<ComputeInterface *>(
&FilterManager::getManager().getObject(additional_field));
if (ptr) {
ptr->build();
dumpField(additional_field, cont, *ptr, ptr->getDim());
}
}
}
paraHelper.endPointDataList();
paraHelper.write_conclusion();
file.close();
}
/* -------------------------------------------------------------------------- */
template <typename Cont> enable_if_mesh<Cont> DumperParaview::dump(Cont &cont) {
constexpr UInt Dim = Cont::Dim;
CommGroup &group = cont.getCommGroup();
UInt my_rank = group.getMyRank();
UInt group_size = group.size();
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_field)
paraHelper.PDataArray("displacements", 3);
if (p0_field)
paraHelper.PDataArray("P0", 3);
if (vel_field)
paraHelper.PDataArray("velocities", 3);
if (force_field)
paraHelper.PDataArray("force", 3);
if (applied_force_field)
paraHelper.PDataArray("applied_force", 3);
if (temperature_field)
paraHelper.PDataArray("temperature", 1);
if (temperatureVar_field)
paraHelper.PDataArray("temperatureVariation", 1);
if (heatCapacity_field)
paraHelper.PDataArray("heatCapacity", 1);
if (heatRate_field)
paraHelper.PDataArray("heatRate", 1);
if (external_heatRate_field)
paraHelper.PDataArray("externalHeatRate", 1);
if (id_field)
paraHelper.PDataArray("id", 1);
if (mass_field)
paraHelper.PDataArray("mass", 1);
if (flag_boundary)
paraHelper.PDataArray("blocked_dof", 3);
if (barycenters_field)
paraHelper.PDataArray("barycenters", 3);
if (proc_field)
paraHelper.PDataArray("procs", 1);
if (alpha_field)
paraHelper.PDataArray("alpha", 1);
for (UInt i = 0; i < additional_fields.size(); ++i) {
LMID additional_field = additional_fields[i];
if (additional_field != invalidFilter) {
auto *ptr = dynamic_cast<ComputeInterface *>(
&FilterManager::getManager().getObject(additional_field));
if (ptr) {
ptr->build();
paraHelper.PDataArray(additional_field, ptr->getDim());
}
}
}
file.printf("</PPointData>");
if (stress_field || strain_field) {
file.printf("<PCellData>\n");
}
if (stress_field && Dim == 3)
paraHelper.PDataArray("stress", 6);
if (strain_field && Dim == 3)
paraHelper.PDataArray("strain", 6);
if (stress_field && Dim == 2)
paraHelper.PDataArray("stress", 3);
if (strain_field && Dim == 2)
paraHelper.PDataArray("strain", 3);
if (stress_field || strain_field) {
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.size(dt_all);
UInt sizes = contElems.size();
std::vector<UInt> nodes;
UInt compteur;
/* start */
paraHelper.write_header(nb, sizes);
UnitsConverter unit;
unit.setInUnits(code_unit_system);
unit.setOutUnits(this->dump_unit_system);
unit.computeConversions();
paraHelper.startDofList();
for (auto &&n : contNodes) {
Vector<Dim> X = n.position0();
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 (auto &&el : contElems) {
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 (auto &&el : contElems) {
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 (auto &&el : contElems) {
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_field) {
paraHelper.startData("displacements", 3);
for (auto &&n : contNodes) {
auto X = n.displacement() * unit.getConversion<Length>();
paraHelper.push(X, 3);
}
paraHelper.endData();
}
if (p0_field) {
paraHelper.startData("P0", 3);
for (auto &&n : contNodes) {
auto X = n.position0() * unit.getConversion<Length>();
paraHelper.push(X, 3);
}
paraHelper.endData();
}
if (vel_field) {
paraHelper.startData("velocities", 3);
for (auto &&n : contNodes) {
auto X = n.velocity();
paraHelper.push(X, 3);
}
paraHelper.endData();
}
if (force_field) {
paraHelper.startData("force", 3);
UInt cpt = 0;
for (auto &&n : contNodes) {
auto X = n.force();
paraHelper.push(X, 3);
++cpt;
}
paraHelper.endData();
}
// if (applied_force_field) {
// 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_field) {
paraHelper.startData("temperature", 1);
for (auto &&n : contNodes) {
Real t = n.temperature();
paraHelper.pushReal(t);
}
paraHelper.endData();
}
if (temperatureVar_field) {
paraHelper.startData("temperatureVariation", 1);
for (auto &&n : contNodes) {
Real t = n.temperatureVar();
paraHelper.pushReal(t);
}
paraHelper.endData();
}
if (heatCapacity_field) {
paraHelper.startData("heatCapacity", 1);
for (auto &&n : contNodes) {
Real t = n.capacity();
paraHelper.pushReal(t);
}
paraHelper.endData();
}
if (heatRate_field) {
paraHelper.startData("heatRate", 1);
for (auto &&n : contNodes) {
Real t = n.heatRate();
paraHelper.pushReal(t);
}
paraHelper.endData();
}
if (external_heatRate_field) {
paraHelper.startData("externalHeatRate", 1);
for (auto &&n : contNodes) {
Real t = n.externalHeatRate();
paraHelper.pushReal(t);
}
paraHelper.endData();
}
if (id_field) {
paraHelper.startData("id", 1);
for (auto &&n : contNodes) {
paraHelper.pushReal(n.id());
}
paraHelper.endData();
}
if (mass_field) {
paraHelper.startData("mass", 1);
for (auto &&n : contNodes) {
Real mass = n.mass() * unit.getConversion<Mass>();
paraHelper.pushReal(mass);
}
paraHelper.endData();
}
if (flag_boundary) {
paraHelper.startData("blocked_dof", 3);
for (auto &&n : contNodes) {
for (UInt i = 0; i < Dim; ++i) {
Real is_blocked = n.boundary(i);
paraHelper.pushReal(is_blocked);
}
}
paraHelper.endData();
}
if (barycenters_field) {
paraHelper.startData("barycenters", 3);
Vector<Dim> X = Vector<Dim>::Zero();
UInt cpt = 0;
for (auto &&n : contNodes) {
X += n.position0();
++cpt;
}
X /= cpt;
for (UInt i = 0; i < contNodes.size(); ++i) {
paraHelper.push(X, 3);
}
paraHelper.endData();
}
if (proc_field) {
paraHelper.startData("procs", 1);
for (UInt i = 0; i < contNodes.size(); ++i) {
paraHelper.pushReal(lm_my_proc_id);
}
paraHelper.endData();
}
if (alpha_field) {
paraHelper.startData("alpha", 1);
for (auto &&n : contNodes) {
paraHelper.pushReal(n.alpha());
}
paraHelper.endData();
}
for (UInt i = 0; i < additional_fields.size(); ++i) {
LMID 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_field || strain_field)
paraHelper.startCellDataList();
if (stress_field) {
if (Dim == 3)
paraHelper.startData("stress", 6);
if (Dim == 2)
paraHelper.startData("stress", 3);
for (auto &&el : contElems) {
// 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_field) {
if (Dim == 3)
paraHelper.startData("strain", 6);
if (Dim == 2)
paraHelper.startData("strain", 3);
for (auto &&el : contElems) {
// 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_field || strain_field)
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();
}
/* --------------------------------------------------------------------------
*/
// template <typename Cont> void DumperParaview::dump(Cont &cont) {
// constexpr UInt Dim = Cont::Dim;
// typedef typename Cont::Ref RefNode;
// typename Cont::ContainerNodes &cNodes = cont.getContainerNodes();
// 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\"
// ");
// file.printf("byte_order=\"LittleEndian\">\n");
// file.printf("<PUnstructuredGrid GhostLevel=\"0\">\n");
// file.printf("<PPointData>\n");
// if (force_field)
// paraHelper.PDataArray("force", 3);
// if (stress_field)
// paraHelper.PDataArray("stress", 6);
// paraHelper.PDataArray("kind", 1);
// file.printf("</PPointData>");
// 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();
// UInt nbrNodes = cNodes.size();
// UInt nbrElems = 0;
// typename Cont::iterator it = cNodes.begin();
// // for (RefNode nd = it.getFirst(); !it.end(); nd = it.getNext()) {
// // ++nbrNodes;
// // if (nd.getConstraint() == 7) {
// // ++nbrElems0;
// // }
// // }
// // nbrElems = nbrElems0 / 2;
// if (nbrElems)
// paraHelper.write_header(nbrNodes, nbrElems);
// else
// paraHelper.write_header(nbrNodes, 1);
// UnitsConverter unit;
// unit.setInUnits(code_unit_system);
// unit.setOutUnits(code_unit_system);
// unit.computeConversions();
// std::vector<UInt> considered_indices;
// std::vector<UInt> offsets;
// // UInt accumulated_offset = 0;
// paraHelper.startDofList();
// std::vector<UInt> constraints;
// for (auto &&nd : cNodes) {
// RefNode nextNode = nd;
// // UInt cnst = nd.getConstraint();
// UInt idx = nd.getIndex();
// considered_indices.push_back(idx);
// Vector<Dim> X = nextNode.position() * unit.getConversion<Length>();
// paraHelper.push(X, Dim);
// }
// paraHelper.endDofList();
// if (offsets.size() != nbrElems)
// LM_FATAL("problem: number of elements:" << nbrElems << " but offset
// size:"
// << offsets.size());
// paraHelper.startCellsConnectivityList();
// for (UInt i = 0; i < nbrNodes; ++i) {
// paraHelper.pushInteger(i);
// }
// if (offsets.size() == 0)
// paraHelper.pushInteger(0);
// paraHelper.endCellsConnectivityList();
// paraHelper.startCellsoffsetsList();
// if (offsets.size() == 0) {
// paraHelper.pushInteger(nbrNodes + 1);
// } else {
// for (UInt i = 0; i < nbrElems; ++i) {
// paraHelper.pushInteger(offsets[i]);
// }
// }
// paraHelper.endCellsoffsetsList();
// paraHelper.startCellstypesList();
// if (nbrNodes) {
// if (offsets.size() == 0) {
// paraHelper.pushInteger(4);
// } else {
// for (UInt i = 0; i < nbrElems; ++i) {
// paraHelper.pushInteger(4);
// }
// }
// }
// paraHelper.endCellstypesList();
// paraHelper.startPointDataList();
// if (force_field) {
// paraHelper.startData("force", 3);
// for (auto &&nd : cNodes) {
// auto f = nd.force();
// paraHelper.push(f, Dim);
// }
// paraHelper.endData();
// }
// if (stress_field) {
// LM_TOIMPLEMENT;
// // paraHelper.startData("stress", 6);
// // for (auto &&nd : cNodes) {
// // auto s = nd.stress();
// // paraHelper.push(s, Dim*(Dim+1)/2);
// // }
// // paraHelper.endData();
// }
// paraHelper.startData("kind", 1);
// UInt count = 0;
// for (auto &&nd : cNodes) {
// if (nbrElems == 0) {
// paraHelper.pushInteger(nd.getConstraint());
// } else {
// paraHelper.pushInteger(constraints[count]);
// ++count;
// }
// }
// paraHelper.endData();
// paraHelper.endPointDataList();
// paraHelper.write_conclusion();
// file.close();
// }
/* --------------------------------------------------------------------------
*/
DECLARE_DUMPER_MAKE_CALL(DumperParaview);
/* --------------------------------------------------------------------------
*/
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment