Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86889619
dumper.cpp
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
Wed, Oct 9, 05:44
Size
3 KB
Mime Type
text/x-c
Expires
Fri, Oct 11, 05:44 (2 d)
Engine
blob
Format
Raw Data
Handle
21500623
Attached To
rIOHELPER iohelper
dumper.cpp
View Options
/*
Copyright 2008 Guillaume ANCIAUX (guillaume.anciaux@epfl.ch)
This file is part of ParaViewHelper.
ParaViewHelper is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ParaViewHelper 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with ParaViewHelper. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dumper.h"
Dumper::Dumper(){
position = NULL;
connec = NULL;
dump_step = 0;
elem_type = -1;
base_name[0] = '\0';
prefix[0] = '\0';
my_rank = -1;
world_size = -1;
flag_compressed = 0;
}
Dumper::~Dumper(){
if (position)
delete position;
if (connec)
delete connec;
{
std::map<std::string,Field *>::iterator it = per_node_data.begin();
std::map<std::string,Field *>::iterator end = per_node_data.end();
while (it != end){
delete (*it).second;
++it;
}
}
{
std::map<std::string,Field *>::iterator it = per_element_data.begin();
std::map<std::string,Field *>::iterator end = per_element_data.end();
while (it != end){
delete (*it).second;
++it;
}
}
}
void Dumper::Init(){
if (position == NULL) FATAL("position array not set. You should call SetPoints method");
if (connec == NULL) FATAL("connectivity array not set. You should call SetConnectivity method");
if (world_size == -1 || my_rank == -1){
DUMP("world_size and my_rank variables are not well set: going to sequential dump");
world_size = 1;
my_rank = 0;
}
}
void Dumper::AddNodeDataField(double * data,int dimension,const char * name){
if (per_node_data.count(name) != 0) delete(per_node_data[name]);
Field * temp = new Field(data,dimension,position->nb_dof);
strncpy(temp->name,name,255);
per_node_data[name] = temp;
}
void Dumper::AddElemDataField(double * data,int dimension,const char * name){
if (per_element_data.count(name) != 0) delete(per_element_data[name]);
if (connec == NULL) FATAL("connectivity should be provided before elemental fields ! Please use SetConnectivity function before AddElemDataField");
Field * temp = new Field(data,dimension,connec->nb_dof);
strncpy(temp->name,name,255);
per_element_data[name] = temp;
}
void Dumper::SetPoints(double * points,int dimension,int nb,const char * n){
position = new Field(points,dimension,nb);
strncpy(base_name,n,255);
}
void Dumper::SetConnectivity(int * connectivity,int elem_type,int nb_elem,int mode){
int dof_per_node=0;
this->elem_type = elem_type;
switch(elem_type){
case TRIANGLE1:dof_per_node = 3;break;
case TRIANGLE2:dof_per_node = 6;break;
case TETRA1:dof_per_node = 4;break;
case TETRA2:dof_per_node = 10;break;
case POINT_SET: break;
default: FATAL("Unknown element type");
}
connec = new Field(connectivity,dof_per_node,nb_elem);
connectivity_mode = mode;
}
void Dumper::SetPrefix(const char * dir){
strncpy(prefix,dir,255);
}
void Dumper::SetParallelContext(int me, int wld_size){
my_rank = me;
world_size = wld_size;
}
Event Timeline
Log In to Comment