Пример #1
0
void Test_Realm::add() {
    Realm realm;
    realm.push_back(1);

    realm.addOffset(1);

    QVERIFY(realm.contains(2));
}
Пример #2
0
void Realm::merge(const Realm &r) {
    if (r._dimension != _dimension)
        throw std::invalid_argument(
                "Tried to merge "+r.toString()+" into Realm "+toString()+".\n"
                "You can only merge realms of equal dimension.");

    for (realm_container_type::const_iterator i = r.cbegin(); i != r.cend(); ++i)
        _subrealm.push_back(*i);
}
Пример #3
0
void Test_Realm::clear() {
    Realm realm;
    realm.push_back(1);

    realm.clear();

    QVERIFY(realm.size() == 0);
    QVERIFY(realm.dimension() == 0);
}
Пример #4
0
MomentumABLForceSrcNodeSuppAlg::MomentumABLForceSrcNodeSuppAlg(
  Realm& realm, ABLForcingAlgorithm* ablsrc)
  : SupplementalAlgorithm(realm),
    ablSrc_(ablsrc),
    coords_(realm.meta_data().get_field<VectorFieldType>(
      stk::topology::NODE_RANK, "coordinates")),
    dualNodalVolume_(realm.meta_data().get_field<ScalarFieldType>(
      stk::topology::NODE_RANK, "dual_nodal_volume")),
    nDim_(realm_.meta_data().spatial_dimension())
  {}
