示例#1
0
bool Scale::internal_execute(const Ioss::Field &field, void *data)
{
    size_t count      = field.transformed_count();
    int    components = field.transformed_storage()->component_count();

    if (field.get_type() == Ioss::Field::REAL) {
        double *rdata = static_cast<double *>(data);

        for (size_t i = 0; i < count * components; i++) {
            rdata[i] *= realMultiplier;
        }
    }
    else if (field.get_type() == Ioss::Field::INTEGER) {
        int *idata = static_cast<int *>(data);

        for (size_t i = 0; i < count * components; i++) {
            idata[i] *= intMultiplier;
        }
    }
    else if (field.get_type() == Ioss::Field::INT64) {
        int64_t *idata = static_cast<int64_t *>(data);

        for (size_t i = 0; i < count * components; i++) {
            idata[i] *= intMultiplier;
        }
    }
    else {
    }
    return true;
}
示例#2
0
  bool Scale3D::internal_execute(const Ioss::Field &field, void *data)
  {
    size_t count = field.transformed_count();
    assert(field.transformed_storage()->component_count() == 3);
    
    if (field.get_type() == Ioss::Field::REAL) {
      double *rdata = static_cast<double*>(data);

      for (size_t i = 0; i < count*3; i+=3) {
	rdata[i+0] *= realScale[0];
	rdata[i+1] *= realScale[1];
	rdata[i+2] *= realScale[2];
      }
    } else if (field.get_type() == Ioss::Field::INTEGER) {
      int *idata = static_cast<int*>(data);

      for (size_t i = 0; i < count*3; i+=3) {
	idata[i+0] *= intScale[0];
	idata[i+1] *= intScale[1];
	idata[i+2] *= intScale[2];
      }
    } else {
    }
    return true;
  }
示例#3
0
  bool VectorMagnitude::internal_execute(const Ioss::Field &field, void *data)
  {
    double *rdata = static_cast<double *>(data);

    size_t count = field.transformed_count();
    if (field.transformed_storage()->component_count() == 3) {
      int j = 0;
      for (size_t i = 0; i < count; i++) {
        rdata[i] = std::sqrt(rdata[j] * rdata[j] + rdata[j + 1] * rdata[j + 1] +
                             rdata[j + 2] * rdata[j + 2]);
        j += 3;
      }
    }
    else {
      int j = 0;
      for (size_t i = 0; i < count; i++) {
        rdata[i] = std::sqrt(rdata[j] * rdata[j] + rdata[j + 1] * rdata[j + 1]);
        j += 2;
      }
    }
    return true;
  }
// ========================================================================
void process_nodeblocks(Ioss::Region &region, stk::mesh::MetaData &meta)
{
    const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks();
    assert(node_blocks.size() == 1);

    Ioss::NodeBlock *nb = node_blocks[0];

    assert(nb->field_exists("mesh_model_coordinates"));
    Ioss::Field coordinates = nb->get_field("mesh_model_coordinates");
    int spatial_dim = coordinates.transformed_storage()->component_count();

    stk::mesh::Field<double,stk::mesh::Cartesian> & coord_field =
        meta.declare_field<stk::mesh::Field<double,stk::mesh::Cartesian> >(stk::topology::NODE_RANK, "coordinates");

    stk::mesh::put_field( coord_field, meta.universal_part(),
                          spatial_dim);

    /** \todo IMPLEMENT truly handle fields... For this case we are
     * just defining a field for each transient field that is present
     * in the mesh...
     */
    stk::io::define_io_fields(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk::topology::NODE_RANK);
}
示例#5
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;
  }