Exemplo n.º 1
0
USHORT FAR prntf (NPSZ buf, NPSZ fmt, PUCHAR arg_ptr)
{
  NPCH	sptr;

  LONG	lval;
  ULONG uval;

  fs.buf    = buf;
  fs.off    = 0;
  fs.fmtptr = fmt;

  while (process_format (&fs) != TYPE_END) {
    switch (fs.type) {
      case TYPE_STRING:
	sptr = va_arg (arg_ptr, NPCH);
	put_field (&fs, sptr);
	break;

      case TYPE_CHAR:
	*(short far *)(fs.buf+fs.off) = va_arg (arg_ptr, USHORT);
	fs.off++;
	break;

      case TYPE_PCT:
	*(short far *)(fs.buf+fs.off) = '%';
	fs.off++;
	break;

      case TYPE_DECIMAL:
	lval = (fs.flags & FS_LONG) ? va_arg (arg_ptr, LONG)
				    : va_arg (arg_ptr, INT );
	cvtld (sbuf, lval);

	put_field (&fs, sbuf);
	break;

      case TYPE_UNSIGNED:
      case TYPE_HEX:
	uval = (fs.flags & FS_LONG) ? va_arg (arg_ptr, ULONG)
				    : va_arg (arg_ptr, USHORT );
	if (fs.type == TYPE_HEX)
	  cvtlx (sbuf, uval);
	else
	  cvtlu (sbuf, uval);

	put_field (&fs, sbuf);
	break;

      case TYPE_INVALID:
	_strncpy (fs.buf+fs.off, fs.fmtstrt, fs.fmtptr-fs.fmtstrt);
	fs.off += fs.fmtptr - fs.fmtstrt;
	break;
    }
  }

  return (0);
}
static void
put_sound_state(struct trace_proc * proc, const char * name, int state)
{

	if (!valuesonly && state == ON)
		put_field(proc, name, "ON");
	else if (!valuesonly && state == OFF)
		put_field(proc, name, "OFF");
	else
		put_value(proc, name, "%d", state);
}
inline
ScalarIntField &
declare_scalar_int_field_on_all_nodes( MetaData & md , const std::string & n )
{
  return put_field( md.declare_field<ScalarIntField>(n) ,
                       Node , md.universal_part() );
}
Exemplo n.º 4
0
/*
 * Start printing a structure.  In general, the function copies the contents of
 * the structure of size 'size' from the traced process at 'addr' into the
 * local 'ptr' structure, opens a nested block with name 'name' (which may
 * be NULL) using an opening bracket, and returns TRUE to indicate that the
 * caller should print fields from the structure.  However, if 'flags' contains
 * PF_FAILED, the structure will be printed as a pointer, no copy will be made,
 * and the call will return FALSE.  Similarly, if the remote copy fails, a
 * pointer will be printed and the call will return FALSE.  If PF_LOCADDR is
 * given, 'addr' is a local address, and an intraprocess copy will be made.
 */
