#include <exodusII_io_helper.h>
Inherited by Nemesis_IO_Helper.
class Conversion
class ElementMaps
ExodusII_IO_Helper (bool v=false)
virtual ~ExodusII_IO_Helper ()
bool created ()
void verbose (bool set_verbosity)
int get_num_dim () const
int get_num_nodes () const
int get_num_elem () const
int get_num_elem_blk () const
int get_num_elem_this_blk () const
int get_num_nodes_per_elem () const
int get_num_side_sets () const
int get_num_node_sets () const
int get_connect (int i) const
int get_num_sides_per_set (int i) const
int get_num_nodes_per_set (int i) const
const std::vector< int > & get_elem_list () const
const std::vector< int > & get_side_list () const
const std::vector< int > & get_node_list () const
int get_nodeset_id (unsigned int i) const
const std::vector< int > & get_id_list () const
const char * get_elem_type () const
double get_x (int i) const
double get_y (int i) const
double get_z (int i) const
void open (const char *filename)
void read_header ()
void print_header ()
void read_nodes ()
void read_node_num_map ()
void print_nodes ()
void read_block_info ()
int get_block_id (int block)
void read_elem_in_block (int block)
void read_elem_num_map ()
void read_sideset_info ()
void read_nodeset_info ()
void read_sideset (int id, int offset)
void read_nodeset (int id)
void print_sideset_info ()
void print_nodeset_info ()
void close ()
int inquire (int req_info, std::string error_msg='')
const std::vector< double > & get_time_steps ()
int get_num_nodal_vars ()
const std::vector< std::string > & get_nodal_var_names ()
const std::vector< double > & get_nodal_var_values (std::string nodal_var_name, int time_step)
void create (std::string filename)
void initialize (std::string title, const MeshBase &mesh)
void write_nodal_coordinates (const MeshBase &mesh)
void write_elements (const MeshBase &mesh)
void write_sidesets (const MeshBase &mesh)
void write_nodesets (const MeshBase &mesh)
void initialize_nodal_variables (std::vector< std::string > names)
void write_timestep (int timestep, double time)
void write_nodal_values (int var_id, const std::vector< Number > &values, int timestep)
void check_err (const int error, const std::string msg)
void message (const std::string msg)
void message (const std::string msg, int i)
int comp_ws
int io_ws
int ex_id
int ex_err
int num_dim
int num_nodes
int num_elem
int num_elem_blk
int num_node_sets
int num_side_sets
int num_elem_this_blk
int num_nodes_per_elem
int num_attr
int req_info
int ret_int
int num_elem_all_sidesets
std::vector< int > block_ids
std::vector< int > connect
std::vector< int > ss_ids
std::vector< int > nodeset_ids
std::vector< int > num_sides_per_set
std::vector< int > num_nodes_per_set
std::vector< int > num_df_per_set
std::vector< int > num_node_df_per_set
std::vector< int > elem_list
std::vector< int > side_list
std::vector< int > node_list
std::vector< int > id_list
std::vector< int > node_num_map
std::vector< int > elem_num_map
float ex_version
float ret_float
std::vector< double > x
std::vector< double > y
std::vector< double > z
char ret_char
std::vector< char > title
std::vector< char > elem_type
std::map< int, int > libmesh_elem_num_to_exodus
int num_time_steps
std::vector< double > time_steps
int num_nodal_vars
std::vector< std::string > nodal_var_names
std::vector< double > nodal_var_values
std::vector< std::vector< char > > vvc
std::vector< char * > strings
This is the ExodusII_IO_Helper class. This class hides the implementation details of interfacing with the Exodus binary format.
Author:
Definition at line 46 of file exodusII_io_helper.h.
Definition at line 55 of file exodusII_io_helper.h.
References elem_type, and title.
:
comp_ws(sizeof(double)),
io_ws(0),
ex_id(0),
ex_err(0),
num_dim(0),
num_nodes(0),
num_elem(0),
num_elem_blk(0),
num_node_sets(0),
num_side_sets(0),
num_elem_this_blk(0),
num_nodes_per_elem(0),
num_attr(0),
req_info(0),
ret_int(0),
num_elem_all_sidesets(0),
ex_version(0.0),
ret_float(0.0),
ret_char(0),
num_time_steps(0),
_created(false),
_verbose(v)
{
title.resize(MAX_LINE_LENGTH+1);
elem_type.resize(MAX_STR_LENGTH);
}
Definition at line 105 of file exodusII_io_helper.C.
{
}
Definition at line 116 of file exodusII_io_helper.C.
Referenced by close(), create(), Nemesis_IO_Helper::get_cmap_params(), Nemesis_IO_Helper::get_eb_info_global(), Nemesis_IO_Helper::get_elem_cmap(), Nemesis_IO_Helper::get_elem_map(), Nemesis_IO_Helper::get_init_global(), Nemesis_IO_Helper::get_init_info(), Nemesis_IO_Helper::get_loadbal_param(), Nemesis_IO_Helper::get_node_cmap(), Nemesis_IO_Helper::get_node_map(), Nemesis_IO_Helper::get_ns_param_global(), Nemesis_IO_Helper::get_ss_param_global(), initialize(), initialize_nodal_variables(), inquire(), open(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), read_sideset_info(), write_elements(), write_nodal_coordinates(), write_nodal_values(), write_nodesets(), write_sidesets(), and write_timestep().
{
if (err < 0)
{
std::cout << msg << std::endl;
libmesh_error();
}
}
Definition at line 435 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, and message().
Referenced by ExodusII_IO::~ExodusII_IO().
{
ex_err = exII::ex_close(ex_id);
check_err(ex_err, 'Error closing Exodus file.');
message('Exodus file closed successfully.');
}
Definition at line 538 of file exodusII_io_helper.C.
References _created, _verbose, check_err(), comp_ws, ex_id, ex_version, and io_ws.
{
//Store things as doubles
comp_ws = 8;
io_ws = 8;
ex_id = exII::ex_create(filename.c_str(), EX_CLOBBER, &comp_ws, &io_ws);
ex_id = exII::ex_open(filename.c_str(),
EX_WRITE,
&comp_ws,
&io_ws,
&ex_version);
check_err(ex_id, 'Error creating ExodusII mesh file.');
if (_verbose) std::cout << 'File created successfully.' << std::endl;
_created = true;
}
Definition at line 819 of file exodusII_io_helper.C.
References _created.
{
return _created;
}
Definition at line 256 of file exodusII_io_helper.C.
References block_ids.
Referenced by ExodusII_IO::read().
{
libmesh_assert (static_cast<unsigned int>(block) < block_ids.size());
return block_ids[block];
}
the $ i^{th} $ node number in the element connectivity list for a given element.
Definition at line 174 of file exodusII_io_helper.h.
References connect.
Referenced by ExodusII_IO::read().
{ return connect[i]; }
a constant reference to the elem_list.
Definition at line 202 of file exodusII_io_helper.h.
References elem_list.
Referenced by ExodusII_IO::read().
{ return elem_list; }
Definition at line 249 of file exodusII_io_helper.h.
References elem_type.
Referenced by ExodusII_IO::read().
{ return &elem_type[0]; }
a constant reference to the id_list.
Definition at line 239 of file exodusII_io_helper.h.
References id_list.
Referenced by ExodusII_IO::read().
{ return id_list; }
Definition at line 464 of file exodusII_io_helper.C.
References _verbose, ex_id, nodal_var_names, num_nodal_vars, strings, and vvc.
Referenced by get_nodal_var_values().
{
// Allocate enough space for our variable name strings.
nodal_var_names.resize(num_nodal_vars);
// Use the vvc and strings objects to emulate the behavior of
// a char** object.
vvc.resize(num_nodal_vars);
strings.resize(num_nodal_vars);
for (int i=0;i<num_nodal_vars;i++)
vvc[i].resize(MAX_STR_LENGTH+1);
for (int i=0;i<num_nodal_vars;i++)
strings[i]=&(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
exII::ex_get_var_names(ex_id,
'n',
num_nodal_vars,
&strings[0]//var_names
);
if (_verbose)
{
std::cout << 'Read the variable(s) from the file:' << std::endl;
for (int i=0; i<num_nodal_vars; i++)
std::cout << 'strings[' << i << ']=' << strings[i] << std::endl;
}
// Copy the char buffers into strings.
for (int i=0;i<num_nodal_vars;i++)
nodal_var_names[i]=strings[i]; // calls string::op=(const char*)
return nodal_var_names;
}
Definition at line 504 of file exodusII_io_helper.C.
References ex_id, get_nodal_var_names(), nodal_var_names, nodal_var_values, and num_nodes.
{
nodal_var_values.resize(num_nodes);
this->get_nodal_var_names();
//See if we can find the variable we are looking for
unsigned int var_index = 0;
bool found = false;
found = nodal_var_names[var_index] == nodal_var_name;
while(!found && var_index < nodal_var_names.size())
{
var_index++;
found = nodal_var_names[var_index] == nodal_var_name;
}
if(!found)
{
std::cerr << 'Unable to locate variable named: ' << nodal_var_name << std::endl;
return nodal_var_values;
}
exII::ex_get_nodal_var(ex_id, time_step, var_index+1, num_nodes, &nodal_var_values[0]);
return nodal_var_values;
}
Definition at line 222 of file exodusII_io_helper.h.
References node_list.
Referenced by ExodusII_IO::read().
{ return node_list; }
Definition at line 227 of file exodusII_io_helper.h.
References nodeset_ids.
Referenced by ExodusII_IO::read().
{ return nodeset_ids[i]; }
Definition at line 107 of file exodusII_io_helper.h.
References num_dim.
{ return num_dim; }
Definition at line 120 of file exodusII_io_helper.h.
References num_elem.
Referenced by ExodusII_IO::read().
{ return num_elem; }
Definition at line 127 of file exodusII_io_helper.h.
References num_elem_blk.
Referenced by ExodusII_IO::read().
{ return num_elem_blk; }
Definition at line 134 of file exodusII_io_helper.h.
References num_elem_this_blk.
Referenced by ExodusII_IO::read().
{ return num_elem_this_blk; }
Definition at line 407 of file exodusII_io_helper.h.
References num_nodal_vars.
{ return num_nodal_vars; }
Definition at line 157 of file exodusII_io_helper.h.
References num_node_sets.
Referenced by ExodusII_IO::read().
{ return num_node_sets; }
Definition at line 113 of file exodusII_io_helper.h.
References num_nodes.
Referenced by ExodusII_IO::read().
{ return num_nodes; }
Definition at line 142 of file exodusII_io_helper.h.
References num_nodes_per_elem.
Referenced by ExodusII_IO::read().
{ return num_nodes_per_elem; }
Definition at line 188 of file exodusII_io_helper.h.
References num_nodes_per_set.
{ return num_nodes_per_set[i]; }
Definition at line 150 of file exodusII_io_helper.h.
References num_side_sets.
Referenced by ExodusII_IO::read().
{ return num_side_sets; }
Definition at line 181 of file exodusII_io_helper.h.
References num_sides_per_set.
Referenced by ExodusII_IO::read().
{ return num_sides_per_set[i]; }
a constant reference to the side_list.
Definition at line 217 of file exodusII_io_helper.h.
References side_list.
Referenced by ExodusII_IO::read().
{ return side_list; }
Definition at line 455 of file exodusII_io_helper.C.
References ex_id, num_time_steps, and time_steps.
{
time_steps.resize(num_time_steps);
exII::ex_get_all_times(ex_id, time_steps.empty() ? NULL : &time_steps[0]);
return time_steps;
}
Definition at line 255 of file exodusII_io_helper.h.
References x.
Referenced by ExodusII_IO::read().
{ return x[i]; }
Definition at line 261 of file exodusII_io_helper.h.
References y.
Referenced by ExodusII_IO::read().
{ return y[i]; }
Definition at line 267 of file exodusII_io_helper.h.
References z.
Referenced by ExodusII_IO::read().
{ return z[i]; }
Definition at line 560 of file exodusII_io_helper.C.
References MeshBase::boundary_info, check_err(), MeshBase::elem(), ex_err, ex_id, DofObject::id(), MeshBase::n_elem(), MeshBase::n_nodes(), num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, MeshBase::spatial_dimension(), and Elem::subdomain_id().
{
num_dim = mesh.spatial_dimension();
num_nodes = mesh.n_nodes();
num_elem = mesh.n_elem();
std::vector<short int> unique_side_boundaries;
std::vector<short int> unique_node_boundaries;
mesh.boundary_info->build_side_boundary_ids(unique_side_boundaries);
mesh.boundary_info->build_node_boundary_ids(unique_node_boundaries);
num_side_sets = unique_side_boundaries.size();
num_node_sets = unique_node_boundaries.size();
//loop through element and map between block and element vector
std::map<subdomain_id_type, std::vector<unsigned int> > subdomain_map;
for(int i=0;i<num_elem;i++)
{
Elem * elem = mesh.elem(i);
subdomain_id_type cur_subdomain = elem->subdomain_id();
subdomain_map[cur_subdomain].push_back(elem->id());
}
num_elem_blk = subdomain_map.size();
std::cout<<'Num elem block: '<<num_elem_blk<<std::endl;
ex_err = exII::ex_put_init(ex_id,
str_title.c_str(),
num_dim,
num_nodes,
num_elem,
num_elem_blk,
num_node_sets,
num_side_sets);
check_err(ex_err, 'Error initializing new Exodus file.');
}
Definition at line 762 of file exodusII_io_helper.C.
References _verbose, check_err(), ex_err, ex_id, num_nodal_vars, strings, and vvc.
{
num_nodal_vars = names.size();
ex_err = exII::ex_put_var_param(ex_id, 'n', num_nodal_vars);
check_err(ex_err, 'Error setting number of nodal vars.');
// Use the vvc and strings objects to emulate the behavior of
// a char** object.
vvc.resize(num_nodal_vars);
strings.resize(num_nodal_vars);
// For each string in names, allocate enough space in vvc and copy from
// the C++ string into vvc for passing to the C interface.
for (int i=0; i<num_nodal_vars; i++)
{
vvc[i].resize(names[i].size()+1);
std::strcpy(&(vvc[i][0]), names[i].c_str());
}
for (int i=0; i<num_nodal_vars; i++)
strings[i] = &(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
if (_verbose)
{
std::cout << 'Writing variable name(s) to file: ' << std::endl;
for (int i=0;i<num_nodal_vars;i++)
std::cout << 'strings[' << i << ']=' << strings[i] << std::endl;
}
ex_err = exII::ex_put_var_names(ex_id,
'n',
num_nodal_vars,
&strings[0]//var_names
);
check_err(ex_err, 'Error setting nodal variable names.');
}
Definition at line 442 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, ret_char, ret_float, and ret_int.
Referenced by read_header().
{
ex_err = exII::ex_inquire(ex_id,
req_info,
&ret_int,
&ret_float,
&ret_char);
check_err(ex_err, error_msg);
return ret_int;
}
Definition at line 127 of file exodusII_io_helper.C.
References _verbose.
Referenced by close(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), and read_sideset_info().
{
if (_verbose) std::cout << msg << std::endl;
}
Definition at line 134 of file exodusII_io_helper.C.
References _verbose.
{
if (_verbose) std::cout << msg << i << '.' << std::endl;
}
Definition at line 141 of file exodusII_io_helper.C.
References _verbose, check_err(), comp_ws, ex_id, ex_version, and io_ws.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
ex_id = exII::ex_open(filename,
EX_READ,
&comp_ws,
&io_ws,
&ex_version);
check_err(ex_id, 'Error opening ExodusII mesh file.');
if (_verbose) std::cout << 'File opened successfully.' << std::endl;
}
Definition at line 178 of file exodusII_io_helper.C.
References _verbose, num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, and title.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
if (_verbose)
std::cout << 'Title: ' << &title[0] << std::endl
<< 'Mesh Dimension: ' << num_dim << std::endl
<< 'Number of Nodes: ' << num_nodes << std::endl
<< 'Number of elements: ' << num_elem << std::endl
<< 'Number of elt blocks: ' << num_elem_blk << std::endl
<< 'Number of node sets: ' << num_node_sets << std::endl
<< 'Number of side sets: ' << num_side_sets << std::endl;
}
Definition at line 229 of file exodusII_io_helper.C.
References num_nodes, x, y, and z.
{
for (int i=0; i<num_nodes; i++)
{
std::cout << '(' << x[i] << ', ' << y[i] << ', ' << z[i] << ')' << std::endl;
}
}
Definition at line 425 of file exodusII_io_helper.C.
References elem_list, num_elem_all_sidesets, and side_list.
{
for (int i=0; i<num_elem_all_sidesets; i++)
{
std::cout << elem_list[i] << ' ' << side_list[i] << std::endl;
}
}
Definition at line 239 of file exodusII_io_helper.C.
References block_ids, check_err(), ex_err, ex_id, message(), and num_elem_blk.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
block_ids.resize(num_elem_blk);
// Get all element block IDs.
ex_err = exII::ex_get_elem_blk_ids(ex_id,
block_ids.empty() ? NULL : &block_ids[0]);
// Usually, there is only one
// block since there is only
// one type of element.
// However, there could be more.
check_err(ex_err, 'Error getting block IDs.');
message('All block IDs retrieved successfully.');
}
Definition at line 265 of file exodusII_io_helper.C.
References _verbose, block_ids, check_err(), connect, elem_type, ex_err, ex_id, message(), num_attr, num_elem_this_blk, and num_nodes_per_elem.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
libmesh_assert (static_cast<unsigned int>(block) < block_ids.size());
ex_err = exII::ex_get_elem_block(ex_id,
block_ids[block],
&elem_type[0],
&num_elem_this_blk,
&num_nodes_per_elem,
&num_attr);
if (_verbose)
std::cout << 'Reading a block of ' << num_elem_this_blk
<< ' ' << &elem_type[0] << '(s)'
<< ' having ' << num_nodes_per_elem
<< ' nodes per element.' << std::endl;
check_err(ex_err, 'Error getting block info.');
message('Info retrieved successfully for block: ', block);
// Read in the connectivity of the elements of this block,
// watching out for the case where we actually have no
// elements in this block (possible with parallel files)
connect.resize(num_nodes_per_elem*num_elem_this_blk);
if (!connect.empty())
{
ex_err = exII::ex_get_elem_conn(ex_id,
block_ids[block],
&connect[0]);
check_err(ex_err, 'Error reading block connectivity.');
message('Connectivity retrieved successfully for block: ', block);
}
}
Definition at line 304 of file exodusII_io_helper.C.
References _verbose, check_err(), elem_num_map, ex_err, ex_id, message(), std::min(), num_elem, and libMesh::processor_id().
Referenced by Nemesis_IO::read().
{
elem_num_map.resize(num_elem);
ex_err = exII::ex_get_elem_num_map (ex_id,
elem_num_map.empty() ? NULL : &elem_num_map[0]);
check_err(ex_err, 'Error retrieving element number map.');
message('Element numbering map retrieved successfully.');
if (_verbose)
{
std::cout << '[' << libMesh::processor_id() << '] elem_num_map[i] = ';
for (unsigned int i=0; i< static_cast<unsigned int>(std::min(10, num_elem-1)); ++i)
std::cout << elem_num_map[i] << ', ';
std::cout << '... ' << elem_num_map.back() << std::endl;
}
}
Definition at line 155 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, inquire(), message(), num_dim, num_elem, num_elem_blk, num_nodal_vars, num_node_sets, num_nodes, num_side_sets, num_time_steps, and title.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
ex_err = exII::ex_get_init(ex_id,
title.empty() ? NULL : &title[0],
&num_dim,
&num_nodes,
&num_elem,
&num_elem_blk,
&num_node_sets,
&num_side_sets);
check_err(ex_err, 'Error retrieving header info.');
num_time_steps = inquire(exII::EX_INQ_TIME, 'Error retrieving time steps');
exII::ex_get_var_param(ex_id, 'n', &num_nodal_vars);
message('Exodus header info retrieved successfully.');
}
Definition at line 209 of file exodusII_io_helper.C.
References _verbose, check_err(), ex_err, ex_id, message(), std::min(), node_num_map, num_nodes, and libMesh::processor_id().
Referenced by Nemesis_IO::read().
{
node_num_map.resize(num_nodes);
ex_err = exII::ex_get_node_num_map (ex_id,
node_num_map.empty() ? NULL : &node_num_map[0]);
check_err(ex_err, 'Error retrieving nodal number map.');
message('Nodal numbering map retrieved successfully.');
if (_verbose)
{
std::cout << '[' << libMesh::processor_id() << '] node_num_map[i] = ';
for (unsigned int i=0; i< static_cast<unsigned int>(std::min(10, num_nodes-1)); ++i)
std::cout << node_num_map[i] << ', ';
std::cout << '... ' << node_num_map.back() << std::endl;
}
}
Definition at line 192 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, message(), num_nodes, x, y, and z.
Referenced by Nemesis_IO::read(), and ExodusII_IO::read().
{
x.resize(num_nodes);
y.resize(num_nodes);
z.resize(num_nodes);
ex_err = exII::ex_get_coord(ex_id,
static_cast<void*>(&x[0]),
static_cast<void*>(&y[0]),
static_cast<void*>(&z[0]));
check_err(ex_err, 'Error retrieving nodal data.');
message('Nodal data retrieved successfully.');
}
Definition at line 401 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, message(), node_list, nodeset_ids, num_node_df_per_set, and num_nodes_per_set.
Referenced by ExodusII_IO::read().
{
libmesh_assert (static_cast<unsigned int>(id) < nodeset_ids.size());
libmesh_assert (static_cast<unsigned int>(id) < num_nodes_per_set.size());
libmesh_assert (static_cast<unsigned int>(id) < num_node_df_per_set.size());
ex_err = exII::ex_get_node_set_param(ex_id,
nodeset_ids[id],
&num_nodes_per_set[id],
&num_node_df_per_set[id]);
check_err(ex_err, 'Error retrieving nodeset parameters.');
message('Parameters retrieved successfully for nodeset: ', id);
node_list.resize(num_nodes_per_set[id]);
ex_err = exII::ex_get_node_set(ex_id,
nodeset_ids[id],
&node_list[0]);
check_err(ex_err, 'Error retrieving nodeset data.');
message('Data retrieved successfully for nodeset: ', id);
}
Definition at line 358 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, message(), nodeset_ids, num_node_df_per_set, num_node_sets, and num_nodes_per_set.
Referenced by ExodusII_IO::read().
{
nodeset_ids.resize(num_node_sets);
if (num_node_sets > 0)
{
ex_err = exII::ex_get_node_set_ids(ex_id,
&nodeset_ids[0]);
check_err(ex_err, 'Error retrieving nodeset information.');
message('All nodeset information retrieved successfully.');
// Resize appropriate data structures -- only do this once outnode the loop
num_nodes_per_set.resize(num_node_sets);
num_node_df_per_set.resize(num_node_sets);
}
}
Definition at line 375 of file exodusII_io_helper.C.
References check_err(), elem_list, ex_err, ex_id, id_list, message(), num_df_per_set, num_sides_per_set, side_list, and ss_ids.
Referenced by ExodusII_IO::read().
{
libmesh_assert (static_cast<unsigned int>(id) < ss_ids.size());
libmesh_assert (static_cast<unsigned int>(id) < num_sides_per_set.size());
libmesh_assert (static_cast<unsigned int>(id) < num_df_per_set.size());
libmesh_assert (static_cast<unsigned int>(offset) < elem_list.size());
libmesh_assert (static_cast<unsigned int>(offset) < side_list.size());
ex_err = exII::ex_get_side_set_param(ex_id,
ss_ids[id],
&num_sides_per_set[id],
&num_df_per_set[id]);
check_err(ex_err, 'Error retrieving sideset parameters.');
message('Parameters retrieved successfully for sideset: ', id);
ex_err = exII::ex_get_side_set(ex_id,
ss_ids[id],
&elem_list[offset],
&side_list[offset]);
check_err(ex_err, 'Error retrieving sideset data.');
message('Data retrieved successfully for sideset: ', id);
for (int i=0; i<num_sides_per_set[id]; i++)
id_list[i+offset] = ss_ids[id];
}
Definition at line 326 of file exodusII_io_helper.C.
References check_err(), elem_list, ex_err, ex_id, id_list, message(), num_df_per_set, num_elem_all_sidesets, num_side_sets, num_sides_per_set, req_info, ret_char, ret_float, ret_int, side_list, and ss_ids.
Referenced by ExodusII_IO::read().
{
ss_ids.resize(num_side_sets);
if (num_side_sets > 0)
{
ex_err = exII::ex_get_side_set_ids(ex_id,
&ss_ids[0]);
check_err(ex_err, 'Error retrieving sideset information.');
message('All sideset information retrieved successfully.');
// Resize appropriate data structures -- only do this once outside the loop
num_sides_per_set.resize(num_side_sets);
num_df_per_set.resize(num_side_sets);
// Inquire about the length of the
// concatenated side sets element list
req_info = exII::EX_INQ_SS_ELEM_LEN;
ex_err = exII::ex_inquire(ex_id,
req_info,
&ret_int,
&ret_float,
&ret_char);
check_err(ex_err, 'Error inquiring about side set element list length.');
//std::cout << 'Value returned by ex_inquire was: ' << ret_int << std::endl;
num_elem_all_sidesets = ret_int;
elem_list.resize (num_elem_all_sidesets);
side_list.resize (num_elem_all_sidesets);
id_list.resize (num_elem_all_sidesets);
}
}
Definition at line 109 of file exodusII_io_helper.C.
References _verbose.
Referenced by Nemesis_IO::verbose(), and ExodusII_IO::verbose().
{
_verbose = set_verbosity;
}
Definition at line 623 of file exodusII_io_helper.C.
References _verbose, Elem::active(), ExodusII_IO_Helper::ElementMaps::assign_conversion(), check_err(), connect, MeshBase::elem(), elem_num_map, ex_err, ex_id, ExodusII_IO_Helper::Conversion::exodus_elem_type(), ExodusII_IO_Helper::Conversion::get_node_map(), DofObject::id(), libmesh_elem_num_to_exodus, Elem::n_nodes(), Elem::node(), num_elem, num_nodes_per_elem, Elem::subdomain_id(), and Elem::type().
{
std::map<unsigned int, std::vector<unsigned int> > subdomain_map;
//loop through element and map between block and element vector
for(unsigned int i=0; i<static_cast<unsigned int>(num_elem); i++)
{
Elem * elem = mesh.elem(i);
//Only write out the active elements
if(elem->active())
{
unsigned int cur_subdomain = elem->subdomain_id();
subdomain_map[cur_subdomain].push_back(elem->id());
}
}
std::vector<int> elem_num_map;
std::map<unsigned int, std::vector<unsigned int> >::iterator it;
for(it = subdomain_map.begin() ; it != subdomain_map.end(); it++)
{
std::vector<unsigned int> & tmp_vec = (*it).second;
ExodusII_IO_Helper::ElementMaps em;
//Use the first element in this block to get representative information.
//Note that Exodus assumes all elements in a block are of the same type!
//We are using that same assumption here!
const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(tmp_vec[0])->type());
num_nodes_per_elem = mesh.elem(tmp_vec[0])->n_nodes();
ex_err = exII::ex_put_elem_block(ex_id, (*it).first, conv.exodus_elem_type().c_str(), tmp_vec.size(),num_nodes_per_elem,0);
check_err(ex_err, 'Error writing element block.');
connect.resize(tmp_vec.size()*num_nodes_per_elem);
for (unsigned int i=0; i<tmp_vec.size(); i++)
{
unsigned int elem_id = tmp_vec[i];
elem_num_map.push_back(elem_id);
libmesh_elem_num_to_exodus[elem_id] = elem_num_map.size();
Elem * elem = mesh.elem(elem_id);
for (unsigned int j=0; j < static_cast<unsigned int>(num_nodes_per_elem); j++)
{
const unsigned int connect_index = (i*num_nodes_per_elem)+j;
const unsigned int elem_node_index = conv.get_node_map(j);
if (_verbose)
{
std::cout << 'Exodus node index: ' << j
<< '=LibMesh node index ' << elem_node_index << std::endl;
}
connect[connect_index] = elem->node(elem_node_index)+1;
}
}
ex_err = exII::ex_put_elem_conn(ex_id, (*it).first, &connect[0]);
check_err(ex_err, 'Error writing element connectivities');
}
// ex_err = exII::ex_put_elem_num_map(ex_id, &elem_num_map[0]);
check_err(ex_err, 'Error writing element connectivities');
}
Definition at line 600 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, MeshBase::node_ptr(), num_nodes, x, y, and z.
{
x.resize(num_nodes);
y.resize(num_nodes);
z.resize(num_nodes);
for (/* unsigned */ int i=0; i<num_nodes; ++i)
{
x[i]=(*mesh.node_ptr(i))(0);
y[i]=(*mesh.node_ptr(i))(1);
z[i]=(*mesh.node_ptr(i))(2);
}
ex_err = exII::ex_put_coord(ex_id,
x.empty() ? NULL : &x[0],
y.empty() ? NULL : &y[0],
z.empty() ? NULL : &z[0]);
check_err(ex_err, 'Error writing coordinates to Exodus file.');
}
Definition at line 811 of file exodusII_io_helper.C.
References check_err(), ex_err, ex_id, and num_nodes.
{
ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, &values[0]);
check_err(ex_err, 'Error writing nodal values.');
}
Definition at line 730 of file exodusII_io_helper.C.
References MeshBase::boundary_info, check_err(), ex_err, and ex_id.
{
ExodusII_IO_Helper::ElementMaps em;
std::vector< unsigned int > nl;
std::vector< short int > il;
mesh.boundary_info->build_node_list(nl, il);
//Maps from nodeset id to the nodes
std::map<short int, std::vector<int> > node;
//Accumulate the vectors to pass into ex_put_node_set
for(unsigned int i = 0; i < nl.size(); i++)
node[il[i]].push_back(nl[i]);
std::vector<short int> node_boundary_ids;
mesh.boundary_info->build_node_boundary_ids(node_boundary_ids);
for(unsigned int i = 0; i < node_boundary_ids.size(); i++)
{
int nodeset_id = node_boundary_ids[i];
ex_err = exII::ex_put_node_set_param(ex_id, nodeset_id, node[nodeset_id].size(), 0);
check_err(ex_err, 'Error writing nodeset parameters');
ex_err = exII::ex_put_node_set(ex_id, nodeset_id, &node[nodeset_id][0]);
check_err(ex_err, 'Error writing nodesets');
}
}
Definition at line 691 of file exodusII_io_helper.C.
References ExodusII_IO_Helper::ElementMaps::assign_conversion(), MeshBase::boundary_info, check_err(), MeshBase::elem(), ex_err, ex_id, ExodusII_IO_Helper::Conversion::get_inverse_side_map(), and Elem::type().
{
ExodusII_IO_Helper::ElementMaps em;
std::vector< unsigned int > el;
std::vector< unsigned short int > sl;
std::vector< short int > il;
mesh.boundary_info->build_side_list(el, sl, il);
//Maps from sideset id to the element and sides
std::map<int, std::vector<int> > elem;
std::map<int, std::vector<int> > side;
//Accumulate the vectors to pass into ex_put_side_set
for(unsigned int i = 0; i < el.size(); i++)
{
const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(el[i])->type());
elem[il[i]].push_back(el[i]+1);
side[il[i]].push_back(conv.get_inverse_side_map(sl[i]));
}
std::vector<short int> side_boundary_ids;
mesh.boundary_info->build_side_boundary_ids(side_boundary_ids);
for(unsigned int i = 0; i < side_boundary_ids.size(); i++)
{
int ss_id = side_boundary_ids[i];
ex_err = exII::ex_put_side_set_param(ex_id, ss_id, elem[ss_id].size(), 4);
check_err(ex_err, 'Error writing sideset parameters');
ex_err = exII::ex_put_side_set(ex_id, ss_id, &elem[ss_id][0], &side[ss_id][0]);
check_err(ex_err, 'Error writing sidesets');
}
}
Definition at line 803 of file exodusII_io_helper.C.
References check_err(), ex_err, and ex_id.
{
ex_err = exII::ex_put_time(ex_id, timestep, &time);
check_err(ex_err, 'Error writing timestep.');
}
Definition at line 581 of file exodusII_io_helper.h.
Referenced by create(), and created().
Definition at line 582 of file exodusII_io_helper.h.
Referenced by create(), Nemesis_IO_Helper::get_cmap_params(), Nemesis_IO_Helper::get_eb_info_global(), Nemesis_IO_Helper::get_elem_cmap(), Nemesis_IO_Helper::get_elem_map(), Nemesis_IO_Helper::get_init_global(), Nemesis_IO_Helper::get_init_info(), Nemesis_IO_Helper::get_loadbal_param(), get_nodal_var_names(), Nemesis_IO_Helper::get_node_cmap(), Nemesis_IO_Helper::get_node_map(), Nemesis_IO_Helper::get_ns_param_global(), Nemesis_IO_Helper::get_ss_param_global(), initialize_nodal_variables(), message(), open(), print_header(), read_elem_in_block(), read_elem_num_map(), read_node_num_map(), verbose(), and write_elements().
Definition at line 539 of file exodusII_io_helper.h.
Referenced by get_block_id(), Nemesis_IO::read(), read_block_info(), and read_elem_in_block().
Definition at line 523 of file exodusII_io_helper.h.
Referenced by create(), and open().
Definition at line 540 of file exodusII_io_helper.h.
Referenced by get_connect(), Nemesis_IO::read(), read_elem_in_block(), and write_elements().
Definition at line 547 of file exodusII_io_helper.h.
Referenced by get_elem_list(), print_sideset_info(), read_sideset(), and read_sideset_info().
Definition at line 552 of file exodusII_io_helper.h.
Referenced by read_elem_num_map(), and write_elements().
Definition at line 561 of file exodusII_io_helper.h.
Referenced by ExodusII_IO_Helper(), get_elem_type(), Nemesis_IO::read(), and read_elem_in_block().
Definition at line 526 of file exodusII_io_helper.h.
Referenced by close(), initialize(), initialize_nodal_variables(), inquire(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), read_sideset_info(), write_elements(), write_nodal_coordinates(), write_nodal_values(), write_nodesets(), write_sidesets(), and write_timestep().
Definition at line 525 of file exodusII_io_helper.h.
Referenced by close(), create(), Nemesis_IO_Helper::get_cmap_params(), Nemesis_IO_Helper::get_eb_info_global(), Nemesis_IO_Helper::get_elem_cmap(), Nemesis_IO_Helper::get_elem_map(), Nemesis_IO_Helper::get_init_global(), Nemesis_IO_Helper::get_init_info(), Nemesis_IO_Helper::get_loadbal_param(), get_nodal_var_names(), get_nodal_var_values(), Nemesis_IO_Helper::get_node_cmap(), Nemesis_IO_Helper::get_node_map(), Nemesis_IO_Helper::get_ns_param_global(), Nemesis_IO_Helper::get_ss_param_global(), get_time_steps(), initialize(), initialize_nodal_variables(), inquire(), open(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), read_sideset_info(), write_elements(), write_nodal_coordinates(), write_nodal_values(), write_nodesets(), write_sidesets(), and write_timestep().
Definition at line 553 of file exodusII_io_helper.h.
Referenced by create(), and open().
Definition at line 550 of file exodusII_io_helper.h.
Referenced by get_id_list(), read_sideset(), and read_sideset_info().
Definition at line 524 of file exodusII_io_helper.h.
Referenced by create(), and open().
Definition at line 565 of file exodusII_io_helper.h.
Referenced by write_elements().
Definition at line 571 of file exodusII_io_helper.h.
Referenced by get_nodal_var_names(), and get_nodal_var_values().
Definition at line 572 of file exodusII_io_helper.h.
Referenced by get_nodal_var_values().
Definition at line 549 of file exodusII_io_helper.h.
Referenced by get_node_list(), and read_nodeset().
Definition at line 551 of file exodusII_io_helper.h.
Referenced by Nemesis_IO::read(), and read_node_num_map().
Definition at line 542 of file exodusII_io_helper.h.
Referenced by get_nodeset_id(), read_nodeset(), and read_nodeset_info().
Definition at line 535 of file exodusII_io_helper.h.
Referenced by read_elem_in_block().
Definition at line 545 of file exodusII_io_helper.h.
Referenced by read_sideset(), and read_sideset_info().
Definition at line 527 of file exodusII_io_helper.h.
Referenced by get_num_dim(), initialize(), print_header(), Nemesis_IO::read(), and read_header().
Definition at line 529 of file exodusII_io_helper.h.
Referenced by get_num_elem(), initialize(), print_header(), Nemesis_IO::read(), read_elem_num_map(), read_header(), and write_elements().
Definition at line 538 of file exodusII_io_helper.h.
Referenced by print_sideset_info(), and read_sideset_info().
Definition at line 530 of file exodusII_io_helper.h.
Referenced by get_num_elem_blk(), initialize(), print_header(), Nemesis_IO::read(), read_block_info(), and read_header().
Definition at line 533 of file exodusII_io_helper.h.
Referenced by get_num_elem_this_blk(), Nemesis_IO::read(), and read_elem_in_block().
Definition at line 570 of file exodusII_io_helper.h.
Referenced by get_nodal_var_names(), get_num_nodal_vars(), initialize_nodal_variables(), and read_header().
Definition at line 546 of file exodusII_io_helper.h.
Referenced by read_nodeset(), and read_nodeset_info().
Definition at line 531 of file exodusII_io_helper.h.
Referenced by get_num_node_sets(), initialize(), print_header(), read_header(), and read_nodeset_info().
Definition at line 528 of file exodusII_io_helper.h.
Referenced by get_nodal_var_values(), get_num_nodes(), initialize(), print_header(), print_nodes(), Nemesis_IO::read(), read_header(), read_node_num_map(), read_nodes(), write_nodal_coordinates(), and write_nodal_values().
Definition at line 534 of file exodusII_io_helper.h.
Referenced by get_num_nodes_per_elem(), Nemesis_IO::read(), read_elem_in_block(), and write_elements().
Definition at line 544 of file exodusII_io_helper.h.
Referenced by get_num_nodes_per_set(), read_nodeset(), and read_nodeset_info().
Definition at line 532 of file exodusII_io_helper.h.
Referenced by get_num_side_sets(), initialize(), print_header(), read_header(), and read_sideset_info().
Definition at line 543 of file exodusII_io_helper.h.
Referenced by get_num_sides_per_set(), read_sideset(), and read_sideset_info().
Definition at line 568 of file exodusII_io_helper.h.
Referenced by get_time_steps(), and read_header().
Definition at line 536 of file exodusII_io_helper.h.
Referenced by read_sideset_info().
Definition at line 558 of file exodusII_io_helper.h.
Referenced by inquire(), and read_sideset_info().
Definition at line 554 of file exodusII_io_helper.h.
Referenced by inquire(), and read_sideset_info().
Definition at line 537 of file exodusII_io_helper.h.
Referenced by inquire(), and read_sideset_info().
Definition at line 548 of file exodusII_io_helper.h.
Referenced by get_side_list(), print_sideset_info(), read_sideset(), and read_sideset_info().
Definition at line 541 of file exodusII_io_helper.h.
Referenced by read_sideset(), and read_sideset_info().
Definition at line 578 of file exodusII_io_helper.h.
Referenced by get_nodal_var_names(), and initialize_nodal_variables().
Definition at line 569 of file exodusII_io_helper.h.
Referenced by get_time_steps().
Definition at line 560 of file exodusII_io_helper.h.
Referenced by ExodusII_IO_Helper(), print_header(), and read_header().
Definition at line 577 of file exodusII_io_helper.h.
Referenced by get_nodal_var_names(), and initialize_nodal_variables().
Definition at line 555 of file exodusII_io_helper.h.
Referenced by get_x(), print_nodes(), Nemesis_IO::read(), read_nodes(), and write_nodal_coordinates().
Definition at line 556 of file exodusII_io_helper.h.
Referenced by get_y(), print_nodes(), Nemesis_IO::read(), read_nodes(), and write_nodal_coordinates().
Definition at line 557 of file exodusII_io_helper.h.
Referenced by get_z(), print_nodes(), Nemesis_IO::read(), read_nodes(), and write_nodal_coordinates().
Generated automatically by Doxygen for libMesh from the source code.