Пример #5
0
void Realm::addRotationStrip(Realm &all_strips, unsigned rotation_step, unsigned num_segments) const {
    Realm temp_realm = rotateStep(0, rotation_step*num_segments, num_segments);
    if (DEBUG_ROTATE) {
        cerr << "addRotationStrip(..., " << rotation_step << ", " << num_segments << "): "
                << "temp realm: " << endl << temp_realm.toString(); }
    all_strips.merge(temp_realm);

    Realm temp_copy = temp_realm;
    temp_copy.addStayingWithinSameStrip(num_segments, rotation_step);
    if (DEBUG_ROTATE) { cerr << "temp copy: " << temp_copy.toString() << endl; }
    all_strips.merge(temp_copy);
}
//==========================================================================
// Class Definition
//==========================================================================
// AssembleCourantReynoldsElemAlgorithm - Courant number calc for both edge
//                                        and elem
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
AssembleCourantReynoldsElemAlgorithm::AssembleCourantReynoldsElemAlgorithm(
  Realm &realm,
  stk::mesh::Part *part)
  : Algorithm(realm, part),
    meshMotion_(realm_.does_mesh_move()),
    velocityRTM_(NULL),
    coordinates_(NULL),
    density_(NULL),
    viscosity_(NULL),
    elemReynolds_(NULL),
    elemCourant_(NULL)
{
  // save off data
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  if ( meshMotion_ )
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity_rtm");
  else
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  const std::string viscName = (realm.is_turbulent())
     ? "effective_viscosity_u" : "viscosity";
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, viscName);

  // provide for elemental fields
  elemReynolds_ = meta_data.get_field<GenericFieldType>(stk::topology::ELEMENT_RANK, "element_reynolds");
  elemCourant_ = meta_data.get_field<GenericFieldType>(stk::topology::ELEMENT_RANK, "element_courant");
}
//==========================================================================
// Class Definition
//==========================================================================
// MomentumMassBackwardEulerElemSuppAlg - base class for algorithm
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
MomentumMassBackwardEulerElemSuppAlg::MomentumMassBackwardEulerElemSuppAlg(
  Realm &realm)
  : SupplementalAlgorithm(realm),
    bulkData_(&realm.bulk_data()),
    velocityN_(NULL),
    velocityNp1_(NULL),
    densityN_(NULL),
    densityNp1_(NULL),
    Gjp_(NULL),
    coordinates_(NULL),
    dt_(0.0),
    nDim_(realm_.spatialDimension_),
    useShifted_(false)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  VectorFieldType *velocity = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");
  velocityN_ = &(velocity->field_of_state(stk::mesh::StateN));
  velocityNp1_ = &(velocity->field_of_state(stk::mesh::StateNP1));
  ScalarFieldType *density = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  densityN_ = &(density->field_of_state(stk::mesh::StateN));
  densityNp1_ = &(density->field_of_state(stk::mesh::StateNP1));
  Gjp_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());

  // scratch vecs
  uNScv_.resize(nDim_);
  uNp1Scv_.resize(nDim_);
  GjpScv_.resize(nDim_);
}
Пример #8
0
//==========================================================================
// Class Definition
//==========================================================================
// ScalarMassBDF2ElemSuppAlg - CMM (BDF2) for scalar equation
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
ScalarMassBDF2ElemSuppAlg::ScalarMassBDF2ElemSuppAlg(
  Realm &realm,
  ScalarFieldType *scalarQ)
  : SupplementalAlgorithm(realm),
    bulkData_(&realm.bulk_data()),
    scalarQNm1_(NULL),
    scalarQN_(NULL),
    scalarQNp1_(NULL),
    densityNm1_(NULL),
    densityN_(NULL),
    densityNp1_(NULL),
    coordinates_(NULL),
    dt_(0.0),
    gamma1_(0.0),
    gamma2_(0.0),
    gamma3_(0.0),
    nDim_(realm_.spatialDimension_),
    useShifted_(false)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  scalarQNm1_ = &(scalarQ->field_of_state(stk::mesh::StateNM1));
  scalarQN_ = &(scalarQ->field_of_state(stk::mesh::StateN));
  scalarQNp1_ = &(scalarQ->field_of_state(stk::mesh::StateNP1));
  ScalarFieldType *density = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  densityNm1_ = &(density->field_of_state(stk::mesh::StateNM1));
  densityN_ = &(density->field_of_state(stk::mesh::StateN));
  densityNp1_ = &(density->field_of_state(stk::mesh::StateNP1));
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
}
//==========================================================================
// Class Definition
//==========================================================================
// ComputeHeatTransferElemWallAlgorithm - compute h and Too
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
ComputeHeatTransferElemWallAlgorithm::ComputeHeatTransferElemWallAlgorithm(
  Realm &realm,
  stk::mesh::Part *part)
  : Algorithm(realm, part),
    temperature_(NULL),
    coordinates_(NULL),
    density_(NULL),
    viscosity_(NULL),
    specificHeat_(NULL),
    exposedAreaVec_(NULL),
    assembledWallArea_(NULL),
    referenceTemperature_(NULL),
    heatTransferCoefficient_(NULL),
    normalHeatFlux_(NULL),
    robinCouplingParameter_(NULL),
    Pr_(realm.get_lam_prandtl("enthalpy"))
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  temperature_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "temperature");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "viscosity");
  specificHeat_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "specific_heat");
  exposedAreaVec_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "exposed_area_vector");
  assembledWallArea_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "assembled_wall_area_ht");
  referenceTemperature_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "reference_temperature");
  heatTransferCoefficient_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "heat_transfer_coefficient");
  normalHeatFlux_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "normal_heat_flux");
  robinCouplingParameter_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "robin_coupling_parameter");
}
Пример #10
0
/** \todo rewrite to make independent of realm_container_type::operator[] */
bool Realm::operator==(const Realm &other) const {

    if (dimension() != other.dimension()) return false;

    if (dimension() == 0) return (toIndex() == other.toIndex());

    if (_subrealm.size() != other._subrealm.size()) return false;

    /* comparing _subrealm to other._subrealm does not always return true, even
     * if the elements are equal. doing it manually. */
    for (unsigned i = 0; i < _subrealm.size(); ++i) {
        if (!(_subrealm[i] == other._subrealm[i])) return false;
    }

    return true;
}
Пример #11
0
void Test_Realm::push_back() {
    Realm realm;
    realm.push_back(1);
    realm.push_back(2);

    QVERIFY(realm.contains(1));
    QVERIFY(realm.contains(2));
    QVERIFY(realm.dimension() == 1);

    try {
        realm.push_back(realm);
    } catch (std::invalid_argument e) {
        return;
    }
    QFAIL("Expected invalid_argument");
}
//==========================================================================
// Class Definition
//==========================================================================
// AssembleScalarElemOpenSolverAlgorithm - lhs for scalar open bc
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
AssembleScalarElemOpenSolverAlgorithm::AssembleScalarElemOpenSolverAlgorithm(
  Realm &realm,
  stk::mesh::Part *part,
  EquationSystem *eqSystem,
  ScalarFieldType *scalarQ,
  ScalarFieldType *bcScalarQ,
  VectorFieldType *dqdx,
  ScalarFieldType *diffFluxCoeff)
  : SolverAlgorithm(realm, part, eqSystem),
    meshMotion_(realm.does_mesh_move()),
    scalarQ_(scalarQ),
    bcScalarQ_(bcScalarQ),
    dqdx_(dqdx),
    diffFluxCoeff_(diffFluxCoeff),
    velocityRTM_(NULL),
    coordinates_(NULL),
    density_(NULL),
    openMassFlowRate_(NULL),
    pecletFunction_(NULL)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  if ( meshMotion_ )
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity_rtm");
  else
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  openMassFlowRate_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "open_mass_flow_rate");

  // create the peclet blending function
  pecletFunction_ = eqSystem->create_peclet_function(scalarQ_->name());
}
//==========================================================================
// Class Definition
//==========================================================================
// SurfaceForceAndMomentAlgorithm - post process sigma_ijnjdS and tau_wall
//                                  via lumped nodal projection (area weighed)
//                                  Driven by SurfaceForceAndMomentAlgDriver
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
SurfaceForceAndMomentAlgorithm::SurfaceForceAndMomentAlgorithm(
  Realm &realm,
  stk::mesh::PartVector &partVec,
  const std::string &outputFileName,
  const int &frequency,
  const std::vector<double > &parameters,
  const bool &useShifted)
  : Algorithm(realm, partVec),
    outputFileName_(outputFileName),
    frequency_(frequency),
    parameters_(parameters),
    useShifted_(useShifted),
    includeDivU_(realm.get_divU()),
    coordinates_(NULL),
    pressure_(NULL),
    pressureForce_(NULL),
    tauWall_(NULL),
    yplus_(NULL),
    density_(NULL),
    viscosity_(NULL),
    dudx_(NULL),
    exposedAreaVec_(NULL),
    assembledArea_(NULL),
    w_(12)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  pressure_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "pressure");
  pressureForce_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "pressure_force");
  tauWall_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "tau_wall");
  yplus_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "yplus");
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  // extract viscosity name
  const std::string viscName = realm_.is_turbulent()
    ? "effective_viscosity_u" : "viscosity";
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, viscName);
  dudx_ = meta_data.get_field<GenericFieldType>(stk::topology::NODE_RANK, "dudx");
  exposedAreaVec_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "exposed_area_vector");
  assembledArea_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "assembled_area_force_moment");
  // error check on params
  const size_t nDim = meta_data.spatial_dimension();
  if ( parameters_.size() > nDim )
    throw std::runtime_error("SurfaceForce: parameter length wrong; expect nDim");

  // deal with file name and banner
  if ( NaluEnv::self().parallel_rank() == 0 ) {
    std::ofstream myfile;
    myfile.open(outputFileName_.c_str());
    myfile << std::setw(w_) 
           << "Time" << std::setw(w_) 
           << "Fpx"  << std::setw(w_) << "Fpy" << std::setw(w_)  << "Fpz" << std::setw(w_) 
           << "Fvx"  << std::setw(w_) << "Fvy" << std::setw(w_)  << "Fxz" << std::setw(w_) 
           << "Mtx"  << std::setw(w_) << "Mty" << std::setw(w_)  << "Mtz" << std::setw(w_) 
           << "Y+min" << std::setw(w_) << "Y+max"<< std::endl;
  }
 }
