inline
Field<Type> & put_field_on_all_elements( Field<Type> & f )
{ put_field_on_elements( f , f.mesh_meta_data().universal_part() );  return f ; }
inline
Field<Type,T1,T2> & put_field_on_all_elements( Field<Type,T1,T2> & f ,
                                unsigned n1 , unsigned n2 )
{ put_field_on_elements( f , f.mesh_meta_data().universal_part() , n1 , n2 );  return f ; }
Beispiel #3
0
void stk_classic::app::use_case_14_declare_fields(Fields &fields, stk_classic::mesh::MetaData &meta_data)
{
  // Nodal vector fields
  fields.model_coordinates     = &declare_vector_field_on_all_nodes(meta_data, "coordinates", SpatialDim);
  fields.coordinates_field     = &declare_vector_field_on_all_nodes(meta_data, "current_coordinates", SpatialDim);
  fields.velocity_field        = &declare_vector_field_on_all_nodes(meta_data, "velocity",    SpatialDim);
  fields.fint_field            = &declare_vector_field_on_all_nodes(meta_data, "force_internal", SpatialDim);

  // Element vector fields:
  fields.Vorticity             = &declare_vector_field_on_all_elements(meta_data, "Vorticity" , SpatialDim);

  // Element scalar fields:
  fields.Shear_Modulus         = &declare_scalar_field_on_all_elements(meta_data, "shear_modulus" );
  fields.Dilatational_Modulus  = &declare_scalar_field_on_all_elements(meta_data, "dilatational_modulus");
  fields.Material_eff_twomu    = &declare_scalar_field_on_all_elements(meta_data, "material_effictive_two_mu");
  fields.Material_eff_bulk_mod = &declare_scalar_field_on_all_elements(meta_data, "material_effective_bulk_moduli");
  fields.Midstep_volume        = &declare_scalar_field_on_all_elements(meta_data, "mid_step_volume");
  fields.Element_time_step     = &declare_scalar_field_on_all_elements(meta_data, "element_time_step");
  fields.Element_mass          = &declare_scalar_field_on_all_elements(meta_data, "element_mass");
  fields.Hourglass_energy      = &declare_scalar_field_on_all_elements(meta_data, "hourglass_energy");
  fields.Internal_energy       = &declare_scalar_field_on_all_elements(meta_data, "internal_energy");

  // Element symmetric tensor fields:
  fields.Stretch               = &declare_symmetric_tensor_field_on_all_elements(meta_data, "stretch",    6 );
  fields.StrainRate            = &declare_symmetric_tensor_field_on_all_elements(meta_data, "StrainRate", 6 );
  fields.RotatedStress         = &declare_symmetric_tensor_field_on_all_elements(meta_data, "RotatedStress", 6 );

  //--------------------------------
  // The multi-state fields don't have the 'declare and put' convenience functions (yet)
  //
  //  For clarity declare a integer to used for the number of states arguments.
  //
  const unsigned two_states = 2 ;

  // Element two state symmetric tensor field, on all elements (as two function calls):
  fields.StressNew = &meta_data.declare_field< SymmetricTensorField >( "Stress" , two_states );
  put_field_on_all_elements( *fields.StressNew , 6 );

  // Element two state full tensor field on all elements (as nested function calls):
  fields.RotationNew = &put_field_on_all_elements( meta_data.declare_field< FullTensorField >("Rotation", two_states ) , 9 );

  //--------------------------------
  // Hourglass fields, these don't have the convenience functions for 'declare and put'

  fields.HourglassResistanceNew =
    &put_field_on_all_elements( meta_data.declare_field< HourglassArrayField >("HourglassResistance" , two_states ) , 12 );

  fields.MidHourglassOp =
    &put_field_on_all_elements( meta_data.declare_field< HourglassOpField >("mid_hourglass_operator") , 32 );

  //--------------------------------
  // Declare aggressive "gather" fields which are an array of
  // pointers to the element's nodes' coordinate, velocity, and
  // internal force field data.
  //
  // The declarations specify element fields of the following form:
  //
  //     double * coord_gather   [ nodes_per_element ]
  //     double * velocity_gather[ nodes_per_element ]
  //
  // where
  //
  //     coord_gather[i]    == field_data( coordinates_field , element_node[i] )
  //     velocity_gather[i] == field_data( velocity ,          element_node[i] )
  //
  // The number of nodes per element could vary, so the field is put
  // on each element block with a size of the number of nodes per
  // element in that element block.

  fields.coord_gather    = &declare_element_node_pointer_field( meta_data , "coord_gather" ,    *fields.coordinates_field );
  fields.velocity_gather = &declare_element_node_pointer_field( meta_data , "velocity_gather" , *fields.velocity_field );

  //----------------------------------
  // Declare an element field with one value per connected node in
  // which to temporarily store nodal force that is calculated by
  // the internal force algorithm.

  fields.force_new_field = &meta_data.declare_field<ElementNodeVectorField>( "force_new_field" , 1 /* 1 state */ );

  // All parts of the meta data:
  {
    const mesh::PartVector & all_parts = meta_data.get_parts();
    for (mesh::PartVector::const_iterator i = all_parts.begin();
	 i != all_parts.end(); ++i) {
      mesh::Part * const part = *i ;
      if ( part->primary_entity_rank() == get_element_rank(meta_data) ) {
	put_field_on_elements(*fields.coord_gather,    *part, shards::Hexahedron<> ::node_count );
	put_field_on_elements(*fields.velocity_gather, *part, shards::Hexahedron<> ::node_count );
	put_field_on_elements(*fields.force_new_field, *part, SpatialDim, shards::Hexahedron<>::node_count );
      }
    }
  }
}