コード例 #1
0
ファイル: Iotr_Scale3D.C プロジェクト: 00liujj/trilinos
  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;
  }
コード例 #2
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;
}
コード例 #3
0
ファイル: Ioss_Map.C プロジェクト: crtrott/Trilinos
void Ioss::Map::map_implicit_data(void *data, const Ioss::Field &field, size_t count, size_t offset) const
{
  if (field.get_type() == Ioss::Field::INTEGER) {
    map_implicit_data_internal(static_cast<int*>(data), count, map, offset);
  } else {
    map_implicit_data_internal(static_cast<int64_t*>(data), count, map, offset);
  }
}
コード例 #4
0
ファイル: Ioss_Map.C プロジェクト: crtrott/Trilinos
void Ioss::Map::map_data(void *data, const Ioss::Field &field, size_t count) const
{
  if (!is_sequential(map)) {
    if (field.get_type() == Ioss::Field::INTEGER) {
      int *datum = static_cast<int*>(data);
      for (size_t i=0; i < count; i++)
	datum[i] = map[datum[i]];
    } else {
      int64_t *datum = static_cast<int64_t*>(data);
      for (size_t i=0; i < count; i++)
	datum[i] = map[datum[i]];
    }
  }
}
コード例 #5
0
ファイル: Ioss_Map.C プロジェクト: crtrott/Trilinos
void Ioss::Map::reverse_map_data(void *data, const Ioss::Field &field, size_t count) const
{
  assert(!map.empty());
  if (!is_sequential(map)) {
    if (field.get_type() == Ioss::Field::INTEGER) {
      int* connect = static_cast<int*>(data);
      for (size_t i=0; i < count; i++) {
	int global_id = connect[i];
	connect[i] = global_to_local(global_id, true);
      }
    } else {
      int64_t* connect = static_cast<int64_t*>(data);
      for (size_t i=0; i < count; i++) {
	int64_t global_id = connect[i];
	connect[i] = global_to_local(global_id, true);
      }
    }
  }
}
コード例 #6
0
ファイル: Iotr_Tensor.C プロジェクト: crtrott/Trilinos
  bool Tensor::internal_execute(const Ioss::Field &field, void *data)
  {
    assert(field.get_type() == Ioss::Field::REAL);
    double *r = static_cast<double*>(data);

    int count = field.raw_count();
    int components = field.raw_storage()->component_count();

    bool success = false;
    switch (type_) {
    case TRACE:
    case INVARIANT1:
      {
	int j = 0;
	for (int i=0; i < count*components; i+=components) {
	  r[j++] = r[i] + r[i+1] + r[i+2];
	}
      }
      success = true;
      break;
    case INVARIANT2:
      {
	int j = 0;
	for (int i=0; i < count*components; i+=components) {
	  r[j++] = r[i+3]*r[i+3] + r[i+4]*r[i+4] + r[i+5]*r[i+5] -
	    (r[i+0]*r[i+1] + r[i+1]*r[i+2] + r[i+0]*r[i+2]);
	}
      }
      success = true;
      break;
    case INVARIANT3:
    case MAGNITUDE:
    case DEVIATOR:
    case SPHERICAL:
    case INVARIANTS:
      success = false;
      break;
    default:
      success = false;
    }

    return success;
  }
コード例 #7
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;
  }