Example #1
0
int64_t Ioex::SuperElement::internal_get_field_data(const Ioss::Field& field,
				      void *data, size_t data_size) const
{
  size_t num_to_get = field.verify(data_size);
  assert(num_to_get == numDOF * numDOF);
  
  if (field.get_name() == "Kr") {
    int status = nc_get_array(filePtr, "Kr", (double*)data);
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load stiffness matrix field 'Kr' from file '"
	     << fileName << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "Mr") {
    int status = nc_get_array(filePtr, "Mr", (double*)data);
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load mass matrix field 'Mr' from file '"
	     << fileName << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else {
    std::cerr << "WARNING: " << type() << " '" << name()
	      << "'. Unknown input field '" << field.get_name() << "'";
    return -4;
  }
  return num_to_get;
}
Example #2
0
  int64_t DatabaseIO::put_field_internal(const Ioss::Region* region, const Ioss::Field& field,
				     void *data, size_t data_size) const
  {
    initialize(region);
    Ioss::Field::RoleType role = field.get_role();
    int64_t num_to_get = field.verify(data_size);

    if ((role == Ioss::Field::TRANSIENT || role == Ioss::Field::REDUCTION) &&
	num_to_get == 1) {

      int ncomp = field.transformed_storage()->component_count();

      if (legend_ != NULL && layout_ != NULL) {
	if (ncomp == 1) {
	  legend_->add_legend(field.get_name());
	}
	else {
	  const Ioss::VariableType *var_type = field.transformed_storage();
	  for (int i=0; i < ncomp; i++) {
	    std::string var_name = var_type->label_name(field.get_name(), i+1, '_');
	    legend_->add_legend(var_name);
	  }
	}
      }

      if (field.get_type() == Ioss::Field::STRING) {
	// Assume that if layout_ is NULL, then we want special one-line output.
	if (layout_ == NULL) {
	  Layout layout(false, 0, separator_, fieldWidth_);
	  layout.add_literal("-");
	  layout.add_literal(time_stamp(tsFormat));
	  layout.add_literal(" ");
	  layout.add_literal(*(std::string*)data);
	  if (logStream != NULL)
	    *logStream << layout << std::endl;
	} else {
	  layout_->add(field.get_name(), *(std::string*)data);
	}
      } else {
	if (layout_ == NULL) {
	  std::ostringstream errmsg;
	  errmsg << "INTERNAL ERROR: Unexpected NULL layout.\n";
	  IOSS_ERROR(errmsg);
	}
	if (field.get_type() == Ioss::Field::INTEGER) {
	  assert(field.transformed_count() == 1);

	  int *i_data = (int*)data;
	  std::vector<int> idata(ncomp);
	  for (int i=0; i < ncomp; i++) {
	    idata[i] = i_data[i];
	  }
	  layout_->add(field.get_name(), idata);
	} else {
	  std::vector<double> rdata(ncomp);
	  double *r_data = (double*)data;
	  for (int i=0; i < ncomp; i++) {
	    rdata[i] = r_data[i];
	  }
	  layout_->add(field.get_name(), rdata);
	}
      }
    } else {
      std::ostringstream errmsg;
      errmsg << "ERROR: Can not handle non-TRANSIENT or non-REDUCTION fields on regions.\n";
      IOSS_ERROR(errmsg);
    }
    return num_to_get;
  }
Example #3
0
int64_t Ioex::SuperElement::internal_get_field_data(const Ioss::Field &field, void *data,
                                                    size_t data_size) const
{
  size_t num_to_get = field.verify(data_size);

  if (field.get_name() == "cbmap") {
    assert(num_to_get == 2 * num_nodes * num_dim);
    int status = nc_get_array(filePtr, "cbmap", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load coodintate data field 'cbmap' from file '" << fileName
             << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "node_num_map") {
    assert(num_to_get == num_nodes);
    int status = nc_get_array(filePtr, "node_num_map", reinterpret_cast<double *>(data));

    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load coodintate data field 'node_num_map' from file '" << fileName
             << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "coordx") {
    assert(num_to_get == num_nodes);
    int status = nc_get_array(filePtr, "coordx", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load coodintate data field 'coordx' from file '" << fileName
             << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "coordy") {
    assert(num_to_get == num_nodes);
    int status = nc_get_array(filePtr, "coordy", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load coodintate data field 'coordy' from file '" << fileName
             << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "coordz") {
    assert(num_to_get == num_nodes);
    int status = nc_get_array(filePtr, "coordz", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load coodintate data field 'coordz' from file '" << fileName
             << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "Kr") {
    assert(num_to_get == numDOF * numDOF);
    int status = nc_get_array(filePtr, "Kr", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load stiffness matrix field 'Kr' from file '" << fileName << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else if (field.get_name() == "Mr") {
    assert(num_to_get == numDOF * numDOF);
    int status = nc_get_array(filePtr, "Mr", reinterpret_cast<double *>(data));
    if (status != 0) {
      std::ostringstream errmsg;
      errmsg << "ERROR: Could not load mass matrix field 'Mr' from file '" << fileName << "'.";
      IOSS_ERROR(errmsg);
    }
  }
  else {
    std::cerr << "WARNING: " << type() << " '" << name() << "'. Unknown input field '"
              << field.get_name() << "'";
    return -4;
  }
  return num_to_get;
}