int
put_open_struct(struct trace_proc * proc, const char * name, int flags,
	vir_bytes addr, void * ptr, size_t size)
{

	if ((flags & PF_FAILED) || valuesonly > 1 || addr == 0) {
		if (flags & PF_LOCADDR)
			put_field(proc, name, "&..");
		else
			put_ptr(proc, name, addr);

		return FALSE;
	}

	if (!(flags & PF_LOCADDR)) {
		if (mem_get_data(proc->pid, addr, ptr, size) < 0) {
			put_ptr(proc, name, addr);

			return FALSE;
		}
	} else
		memcpy(ptr, (void *) addr, size);

	put_open(proc, name, flags, "{", ", ");

	return TRUE;
}
Exemplo n.º 5
0
  HexFixture::HexFixture(   stk::ParallelMachine pm
              , size_t nx
              , size_t ny
              , size_t nz
              , ConnectivityMap const* connectivity_map
            )
  : m_spatial_dimension(3),
    m_nx(nx),
    m_ny(ny),
    m_nz(nz),
    m_meta( m_spatial_dimension ),
    m_bulk_data(  m_meta
                , pm
                , stk::mesh::BulkData::AUTO_AURA
#ifdef SIERRA_MIGRATION
                , false
#endif
                , connectivity_map
               ),
    m_elem_parts( 1, &m_meta.declare_part_with_topology("hex_part", stk::topology::HEX_8) ),
    m_node_parts( 1, &m_meta.declare_part_with_topology("node_part", stk::topology::NODE) ),
    m_coord_field( m_meta.declare_field<CoordFieldType>(stk::topology::NODE_RANK, "Coordinates") )
{

  //put coord-field on all nodes:
  put_field(
    m_coord_field,
    m_meta.universal_part(),
    m_spatial_dimension);

}
inline
Field<Type,T1,T2,T3,T4,T5,T6,T7> &
put_field_on_nodes( Field<Type,T1,T2,T3,T4,T5,T6,T7> & f , Part & p ,
                    unsigned n1 , unsigned n2 , unsigned n3 , unsigned n4 )
{
  put_field( f , Node , p , n1 , n2 , n3 , n4 );
  return f ;
}
inline
VectorField &
declare_vector_field_on_all_elements(
  MetaData & md , const std::string & s , unsigned n1 )
{
  return put_field( md.declare_field<VectorField>(s),
                       Element , md.universal_part() , n1 );
}
inline
ScalarField &
declare_scalar_field_on_all_elements( MetaData & md ,
                                      const std::string & n )
{
  return put_field( md.declare_field<ScalarField>(n) ,
                       Element , md.universal_part() );
}
inline
FullTensorField &
declare_full_tensor_field_on_all_nodes(
  MetaData & md , const std::string & s , unsigned n1 )
{
  return put_field( md.declare_field<FullTensorField>(s),
                       Node , md.universal_part() , n1 );
}
inline
SymmetricTensorField &
declare_symmetric_tensor_field_on_all_elements(
  MetaData & md , const std::string & s , unsigned n1 )
{
  return put_field( md.declare_field<SymmetricTensorField>(s) ,
                       Element , md.universal_part() , n1 );
}
inline
Field<Type,T1,T2,T3,T4,T5,T6,T7> &
put_field_on_all_nodes( Field<Type,T1,T2,T3,T4,T5,T6,T7> & f )
{
  MetaData & md = f.mesh_meta_data();
  put_field( f, Node, md.universal_part() );
  return f ;
}
Exemplo n.º 12
0
UseCase_3_Mesh::UseCase_3_Mesh( stk::ParallelMachine comm, bool doCommit ) :
  m_spatial_dimension(3)
  , m_fem_metaData( m_spatial_dimension )
  , m_bulkData( m_fem_metaData , comm )
  , m_block_hex(        m_fem_metaData.declare_part_with_topology( "block_1", stk::topology::HEX_8))
  , m_block_wedge(      m_fem_metaData.declare_part_with_topology( "block_2", stk::topology::WEDGE_6))
  , m_block_tet(        m_fem_metaData.declare_part_with_topology( "block_3", stk::topology::TET_4))
  , m_block_pyramid(    m_fem_metaData.declare_part_with_topology( "block_4", stk::topology::PYRAMID_5))
  , m_block_quad_shell( m_fem_metaData.declare_part_with_topology( "block_5", stk::topology::SHELL_QUAD_4))
  , m_block_tri_shell(  m_fem_metaData.declare_part_with_topology( "block_6", stk::topology::SHELL_TRI_3))
  , m_elem_rank( stk::topology::ELEMENT_RANK )
  , m_node_rank( topology::NODE_RANK )
  , m_coordinates_field( m_fem_metaData.declare_field< VectorFieldType >(stk::topology::NODE_RANK, "coordinates" ))
  , m_centroid_field(    m_fem_metaData.declare_field< VectorFieldType >(stk::topology::ELEMENT_RANK, "centroid" ))
  , m_temperature_field( m_fem_metaData.declare_field< ScalarFieldType >(stk::topology::NODE_RANK, "temperature" ))
  , m_volume_field( m_fem_metaData.declare_field< ScalarFieldType >(stk::topology::ELEMENT_RANK, "volume" ))
{
  // Define where fields exist on the mesh:
  Part & universal = m_fem_metaData.universal_part();

  put_field( m_coordinates_field , universal );
  put_field( m_centroid_field , universal );
  put_field( m_temperature_field, universal );
  put_field( m_volume_field, m_block_hex );
  put_field( m_volume_field, m_block_wedge );
  put_field( m_volume_field, m_block_tet );
  put_field( m_volume_field, m_block_pyramid );

  if (doCommit)
    m_fem_metaData.commit();
}
inline
Field<Type,T1,T2,T3,T4,T5,T6,T7> &
put_field_on_all_nodes( Field<Type,T1,T2,T3,T4,T5,T6,T7> & f ,
                        unsigned n1 , unsigned n2 , unsigned n3 , unsigned n4 )
{
  MetaData & md = f.mesh_meta_data();
  put_field( f, Node, md.universal_part(), n1, n2, n3, n4 );
  return f ;
}
Exemplo n.º 14
0
/*
 * End printing a structure.  This must be called only to match a successful
 * call to put_open_struct.  The given 'all' flag indicates whether all fields
 * of the structure have been printed; if not, a ".." continuation text is
 * printed to show the user that some structure fields have not been printed.
 */
