Пример #1
0
int sipg_sem_1d<FLOAT_TYPE>::solve()
{

  stiffness_matrix_generation.start(); // start timer  
  compute_stiffness_matrix();
  stiffness_matrix_generation.stop();  // stop timer


  compute_rhs_vector();



#ifdef USE_LAPACK

  std::vector<int> ipiv(_vec_size,0); // pivot
  _u = _rhs;

  linear_system_solution.start(); // start timer

  int info = lapacke_gesv( LAPACK_ROW_MAJOR,
                           _vec_size,
                           1,
                            _A.data(),
                           _vec_size,
                           ipiv.data(),
                           _u.data(),
                           1                );

#else

  ConjugateGradient<Eigen::SparseMatrix<FLOAT_TYPE> > cg;
  cg.compute(_A);
  _u = cg.solve(_rhs);
 
#endif


  linear_system_solution.stop(); // stop timer 

  compute_err_norms();

  return info;

}
Пример #2
0
  void ATC_TransferThermal::post_final_integrate()
  {
    //ATC_Transfer::post_final_integrate();
    double dt = lammpsInterface_->dt();
    double dtLambda = dt*0.5;
    // predict thermostat contributions
    // compute sources based on predicted FE temperature
    prescribedDataMgr_->set_sources(simTime_+.5*dt,sources_);
    extrinsicModelManager_.set_sources(fields_,extrinsicSources_);
    thermostat_.compute_boundary_flux(fields_);
    compute_atomic_sources(temperatureMask_,fields_,atomicSources_);
    thermostat_.apply_pre_corrector(dtLambda,lammpsInterface_->ntimestep());

    // Determine FE contributions to d theta/dt    
    // Compute atom-integrated rhs
    // parallel communication happens within FE_Engine
    compute_rhs_vector(temperatureMask_,fields_,rhs_,FE_DOMAIN);

    // For flux matching, add 1/2 of "drag" power
    thermostat_.add_to_rhs(rhs_);

    extrinsicModelManager_.post_final_integrate();
    // add in atomic FE contributions for verlet method
    if (integrationType_==TimeIntegrator::VERLET) {
      DENS_MAT atomicPower(nLocal_,1);
      compute_atomic_power(atomicPower,
                           lammpsInterface_->vatom(),
                           lammpsInterface_->fatom());
      DENS_MAT nodalAtomicPower(nNodes_,1);
      restrict_volumetric_quantity(atomicPower,nodalAtomicPower);
      nodalAtomicPower *= 2.;

      if (timeFilterManager_.filter_variables())
        update_filter_implicit(fieldRateNdFiltered_[TEMPERATURE],nodalAtomicPower,dt);
      else
        fieldRateNdFiltered_[TEMPERATURE] = nodalAtomicPower;
      if (!timeFilterManager_.filter_variables() || timeFilterManager_.filter_dynamics())
        rhs_[TEMPERATURE] += fieldRateNdFiltered_[TEMPERATURE];
      else
        rhs_[TEMPERATURE] += nodalAtomicPower;
    }
 
    // Finish updating temperature
    DENS_MAT R_theta(nNodes_,1);
    apply_inverse_mass_matrix(rhs_[TEMPERATURE],TEMPERATURE);
    R_theta = (rhs_[TEMPERATURE] - dot_fields_[TEMPERATURE])*dt;
    if (timeFilterManager_.filter_dynamics())
      gear1_4_correct(fields_[TEMPERATURE],dot_fields_[TEMPERATURE],
                      ddot_fields_[TEMPERATURE],dddot_fields_[TEMPERATURE],
                      R_theta,dt);
    else
      gear1_3_correct(fields_[TEMPERATURE],dot_fields_[TEMPERATURE],
                      ddot_fields_[TEMPERATURE],R_theta,dt);

    // only requirecd for poor man's fractional step
    if (pmfcOn_) {
      DENS_MAT atomicKineticEnergy(nLocal_,1);
      compute_atomic_kinetic_energy(atomicKineticEnergy,
				    lammpsInterface_->vatom());
      DENS_MAT temperatureNd(nNodes_,1);
      project_md_volumetric_quantity(atomicKineticEnergy,
				     temperatureNd,
				     TEMPERATURE);
      temperatureNd *= 2.;
      dot_fields_[TEMPERATURE] = 1.0/dt * ( temperatureNd - oldFieldTemp_); 
      fields_[TEMPERATURE] = temperatureNd;
    }

    // fix nodes, non-group bcs applied through FE
    set_fixed_nodes();

    // compute sources based on final FE updates
    prescribedDataMgr_->set_sources(simTime_+.5*dt,sources_);
    extrinsicModelManager_.set_sources(fields_,extrinsicSources_);
    thermostat_.compute_boundary_flux(fields_);
    compute_atomic_sources(temperatureMask_,fields_,atomicSources_);

    // apply corrector phase of thermostat
    thermostat_.apply_post_corrector(dtLambda,lammpsInterface_->ntimestep());

    // add in MD contributions to time derivative
    // update filtered temperature
    DENS_MAT atomicKineticEnergy(nLocal_,1);
    compute_atomic_kinetic_energy(atomicKineticEnergy, 
                                  lammpsInterface_->vatom());
    DENS_MAT temperatureNd(nNodes_,1);
    project_md_volumetric_quantity(atomicKineticEnergy,temperatureNd,TEMPERATURE);
    temperatureNd *= 2.;
    if (!timeFilterManager_.filter_dynamics()) 
      fieldNdFiltered_[TEMPERATURE] = temperatureNd;
    else if (integrationType_==TimeIntegrator::VERLET)
      update_filter_implicit(fieldNdFiltered_[TEMPERATURE],temperatureNd,dt);

    simTime_ += .5*dt;
    output();
  }