コード例 #1
0
ファイル: GodunovTrace.cpp プロジェクト: rsnemmen/Chombo
void TraceState(/// state at time t+dt/2 on edges in direction dir
                FArrayBox& a_stateHalf,
                /// cell-centered state at time t
                const FArrayBox& a_state,
                /// cell-centered velocity at time t
                const FArrayBox& a_cellVel,
                /// edge-centered advection velocity at time t+dt/2
                const FluxBox& a_advectionVel,
                /// cell-centered source
                const FArrayBox& a_source,
                /// Physical domain
                const ProblemDomain& a_dProblem,
                /// interior of grid patch
                const Box& a_gridBox,
                /// timeStep
                const Real a_dt,
                /// cell-spacing
                const Real a_dx,
                /// direction in which to perform tracing
                const int a_dir,
                /// which components to trace
                const Interval& a_srcComps,
                ///  where to put traced components in a_stateHalf,
                const Interval& a_destComps)

{

  int ncomp = a_srcComps.size();
  CH_assert (ncomp == a_destComps.size());
  int offset = a_destComps.begin() - a_srcComps.begin();
  Box edgeBox = a_gridBox;
  edgeBox.surroundingNodes(a_dir);

#ifdef SIMPLEUPWIND
  // simple cell-to-edge averaging may be causing us problems --
  // instead do simple upwinding

  for (int comp=a_srcComps.begin(); comp <= a_srcComps.end(); comp++)
  {
    int destcomp = comp+offset;
    FORT_UPWINDCELLTOEDGE(CHF_FRA1(a_stateHalf, destComp),
                          CHF_CONST_FRA1(a_state,comp),
                          CHF_CONST_FRA(a_advectionVel[a_dir]),
                          CHF_BOX(edgeBox),
                          CHF_CONST_INT(a_dir));
  }

#else


  // first compute slopes
  Box slopesBox = grow(a_gridBox,1);

  // these are debugging changes to sync with old code
#ifdef MATCH_OLDCODE
  FluxBox tempEdgeVel(slopesBox,1);
  tempEdgeVel.setVal(0.0);

  FArrayBox tempCellVel(slopesBox,SpaceDim);
  tempCellVel.setVal(0.0);


  CellToEdge(a_cellVel, tempEdgeVel);
  EdgeToCell(tempEdgeVel, tempCellVel);
  tempEdgeVel.clear(); // done with this, so reclaim memory
  EdgeToCell(a_advectionVel, tempCellVel);
#endif

  FArrayBox delS(slopesBox,1);
  FArrayBox sHat(slopesBox,1);
  FArrayBox sTilde(a_state.box(),1);

  for (int comp=a_srcComps.begin(); comp<=a_srcComps.end(); comp++)
  {
    int destComp = comp+offset;

#ifdef SET_BOGUS_VALUES
    delS.setVal(BOGUS_VALUE);
    sHat.setVal(BOGUS_VALUE);
    sTilde.setVal(BOGUS_VALUE);
#endif

    // compute van leer limited slopes in the normal direction
    // for now, always limit slopes, although might want to make
    // this a parameter
    int limitSlopes = 1;
    FORT_SLOPES(CHF_FRA1(delS,0),
                CHF_CONST_FRA1(a_state,comp),
                CHF_BOX(slopesBox),
                CHF_CONST_INT(a_dir),
                CHF_CONST_INT(limitSlopes));

    // this is a way to incorporate the minion correction --
    // stateTilde = state + (dt/2)*source
    sTilde.copy(a_source,comp,0,1);
    Real sourceFactor = a_dt/2.0;
    sTilde *= sourceFactor;
    sTilde.plus(a_state, comp,0,1);
    sHat.copy(sTilde,slopesBox);

    // now loop over directions, adding transverse components
    for (int localDir=0; localDir < SpaceDim; localDir++)
    {
      if (localDir != a_dir)
      {
        // add simple transverse components
        FORT_TRANSVERSE(CHF_FRA1(sHat,0),
                        CHF_CONST_FRA1(sTilde,0),
#ifdef MATCH_OLDCODE
                        CHF_CONST_FRA1(tempCellVel, localDir),
#else
                        CHF_CONST_FRA1(a_cellVel,localDir),
#endif
                        CHF_BOX(slopesBox),
                        CHF_CONST_REAL(a_dt),
                        CHF_CONST_REAL(a_dx),
                        CHF_CONST_INT(localDir));
                        //CHF_FRA1(temp,0));  // not used in function

      }
      else if (SpaceDim == 3)
      {
        // only add cross derivative transverse piece if we're in 3D
        // note that we need both components of velocity for this one
        FORT_TRANSVERSECROSS(CHF_FRA1(sHat,0),
                             CHF_CONST_FRA1(sTilde,0),
                             CHF_CONST_FRA(a_cellVel),
                             CHF_BOX(slopesBox),
                             CHF_CONST_REAL(a_dt),
                             CHF_CONST_REAL(a_dx),
                             CHF_CONST_INT(localDir));
      }
    } // end loop over directions

    // now compute left and right states and resolve the Reimann
    // problem to get single set of edge-centered values
    FORT_PREDICT(CHF_FRA1(a_stateHalf,destComp),
                 CHF_CONST_FRA1(sHat,0),
                 CHF_CONST_FRA1(delS,0),
                 CHF_CONST_FRA1(a_cellVel,a_dir),
                 CHF_CONST_FRA1(a_advectionVel[a_dir],0),
                 CHF_BOX(edgeBox),
                 CHF_CONST_REAL(a_dt),
                 CHF_CONST_REAL(a_dx),
                 CHF_CONST_INT(a_dir));
  } // end loop over components

#endif


}
コード例 #2
0
ファイル: PLC_LSH.C プロジェクト: Liuux/moose
void
PLC_LSH::computeStress()
{
  // Given the stretching, compute the stress increment and add it to the old stress. Also update the creep strain
  // stress = stressOld + stressIncrement
  // creep_strain = creep_strainOld + creep_strainIncrement

  if (_t_step == 0 && !_app.isRestarting())
    return;

  if (_output_iteration_info == true)
  {
    _console
      << std::endl
      << "iteration output for combined creep-plasticity solve:"
      << " time=" <<_t
      << " temperature=" << _temperature[_qp]
      << " int_pt=" << _qp
      << std::endl;
  }

  // compute trial stress
  SymmTensor stress_new( *elasticityTensor() * _strain_increment );
  stress_new += _stress_old;

  SymmTensor creep_strain_increment;
  SymmTensor plastic_strain_increment;
  SymmTensor elastic_strain_increment;
  SymmTensor stress_new_last( stress_new );
  Real delS(_absolute_stress_tolerance+1);
  Real first_delS(delS);
  unsigned int counter(0);

  while (counter < _max_its &&
        delS > _absolute_stress_tolerance &&
        (delS/first_delS) > _relative_tolerance)
  {
    elastic_strain_increment = _strain_increment;
    elastic_strain_increment -= plastic_strain_increment;
    stress_new = *elasticityTensor() * elastic_strain_increment;
    stress_new += _stress_old;

    elastic_strain_increment = _strain_increment;
    computeCreep( elastic_strain_increment, creep_strain_increment, stress_new );

    // now use stress_new to calculate a new effective_trial_stress and determine if
    // yield has occured and if so, calculate the corresponding plastic strain

    elastic_strain_increment -= creep_strain_increment;

    computeLSH( elastic_strain_increment, plastic_strain_increment, stress_new );

    elastic_strain_increment -= plastic_strain_increment;

    // now check convergence
    SymmTensor deltaS(stress_new_last - stress_new);
    delS = std::sqrt(deltaS.doubleContraction(deltaS));
    if (counter == 0)
    {
      first_delS = delS;
    }
    stress_new_last = stress_new;

    if (_output_iteration_info == true)
    {
      _console
        << "stress_it=" << counter
        << " rel_delS=" << delS/first_delS
        << " rel_tol="  << _relative_tolerance
        << " abs_delS=" << delS
        << " abs_tol="  << _absolute_stress_tolerance
        << std::endl;
    }

    ++counter;
  }

  if (counter == _max_its &&
     delS > _absolute_stress_tolerance &&
     (delS/first_delS) > _relative_tolerance)
  {
    mooseError("Max stress iteration hit during plasticity-creep solve!");
  }

  _strain_increment = elastic_strain_increment;
  _stress[_qp] = stress_new;

}
コード例 #3
0
void
CombinedCreepPlasticity::computeStress( const Elem & current_elem,
                                        unsigned qp, const SymmElasticityTensor & elasticityTensor,
                                        const SymmTensor & stress_old, SymmTensor & strain_increment,
                                        SymmTensor & stress_new )
{
    // Given the stretching, compute the stress increment and add it to the old stress. Also update the creep strain
    // stress = stressOld + stressIncrement
    // creep_strain = creep_strainOld + creep_strainIncrement

    if(_t_step == 0) return;

    if (_output_iteration_info == true)
    {
        Moose::out
                << std::endl
                << "iteration output for CombinedCreepPlasticity solve:"
                << " time=" <<_t
                << " temperature=" << _temperature[qp]
                << " int_pt=" << qp
                << std::endl;
    }

    // compute trial stress
    stress_new = elasticityTensor * strain_increment;
    stress_new += stress_old;

    const SubdomainID current_block = current_elem.subdomain_id();
    const std::vector<ReturnMappingModel*> & rmm( _submodels[current_block] );
    const unsigned num_submodels = rmm.size();

    SymmTensor inelastic_strain_increment;

    SymmTensor elastic_strain_increment;
    SymmTensor stress_new_last( stress_new );
    Real delS(_absolute_tolerance+1);
    Real first_delS(delS);
    unsigned int counter(0);

    while(counter < _max_its &&
            delS > _absolute_tolerance &&
            (delS/first_delS) > _relative_tolerance &&
            (num_submodels != 1 || counter < 1))
    {
        elastic_strain_increment = strain_increment;
        stress_new = elasticityTensor * (elastic_strain_increment - inelastic_strain_increment);
        stress_new += stress_old;

        for (unsigned i_rmm(0); i_rmm < num_submodels; ++i_rmm)
        {
            rmm[i_rmm]->computeStress( current_elem, qp, elasticityTensor, stress_old, elastic_strain_increment,
                                       stress_new, inelastic_strain_increment );
        }

        // now check convergence
        SymmTensor deltaS(stress_new_last - stress_new);
        delS = std::sqrt(deltaS.doubleContraction(deltaS));
        if (counter == 0)
        {
            first_delS = delS;
        }
        stress_new_last = stress_new;

        if (_output_iteration_info == true)
        {
            Moose::out
                    << "stress_it=" << counter
                    << " rel_delS=" << (0 == first_delS ? 0 : delS/first_delS)
                    << " rel_tol="  << _relative_tolerance
                    << " abs_delS=" << delS
                    << " abs_tol="  << _absolute_tolerance
                    << std::endl;
        }

        ++counter;
    }

    if(counter == _max_its &&
            delS > _absolute_tolerance &&
            (delS/first_delS) > _relative_tolerance)
    {
        mooseError("Max stress iteration hit during CombinedCreepPlasticity solve!");
    }

    strain_increment = elastic_strain_increment;

}