Пример #14
0
void Realm::push_back(const Realm &r) {
    if (!_dimension) _dimension = r._dimension+1;

    if (r._dimension != _dimension-1)
        throw std::invalid_argument(
                "Tried to push_back() "+r.toString()+" to Realm "+toString()+".\n"
                "You can only add realms of dimension this->_dimension-1.");

    _subrealm.push_back(r);
}
Пример #15
0
ContinuityMassElemSuppAlg<AlgTraits>::ContinuityMassElemSuppAlg(
   Realm &realm,
   ElemDataRequests& dataPreReqs,
   const bool lumpedMass)
  : SupplementalAlgorithm(realm),
    densityNm1_(NULL),
    densityN_(NULL),
    densityNp1_(NULL),
    coordinates_(NULL),
    dt_(0.0),
    gamma1_(0.0),
    gamma2_(0.0),
    gamma3_(0.0),
    lumpedMass_(lumpedMass),
    ipNodeMap_(realm.get_volume_master_element(AlgTraits::topo_)->ipNodeMap())
{
  // save off fields; shove state N into Nm1 if this is BE
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  ScalarFieldType *density = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  densityNm1_ = realm_.number_of_states() == 2 ? &(density->field_of_state(stk::mesh::StateN)) : &(density->field_of_state(stk::mesh::StateNM1));
  densityN_ = &(density->field_of_state(stk::mesh::StateN));
  densityNp1_ = &(density->field_of_state(stk::mesh::StateNP1));
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());

  MasterElement *meSCV = realm.get_volume_master_element(AlgTraits::topo_);

  // compute shape function
  if ( lumpedMass_ )
    meSCV->shifted_shape_fcn(&v_shape_function_(0,0));
  else
    meSCV->shape_fcn(&v_shape_function_(0,0));

  // add master elements
  dataPreReqs.add_cvfem_volume_me(meSCV);

  // fields and data
  dataPreReqs.add_gathered_nodal_field(*coordinates_, AlgTraits::nDim_);
  dataPreReqs.add_gathered_nodal_field(*densityNm1_, 1);
  dataPreReqs.add_gathered_nodal_field(*densityN_, 1);
  dataPreReqs.add_gathered_nodal_field(*densityNp1_, 1);
  dataPreReqs.add_master_element_call(SCV_VOLUME);
}
Пример #16
0
BObjectImp* UOExecutorModule::mf_MoveObjectToLocation(/*object, x, y, z, realm, flags*/)
{
	UObject* obj;
	unsigned short x, y;
	short z;
	long flags;
	const String* realm_name;

	// Initialize variables
	if ( !(getUObjectParam( exec, 0, obj) &&
			getParam(1, x) &&
			getParam(2, y) &&
			getParam(3, z, WORLD_MIN_Z, WORLD_MAX_Z) &&
			getStringParam(4, realm_name) &&
			getParam(5, flags)) )
	{
			return new BError("Invalid parameter");
    }
	Realm* realm = find_realm(realm_name->value());
	if( !realm ) 
		return new BError("Realm not found.");
	else if( !realm->valid(x, y, z) ) 
		return new BError("Invalid coordinates for realm.");
    
	if ( obj->script_isa(POLCLASS_MOBILE) )
		return internal_MoveCharacter(static_cast<Character*>(obj), x, y, z, flags, realm);
	else if ( obj->script_isa(POLCLASS_BOAT) )
		return internal_MoveBoat(static_cast<UBoat*>(obj), x, y, z, flags, realm);
	else if ( obj->script_isa(POLCLASS_MULTI) )
		return new BError("Can't move multis at this time.");
	else if ( obj->script_isa(POLCLASS_CONTAINER) )
		return internal_MoveContainer(static_cast<UContainer*>(obj), x, y, z, flags, realm);
	else if ( obj->script_isa(POLCLASS_ITEM) )
		return internal_MoveItem(static_cast<Item*>(obj), x ,y ,z , flags, realm);
	else
		return new BError("Can't handle that object type.");
}
//==========================================================================
// Class Definition
//==========================================================================
// AssembleMomentumElemSymmetrySolverAlgorithm - lhs for momentum symm bc
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
AssembleMomentumElemSymmetrySolverAlgorithm::AssembleMomentumElemSymmetrySolverAlgorithm(
  Realm &realm,
  stk::mesh::Part *part,
  EquationSystem *eqSystem)
  : SolverAlgorithm(realm, part, eqSystem),
    includeDivU_(realm_.get_divU())
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  velocity_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  const std::string viscName = realm.is_turbulent()
    ? "effective_viscosity_u" : "viscosity";
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, viscName);
  exposedAreaVec_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "exposed_area_vector");
}
Пример #18
0
//==========================================================================
// Class Definition
//==========================================================================
// ScalarKeNSOElemSuppAlg - NSO for scalar equation
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
ScalarKeNSOElemSuppAlg::ScalarKeNSOElemSuppAlg(
  Realm &realm,
  ScalarFieldType *scalarQ,
  VectorFieldType *Gjq,
  const double turbCoeff,
  const double fourthFac)
  : SupplementalAlgorithm(realm),
    bulkData_(&realm.bulk_data()),
    scalarQNp1_(NULL),
    densityNp1_(NULL),
    pressure_(NULL),
    velocityNp1_(NULL),
    velocityRTM_(NULL),
    Gjq_(Gjq),
    Gjp_(NULL),
    coordinates_(NULL),
    nDim_(realm_.spatialDimension_),
    Cupw_(0.1),
    small_(1.0e-16),
    turbCoeff_(turbCoeff),
    fourthFac_(fourthFac)
{
  // save off fields; for non-BDF2 gather in state N for Nm1 (gamma3_ will be zero)
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  scalarQNp1_ = &(scalarQ->field_of_state(stk::mesh::StateNP1));
  pressure_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "pressure");
  densityNp1_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  velocityNp1_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");

  // check for mesh motion for proper velocity
  const bool meshMotion = realm_.does_mesh_move();
  if ( meshMotion )
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity_rtm");
  else
    velocityRTM_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");

  Gjp_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx");
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());

  // fixed size
  ws_rhoVrtmScs_.resize(nDim_);
  ws_uNp1Scs_.resize(nDim_);
  ws_dpdxScs_.resize(nDim_);
  ws_GjpScs_.resize(nDim_);
  ws_dkedxScs_.resize(nDim_);
}
Пример #19
0
bool Realm::contains(const Realm &other) const {

    if (std::find(_subrealm.begin(), _subrealm.end(), other) != _subrealm.end()) {
        return true;
    }

    if (other.dimension() < dimension()) {
        for (realm_container_type::const_iterator i = _subrealm.begin();
             i != _subrealm.end(); ++i) {
            if (i->contains(other)) {
                return true;
            }
        }
    }

    return false;
}
//==========================================================================
// Class Definition
//==========================================================================
// ComputeLowReynoldsSDRWallAlgorithm - low Re omega at wall bc; 
//                                      6*nu/(beta*yp^2)
// compute yp locally
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
ComputeLowReynoldsSDRWallAlgorithm::ComputeLowReynoldsSDRWallAlgorithm(
  Realm &realm,
  stk::mesh::Part *part,
  const bool &useShifted)
  : Algorithm(realm, part),
    useShifted_(useShifted),
    betaOne_(realm.get_turb_model_constant(TM_betaOne)),
    wallFactor_(1.0)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "viscosity");
  exposedAreaVec_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "exposed_area_vector");
  sdrBc_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "wall_model_sdr_bc");
  assembledWallArea_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "assembled_wall_area_sdr");
}
//==========================================================================
// Class Definition
//==========================================================================
// MomentumBuoyancySrcElemSuppAlgDep - CMM for momentum buoyancy (u-dof)
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
MomentumBuoyancySrcElemSuppAlgDep::MomentumBuoyancySrcElemSuppAlgDep(
  Realm &realm)
  : SupplementalAlgorithm(realm),
    bulkData_(&realm.bulk_data()),
    densityNp1_(NULL),
    coordinates_(NULL),
    nDim_(realm_.spatialDimension_),
    rhoRef_(0.0),
    useShifted_(false)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  ScalarFieldType *density = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  densityNp1_ = &(density->field_of_state(stk::mesh::StateNP1));
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  
  // extract user parameters from solution options
  gravity_.resize(nDim_);
  gravity_ = realm_.solutionOptions_->gravity_;
  rhoRef_ = realm_.solutionOptions_->referenceDensity_;
}
Пример #22
0
void RealmCoordinator::commit_write(Realm& realm)
{
    REALM_ASSERT(!m_config.read_only());
    REALM_ASSERT(realm.is_in_transaction());

    {
        // Need to acquire this lock before committing or another process could
        // perform a write and notify us before we get the chance to set the
        // skip version
        std::lock_guard<std::mutex> l(m_notifier_mutex);

        transaction::commit(Realm::Internal::get_shared_group(realm));

        // Don't need to check m_new_notifiers because those don't skip versions
        bool have_notifiers = std::any_of(m_notifiers.begin(), m_notifiers.end(),
                                          [&](auto&& notifier) { return notifier->is_for_realm(realm); });
        if (have_notifiers) {
            m_notifier_skip_version = Realm::Internal::get_shared_group(realm).get_version_of_current_transaction();
        }
    }

    if (realm.m_binding_context) {
        realm.m_binding_context->did_change({}, {});
    }

    if (m_notifier) {
        m_notifier->notify_others();
    }
#if REALM_ENABLE_SYNC
    if (m_sync_session) {
        auto& sg = Realm::Internal::get_shared_group(realm);
        auto version = LangBindHelper::get_version_of_latest_snapshot(sg);
        SyncSession::Internal::nonsync_transact_notify(*m_sync_session, version);
    }
#endif
}
Пример #23
0
Realm Realm::generateEmpty3DRealm() {
    Realm realm;
    realm.setDimension(3);
    return realm;
}
//==========================================================================
// Class Definition
//==========================================================================
// SurfaceForceAndMomentWallFunctionAlgorithm - post process sigma_ijnjdS and 
//                                  tau_wall via lumped nodal projection (area 
//                                  weighed) Driven by SurfaceForceAndMomentAlgDriver
//==========================================================================
//--------------------------------------------------------------------------
//-------- constructor -----------------------------------------------------
//--------------------------------------------------------------------------
SurfaceForceAndMomentWallFunctionAlgorithm::SurfaceForceAndMomentWallFunctionAlgorithm(
  Realm &realm,
  stk::mesh::PartVector &partVec,
  const std::string &outputFileName,
  const int &frequency,
  const std::vector<double > &parameters,
  const bool &useShifted)
  : Algorithm(realm, partVec),
    outputFileName_(outputFileName),
    frequency_(frequency),
    parameters_(parameters),
    useShifted_(useShifted),
    yplusCrit_(11.63),
    elog_(9.8),
    kappa_(realm.get_turb_model_constant(TM_kappa)),
    coordinates_(NULL),
    velocity_(NULL),
    pressure_(NULL),
    pressureForce_(NULL),
    tauWall_(NULL),
    yplus_(NULL),
    bcVelocity_(NULL),
    density_(NULL),
    viscosity_(NULL),
    wallFrictionVelocityBip_(NULL),
    wallNormalDistanceBip_(NULL),
    exposedAreaVec_(NULL),
    assembledArea_(NULL),
    w_(12)
{
  // save off fields
  stk::mesh::MetaData & meta_data = realm_.meta_data();
  coordinates_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, realm_.get_coordinates_name());
  velocity_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "velocity");
  pressure_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "pressure");
  pressureForce_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "pressure_force");
  tauWall_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "tau_wall");
  yplus_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "yplus");
  bcVelocity_ = meta_data.get_field<VectorFieldType>(stk::topology::NODE_RANK, "wall_velocity_bc");
  density_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "density");
  viscosity_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "viscosity");
  wallFrictionVelocityBip_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "wall_friction_velocity_bip");
  wallNormalDistanceBip_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "wall_normal_distance_bip");
  exposedAreaVec_ = meta_data.get_field<GenericFieldType>(meta_data.side_rank(), "exposed_area_vector");
  assembledArea_ = meta_data.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "assembled_area_force_moment_wf");

  // error check on params
  const size_t nDim = meta_data.spatial_dimension();
  if ( parameters_.size() > nDim )
    throw std::runtime_error("SurfaceForce: parameter length wrong; expect nDim");

  // make sure that the wall function params are registered
  if ( NULL == wallFrictionVelocityBip_ )
    throw std::runtime_error("SurfaceForce: wall friction velocity is not registered; wall bcs and post processing must be consistent");

  // deal with file name and banner
  if ( NaluEnv::self().parallel_rank() == 0 ) {
    std::ofstream myfile;
    myfile.open(outputFileName_.c_str());
    myfile << std::setw(w_) 
           << "Time" << std::setw(w_) 
           << "Fpx"  << std::setw(w_) << "Fpy" << std::setw(w_)  << "Fpz" << std::setw(w_) 
           << "Fvx"  << std::setw(w_) << "Fvy" << std::setw(w_)  << "Fxz" << std::setw(w_) 
           << "Mtx"  << std::setw(w_) << "Mty" << std::setw(w_)  << "Mtz" << std::setw(w_) 
           << "Y+min" << std::setw(w_) << "Y+max"<< std::endl;
    myfile.close();
  }
 }
Пример #25
0
static TableRef get_table(Realm& realm, const ObjectSchema &object_schema) {
    return ObjectStore::table_for_object_type(realm.read_group(), object_schema.name);
}
Пример #26
0
void Realm::Internal::begin_read(Realm& realm, VersionID version_id)
{
    realm.begin_read(version_id);
}