Sierra Toolkit  Version of the Day
MeshReadWriteUtils.cpp
1  /*------------------------------------------------------------------------*/
2 /* Copyright 2010, 2011 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #include <stk_io/MeshReadWriteUtils.hpp>
10 
11 #include <stk_mesh/base/BulkData.hpp>
12 #include <stk_mesh/base/GetEntities.hpp>
13 #include <stk_mesh/fem/FEMMetaData.hpp>
14 #include <stk_mesh/fem/FEMHelpers.hpp>
15 
16 #include <stk_mesh/base/Field.hpp>
17 #include <stk_mesh/base/FieldData.hpp>
18 #include <stk_mesh/base/FieldParallel.hpp>
19 
20 #include <Shards_BasicTopologies.hpp>
21 
22 #include <stk_io/IossBridge.hpp>
23 
24 #include <Ioss_SubSystem.h>
25 
26 #include <stk_util/util/tokenize.hpp>
27 #include <iostream>
28 #include <sstream>
29 #include <cmath>
30 
31 #include <limits>
32 #include <assert.h>
33 
34 namespace {
35 void process_surface_entity(Ioss::SideSet *sset, stk_classic::mesh::fem::FEMMetaData &fem_meta)
36 {
37  assert(sset->type() == Ioss::SIDESET);
38  const Ioss::SideBlockContainer& blocks = sset->get_side_blocks();
40 
41  stk_classic::mesh::Part* const ss_part = fem_meta.get_part(sset->name());
42  assert(ss_part != NULL);
43 
45  bool surface_df_defined = false; // Has the surface df field been defined yet?
46 
47  size_t block_count = sset->block_count();
48  for (size_t i=0; i < block_count; i++) {
49  Ioss::SideBlock *sb = sset->get_block(i);
51  stk_classic::mesh::Part * const sb_part = fem_meta.get_part(sb->name());
52  assert(sb_part != NULL);
53  fem_meta.declare_part_subset(*ss_part, *sb_part);
54 
55  if (sb->field_exists("distribution_factors")) {
56  if (!surface_df_defined) {
57  std::string field_name = sset->name() + "_df";
58  distribution_factors_field =
60  stk_classic::io::set_field_role(*distribution_factors_field, Ioss::Field::MESH);
61  stk_classic::io::set_distribution_factor_field(*ss_part, *distribution_factors_field);
62  surface_df_defined = true;
63  }
64  stk_classic::io::set_distribution_factor_field(*sb_part, *distribution_factors_field);
65  int side_node_count = sb->topology()->number_nodes();
66  stk_classic::mesh::put_field(*distribution_factors_field,
67  stk_classic::io::part_primary_entity_rank(*sb_part),
68  *sb_part, side_node_count);
69  }
70  }
71  }
72 }
73 
75  const stk_classic::mesh::BulkData &bulk,
76  std::vector<stk_classic::mesh::Entity*> &entities,
77  const stk_classic::mesh::Selector *anded_selector)
78  {
79  stk_classic::mesh::MetaData & meta = stk_classic::mesh::MetaData::get(part);
80  stk_classic::mesh::EntityRank type = stk_classic::io::part_primary_entity_rank(part);
81 
83  stk_classic::mesh::Selector selector = part & own;
84  if (anded_selector) selector &= *anded_selector;
85 
86  get_selected_entities(selector, bulk.buckets(type), entities);
87  return entities.size();
88  }
89 }
90 
91 // ========================================================================
92 template <typename INT>
93 void process_surface_entity(const Ioss::SideSet* sset, stk_classic::mesh::BulkData & bulk, INT /*dummy*/)
94 {
95  assert(sset->type() == Ioss::SIDESET);
96 
98 
99  size_t block_count = sset->block_count();
100  for (size_t i=0; i < block_count; i++) {
101  Ioss::SideBlock *block = sset->get_block(i);
102  if (stk_classic::io::include_entity(block)) {
103  std::vector<INT> side_ids ;
104  std::vector<INT> elem_side ;
105 
106  stk_classic::mesh::Part * const sb_part = fem_meta.get_part(block->name());
107  stk_classic::mesh::EntityRank elem_rank = fem_meta.element_rank();
108 
109  block->get_field_data("ids", side_ids);
110  block->get_field_data("element_side", elem_side);
111 
112  assert(side_ids.size() * 2 == elem_side.size());
113  stk_classic::mesh::PartVector add_parts( 1 , sb_part );
114 
115  size_t side_count = side_ids.size();
116  std::vector<stk_classic::mesh::Entity*> sides(side_count);
117  for(size_t is=0; is<side_count; ++is) {
118  stk_classic::mesh::Entity* const elem = bulk.get_entity(elem_rank, elem_side[is*2]);
119 
120  // If NULL, then the element was probably assigned to an
121  // element block that appears in the database, but was
122  // subsetted out of the analysis mesh. Only process if
123  // non-null.
124  if (elem != NULL) {
125  // Ioss uses 1-based side ordinal, stk_classic::mesh uses 0-based.
126  int side_ordinal = elem_side[is*2+1] - 1;
127 
128  stk_classic::mesh::Entity* side_ptr = NULL;
129  side_ptr = &stk_classic::mesh::fem::declare_element_side(bulk, side_ids[is], *elem, side_ordinal);
130  stk_classic::mesh::Entity& side = *side_ptr;
131 
132  bulk.change_entity_parts( side, add_parts );
133  sides[is] = &side;
134  } else {
135  sides[is] = NULL;
136  }
137  }
138 
141  if (df_field != NULL) {
142  stk_classic::io::field_data_from_ioss(df_field, sides, block, "distribution_factors");
143  }
144 
145  // Add all attributes as fields.
146  // If the only attribute is 'attribute', then add it; otherwise the other attributes are the
147  // named components of the 'attribute' field, so add them instead.
148  Ioss::NameList names;
149  block->field_describe(Ioss::Field::ATTRIBUTE, &names);
150  for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
151  if(*I == "attribute" && names.size() > 1)
152  continue;
153  stk_classic::mesh::FieldBase *field = fem_meta.get_field<stk_classic::mesh::FieldBase> (*I);
154  if (field)
155  stk_classic::io::field_data_from_ioss(field, sides, block, *I);
156  }
157  }
158  }
159 }
160 
161 void process_surface_entity(const Ioss::SideSet* sset, stk_classic::mesh::BulkData & bulk)
162 {
163  if (stk_classic::io::db_api_int_size(sset) == 4)
164  process_surface_entity(sset, bulk, (int)0);
165  else
166  process_surface_entity(sset, bulk, (int64_t)0);
167 }
168 
169 void process_nodeblocks(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
170 {
171  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
172  assert(node_blocks.size() == 1);
173 
174  Ioss::NodeBlock *nb = node_blocks[0];
175 
176  assert(nb->field_exists("mesh_model_coordinates"));
177  Ioss::Field coordinates = nb->get_field("mesh_model_coordinates");
178  int spatial_dim = coordinates.transformed_storage()->component_count();
179 
182 
183  stk_classic::mesh::put_field( coord_field, fem_meta.node_rank(), fem_meta.universal_part(), spatial_dim);
184  stk_classic::io::define_io_fields(nb, Ioss::Field::ATTRIBUTE, fem_meta.universal_part(), 0);
185 }
186 
187 void process_nodeblocks(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
188 {
189  // This must be called after the "process_element_blocks" call
190  // since there may be nodes that exist in the database that are
191  // not part of the analysis mesh due to subsetting of the element
192  // blocks.
193 
195 
196  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
197  assert(node_blocks.size() == 1);
198 
199  Ioss::NodeBlock *nb = node_blocks[0];
200 
201  std::vector<stk_classic::mesh::Entity*> nodes;
202  stk_classic::io::get_entity_list(nb, fem_meta.node_rank(), bulk, nodes);
203 
206 
207  stk_classic::io::field_data_from_ioss(coord_field, nodes, nb, "mesh_model_coordinates");
208 
209  // Add all attributes as fields.
210  // If the only attribute is 'attribute', then add it; otherwise the other attributes are the
211  // named components of the 'attribute' field, so add them instead.
212  Ioss::NameList names;
213  nb->field_describe(Ioss::Field::ATTRIBUTE, &names);
214  for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
215  if(*I == "attribute" && names.size() > 1)
216  continue;
218  if (field)
219  stk_classic::io::field_data_from_ioss(field, nodes, nb, *I);
220  }
221 }
222 
223 // ========================================================================
224 void process_elementblocks(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
225 {
226  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
227  stk_classic::io::default_part_processing(elem_blocks, fem_meta);
228 }
229 
230 template <typename INT>
231 void process_elementblocks(Ioss::Region &region, stk_classic::mesh::BulkData &bulk, INT /*dummy*/)
232 {
234 
235  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
236  for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin();
237  it != elem_blocks.end(); ++it) {
238  Ioss::ElementBlock *entity = *it;
239 
240  if (stk_classic::io::include_entity(entity)) {
241  const std::string &name = entity->name();
242  stk_classic::mesh::Part* const part = fem_meta.get_part(name);
243  assert(part != NULL);
244 
245  const CellTopologyData* cell_topo = stk_classic::io::get_cell_topology(*part);
246  if (cell_topo == NULL) {
247  std::ostringstream msg ;
248  msg << " INTERNAL_ERROR: Part " << part->name() << " returned NULL from get_cell_topology()";
249  throw std::runtime_error( msg.str() );
250  }
251 
252  std::vector<INT> elem_ids ;
253  std::vector<INT> connectivity ;
254 
255  entity->get_field_data("ids", elem_ids);
256  entity->get_field_data("connectivity", connectivity);
257 
258  size_t element_count = elem_ids.size();
259  int nodes_per_elem = cell_topo->node_count ;
260 
261  std::vector<stk_classic::mesh::EntityId> id_vec(nodes_per_elem);
262  std::vector<stk_classic::mesh::Entity*> elements(element_count);
263 
264  for(size_t i=0; i<element_count; ++i) {
265  INT *conn = &connectivity[i*nodes_per_elem];
266  std::copy(&conn[0], &conn[0+nodes_per_elem], id_vec.begin());
267  elements[i] = &stk_classic::mesh::fem::declare_element(bulk, *part, elem_ids[i], &id_vec[0]);
268  }
269 
270  // Add all element attributes as fields.
271  // If the only attribute is 'attribute', then add it; otherwise the other attributes are the
272  // named components of the 'attribute' field, so add them instead.
273  Ioss::NameList names;
274  entity->field_describe(Ioss::Field::ATTRIBUTE, &names);
275  for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
276  if(*I == "attribute" && names.size() > 1)
277  continue;
279  if (field)
280  stk_classic::io::field_data_from_ioss(field, elements, entity, *I);
281  }
282  }
283  }
284 }
285 
286 // ========================================================================
287 // ========================================================================
288 void process_nodesets(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
289 {
290  const Ioss::NodeSetContainer& node_sets = region.get_nodesets();
291  stk_classic::io::default_part_processing(node_sets, fem_meta);
292 
293  stk_classic::mesh::Field<double> & distribution_factors_field =
294  fem_meta.declare_field<stk_classic::mesh::Field<double> >("distribution_factors");
295  stk_classic::io::set_field_role(distribution_factors_field, Ioss::Field::MESH);
296 
302  for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin();
303  it != node_sets.end(); ++it) {
304  Ioss::NodeSet *entity = *it;
305 
306  if (stk_classic::io::include_entity(entity)) {
307  stk_classic::mesh::Part* const part = fem_meta.get_part(entity->name());
308  assert(part != NULL);
309  assert(entity->field_exists("distribution_factors"));
310 
311  stk_classic::mesh::put_field(distribution_factors_field, fem_meta.node_rank(), *part);
312  }
313  }
314 }
315 
316 // ========================================================================
317 // ========================================================================
318 void process_sidesets(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
319 {
320  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
321  stk_classic::io::default_part_processing(side_sets, fem_meta);
322 
323  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
324  it != side_sets.end(); ++it) {
325  Ioss::SideSet *entity = *it;
326 
327  if (stk_classic::io::include_entity(entity)) {
328  process_surface_entity(entity, fem_meta);
329  }
330  }
331 }
332 
333 // ========================================================================
334 template <typename INT>
335 void process_nodesets(Ioss::Region &region, stk_classic::mesh::BulkData &bulk, INT /*dummy*/)
336 {
337  // Should only process nodes that have already been defined via the element
338  // blocks connectivity lists.
339  const Ioss::NodeSetContainer& node_sets = region.get_nodesets();
341 
342  for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin();
343  it != node_sets.end(); ++it) {
344  Ioss::NodeSet *entity = *it;
345 
346  if (stk_classic::io::include_entity(entity)) {
347  const std::string & name = entity->name();
348  stk_classic::mesh::Part* const part = fem_meta.get_part(name);
349  assert(part != NULL);
350  stk_classic::mesh::PartVector add_parts( 1 , part );
351 
352  std::vector<INT> node_ids ;
353  size_t node_count = entity->get_field_data("ids", node_ids);
354 
355  std::vector<stk_classic::mesh::Entity*> nodes(node_count);
356  stk_classic::mesh::EntityRank n_rank = fem_meta.node_rank();
357  for(size_t i=0; i<node_count; ++i) {
358  nodes[i] = bulk.get_entity(n_rank, node_ids[i] );
359  if (nodes[i] != NULL)
360  bulk.declare_entity(n_rank, node_ids[i], add_parts );
361  }
362 
364  fem_meta.get_field<stk_classic::mesh::Field<double> >("distribution_factors");
365 
366  if (df_field != NULL) {
367  stk_classic::io::field_data_from_ioss(df_field, nodes, entity, "distribution_factors");
368  }
369 
370  // Add all attributes as fields.
371  // If the only attribute is 'attribute', then add it; otherwise the other attributes are the
372  // named components of the 'attribute' field, so add them instead.
373  Ioss::NameList names;
374  entity->field_describe(Ioss::Field::ATTRIBUTE, &names);
375  for(Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
376  if(*I == "attribute" && names.size() > 1)
377  continue;
379  if (field)
380  stk_classic::io::field_data_from_ioss(field, nodes, entity, *I);
381  }
382  }
383  }
384 }
385 
386 // ========================================================================
387 void process_sidesets(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
388 {
389  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
390 
391  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
392  it != side_sets.end(); ++it) {
393  Ioss::SideSet *entity = *it;
394 
395  if (stk_classic::io::include_entity(entity)) {
396  process_surface_entity(entity, bulk);
397  }
398  }
399 }
400 
401 // ========================================================================
402 void put_field_data(stk_classic::mesh::BulkData &bulk, stk_classic::mesh::Part &part,
403  stk_classic::mesh::EntityRank part_type,
404  Ioss::GroupingEntity *io_entity,
405  Ioss::Field::RoleType filter_role,
406  const stk_classic::mesh::Selector *anded_selector=NULL)
407 {
408  std::vector<stk_classic::mesh::Entity*> entities;
409  if (io_entity->type() == Ioss::SIDEBLOCK) {
410  // Temporary Kluge to handle sideblocks which contain internally generated sides
411  // where the "ids" field on the io_entity doesn't work to get the correct side...
412  // NOTE: Could use this method for all entity types, but then need to correctly
413  // specify whether shared entities are included/excluded (See IossBridge version).
414  size_t num_sides = get_entities(part, bulk, entities, anded_selector);
415  if (num_sides != (size_t)io_entity->get_property("entity_count").get_int()) {
416  std::ostringstream msg ;
417  msg << " INTERNAL_ERROR: Number of sides on part " << part.name() << " (" << num_sides
418  << ") does not match number of sides in the associated Ioss SideBlock named "
419  << io_entity->name() << " (" << io_entity->get_property("entity_count").get_int()
420  << ").";
421  throw std::runtime_error( msg.str() );
422  }
423  } else {
424  stk_classic::io::get_entity_list(io_entity, part_type, bulk, entities);
425  }
426 
428  const std::vector<stk_classic::mesh::FieldBase*> &fields = fem_meta.get_fields();
429 
430  std::vector<stk_classic::mesh::FieldBase *>::const_iterator I = fields.begin();
431  while (I != fields.end()) {
432  const stk_classic::mesh::FieldBase *f = *I; ++I;
433  stk_classic::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role);
434  }
435 }
436 
437 void internal_process_output_request(stk_classic::io::MeshData &mesh_data,
439  int step,
440  const std::set<const stk_classic::mesh::Part*> &exclude)
441 {
442  Ioss::Region *region = mesh_data.m_output_region;
443  region->begin_state(step);
445 
446  // Special processing for nodeblock (all nodes in model)...
447  put_field_data(bulk, fem_meta.universal_part(), fem_meta.node_rank(),
448  region->get_node_blocks()[0], Ioss::Field::Field::TRANSIENT,
449  mesh_data.m_anded_selector);
450 
451  // Now handle all non-nodeblock parts...
452  const stk_classic::mesh::PartVector & all_parts = fem_meta.get_parts();
453  for ( stk_classic::mesh::PartVector::const_iterator
454  ip = all_parts.begin(); ip != all_parts.end(); ++ip ) {
455 
456  stk_classic::mesh::Part * const part = *ip;
457 
458  // Check whether this part should be output to results database.
459  if (stk_classic::io::is_part_io_part(*part) && !exclude.count(part)) {
460  // Get Ioss::GroupingEntity corresponding to this part...
461  Ioss::GroupingEntity *entity = region->get_entity(part->name());
462  if (entity != NULL && entity->type() != Ioss::SIDESET) {
463  put_field_data(bulk, *part, stk_classic::io::part_primary_entity_rank(*part),
464  entity, Ioss::Field::Field::TRANSIENT,
465  mesh_data.m_anded_selector);
466  }
467  }
468  }
469  region->end_state(step);
470 }
471 
472 namespace stk_classic {
473 namespace io {
474 
475 MeshData::~MeshData()
476 {
477  delete m_input_region;
478  delete m_output_region;
479 }
480 
482 {
483  std::cerr << "Options are:\n"
484  << "\n"
485  << "filename -- specify the name of the file from which to read the\n"
486  << " mesh file. If the --directory option is specified, it will be\n"
487  << " prepended to the filename unless the filename specifies an absolute path.\n"
488  << "\n"
489  << "gen:NxMxL -- internally generate a hex mesh of size N by M by L\n"
490  << " intervals. See 'Generated Options' below for more options.\n"
491  << "\n"
492  << "Generated Options:\n"
493  << "shell:xXyYzZ\n"
494  << "The argument specifies whether there is a shell block\n"
495  << "at the location. 'x' is minX, 'X' is maxX, etc.\n"
496  << "\n"
497  << "help -- no argument, shows valid options\n"
498  << "\n"
499  << "show -- no argument, prints out a summary of the settings used to\n"
500  << "generate the mesh. The output will look similar to:\n"
501  << " \"10x12x8|shell:xX|bbox:-10,-10,-10,10,10,10|show\"\n"
502  << "\n"
503  << " Mesh Parameters:\n"
504  << "\tIntervals: 10 by 12 by 8\n"
505  << "\tX = 2 * (0..10) + -10 Range: -10 <= X <= 10\n"
506  << "\tY = 1.66667 * (0..12) + -10 Range: -10 <= Y <= 10\n"
507  << "\tZ = 2.5 * (0..8) + -10 Range: -10 <= Z <= 10\n"
508  << "\tNode Count (total) = 1287\n"
509  << "\tElement Count (total) = 1152\n"
510  << "\tBlock Count = 3\n"
511  << "\n"
512  << "shell:xXyYzZ \n"
513  << "which specifies whether there is a shell block at that\n"
514  << "location. 'x' is minimum x face, 'X' is maximum x face,\n"
515  << "similarly for y and z. Note that the argument string is a\n"
516  << "single multicharacter string. You can add multiple shell blocks\n"
517  << "to a face, for example, shell:xxx would add three layered shell\n"
518  << "blocks on the minimum x face. An error is output if a non\n"
519  << "xXyYzZ character is found, but execution continues.\n"
520  << "\n"
521  << "zdecomp:n0 n1,n2,...,n#proc-1\n"
522  << "which are the number of intervals in the z direction for each\n"
523  << "processor in a pallel run. If this option is specified, then\n"
524  << "the total number of intervals in the z direction is the sum of\n"
525  << "the n0, n1, ... An interval count must be specified for each\n"
526  << "processor. If this option is not specified, then the number of\n"
527  << "intervals on each processor in the z direction is numZ/numProc\n"
528  << "with the extras added to the lower numbered processors.\n"
529  << "\n"
530  << "scale:xs,ys,zs\n"
531  << "which are the scale factors in the x, y, and z directions. All\n"
532  << "three must be specified if this option is present.\n"
533  << "\n"
534  << "- offset -- argument = xoff, yoff, zoff which are the offsets in the\n"
535  << "x, y, and z directions. All three must be specified if this option\n"
536  << "is present.\n"
537  << "\n"
538  << "- bbox -- argument = xmin, ymin, zmin, xmax, ymax, zmax\n"
539  << "which specify the lower left and upper right corners of\n"
540  << "the bounding box for the generated mesh. This will\n"
541  << "calculate the scale and offset which will fit the mesh in\n"
542  << "the specified box. All calculations are based on the currently\n"
543  << "active interval settings. If scale or offset or zdecomp\n"
544  << "specified later in the option list, you may not get the\n"
545  << "desired bounding box.\n"
546  << "\n"
547  << "- rotate -- argument = axis,angle,axis,angle,...\n"
548  << "where axis is 'x', 'y', or 'z' and angle is the rotation angle in\n"
549  << "degrees. Multiple rotations are cumulative. The composite rotation\n"
550  << "matrix is applied at the time the coordinates are retrieved after\n"
551  << "scaling and offset are applied.\n"
552  << "\n"
553  << "The unrotated coordinate of a node at grid location i,j,k is:\n"
554  << "\n"
555  << "\tx = x_scale * i + x_off,\n"
556  << "\ty = z_scale * j + y_off,\n"
557  << "\tz = z_scale * k + z_off,\n"
558  << "\n"
559  << "The extent of the unrotated mesh will be:\n"
560  << "\n"
561  << "\tx_off <= x <= x_scale * numX + x_off\n"
562  << "\ty_off <= y <= y_scale * numY + y_off\n"
563  << "\tz_off <= z <= z_scale * numZ + z_off\n"
564  << "\n"
565  << "If an unrecognized option is specified, an error message will be\n"
566  << "output and execution will continue.\n"
567  << "\n"
568  << "An example of valid input is:\n"
569  << "\n"
570  << "\t\"10x20x40|scale:1,0.5,0.25|offset:-5,-5,-5|shell:xX\"\n"
571  << "\n"
572  << "\n"
573  << "This would create a mesh with 10 intervals in x, 20 in y, 40 in z\n"
574  << "The mesh would be centered on 0,0,0 with a range of 10 in each\n"
575  << "direction. There would be a shell layer on the min and max\n"
576  << "x faces.\n"
577  << "\n"
578  << "NOTE: All options are processed in the order they appear in\n"
579  << "the parameters string (except rotate which is applied at the\n"
580  << "time the coordinates are generated/retrieved)\n"
581  << "\n";
582 }
583 
584 void create_input_mesh(const std::string &mesh_type,
585  const std::string &mesh_filename,
588  stk_classic::io::MeshData &mesh_data,
589  bool lower_case_variable_names)
590 {
591  Ioss::Region *in_region = mesh_data.m_input_region;
592  if (in_region == NULL) {
593  // If in_region is NULL, then open the file;
594  // If in_region is non-NULL, then user has given us a valid Ioss::Region that
595  // should be used.
596  Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename,
597  Ioss::READ_MODEL, comm,
598  mesh_data.m_property_manager);
599 
600  // set up the casing for variable names
601  dbi->set_lower_case_variable_names(lower_case_variable_names);
602 
603  if (dbi == NULL || !dbi->ok()) {
604  std::cerr << "ERROR: Could not open database '" << mesh_filename
605  << "' of type '" << mesh_type << "'\n";
606  Ioss::NameList db_types;
607  Ioss::IOFactory::describe(&db_types);
608  std::cerr << "\nSupported database types:\n\t";
609  for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) {
610  std::cerr << *IF << " ";
611  }
612  std::cerr << "\n\n";
613  }
614 
615  // NOTE: 'in_region' owns 'dbi' pointer at this time...
616  in_region = new Ioss::Region(dbi, "input_model");
617  mesh_data.m_input_region = in_region;
618  }
619 
620  size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int();
621  initialize_spatial_dimension(fem_meta, spatial_dimension, stk_classic::mesh::fem::entity_rank_names(spatial_dimension));
622 
623  process_elementblocks(*in_region, fem_meta);
624  process_nodeblocks(*in_region, fem_meta);
625  process_sidesets(*in_region, fem_meta);
626  process_nodesets(*in_region, fem_meta);
627 }
628 
629 void create_input_mesh(const std::string &mesh_type,
630  const std::string &mesh_filename,
633  stk_classic::io::MeshData &mesh_data,
634  const std::vector<std::string>& names_to_add,
635  bool lower_case_variable_names)
636 {
637  Ioss::Region *in_region = mesh_data.m_input_region;
638  if (in_region == NULL) {
639  // If in_region is NULL, then open the file;
640  // If in_region is non-NULL, then user has given us a valid Ioss::Region that
641  // should be used.
642  Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename,
643  Ioss::READ_MODEL, comm,
644  mesh_data.m_property_manager);
645 
646  // set up the casing for variable names
647  dbi->set_lower_case_variable_names(lower_case_variable_names);
648 
649  if (dbi == NULL || !dbi->ok()) {
650  std::cerr << "ERROR: Could not open database '" << mesh_filename
651  << "' of type '" << mesh_type << "'\n";
652  Ioss::NameList db_types;
653  Ioss::IOFactory::describe(&db_types);
654  std::cerr << "\nSupported database types:\n\t";
655  for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) {
656  std::cerr << *IF << " ";
657  }
658  std::cerr << "\n\n";
659  }
660 
661  // NOTE: 'in_region' owns 'dbi' pointer at this time...
662  in_region = new Ioss::Region(dbi, "input_model");
663  mesh_data.m_input_region = in_region;
664  }
665 
666  size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int();
667 
668  std::vector<std::string> entity_rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension);
669 
670  for(std::size_t i = 0; i < names_to_add.size(); i++)
671  entity_rank_names.push_back(names_to_add[i]);
672 
673  initialize_spatial_dimension(fem_meta, spatial_dimension, entity_rank_names);
674 
675  process_elementblocks(*in_region, fem_meta);
676  process_nodeblocks(*in_region, fem_meta);
677  process_sidesets(*in_region, fem_meta);
678  process_nodesets(*in_region, fem_meta);
679 }
680 
681 
682 void create_output_mesh(const std::string &filename,
684  stk_classic::mesh::BulkData &bulk_data,
685  MeshData &mesh_data,
686  bool lower_case_variable_names)
687 {
688  Ioss::Region *out_region = NULL;
689 
690  std::string out_filename = filename;
691  if (filename.empty()) {
692  out_filename = "default_output_mesh";
693  } else {
694  // These filenames may be coming from the generated options which
695  // may have forms similar to: "2x2x1|size:.05|height:-0.1,1"
696  // Strip the name at the first "+:|," character:
697  std::vector<std::string> tokens;
698  stk_classic::util::tokenize(out_filename, "+|:,", tokens);
699  out_filename = tokens[0];
700  }
701 
702  Ioss::DatabaseIO *dbo = Ioss::IOFactory::create("exodusII", out_filename,
703  Ioss::WRITE_RESULTS,
704  comm, mesh_data.m_property_manager);
705  // set up the casing for variable names
706  dbo->set_lower_case_variable_names(lower_case_variable_names);
707 
708  if (dbo == NULL || !dbo->ok()) {
709  std::cerr << "ERROR: Could not open results database '" << out_filename
710  << "' of type 'exodusII'\n";
711  std::exit(EXIT_FAILURE);
712  }
713 
714  // NOTE: 'out_region' owns 'dbo' pointer at this time...
715  out_region = new Ioss::Region(dbo, "results_output");
716 
717  stk_classic::io::define_output_db(*out_region, bulk_data, mesh_data.m_input_region, mesh_data.m_anded_selector);
718  stk_classic::io::write_output_db(*out_region, bulk_data, mesh_data.m_anded_selector);
719  mesh_data.m_output_region = out_region;
720 }
721 
722 // ========================================================================
723 int process_output_request(MeshData &mesh_data,
725  double time,
726  const std::set<const stk_classic::mesh::Part*> &exclude)
727 {
728  Ioss::Region *region = mesh_data.m_output_region;
729  region->begin_mode(Ioss::STATE_TRANSIENT);
730 
731  int out_step = region->add_state(time);
732  internal_process_output_request(mesh_data, bulk, out_step,exclude);
733 
734  region->end_mode(Ioss::STATE_TRANSIENT);
735 
736  return out_step;
737 }
738 
739 // ========================================================================
741  MeshData &mesh_data)
742 {
743  Ioss::Region *region = mesh_data.m_input_region;
744 
745  if (region) {
746 
747  bulk_data.modification_begin();
748  process_mesh_bulk_data(region, bulk_data);
749  bulk_data.modification_end();
750 
751  } else {
752  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in populate_bulk_data.\n";
753  std::exit(EXIT_FAILURE);
754  }
755 }
756 
757 // ========================================================================
758 void process_mesh_bulk_data(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data)
759 {
760  bool ints64bit = db_api_int_size(region) == 8;
761  if (ints64bit) {
762  int64_t zero = 0;
763  process_elementblocks(*region, bulk_data, zero);
764  process_nodeblocks(*region, bulk_data);
765  process_nodesets(*region, bulk_data, zero);
766  process_sidesets(*region, bulk_data);
767  } else {
768  int zero = 0;
769  process_elementblocks(*region, bulk_data, zero);
770  process_nodeblocks(*region, bulk_data);
771  process_nodesets(*region, bulk_data, zero);
772  process_sidesets(*region, bulk_data);
773  }
774 }
775 
776 namespace {
777 // ========================================================================
778 // Transfer transient field data from mesh file for io_entity to
779 // the corresponding stk_mesh entities If there is a stk_mesh
780 // field with the same name as the database field.
781 // Assumes that mesh is positioned at the correct state for reading.
782 void internal_process_input_request(Ioss::GroupingEntity *io_entity,
783  stk_classic::mesh::EntityRank entity_rank,
785 {
786  assert(io_entity != NULL);
787  std::vector<stk_classic::mesh::Entity*> entity_list;
788  stk_classic::io::get_entity_list(io_entity, entity_rank, bulk, entity_list);
789 
791 
792  Ioss::NameList names;
793  io_entity->field_describe(Ioss::Field::TRANSIENT, &names);
794  for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
796  if (field) {
797  stk_classic::io::field_data_from_ioss(field, entity_list, io_entity, *I);
798  }
799  }
800 }
801 
802 void input_nodeblock_fields(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
803 {
805  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
806  assert(node_blocks.size() == 1);
807 
808  Ioss::NodeBlock *nb = node_blocks[0];
809  internal_process_input_request(nb, fem_meta.node_rank(), bulk);
810 }
811 
812 void input_elementblock_fields(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
813 {
815  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
816  for(size_t i=0; i < elem_blocks.size(); i++) {
817  if (stk_classic::io::include_entity(elem_blocks[i])) {
818  internal_process_input_request(elem_blocks[i], fem_meta.element_rank(), bulk);
819  }
820  }
821 }
822 
823 void input_nodeset_fields(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
824 {
826  const Ioss::NodeSetContainer& nodesets = region.get_nodesets();
827  for(size_t i=0; i < nodesets.size(); i++) {
828  if (stk_classic::io::include_entity(nodesets[i])) {
829  internal_process_input_request(nodesets[i], fem_meta.node_rank(), bulk);
830  }
831  }
832 }
833 
834 void input_sideset_fields(Ioss::Region &region, stk_classic::mesh::BulkData &bulk)
835 {
837  if (fem_meta.spatial_dimension() <= fem_meta.side_rank())
838  return;
839 
840  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
841  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
842  it != side_sets.end(); ++it) {
843  Ioss::SideSet *entity = *it;
844  if (stk_classic::io::include_entity(entity)) {
845  const Ioss::SideBlockContainer& blocks = entity->get_side_blocks();
846  for(size_t i=0; i < blocks.size(); i++) {
847  if (stk_classic::io::include_entity(blocks[i])) {
848  internal_process_input_request(blocks[i], fem_meta.side_rank(), bulk);
849  }
850  }
851  }
852  }
853 }
854 
855 void define_input_nodeblock_fields(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
856 {
857  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
858  assert(node_blocks.size() == 1);
859 
860  Ioss::NodeBlock *nb = node_blocks[0];
861  stk_classic::io::define_io_fields(nb, Ioss::Field::TRANSIENT,
862  fem_meta.universal_part(), fem_meta.node_rank());
863 }
864 
865 void define_input_elementblock_fields(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
866 {
867  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
868  for(size_t i=0; i < elem_blocks.size(); i++) {
869  if (stk_classic::io::include_entity(elem_blocks[i])) {
870  stk_classic::mesh::Part* const part = fem_meta.get_part(elem_blocks[i]->name());
871  assert(part != NULL);
872  stk_classic::io::define_io_fields(elem_blocks[i], Ioss::Field::TRANSIENT,
873  *part, part_primary_entity_rank(*part));
874  }
875  }
876 }
877 
878 void define_input_nodeset_fields(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
879 {
880  const Ioss::NodeSetContainer& nodesets = region.get_nodesets();
881  for(size_t i=0; i < nodesets.size(); i++) {
882  if (stk_classic::io::include_entity(nodesets[i])) {
883  stk_classic::mesh::Part* const part = fem_meta.get_part(nodesets[i]->name());
884  assert(part != NULL);
885  stk_classic::io::define_io_fields(nodesets[i], Ioss::Field::TRANSIENT,
886  *part, part_primary_entity_rank(*part));
887  }
888  }
889 }
890 
891 void define_input_sideset_fields(Ioss::Region &region, stk_classic::mesh::fem::FEMMetaData &fem_meta)
892 {
893  if (fem_meta.spatial_dimension() <= fem_meta.side_rank())
894  return;
895 
896  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
897  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
898  it != side_sets.end(); ++it) {
899  Ioss::SideSet *entity = *it;
900  if (stk_classic::io::include_entity(entity)) {
901  const Ioss::SideBlockContainer& blocks = entity->get_side_blocks();
902  for(size_t i=0; i < blocks.size(); i++) {
903  if (stk_classic::io::include_entity(blocks[i])) {
904  stk_classic::mesh::Part* const part = fem_meta.get_part(blocks[i]->name());
905  assert(part != NULL);
906  stk_classic::io::define_io_fields(blocks[i], Ioss::Field::TRANSIENT,
907  *part, part_primary_entity_rank(*part));
908  }
909  }
910  }
911  }
912 }
913 
914 }
915 
916 // ========================================================================
917 // Iterate over all Ioss entities in the input mesh database and
918 // define a stk_field for all transient fields found. The stk
919 // field will have the same name as the field on the database.
920 //
921 // Note that all fields found on the database will have a
922 // corresponding stk field defined. If you want just a selected
923 // subset of the defined fields, you will need to define the
924 // fields manually.
925 //
926 // To populate the stk field with data from the database, call
927 // process_input_request().
928 void define_input_fields(MeshData &mesh_data, stk_classic::mesh::fem::FEMMetaData &fem_meta)
929 {
930  Ioss::Region *region = mesh_data.m_input_region;
931  if (region) {
932  define_input_nodeblock_fields(*region, fem_meta);
933  define_input_elementblock_fields(*region, fem_meta);
934  define_input_nodeset_fields(*region, fem_meta);
935  define_input_sideset_fields(*region, fem_meta);
936  } else {
937  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
938  std::exit(EXIT_FAILURE);
939  }
940 }
941 
942 // ========================================================================
943 // Iterate over all fields defined in the stk mesh data structure.
944 // If the field has the io_attribute set, then define that field
945 // on the corresponding io entity on the output mesh database.
946 // The database field will have the same name as the stk field.
947 //
948 // To export the data to the database, call
949 // process_output_request().
950 
951 void define_output_fields(const MeshData &mesh_data, const stk_classic::mesh::fem::FEMMetaData &fem_meta,
952  bool add_all_fields)
953 {
954  Ioss::Region *region = mesh_data.m_output_region;
955  if (region) {
956  region->begin_mode(Ioss::STATE_DEFINE_TRANSIENT);
957 
958  // Special processing for nodeblock (all nodes in model)...
960  region->get_node_blocks()[0],
961  Ioss::Field::TRANSIENT, add_all_fields);
962 
963  const stk_classic::mesh::PartVector & all_parts = fem_meta.get_parts();
964  for ( stk_classic::mesh::PartVector::const_iterator
965  ip = all_parts.begin(); ip != all_parts.end(); ++ip ) {
966 
967  stk_classic::mesh::Part * const part = *ip;
968 
969  // Check whether this part should be output to results database.
971  // Get Ioss::GroupingEntity corresponding to this part...
972  Ioss::GroupingEntity *entity = region->get_entity(part->name());
973  if (entity != NULL) {
974  stk_classic::io::ioss_add_fields(*part, part_primary_entity_rank(*part),
975  entity, Ioss::Field::TRANSIENT, add_all_fields);
976  }
977  }
978  }
979  region->end_mode(Ioss::STATE_DEFINE_TRANSIENT);
980  } else {
981  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
982  std::exit(EXIT_FAILURE);
983  }
984 }
985 // ========================================================================
986 void process_input_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, double time)
987 {
988  // Find the step on the database with time closest to the requested time...
989  Ioss::Region *region = mesh_data.m_input_region;
990  int step_count = region->get_property("state_count").get_int();
991  double delta_min = 1.0e30;
992  int step_min = 0;
993  for (int istep = 0; istep < step_count; istep++) {
994  double state_time = region->get_state_time(istep+1);
995  double delta = state_time - time;
996  if (delta < 0.0) delta = -delta;
997  if (delta < delta_min) {
998  delta_min = delta;
999  step_min = istep;
1000  if (delta == 0.0) break;
1001  }
1002  }
1003  // Exodus steps are 1-based;
1004  process_input_request(mesh_data, bulk, step_min+1);
1005 }
1006 
1007 void process_input_request(MeshData &mesh_data,
1009  int step)
1010 {
1011  if (step <= 0)
1012  return;
1013 
1014  Ioss::Region *region = mesh_data.m_input_region;
1015  if (region) {
1016  bulk.modification_begin();
1017 
1018  input_mesh_fields(region, bulk, step);
1019 
1020  bulk.modification_end();
1021 
1022  } else {
1023  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
1024  std::exit(EXIT_FAILURE);
1025  }
1026 }
1027 
1028 void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk,
1029  double time)
1030 {
1031  // Find the step on the database with time closest to the requested time...
1032  int step_count = region->get_property("state_count").get_int();
1033  double delta_min = 1.0e30;
1034  int step_min = 0;
1035  for (int istep = 0; istep < step_count; istep++) {
1036  double state_time = region->get_state_time(istep+1);
1037  double delta = state_time - time;
1038  if (delta < 0.0) delta = -delta;
1039  if (delta < delta_min) {
1040  delta_min = delta;
1041  step_min = istep;
1042  if (delta == 0.0) break;
1043  }
1044  }
1045  // Exodus steps are 1-based;
1046  input_mesh_fields(region, bulk, step_min+1);
1047 }
1048 
1049 void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk,
1050  int step)
1051 {
1052  // Pick which time index to read into solution field.
1053  region->begin_state(step);
1054 
1055  input_nodeblock_fields(*region, bulk);
1056  input_elementblock_fields(*region, bulk);
1057  input_nodeset_fields(*region, bulk);
1058  input_sideset_fields(*region, bulk);
1059 
1060  region->end_state(step);
1061 }
1062 
1063 // ========================================================================
1064 template <typename INT>
1065 void get_element_block_sizes(MeshData &mesh_data,
1066  std::vector<INT>& el_blocks)
1067 {
1068  Ioss::Region *io = mesh_data.m_input_region;
1069  const Ioss::ElementBlockContainer& elem_blocks = io->get_element_blocks();
1070  for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); it != elem_blocks.end(); ++it) {
1071  Ioss::ElementBlock *entity = *it;
1072  if (stk_classic::io::include_entity(entity)) {
1073  el_blocks.push_back(entity->get_property("entity_count").get_int());
1074  }
1075  }
1076 }
1077 template void get_element_block_sizes(MeshData &mesh_data, std::vector<int>& el_blocks);
1078 template void get_element_block_sizes(MeshData &mesh_data, std::vector<int64_t>& el_blocks);
1079 } // namespace io
1080 } // namespace stk_classic
stk_classic::mesh::FieldBase
Field base class with an anonymous data type and anonymous multi-dimension.
Definition: FieldBase.hpp:53
stk_classic::mesh::fem::declare_element_side
Entity & declare_element_side(Entity &elem, Entity &side, const unsigned local_side_id, Part *part)
Create (or find) an element side.
Definition: FEMHelpers.cpp:104
stk_classic::mesh::put_field
field_type & put_field(field_type &field, EntityRank entity_rank, const Part &part, const void *init_value=NULL)
Declare a field to exist for a given entity type and Part.
stk_classic::mesh::fem::FEMMetaData::spatial_dimension
size_t spatial_dimension() const
Returns the spatial dimension that was passed in through FEM_initialize.
Definition: FEMMetaData.hpp:118
stk_classic::mesh::fem::FEMMetaData::get
static FEMMetaData & get(const MetaData &meta)
Getter for FEMMetaData off of a MetaData object.
Definition: FEMMetaData.hpp:200
stk_classic::io::populate_bulk_data
void populate_bulk_data(stk_classic::mesh::BulkData &bulk_data, MeshData &mesh_data)
Definition: MeshReadWriteUtils.cpp:740
stk_classic::io::create_output_mesh
void create_output_mesh(const std::string &filename, stk_classic::ParallelMachine comm, stk_classic::mesh::BulkData &bulk_data, MeshData &mesh_data, bool lower_case_variable_names)
Definition: MeshReadWriteUtils.cpp:682
stk_classic::io::set_distribution_factor_field
void set_distribution_factor_field(stk_classic::mesh::Part &p, const stk_classic::mesh::Field< double, stk_classic::mesh::ElementNode > &df_field)
Definition: IossBridge.cpp:1706
stk_classic::mesh::MetaData::locally_owned_part
Part & locally_owned_part() const
Subset for the problem domain that is owned by the local process. Ghost entities are not members of t...
Definition: MetaData.hpp:93
stk_classic::io::include_entity
bool include_entity(const Ioss::GroupingEntity *entity)
Definition: IossBridge.cpp:1035
stk_classic::mesh::Field
Field with defined data type and multi-dimensions (if any)
Definition: Field.hpp:118
stk_classic::io::define_input_fields
void define_input_fields(MeshData &mesh_data, stk_classic::mesh::fem::FEMMetaData &fem_meta)
Definition: MeshReadWriteUtils.cpp:928
stk_classic::mesh::Part
An application-defined subset of a problem domain.
Definition: Part.hpp:49
stk_classic::mesh::fem::declare_element
Entity & declare_element(BulkData &mesh, Part &part, const EntityId elem_id, const EntityId node_id[])
Declare an element member of a Part with a CellTopology and nodes conformal to that topology.
Definition: FEMHelpers.cpp:72
stk_classic::io::field_data_from_ioss
void field_data_from_ioss(const stk_classic::mesh::FieldBase *field, std::vector< stk_classic::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name)
Definition: IossBridge.cpp:964
stk_classic::io::process_output_request
int process_output_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, double time, const std::set< const stk_classic::mesh::Part * > &exclude)
Definition: MeshReadWriteUtils.cpp:723
stk_classic::mesh::BulkData::declare_entity
Entity & declare_entity(EntityRank ent_rank, EntityId ent_id, const PartVector &parts)
Create or retrieve a locally owned entity of a given rank and id.
Definition: BulkData.cpp:215
stk_classic::io::write_output_db
void write_output_db(Ioss::Region &io_region, const stk_classic::mesh::BulkData &bulk, const stk_classic::mesh::Selector *anded_selector)
Definition: IossBridge.cpp:1643
stk_classic::mesh::BulkData::change_entity_parts
void change_entity_parts(Entity &entity, const PartVector &add_parts, const PartVector &remove_parts=PartVector())
Change the parallel-locally-owned entity's part membership by adding and/or removing parts.
Definition: BulkData.hpp:249
stk_classic::io::default_part_processing
void default_part_processing(const std::vector< T * > &entities, stk_classic::mesh::fem::FEMMetaData &fem_meta)
Definition: IossBridge.hpp:93
stk_classic::io::define_output_fields
void define_output_fields(const MeshData &mesh_data, const stk_classic::mesh::fem::FEMMetaData &fem_meta, bool add_all_fields)
Definition: MeshReadWriteUtils.cpp:951
stk_classic::ParallelMachine
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
stk_classic::mesh::fem::FEMMetaData::get_parts
const PartVector & get_parts() const
Query all parts of the mesh ordered by the parts' ordinal.
Definition: FEMMetaData.hpp:304
stk_classic::mesh::BulkData::get_entity
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
Definition: BulkData.hpp:211
stk_classic::mesh::BulkData::modification_end
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state.
Definition: BulkDataEndSync.cpp:729
stk_classic::io::field_data_to_ioss
void field_data_to_ioss(const stk_classic::mesh::FieldBase *field, std::vector< stk_classic::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name, Ioss::Field::RoleType filter_role)
Definition: IossBridge.cpp:999
stk_classic::io::create_input_mesh
void create_input_mesh(const std::string &mesh_type, const std::string &mesh_filename, stk_classic::ParallelMachine comm, stk_classic::mesh::fem::FEMMetaData &fem_meta, stk_classic::io::MeshData &mesh_data, bool lower_case_variable_names)
Definition: MeshReadWriteUtils.cpp:584
stk_classic::mesh::get_entities
void get_entities(const BulkData &mesh, EntityRank entity_rank, std::vector< Entity * > &entities)
Get all entities of the specified type, sorted by ID.
Definition: GetEntities.cpp:25
stk_classic::mesh::get_selected_entities
void get_selected_entities(const Selector &selector, const std::vector< Bucket * > &input_buckets, std::vector< Entity * > &entities)
Get entities in selected buckets (selected by the given selector instance), and sorted by ID.
Definition: GetEntities.cpp:77
stk_classic::io::is_part_io_part
bool is_part_io_part(stk_classic::mesh::Part &part)
Definition: IossBridge.cpp:1696
stk_classic
Sierra Toolkit.
Definition: AlgorithmRunner.cpp:16
stk_classic::io::get_distribution_factor_field
const stk_classic::mesh::Field< double, stk_classic::mesh::ElementNode > * get_distribution_factor_field(const stk_classic::mesh::Part &p)
Definition: IossBridge.cpp:1701
stk_classic::io::input_mesh_fields
void input_mesh_fields(Ioss::Region *region, stk_classic::mesh::BulkData &bulk, double time)
Definition: MeshReadWriteUtils.cpp:1028
stk_classic::io::show_mesh_help
void show_mesh_help()
Definition: MeshReadWriteUtils.cpp:481
stk_classic::mesh::BulkData::modification_begin
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent....
Definition: BulkData.cpp:172
stk_classic::mesh::MetaData
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
stk_classic::mesh::PartVector
std::vector< Part * > PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31
stk_classic::io::get_entity_list
void get_entity_list(Ioss::GroupingEntity *io_entity, stk_classic::mesh::EntityRank part_type, const stk_classic::mesh::BulkData &bulk, std::vector< stk_classic::mesh::Entity * > &entities)
Definition: IossBridge.cpp:952
stk_classic::io::set_field_role
void set_field_role(stk_classic::mesh::FieldBase &f, const Ioss::Field::RoleType &role)
Definition: IossBridge.cpp:1718
stk_classic::mesh::fem::FEMMetaData::get_fields
const FieldVector & get_fields() const
Get all defined fields.
Definition: FEMMetaData.hpp:415
stk_classic::mesh::Selector
This is a class for selecting buckets based on a set of meshparts and set logic.
Definition: Selector.hpp:112
stk_classic::mesh::entity_rank
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
Definition: base/EntityKey.hpp:161
stk_classic::io::define_io_fields
void define_io_fields(Ioss::GroupingEntity *entity, Ioss::Field::RoleType role, stk_classic::mesh::Part &part, stk_classic::mesh::EntityRank part_type)
Definition: IossBridge.cpp:905
stk_classic::io::process_input_request
void process_input_request(MeshData &mesh_data, stk_classic::mesh::BulkData &bulk, double time)
Definition: MeshReadWriteUtils.cpp:986
stk_classic::mesh::fem::FEMMetaData::declare_part_subset
void declare_part_subset(Part &superset, Part &subset)
Declare a superset-subset relationship between parts Note: Cell Topologies are induced through part s...
Definition: FEMMetaData.cpp:309
stk_classic::io::get_element_block_sizes
void get_element_block_sizes(MeshData &mesh_data, std::vector< INT > &el_blocks)
Definition: MeshReadWriteUtils.cpp:1065
stk_classic::mesh::fem::FEMMetaData::node_rank
EntityRank node_rank() const
Returns the node rank, which is always zero.
Definition: FEMMetaData.hpp:125
stk_classic::mesh::fem::FEMMetaData::declare_field
field_type & declare_field(const std::string &name, unsigned number_of_states=1)
Declare a field of the given field_type, test name, and number of states.
Definition: FEMMetaData.hpp:427
stk_classic::mesh::fem::FEMMetaData::get_field
field_type * get_field(const std::string &name) const
Get a field, return NULL if it does not exist.
Definition: FEMMetaData.hpp:411
stk_classic::mesh::Part::name
const std::string & name() const
Application-defined text name of this part.
Definition: Part.hpp:67
stk_classic::mesh::FieldBase::name
const std::string & name() const
Application-defined text name of this field.
Definition: FieldBase.hpp:66
stk_classic::mesh::fem::FEMMetaData::get_part
Part * get_part(const std::string &p_name, const char *required_by=NULL) const
Get an existing part by its application-defined text name.
Definition: FEMMetaData.hpp:295
stk_classic::io::ioss_add_fields
void ioss_add_fields(const stk_classic::mesh::Part &part, const stk_classic::mesh::EntityRank part_type, Ioss::GroupingEntity *entity, const Ioss::Field::RoleType filter_role, const bool add_all)
Definition: IossBridge.cpp:868
stk_classic::io::define_output_db
void define_output_db(Ioss::Region &io_region, const mesh::BulkData &bulk_data, const Ioss::Region *input_region, const stk_classic::mesh::Selector *anded_selector, const bool sort_stk_parts)
Definition: IossBridge.cpp:1276
stk_classic::mesh::fem::FEMMetaData::element_rank
EntityRank element_rank() const
Returns the element rank which is always equal to spatial dimension.
Definition: FEMMetaData.hpp:160
stk_classic::mesh::fem::FEMMetaData
FEMMetaData is a class that implements a Finite Element Method skin on top of the Sierra Tool Kit Met...
Definition: FEMMetaData.hpp:54
stk_classic::mesh::Entity
A fundamental unit within the discretization of a problem domain, including but not limited to nodes,...
Definition: Entity.hpp:120
stk_classic::mesh::fem::FEMMetaData::universal_part
Part & universal_part() const
Universal subset for the problem domain. All other parts are a subset of the universal part.
Definition: FEMMetaData.hpp:272
stk_classic::mesh::BulkData
Manager for an integrated collection of entities, entity relations, and buckets of field data.
Definition: BulkData.hpp:49
stk_classic::mesh::BulkData::buckets
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
Definition: BulkData.hpp:195
stk_classic::io::process_mesh_bulk_data
void process_mesh_bulk_data(Ioss::Region *region, stk_classic::mesh::BulkData &bulk_data)
Definition: MeshReadWriteUtils.cpp:758
stk_classic::mesh::fem::FEMMetaData::side_rank
EntityRank side_rank() const
Returns the side rank which changes depending on spatial dimension.
Definition: FEMMetaData.hpp:153