void
put_close_struct(struct trace_proc * proc, int all)
{

	if (!all)
		put_field(proc, NULL, "..");

	put_close(proc, "}");
}
Exemplo n.º 15
0
/*
 * Print a pointer.  NULL is treated as a special case.
 */
void
put_ptr(struct trace_proc * proc, const char * name, vir_bytes addr)
{

	if (addr == 0 && !valuesonly)
		put_field(proc, name, "NULL");
	else
		put_value(proc, name, "&0x%lx", addr);
}
Exemplo n.º 16
0
/*
 * Print a tail field at the end of an array.  The given 'count' value is the
 * total number of elements in the array, or 0 to indicate that an error
 * occurred.  The given 'printed' value is the number of fields printed so far.
 * If some fields have been printed already, the number of fields not printed
 * will be shown as "..(+N)".  If no fields have been printed already, the
 * (total) number of fields not printed will be shown as "..(N)".  An error
 * will print "..(?)".
 *
 * The rules for printing an array are as follows.  In principle, arrays should
 * be enclosed in "[]".  However, if a copy error occurs immediately, a pointer
 * to the array should be printed instead.  An empty array should be printed as
 * "[]" (not "[..(0)]").  If a copy error occurs in the middle of the array,
 * put_tail should be used with count == 0.  Only if not all fields in the
 * array are printed, put_tail should be used with count > 0.  The value of
 * 'printed' is typically the result of an arbitrary limit set based on the
 * verbosity level.
 */
