Sierra Toolkit  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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::mesh::fem::FEMMetaData &fem_meta)
36 {
37  assert(sset->type() == Ioss::SIDESET);
38  const Ioss::SideBlockContainer& blocks = sset->get_side_blocks();
39  stk::io::default_part_processing(blocks, fem_meta);
40 
41  stk::mesh::Part* const ss_part = fem_meta.get_part(sset->name());
42  assert(ss_part != NULL);
43 
44  stk::mesh::Field<double, stk::mesh::ElementNode> *distribution_factors_field = NULL;
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);
50  if (stk::io::include_entity(sb)) {
51  stk::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::io::set_field_role(*distribution_factors_field, Ioss::Field::MESH);
61  stk::io::set_distribution_factor_field(*ss_part, *distribution_factors_field);
62  surface_df_defined = true;
63  }
64  stk::io::set_distribution_factor_field(*sb_part, *distribution_factors_field);
65  int side_node_count = sb->topology()->number_nodes();
66  stk::mesh::put_field(*distribution_factors_field,
67  stk::io::part_primary_entity_rank(*sb_part),
68  *sb_part, side_node_count);
69  }
70  }
71  }
72 }
73 
74  size_t get_entities(stk::mesh::Part &part,
75  const stk::mesh::BulkData &bulk,
76  std::vector<stk::mesh::Entity*> &entities,
77  const stk::mesh::Selector *anded_selector)
78  {
79  stk::mesh::MetaData & meta = stk::mesh::MetaData::get(part);
80  stk::mesh::EntityRank type = stk::io::part_primary_entity_rank(part);
81 
83  stk::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::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::io::include_entity(block)) {
103  std::vector<INT> side_ids ;
104  std::vector<INT> elem_side ;
105 
106  stk::mesh::Part * const sb_part = fem_meta.get_part(block->name());
107  stk::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::mesh::PartVector add_parts( 1 , sb_part );
114 
115  size_t side_count = side_ids.size();
116  std::vector<stk::mesh::Entity*> sides(side_count);
117  for(size_t is=0; is<side_count; ++is) {
118  stk::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::mesh uses 0-based.
126  int side_ordinal = elem_side[is*2+1] - 1;
127 
128  stk::mesh::Entity* side_ptr = NULL;
129  side_ptr = &stk::mesh::fem::declare_element_side(bulk, side_ids[is], *elem, side_ordinal);
130  stk::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::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::mesh::FieldBase *field = fem_meta.get_field<stk::mesh::FieldBase> (*I);
154  if (field)
155  stk::io::field_data_from_ioss(field, sides, block, *I);
156  }
157  }
158  }
159 }
160 
161 void process_surface_entity(const Ioss::SideSet* sset, stk::mesh::BulkData & bulk)
162 {
163  if (stk::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::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::mesh::put_field( coord_field, fem_meta.node_rank(), fem_meta.universal_part(), spatial_dim);
184  stk::io::define_io_fields(nb, Ioss::Field::ATTRIBUTE, fem_meta.universal_part(), 0);
185 }
186 
187 void process_nodeblocks(Ioss::Region &region, stk::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::mesh::Entity*> nodes;
202  stk::io::get_entity_list(nb, fem_meta.node_rank(), bulk, nodes);
203 
206 
207  stk::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;
217  stk::mesh::FieldBase *field = fem_meta.get_field<stk::mesh::FieldBase> (*I);
218  if (field)
219  stk::io::field_data_from_ioss(field, nodes, nb, *I);
220  }
221 }
222 
223 // ========================================================================
224 void process_elementblocks(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
225 {
226  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
227  stk::io::default_part_processing(elem_blocks, fem_meta);
228 }
229 
230 template <typename INT>
231 void process_elementblocks(Ioss::Region &region, stk::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::io::include_entity(entity)) {
241  const std::string &name = entity->name();
242  stk::mesh::Part* const part = fem_meta.get_part(name);
243  assert(part != NULL);
244 
245  const CellTopologyData* cell_topo = stk::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::mesh::EntityId> id_vec(nodes_per_elem);
262  std::vector<stk::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::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;
278  stk::mesh::FieldBase *field = fem_meta.get_field<stk::mesh::FieldBase> (*I);
279  if (field)
280  stk::io::field_data_from_ioss(field, elements, entity, *I);
281  }
282  }
283  }
284 }
285 
286 // ========================================================================
287 // ========================================================================
288 void process_nodesets(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
289 {
290  const Ioss::NodeSetContainer& node_sets = region.get_nodesets();
291  stk::io::default_part_processing(node_sets, fem_meta);
292 
293  stk::mesh::Field<double> & distribution_factors_field =
294  fem_meta.declare_field<stk::mesh::Field<double> >("distribution_factors");
295  stk::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::io::include_entity(entity)) {
307  stk::mesh::Part* const part = fem_meta.get_part(entity->name());
308  assert(part != NULL);
309  assert(entity->field_exists("distribution_factors"));
310 
311  stk::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::mesh::fem::FEMMetaData &fem_meta)
319 {
320  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
321  stk::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::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::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::io::include_entity(entity)) {
347  const std::string & name = entity->name();
348  stk::mesh::Part* const part = fem_meta.get_part(name);
349  assert(part != NULL);
350  stk::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::mesh::Entity*> nodes(node_count);
356  stk::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 
363  stk::mesh::Field<double> *df_field =
364  fem_meta.get_field<stk::mesh::Field<double> >("distribution_factors");
365 
366  if (df_field != NULL) {
367  stk::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;
378  stk::mesh::FieldBase *field = fem_meta.get_field<stk::mesh::FieldBase> (*I);
379  if (field)
380  stk::io::field_data_from_ioss(field, nodes, entity, *I);
381  }
382  }
383  }
384 }
385 
386 // ========================================================================
387 void process_sidesets(Ioss::Region &region, stk::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::io::include_entity(entity)) {
396  process_surface_entity(entity, bulk);
397  }
398  }
399 }
400 
401 // ========================================================================
402 void put_field_data(stk::mesh::BulkData &bulk, stk::mesh::Part &part,
403  stk::mesh::EntityRank part_type,
404  Ioss::GroupingEntity *io_entity,
405  Ioss::Field::RoleType filter_role,
406  const stk::mesh::Selector *anded_selector=NULL)
407 {
408  std::vector<stk::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::io::get_entity_list(io_entity, part_type, bulk, entities);
425  }
426 
428  const std::vector<stk::mesh::FieldBase*> &fields = fem_meta.get_fields();
429 
430  std::vector<stk::mesh::FieldBase *>::const_iterator I = fields.begin();
431  while (I != fields.end()) {
432  const stk::mesh::FieldBase *f = *I; ++I;
433  stk::io::field_data_to_ioss(f, entities, io_entity, f->name(), filter_role);
434  }
435 }
436 
437 void internal_process_output_request(stk::io::MeshData &mesh_data,
438  stk::mesh::BulkData &bulk,
439  int step,
440  const std::set<const stk::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::mesh::PartVector & all_parts = fem_meta.get_parts();
453  for ( stk::mesh::PartVector::const_iterator
454  ip = all_parts.begin(); ip != all_parts.end(); ++ip ) {
455 
456  stk::mesh::Part * const part = *ip;
457 
458  // Check whether this part should be output to results database.
459  if (stk::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::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 {
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,
587  stk::mesh::fem::FEMMetaData &fem_meta,
588  stk::io::MeshData &mesh_data)
589 {
590  Ioss::Region *in_region = mesh_data.m_input_region;
591  if (in_region == NULL) {
592  // If in_region is NULL, then open the file;
593  // If in_region is non-NULL, then user has given us a valid Ioss::Region that
594  // should be used.
595  Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename,
596  Ioss::READ_MODEL, comm,
597  mesh_data.m_property_manager);
598  if (dbi == NULL || !dbi->ok()) {
599  std::cerr << "ERROR: Could not open database '" << mesh_filename
600  << "' of type '" << mesh_type << "'\n";
601  Ioss::NameList db_types;
602  Ioss::IOFactory::describe(&db_types);
603  std::cerr << "\nSupported database types:\n\t";
604  for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) {
605  std::cerr << *IF << " ";
606  }
607  std::cerr << "\n\n";
608  }
609 
610  // NOTE: 'in_region' owns 'dbi' pointer at this time...
611  in_region = new Ioss::Region(dbi, "input_model");
612  mesh_data.m_input_region = in_region;
613  }
614 
615  size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int();
616  initialize_spatial_dimension(fem_meta, spatial_dimension, stk::mesh::fem::entity_rank_names(spatial_dimension));
617 
618  process_elementblocks(*in_region, fem_meta);
619  process_nodeblocks(*in_region, fem_meta);
620  process_sidesets(*in_region, fem_meta);
621  process_nodesets(*in_region, fem_meta);
622 }
623 
624 void create_input_mesh(const std::string &mesh_type,
625  const std::string &mesh_filename,
627  stk::mesh::fem::FEMMetaData &fem_meta,
628  stk::io::MeshData &mesh_data,
629  const std::vector<std::string>& names_to_add)
630 {
631  Ioss::Region *in_region = mesh_data.m_input_region;
632  if (in_region == NULL) {
633  // If in_region is NULL, then open the file;
634  // If in_region is non-NULL, then user has given us a valid Ioss::Region that
635  // should be used.
636  Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(mesh_type, mesh_filename,
637  Ioss::READ_MODEL, comm,
638  mesh_data.m_property_manager);
639  if (dbi == NULL || !dbi->ok()) {
640  std::cerr << "ERROR: Could not open database '" << mesh_filename
641  << "' of type '" << mesh_type << "'\n";
642  Ioss::NameList db_types;
643  Ioss::IOFactory::describe(&db_types);
644  std::cerr << "\nSupported database types:\n\t";
645  for (Ioss::NameList::const_iterator IF = db_types.begin(); IF != db_types.end(); ++IF) {
646  std::cerr << *IF << " ";
647  }
648  std::cerr << "\n\n";
649  }
650 
651  // NOTE: 'in_region' owns 'dbi' pointer at this time...
652  in_region = new Ioss::Region(dbi, "input_model");
653  mesh_data.m_input_region = in_region;
654  }
655 
656  size_t spatial_dimension = in_region->get_property("spatial_dimension").get_int();
657 
658  std::vector<std::string> entity_rank_names = stk::mesh::fem::entity_rank_names(spatial_dimension);
659 
660  for(std::size_t i = 0; i < names_to_add.size(); i++)
661  entity_rank_names.push_back(names_to_add[i]);
662 
663  initialize_spatial_dimension(fem_meta, spatial_dimension, entity_rank_names);
664 
665  process_elementblocks(*in_region, fem_meta);
666  process_nodeblocks(*in_region, fem_meta);
667  process_sidesets(*in_region, fem_meta);
668  process_nodesets(*in_region, fem_meta);
669 }
670 
671 
672 void create_output_mesh(const std::string &filename,
674  stk::mesh::BulkData &bulk_data,
675  MeshData &mesh_data)
676 {
677  Ioss::Region *out_region = NULL;
678 
679  std::string out_filename = filename;
680  if (filename.empty()) {
681  out_filename = "default_output_mesh";
682  } else {
683  // These filenames may be coming from the generated options which
684  // may have forms similar to: "2x2x1|size:.05|height:-0.1,1"
685  // Strip the name at the first "+:|," character:
686  std::vector<std::string> tokens;
687  stk::util::tokenize(out_filename, "+|:,", tokens);
688  out_filename = tokens[0];
689  }
690 
691  Ioss::DatabaseIO *dbo = Ioss::IOFactory::create("exodusII", out_filename,
692  Ioss::WRITE_RESULTS,
693  comm, mesh_data.m_property_manager);
694  if (dbo == NULL || !dbo->ok()) {
695  std::cerr << "ERROR: Could not open results database '" << out_filename
696  << "' of type 'exodusII'\n";
697  std::exit(EXIT_FAILURE);
698  }
699 
700  // NOTE: 'out_region' owns 'dbo' pointer at this time...
701  out_region = new Ioss::Region(dbo, "results_output");
702 
703  stk::io::define_output_db(*out_region, bulk_data, mesh_data.m_input_region, mesh_data.m_anded_selector);
704  stk::io::write_output_db(*out_region, bulk_data, mesh_data.m_anded_selector);
705  mesh_data.m_output_region = out_region;
706 }
707 
708 // ========================================================================
709 int process_output_request(MeshData &mesh_data,
710  stk::mesh::BulkData &bulk,
711  double time,
712  const std::set<const stk::mesh::Part*> &exclude)
713 {
714  Ioss::Region *region = mesh_data.m_output_region;
715  region->begin_mode(Ioss::STATE_TRANSIENT);
716 
717  int out_step = region->add_state(time);
718  internal_process_output_request(mesh_data, bulk, out_step,exclude);
719 
720  region->end_mode(Ioss::STATE_TRANSIENT);
721 
722  return out_step;
723 }
724 
725 // ========================================================================
727  MeshData &mesh_data)
728 {
729  Ioss::Region *region = mesh_data.m_input_region;
730 
731  if (region) {
732 
733  bulk_data.modification_begin();
734  process_mesh_bulk_data(region, bulk_data);
735  bulk_data.modification_end();
736 
737  } else {
738  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in populate_bulk_data.\n";
739  std::exit(EXIT_FAILURE);
740  }
741 }
742 
743 // ========================================================================
744 void process_mesh_bulk_data(Ioss::Region *region, stk::mesh::BulkData &bulk_data)
745 {
746  bool ints64bit = db_api_int_size(region) == 8;
747  if (ints64bit) {
748  int64_t zero = 0;
749  process_elementblocks(*region, bulk_data, zero);
750  process_nodeblocks(*region, bulk_data);
751  process_nodesets(*region, bulk_data, zero);
752  process_sidesets(*region, bulk_data);
753  } else {
754  int zero = 0;
755  process_elementblocks(*region, bulk_data, zero);
756  process_nodeblocks(*region, bulk_data);
757  process_nodesets(*region, bulk_data, zero);
758  process_sidesets(*region, bulk_data);
759  }
760 }
761 
762 namespace {
763 // ========================================================================
764 // Transfer transient field data from mesh file for io_entity to
765 // the corresponding stk_mesh entities If there is a stk_mesh
766 // field with the same name as the database field.
767 // Assumes that mesh is positioned at the correct state for reading.
768 void internal_process_input_request(Ioss::GroupingEntity *io_entity,
769  stk::mesh::EntityRank entity_rank,
770  stk::mesh::BulkData &bulk)
771 {
772  assert(io_entity != NULL);
773  std::vector<stk::mesh::Entity*> entity_list;
774  stk::io::get_entity_list(io_entity, entity_rank, bulk, entity_list);
775 
777 
778  Ioss::NameList names;
779  io_entity->field_describe(Ioss::Field::TRANSIENT, &names);
780  for (Ioss::NameList::const_iterator I = names.begin(); I != names.end(); ++I) {
781  stk::mesh::FieldBase *field = fem_meta.get_field<stk::mesh::FieldBase>(*I);
782  if (field) {
783  stk::io::field_data_from_ioss(field, entity_list, io_entity, *I);
784  }
785  }
786 }
787 
788 void input_nodeblock_fields(Ioss::Region &region, stk::mesh::BulkData &bulk)
789 {
791  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
792  assert(node_blocks.size() == 1);
793 
794  Ioss::NodeBlock *nb = node_blocks[0];
795  internal_process_input_request(nb, fem_meta.node_rank(), bulk);
796 }
797 
798 void input_elementblock_fields(Ioss::Region &region, stk::mesh::BulkData &bulk)
799 {
801  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
802  for(size_t i=0; i < elem_blocks.size(); i++) {
803  if (stk::io::include_entity(elem_blocks[i])) {
804  internal_process_input_request(elem_blocks[i], fem_meta.element_rank(), bulk);
805  }
806  }
807 }
808 
809 void input_nodeset_fields(Ioss::Region &region, stk::mesh::BulkData &bulk)
810 {
812  const Ioss::NodeSetContainer& nodesets = region.get_nodesets();
813  for(size_t i=0; i < nodesets.size(); i++) {
814  if (stk::io::include_entity(nodesets[i])) {
815  internal_process_input_request(nodesets[i], fem_meta.node_rank(), bulk);
816  }
817  }
818 }
819 
820 void input_sideset_fields(Ioss::Region &region, stk::mesh::BulkData &bulk)
821 {
823  if (fem_meta.spatial_dimension() <= fem_meta.side_rank())
824  return;
825 
826  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
827  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
828  it != side_sets.end(); ++it) {
829  Ioss::SideSet *entity = *it;
830  if (stk::io::include_entity(entity)) {
831  const Ioss::SideBlockContainer& blocks = entity->get_side_blocks();
832  for(size_t i=0; i < blocks.size(); i++) {
833  if (stk::io::include_entity(blocks[i])) {
834  internal_process_input_request(blocks[i], fem_meta.side_rank(), bulk);
835  }
836  }
837  }
838  }
839 }
840 
841 void define_input_nodeblock_fields(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
842 {
843  const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
844  assert(node_blocks.size() == 1);
845 
846  Ioss::NodeBlock *nb = node_blocks[0];
847  stk::io::define_io_fields(nb, Ioss::Field::TRANSIENT,
848  fem_meta.universal_part(), fem_meta.node_rank());
849 }
850 
851 void define_input_elementblock_fields(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
852 {
853  const Ioss::ElementBlockContainer& elem_blocks = region.get_element_blocks();
854  for(size_t i=0; i < elem_blocks.size(); i++) {
855  if (stk::io::include_entity(elem_blocks[i])) {
856  stk::mesh::Part* const part = fem_meta.get_part(elem_blocks[i]->name());
857  assert(part != NULL);
858  stk::io::define_io_fields(elem_blocks[i], Ioss::Field::TRANSIENT,
859  *part, part_primary_entity_rank(*part));
860  }
861  }
862 }
863 
864 void define_input_nodeset_fields(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
865 {
866  const Ioss::NodeSetContainer& nodesets = region.get_nodesets();
867  for(size_t i=0; i < nodesets.size(); i++) {
868  if (stk::io::include_entity(nodesets[i])) {
869  stk::mesh::Part* const part = fem_meta.get_part(nodesets[i]->name());
870  assert(part != NULL);
871  stk::io::define_io_fields(nodesets[i], Ioss::Field::TRANSIENT,
872  *part, part_primary_entity_rank(*part));
873  }
874  }
875 }
876 
877 void define_input_sideset_fields(Ioss::Region &region, stk::mesh::fem::FEMMetaData &fem_meta)
878 {
879  if (fem_meta.spatial_dimension() <= fem_meta.side_rank())
880  return;
881 
882  const Ioss::SideSetContainer& side_sets = region.get_sidesets();
883  for(Ioss::SideSetContainer::const_iterator it = side_sets.begin();
884  it != side_sets.end(); ++it) {
885  Ioss::SideSet *entity = *it;
886  if (stk::io::include_entity(entity)) {
887  const Ioss::SideBlockContainer& blocks = entity->get_side_blocks();
888  for(size_t i=0; i < blocks.size(); i++) {
889  if (stk::io::include_entity(blocks[i])) {
890  stk::mesh::Part* const part = fem_meta.get_part(blocks[i]->name());
891  assert(part != NULL);
892  stk::io::define_io_fields(blocks[i], Ioss::Field::TRANSIENT,
893  *part, part_primary_entity_rank(*part));
894  }
895  }
896  }
897  }
898 }
899 
900 }
901 
902 // ========================================================================
903 // Iterate over all Ioss entities in the input mesh database and
904 // define a stk_field for all transient fields found. The stk
905 // field will have the same name as the field on the database.
906 //
907 // Note that all fields found on the database will have a
908 // corresponding stk field defined. If you want just a selected
909 // subset of the defined fields, you will need to define the
910 // fields manually.
911 //
912 // To populate the stk field with data from the database, call
913 // process_input_request().
914 void define_input_fields(MeshData &mesh_data, stk::mesh::fem::FEMMetaData &fem_meta)
915 {
916  Ioss::Region *region = mesh_data.m_input_region;
917  if (region) {
918  define_input_nodeblock_fields(*region, fem_meta);
919  define_input_elementblock_fields(*region, fem_meta);
920  define_input_nodeset_fields(*region, fem_meta);
921  define_input_sideset_fields(*region, fem_meta);
922  } else {
923  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
924  std::exit(EXIT_FAILURE);
925  }
926 }
927 
928 // ========================================================================
929 // Iterate over all fields defined in the stk mesh data structure.
930 // If the field has the io_attribute set, then define that field
931 // on the corresponding io entity on the output mesh database.
932 // The database field will have the same name as the stk field.
933 //
934 // To export the data to the database, call
935 // process_output_request().
936 
937 void define_output_fields(const MeshData &mesh_data, const stk::mesh::fem::FEMMetaData &fem_meta,
938  bool add_all_fields)
939 {
940  Ioss::Region *region = mesh_data.m_output_region;
941  if (region) {
942  region->begin_mode(Ioss::STATE_DEFINE_TRANSIENT);
943 
944  // Special processing for nodeblock (all nodes in model)...
945  stk::io::ioss_add_fields(fem_meta.universal_part(), fem_meta.node_rank(),
946  region->get_node_blocks()[0],
947  Ioss::Field::TRANSIENT, add_all_fields);
948 
949  const stk::mesh::PartVector & all_parts = fem_meta.get_parts();
950  for ( stk::mesh::PartVector::const_iterator
951  ip = all_parts.begin(); ip != all_parts.end(); ++ip ) {
952 
953  stk::mesh::Part * const part = *ip;
954 
955  // Check whether this part should be output to results database.
956  if (stk::io::is_part_io_part(*part)) {
957  // Get Ioss::GroupingEntity corresponding to this part...
958  Ioss::GroupingEntity *entity = region->get_entity(part->name());
959  if (entity != NULL) {
960  stk::io::ioss_add_fields(*part, part_primary_entity_rank(*part),
961  entity, Ioss::Field::TRANSIENT, add_all_fields);
962  }
963  }
964  }
965  region->end_mode(Ioss::STATE_DEFINE_TRANSIENT);
966  } else {
967  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
968  std::exit(EXIT_FAILURE);
969  }
970 }
971 // ========================================================================
972 void process_input_request(MeshData &mesh_data, stk::mesh::BulkData &bulk, double time)
973 {
974  // Find the step on the database with time closest to the requested time...
975  Ioss::Region *region = mesh_data.m_input_region;
976  int step_count = region->get_property("state_count").get_int();
977  double delta_min = 1.0e30;
978  int step_min = 0;
979  for (int istep = 0; istep < step_count; istep++) {
980  double state_time = region->get_state_time(istep+1);
981  double delta = state_time - time;
982  if (delta < 0.0) delta = -delta;
983  if (delta < delta_min) {
984  delta_min = delta;
985  step_min = istep;
986  if (delta == 0.0) break;
987  }
988  }
989  // Exodus steps are 1-based;
990  process_input_request(mesh_data, bulk, step_min+1);
991 }
992 
993 void process_input_request(MeshData &mesh_data,
994  stk::mesh::BulkData &bulk,
995  int step)
996 {
997  if (step <= 0)
998  return;
999 
1000  Ioss::Region *region = mesh_data.m_input_region;
1001  if (region) {
1002  bulk.modification_begin();
1003 
1004  input_mesh_fields(region, bulk, step);
1005 
1006  bulk.modification_end();
1007 
1008  } else {
1009  std::cerr << "INTERNAL ERROR: Mesh Input Region pointer is NULL in process_input_request.\n";
1010  std::exit(EXIT_FAILURE);
1011  }
1012 }
1013 
1014 void input_mesh_fields(Ioss::Region *region, stk::mesh::BulkData &bulk,
1015  double time)
1016 {
1017  // Find the step on the database with time closest to the requested time...
1018  int step_count = region->get_property("state_count").get_int();
1019  double delta_min = 1.0e30;
1020  int step_min = 0;
1021  for (int istep = 0; istep < step_count; istep++) {
1022  double state_time = region->get_state_time(istep+1);
1023  double delta = state_time - time;
1024  if (delta < 0.0) delta = -delta;
1025  if (delta < delta_min) {
1026  delta_min = delta;
1027  step_min = istep;
1028  if (delta == 0.0) break;
1029  }
1030  }
1031  // Exodus steps are 1-based;
1032  input_mesh_fields(region, bulk, step_min+1);
1033 }
1034 
1035 void input_mesh_fields(Ioss::Region *region, stk::mesh::BulkData &bulk,
1036  int step)
1037 {
1038  // Pick which time index to read into solution field.
1039  region->begin_state(step);
1040 
1041  input_nodeblock_fields(*region, bulk);
1042  input_elementblock_fields(*region, bulk);
1043  input_nodeset_fields(*region, bulk);
1044  input_sideset_fields(*region, bulk);
1045 
1046  region->end_state(step);
1047 }
1048 
1049 // ========================================================================
1050 template <typename INT>
1051 void get_element_block_sizes(MeshData &mesh_data,
1052  std::vector<INT>& el_blocks)
1053 {
1054  Ioss::Region *io = mesh_data.m_input_region;
1055  const Ioss::ElementBlockContainer& elem_blocks = io->get_element_blocks();
1056  for(Ioss::ElementBlockContainer::const_iterator it = elem_blocks.begin(); it != elem_blocks.end(); ++it) {
1057  Ioss::ElementBlock *entity = *it;
1058  if (stk::io::include_entity(entity)) {
1059  el_blocks.push_back(entity->get_property("entity_count").get_int());
1060  }
1061  }
1062 }
1063 template void get_element_block_sizes(MeshData &mesh_data, std::vector<int>& el_blocks);
1064 template void get_element_block_sizes(MeshData &mesh_data, std::vector<int64_t>& el_blocks);
1065 } // namespace io
1066 } // namespace stk
bool is_part_io_part(stk::mesh::Part &part)
field_type * get_field(const std::string &name) const
Get a field, return NULL if it does not exist.
void change_entity_parts(Entity &entity, const PartVector &add_parts, const PartVector &remove_parts=PartVector())
Change the parallel-locally-owned entity&#39;s part membership by adding and/or removing parts...
Definition: BulkData.hpp:249
void field_data_to_ioss(const stk::mesh::FieldBase *field, std::vector< stk::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name, Ioss::Field::RoleType filter_role)
Definition: IossBridge.cpp:999
std::vector< Part * > PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Definition: Types.hpp:31
The manager of an integrated collection of parts and fields.
Definition: MetaData.hpp:56
This is a class for selecting buckets based on a set of meshparts and set logic.
Definition: Selector.hpp:112
void process_mesh_bulk_data(Ioss::Region *region, stk::mesh::BulkData &bulk_data)
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
size_t spatial_dimension() const
Returns the spatial dimension that was passed in through FEM_initialize.
const std::string & name() const
Application-defined text name of this field.
Definition: FieldBase.hpp:66
Field with defined data type and multi-dimensions (if any)
Definition: Field.hpp:118
const PartVector & get_parts() const
Query all parts of the mesh ordered by the parts&#39; ordinal.
void create_output_mesh(const std::string &filename, stk::ParallelMachine comm, stk::mesh::BulkData &bulk_data, MeshData &mesh_data)
void get_entity_list(Ioss::GroupingEntity *io_entity, stk::mesh::EntityRank part_type, const stk::mesh::BulkData &bulk, std::vector< stk::mesh::Entity * > &entities)
Definition: IossBridge.cpp:952
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
bool include_entity(const Ioss::GroupingEntity *entity)
void set_distribution_factor_field(stk::mesh::Part &p, const stk::mesh::Field< double, stk::mesh::ElementNode > &df_field)
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
void declare_part_subset(Part &superset, Part &subset)
Declare a superset-subset relationship between parts Note: Cell Topologies are induced through part s...
int process_output_request(MeshData &mesh_data, stk::mesh::BulkData &bulk, double time, const std::set< const stk::mesh::Part * > &exclude)
Entity * get_entity(EntityRank entity_rank, EntityId entity_id) const
Get entity with a given key.
Definition: BulkData.hpp:211
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
Definition: Entity.hpp:120
void set_field_role(stk::mesh::FieldBase &f, const Ioss::Field::RoleType &role)
void populate_bulk_data(stk::mesh::BulkData &bulk_data, MeshData &mesh_data)
static FEMMetaData & get(const MetaData &meta)
Getter for FEMMetaData off of a MetaData object.
void process_input_request(MeshData &mesh_data, stk::mesh::BulkData &bulk, double time)
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.
void input_mesh_fields(Ioss::Region *region, stk::mesh::BulkData &bulk, double time)
bool modification_end()
Parallel synchronization of modifications and transition to the guaranteed parallel consistent state...
const std::string & name() const
Application-defined text name of this part.
Definition: Part.hpp:67
void create_input_mesh(const std::string &mesh_type, const std::string &mesh_filename, stk::ParallelMachine comm, stk::mesh::fem::FEMMetaData &fem_meta, stk::io::MeshData &mesh_data)
Part & universal_part() const
Universal subset for the problem domain. All other parts are a subset of the universal part...
const stk::mesh::Field< double, stk::mesh::ElementNode > * get_distribution_factor_field(const stk::mesh::Part &p)
void get_element_block_sizes(MeshData &mesh_data, std::vector< INT > &el_blocks)
void define_output_db(Ioss::Region &io_region, const mesh::BulkData &bulk_data, const Ioss::Region *input_region, const stk::mesh::Selector *anded_selector, const bool sort_stk_parts)
Field base class with an anonymous data type and anonymous multi-dimension.
Definition: FieldBase.hpp:53
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
void define_output_fields(const MeshData &mesh_data, const stk::mesh::fem::FEMMetaData &fem_meta, bool add_all_fields)
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.
An application-defined subset of a problem domain.
Definition: Part.hpp:49
Manager for an integrated collection of entities, entity relations, and buckets of field data...
Definition: BulkData.hpp:49
const std::vector< Bucket * > & buckets(EntityRank rank) const
Query all buckets of a given entity rank.
Definition: BulkData.hpp:195
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
void define_input_fields(MeshData &mesh_data, stk::mesh::fem::FEMMetaData &fem_meta)
Part * get_part(const std::string &p_name, const char *required_by=NULL) const
Get an existing part by its application-defined text name.
void write_output_db(Ioss::Region &io_region, const stk::mesh::BulkData &bulk, const stk::mesh::Selector *anded_selector)
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
EntityRank side_rank() const
Returns the side rank which changes depending on spatial dimension.
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
void ioss_add_fields(const stk::mesh::Part &part, const stk::mesh::EntityRank part_type, Ioss::GroupingEntity *entity, const Ioss::Field::RoleType filter_role, const bool add_all)
Definition: IossBridge.cpp:868
FEMMetaData is a class that implements a Finite Element Method skin on top of the Sierra Tool Kit Met...
Definition: FEMMetaData.hpp:54
void field_data_from_ioss(const stk::mesh::FieldBase *field, std::vector< stk::mesh::Entity * > &entities, Ioss::GroupingEntity *io_entity, const std::string &io_fld_name)
Definition: IossBridge.cpp:964
void default_part_processing(const std::vector< T * > &entities, stk::mesh::fem::FEMMetaData &fem_meta)
Definition: IossBridge.hpp:93
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
void define_io_fields(Ioss::GroupingEntity *entity, Ioss::Field::RoleType role, stk::mesh::Part &part, stk::mesh::EntityRank part_type)
Definition: IossBridge.cpp:905
void show_mesh_help()
const FieldVector & get_fields() const
Get all defined fields.
EntityRank element_rank() const
Returns the element rank which is always equal to spatial dimension.
bool modification_begin()
Begin a modification phase during which the mesh bulk data could become parallel inconsistent. This is a parallel synchronous call. The first time this method is called the mesh meta data is verified to be committed and parallel consistent. An exception is thrown if this verification fails.
Definition: BulkData.cpp:172
EntityRank node_rank() const
Returns the node rank, which is always zero.