void
put_tail(struct trace_proc * proc, unsigned int count, unsigned int printed)
{

	if (count == 0)
		put_field(proc, NULL, "..(?)");
	else
		put_value(proc, NULL, "..(%s%u)",
		    (printed > 0) ? "+" : "", count - printed);
}
Exemplo n.º 17
0
    BeamFixture::BeamFixture( stk::ParallelMachine comm, bool doCommit ) :
      m_spatial_dimension(3)
      , m_metaData(m_spatial_dimension, stk::mesh::fem::entity_rank_names(m_spatial_dimension) )
      , m_bulkData( stk::mesh::fem::FEMMetaData::get_meta_data(m_metaData) , comm )
      , m_block_beam( m_metaData.declare_part< Beam2 >( "block_2" ) )
      , m_elem_rank( m_metaData.element_rank() )
      , m_coordinates_field( m_metaData.declare_field< VectorFieldType >( "coordinates" ))
      , m_centroid_field(    m_metaData.declare_field< VectorFieldType >( "centroid" ))
      , m_temperature_field( m_metaData.declare_field< ScalarFieldType >( "temperature" ))
      , m_volume_field( m_metaData.declare_field< ScalarFieldType >( "volume" ))
      , m_element_node_coordinates_field( m_metaData.declare_field< ElementNodePointerFieldType >( "elem_node_coord" ))
    {
      // Define where fields exist on the mesh:
      stk::mesh::Part & universal = m_metaData.universal_part();

      put_field( m_coordinates_field , stk::mesh::fem::FEMMetaData::NODE_RANK , universal );
      put_field( m_centroid_field , m_elem_rank , universal );
      put_field( m_temperature_field, stk::mesh::fem::FEMMetaData::NODE_RANK, universal );
      put_field( m_volume_field, m_elem_rank, m_block_beam );

      // Define the field-relation such that the values of the
      // 'element_node_coordinates_field' are pointers to the
      // element's nodal 'coordinates_field'.
      // I.e., let:
      //   double *const* elem_node_coord =
      //     field_data( m_element_node_coordinates_field , element );
      // then
      //     elem_node_coord[n][0..2] is the coordinates of element node 'n'
      //     that are attached to that node.

      m_metaData.declare_field_relation(
                                        m_element_node_coordinates_field ,
                                        stk::mesh::fem::get_element_node_stencil(3) ,
                                        m_coordinates_field
                                        );

      // Define element node coordinate field for all element parts
      put_field( m_element_node_coordinates_field, m_elem_rank, m_block_beam, Beam2::node_count );

      if (doCommit)
        m_metaData.commit();
    }
Exemplo n.º 18
0
/*
 * Version of put_field with variadic arguments.
 */
void
put_value(struct trace_proc * proc, const char * name, const char * fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)vsnprintf(formatbuf, sizeof(formatbuf), fmt, ap);
	va_end(ap);

	put_field(proc, name, formatbuf);
}
Exemplo n.º 19
0
/*
 * Increase the nesting depth with a new block of fields, enclosed within
 * parentheses, brackets, etcetera.  The given name, which may be NULL, is the
 * name of the entire nested block.  In the flags field, PF_NONAME indicates
 * that the fields within the block should have their names printed or not,
 * although this may be overridden by setting the allnames variable.  The given
 * string is the block opening string (e.g., an opening parenthesis).  The
 * given separator is used to separate the fields within the nested block, and
 * should generally be ", " to maintain output consistency.
 */
void
put_open(struct trace_proc * proc, const char * name, int flags,
	const char * string, const char * sep)
{

	put_field(proc, name, string);

	proc->depth++;

	assert(proc->depth < MAX_DEPTH);

	proc->depths[proc->depth].sep = sep;
	proc->depths[proc->depth].name = !(flags & PF_NONAME);

	format_set_sep(proc, NULL);
}
Exemplo n.º 20
0
/*
 * Print a flags field, using known flag names.  The name of the whole field is
 * given as 'name' and may be NULL.  The caller must supply an array of known
 * flags as 'fp' (with 'num' entries).  Each entry in the array has a mask, a
 * value, and a name.  If the given flags 'value', bitwise-ANDed with the mask
 * of an entry, yields the value of that entry, then the name is printed.  This
 * means that certain zero bits may also be printed as actual flags, and that
 * by supplying an all-bits-set mask can print a flag name for a zero value,
 * for example F_OK for access().  See the FLAG macros and their usage for
 * examples.  All matching flag names are printed with a "|" separator, and if
 * after evaluating all 'num' entries in 'fp' there are still bits in 'value'
 * for which nothing has been printed, the remaining bits will be printed with
 * the 'fmt' format string for an integer (generally "%d" should be used).
 */
void
put_flags(struct trace_proc * proc, const char * name, const struct flags * fp,
	unsigned int num, const char * fmt, unsigned int value)
{
	unsigned int left;
	int first;

	if (valuesonly) {
		put_value(proc, name, fmt, value);

		return;
	}

	put_field(proc, name, "");

	for (first = TRUE, left = value; num > 0; fp++, num--) {
		if ((value & fp->mask) == fp->value) {
			if (first)
				first = FALSE;
			else
				put_text(proc, "|");
			put_text(proc, fp->name);

			left -= fp->value;
		}
	}

	if (left != 0) {
		if (first)
			first = FALSE;
		else
			put_text(proc, "|");

		put_fmt(proc, fmt, left);
	}

	/*
	 * If nothing has been printed so far, simply print a zero.  Ignoring
	 * the given format in this case is intentional: a simple 0 looks
	 * better than 0x0 or 00 etc.
	 */
	if (first)
		put_text(proc, "0");
}
Exemplo n.º 21
0
static void
put_fbd_action(struct trace_proc * proc, const char * name, int action)
{
	const char *text = NULL;

	if (!valuesonly) {
		switch (action) {
		TEXT(FBD_ACTION_CORRUPT);
		TEXT(FBD_ACTION_ERROR);
		TEXT(FBD_ACTION_MISDIR);
		TEXT(FBD_ACTION_LOSTTORN);
		}
	}

	if (text != NULL)
		put_field(proc, name, text);
	else
		put_value(proc, name, "%d", action);
}
static void
put_i2c_op(struct trace_proc * proc, const char *name, i2c_op_t op)
{
	const char *text = NULL;

	if (!valuesonly) {
		switch (op) {
		TEXT(I2C_OP_READ);
		TEXT(I2C_OP_READ_WITH_STOP);
		TEXT(I2C_OP_WRITE);
		TEXT(I2C_OP_WRITE_WITH_STOP);
		TEXT(I2C_OP_READ_BLOCK);
		TEXT(I2C_OP_WRITE_BLOCK);
		}
	}

	if (text != NULL)
		put_field(proc, name, text);
	else
		put_value(proc, name, "%d", op);
}
static void
put_tty_disc(struct trace_proc * proc, const char * name, int disc)
{
	const char *text = NULL;

	if (!valuesonly) {
		switch (disc) {
		TEXT(TTYDISC);
		TEXT(TABLDISC);
		TEXT(SLIPDISC);
		TEXT(PPPDISC);
		TEXT(STRIPDISC);
		TEXT(HDLCDISC);
		}
	}

	if (text != NULL)
		put_field(proc, name, text);
	else
		put_value(proc, name, "%d", disc);
}
static void
put_sound_device(struct trace_proc * proc, const char * name, int device)
{
	const char *text = NULL;

	if (!valuesonly) {
		switch (device) {
		TEXT(Master);
		TEXT(Dac);
		TEXT(Fm);
		TEXT(Cd);
		TEXT(Line);
		TEXT(Mic);
		TEXT(Speaker);
		TEXT(Treble);
		TEXT(Bass);
		}
	}

	if (text != NULL)
		put_field(proc, name, text);
	else
		put_value(proc, name, "%d", device);
}
Exemplo n.º 25
0
int
main ()
{
  put_field (0, 1);
  abort ();
}
inline
Field<Type,T1,T2,T3,T4,T5,T6,T7> &
put_field_on_nodes( Field<Type,T1,T2,T3,T4,T5,T6,T7> & f , Part & p )
{ put_field( f , Node , p );  return f ; }
inline
Field<Type,T1,T2> &
put_field_on_elements( Field<Type,T1,T2> & f , Part & p ,
                                unsigned n1 , unsigned n2 )
{ put_field( f , Element , p , n1 , n2 );  return f ; }
inline
Field<Type> & put_field_on_elements( Field<Type> & f , Part & p )
{ put_field( f , Element , p );  return f ; }
Exemplo n.º 29
0
bool test_change_owner_with_constraint( stk_classic::ParallelMachine pm )
{
  bool success = true ;

  const unsigned p_rank = stk_classic::parallel_machine_rank( pm );
  const unsigned p_size = stk_classic::parallel_machine_size( pm );

  if ( p_size != 2 ) { return success ; }

  std::vector<std::string> rank_names = stk_classic::mesh::fem::entity_rank_names(spatial_dimension);
  const stk_classic::mesh::EntityRank constraint_rank = rank_names.size();
  rank_names.push_back("Constraint");
  stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension, rank_names );
  const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank();

  VectorField * coordinates_field =
    & put_field(
        fem_meta_data.declare_field<VectorField>("coordinates"),
        NODE_RANK,
        fem_meta_data.universal_part() ,
        3
        );

  stk_classic::mesh::Part & owned_part = fem_meta_data.locally_owned_part();
  stk_classic::mesh::Part & quad_part  = stk_classic::mesh::fem::declare_part<Quad4>( fem_meta_data, "quad");

  fem_meta_data.commit();

  stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta_data),
                                 pm,
                                 100 );
  bulk_data.modification_begin();

  unsigned nx = 3;
  unsigned ny = 3;

  if ( p_rank==0 )
  {
    const unsigned nnx = nx + 1 ;
    for ( unsigned iy = 0 ; iy < ny ; ++iy ) {
      for ( unsigned ix = 0 ; ix < nx ; ++ix ) {
        stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ;
        stk_classic::mesh::EntityId nodes[4] ;
        nodes[0] = 1 + ix + iy * nnx ;
        nodes[1] = 2 + ix + iy * nnx ;
        nodes[2] = 2 + ix + ( iy + 1 ) * nnx ;
        nodes[3] = 1 + ix + ( iy + 1 ) * nnx ;

        stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes );
      }
    }

    for ( unsigned iy = 0 ; iy < ny+1 ; ++iy ) {
      for ( unsigned ix = 0 ; ix < nx+1 ; ++ix ) {
        stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ;
        stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid );
        double * const coord = stk_classic::mesh::field_data( *coordinates_field , *n );
        coord[0] = .1*ix;
        coord[1] = .1*iy;
        coord[2] = 0;
      }
    }
  }

  bulk_data.modification_end();

  if ( p_size>1 )
  {
    std::vector<stk_classic::mesh::EntityProc> ep;

    if ( p_rank==0 )
    {
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  3 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  4 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  7 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  8 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 1 ) );
    }

    bulk_data.modification_begin();
    bulk_data.change_entity_owner( ep );
    bulk_data.modification_end();

    bulk_data.modification_begin();

    if ( p_rank==1 )
    {
      // create constraint

      stk_classic::mesh::Entity * n10 = bulk_data.get_entity( NODE_RANK, 10 );
      stk_classic::mesh::Entity * n11 = bulk_data.get_entity( NODE_RANK, 11 );
      stk_classic::mesh::Entity * n12 = bulk_data.get_entity( NODE_RANK, 12 );

      stk_classic::mesh::PartVector add;
      add.push_back( &owned_part );
      const stk_classic::mesh::EntityId c_entity_id = 1;
      stk_classic::mesh::Entity & c = bulk_data.declare_entity( constraint_rank, c_entity_id, add );
      bulk_data.declare_relation( c , *n10 , 0 );
      bulk_data.declare_relation( c , *n11 , 1 );
      bulk_data.declare_relation( c , *n12 , 2 );
    }

    bulk_data.modification_end();

    stk_classic::mesh::Entity * n10 = bulk_data.get_entity( NODE_RANK, 10 );

    if ( p_rank==0 or p_rank==1 )
    {
      ThrowErrorMsgIf( !stk_classic::mesh::in_shared( *n10 ), "NODE[10] not shared" );
    }

    bulk_data.modification_begin();

    if ( p_rank==1 )
    {
      // destroy constraint

      stk_classic::mesh::Entity * c1 = bulk_data.get_entity( constraint_rank, 1 );

      ThrowErrorMsgIf( !bulk_data.destroy_entity( c1 ),
                       "failed to destroy constraint" );
    }

    bulk_data.modification_end();

    if ( p_rank==0 or p_rank==1 )
    {
      ThrowErrorMsgIf( stk_classic::mesh::in_shared( *n10 ), "NODE[10] shared" );
    }
  }

  return success ;
}
Exemplo n.º 30
0
bool test_change_owner_3( stk_classic::ParallelMachine pm )
{
  const int p_rank = stk_classic::parallel_machine_rank( pm );
  const unsigned p_size = stk_classic::parallel_machine_size( pm );

  stk_classic::mesh::fem::FEMMetaData fem_meta_data( spatial_dimension );
  const stk_classic::mesh::EntityRank element_rank = fem_meta_data.element_rank();

  VectorField * coordinates_field =
    & put_field(
        fem_meta_data.declare_field<VectorField>("coordinates"),
        NODE_RANK,
        fem_meta_data.universal_part() ,
        3
        );

  stk_classic::mesh::Part & quad_part  = stk_classic::mesh::fem::declare_part<Quad4>( fem_meta_data, "quad");

  fem_meta_data.commit();

  stk_classic::mesh::BulkData bulk_data( stk_classic::mesh::fem::FEMMetaData::get_meta_data(fem_meta_data),
                                 pm,
                                 100 );
  bulk_data.modification_begin();

  unsigned nx = 3;
  unsigned ny = 3;

  if ( p_rank==0 )
  {
    const unsigned nnx = nx + 1 ;
    for ( unsigned iy = 0 ; iy < ny ; ++iy ) {
      for ( unsigned ix = 0 ; ix < nx ; ++ix ) {
        stk_classic::mesh::EntityId elem = 1 + ix + iy * nx ;
        stk_classic::mesh::EntityId nodes[4] ;
        nodes[0] = 1 + ix + iy * nnx ;
        nodes[1] = 2 + ix + iy * nnx ;
        nodes[2] = 2 + ix + ( iy + 1 ) * nnx ;
        nodes[3] = 1 + ix + ( iy + 1 ) * nnx ;

        stk_classic::mesh::fem::declare_element( bulk_data , quad_part , elem , nodes );
      }
    }

    for ( unsigned iy = 0 ; iy < ny+1 ; ++iy ) {
      for ( unsigned ix = 0 ; ix < nx+1 ; ++ix ) {
        stk_classic::mesh::EntityId nid = 1 + ix + iy * nnx ;
        stk_classic::mesh::Entity * n = bulk_data.get_entity( NODE_RANK, nid );
        double * const coord = stk_classic::mesh::field_data( *coordinates_field , *n );
        coord[0] = .1*ix;
        coord[1] = .1*iy;
        coord[2] = 0;
      }
    }
  }

  bulk_data.modification_end();

  if ( p_size>1 ) {

    std::vector<stk_classic::mesh::EntityProc> ep;

    if ( p_rank==0 )
    {
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  2 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  3 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  4 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  6 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  7 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  8 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 10 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 2 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 5 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 3 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 6 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 1 ) );
    }

    bulk_data.modification_begin();
    bulk_data.change_entity_owner( ep );
    bulk_data.modification_end();

    // output to debug

    ep.clear();

    if ( p_rank==0 )
    {
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  1 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK,  5 ), 1 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 1 ), 1 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 4 ), 1 ) );
    }
    else if ( p_rank==1 )
    {
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 10 ), 0 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 11 ), 0 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 12 ), 0 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 14 ), 0 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 15 ), 0 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( NODE_RANK, 16 ), 0 ) );

      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 8 ), 0 ) );
      ep.push_back( stk_classic::mesh::EntityProc( bulk_data.get_entity( element_rank, 9 ), 0 ) );
    }

    bulk_data.modification_begin();
    bulk_data.change_entity_owner( ep );
    bulk_data.modification_end();
  }

  return true ;
}