Пример #1
0
void
SetupMeshCompleteAction::act()
{
  if (!_mesh)
    mooseError("No mesh file was supplied and no generation block was provided");

  if (_current_task == "execute_mesh_modifiers")
  {
    // we don't need to run mesh modifiers *again* after they ran already during the mesh
    // splitting process
    if (_app.isUseSplit())
      return;
    _app.executeMeshModifiers();
  }
  else if (_current_task == "uniform_refine_mesh")
  {
    // we don't need to run mesh modifiers *again* after they ran already during the mesh
    // splitting process
    if (_app.isUseSplit())
      return;

    /**
     * If possible we'd like to refine the mesh here before the equation systems
     * are setup to avoid doing expensive projections. If however we are doing a
     * file based restart and we need uniform refinements, we'll have to postpone
     * those refinements until after the solution has been read in.
     */
    if (_app.setFileRestart() == false && _app.isRecovering() == false)
    {
      if (_mesh->uniformRefineLevel())
      {
        TIME_SECTION(_uniform_refine_timer);

        Adaptivity::uniformRefine(_mesh.get());

        if (_displaced_mesh)
          Adaptivity::uniformRefine(_displaced_mesh.get());
      }
    }
  }
  else
  {
    // Prepare the mesh (may occur multiple times)
    completeSetup(_mesh.get());

    if (_displaced_mesh)
      completeSetup(_displaced_mesh.get());
  }
}
Пример #2
0
bool CppCompiler::compile()
{
    if (abortChecker && abortChecker->abortRequested())
        return false;

    TIME_SECTION(!verbose ? NULL : onlyCompile ? "compile" : "compile/link");

    Owned<IThreadPool> pool = createThreadPool("CCompilerWorker", this, NULL, maxCompileThreads?maxCompileThreads:1, INFINITE);
    addCompileOption(COMPILE_ONLY[targetCompiler]);

    bool ret = false;
    Semaphore finishedCompiling;
    int numSubmitted = 0;
    numFailed.store(0);

    ForEachItemIn(i0, allSources)
    {
        ret = compileFile(pool, allSources.item(i0), finishedCompiling);
        if (!ret)
            break;
        ++numSubmitted;
    }
Пример #3
0
void
AuxiliarySystem::computeScalarVars(ExecFlagType type)
{
  setScalarVariableCoupleableTags(type);

  // Reference to the current storage container
  const MooseObjectWarehouse<AuxScalarKernel> & storage = _aux_scalar_storage[type];

  if (storage.hasActiveObjects())
  {
    TIME_SECTION(_compute_scalar_vars_timer);

    PARALLEL_TRY
    {
      // FIXME: run multi-threaded
      THREAD_ID tid = 0;
      if (storage.hasActiveObjects())
      {
        _fe_problem.reinitScalars(tid);

        // Call compute() method on all active AuxScalarKernel objects
        const std::vector<std::shared_ptr<AuxScalarKernel>> & objects =
            storage.getActiveObjects(tid);
        for (const auto & obj : objects)
          obj->compute();

        const std::vector<MooseVariableScalar *> & scalar_vars = getScalarVariables(tid);
        for (const auto & var : scalar_vars)
          var->insert(solution());
      }
    }
    PARALLEL_CATCH;

    solution().close();
    _sys.update();
  }
Пример #4
0
void
PhysicsBasedPreconditioner::init()
{
  TIME_SECTION(_init_timer);

  // Tell libMesh that this is initialized!
  _is_initialized = true;

  const unsigned int num_systems = _systems.size();

  // If no order was specified, just solve them in increasing order
  if (_solve_order.size() == 0)
  {
    _solve_order.resize(num_systems);
    for (unsigned int i = 0; i < num_systems; i++)
      _solve_order[i] = i;
  }

  // Loop over variables
  for (unsigned int system_var = 0; system_var < num_systems; system_var++)
  {
    LinearImplicitSystem & u_system = *_systems[system_var];

    if (!_preconditioners[system_var])
      _preconditioners[system_var] =
          Preconditioner<Number>::build_preconditioner(MoosePreconditioner::_communicator);

    // we have to explicitly set the matrix in the preconditioner, because h-adaptivity could have
    // changed it and we have to work with the current one
    Preconditioner<Number> * preconditioner = _preconditioners[system_var].get();
    preconditioner->set_matrix(*u_system.matrix);
    preconditioner->set_type(_pre_type[system_var]);

    preconditioner->init();
  }
}
Пример #5
0
void
Steady::execute()
{
  if (_app.isRecovering())
    return;

  _time_step = 0;
  _time = _time_step;
  _problem.outputStep(EXEC_INITIAL);
  _time = _system_time;

  preExecute();

  _problem.advanceState();

  // first step in any steady state solve is always 1 (preserving backwards compatibility)
  _time_step = 1;

#ifdef LIBMESH_ENABLE_AMR

  // Define the refinement loop
  unsigned int steps = _problem.adaptivity().getSteps();
  for (unsigned int r_step = 0; r_step <= steps; r_step++)
  {
#endif // LIBMESH_ENABLE_AMR
    _problem.timestepSetup();

    _last_solve_converged = _picard_solve.solve();

    if (!lastSolveConverged())
    {
      _console << "Aborting as solve did not converge\n";
      break;
    }

    _problem.computeIndicators();
    _problem.computeMarkers();

    // need to keep _time in sync with _time_step to get correct output
    _time = _time_step;
    _problem.outputStep(EXEC_TIMESTEP_END);
    _time = _system_time;

#ifdef LIBMESH_ENABLE_AMR
    if (r_step != steps)
    {
      _problem.adaptMesh();
    }

    _time_step++;
  }
#endif

  {
    TIME_SECTION(_final_timer)
    _problem.execute(EXEC_FINAL);
    _time = _time_step;
    _problem.outputStep(EXEC_FINAL);
    _time = _system_time;
  }

  postExecute();
}
Пример #6
0
void
PhysicsBasedPreconditioner::apply(const NumericVector<Number> & x, NumericVector<Number> & y)
{
  TIME_SECTION(_apply_timer);

  const unsigned int num_systems = _systems.size();

  MooseMesh & mesh = _fe_problem.mesh();

  // Zero out the solution vectors
  for (unsigned int sys = 0; sys < num_systems; sys++)
    _systems[sys]->solution->zero();

  // Loop over solve order
  for (unsigned int i = 0; i < _solve_order.size(); i++)
  {
    unsigned int system_var = _solve_order[i];

    LinearImplicitSystem & u_system = *_systems[system_var];

    // Copy rhs from the big system into the small one
    MoosePreconditioner::copyVarValues(
        mesh, _nl.system().number(), system_var, x, u_system.number(), 0, *u_system.rhs);

    // Modify the RHS by subtracting off the matvecs of the solutions for the other preconditioning
    // systems with the off diagonal blocks in this system.
    for (unsigned int diag = 0; diag < _off_diag[system_var].size(); diag++)
    {
      unsigned int coupled_var = _off_diag[system_var][diag];
      LinearImplicitSystem & coupled_system = *_systems[coupled_var];
      SparseMatrix<Number> & off_diag = *_off_diag_mats[system_var][diag];
      NumericVector<Number> & rhs = *u_system.rhs;

      // This next bit computes rhs -= A*coupled_solution
      // It does what it does because there is no vector_mult_sub()
      rhs.close();
      rhs.scale(-1.0);
      rhs.close();
      off_diag.vector_mult_add(rhs, *coupled_system.solution);
      rhs.close();
      rhs.scale(-1.0);
      rhs.close();
    }

    // Apply the preconditioner to the small system
    _preconditioners[system_var]->apply(*u_system.rhs, *u_system.solution);

    // Copy solution from small system into the big one
    // copyVarValues(mesh,system,0,*u_system.solution,0,system_var,y);
  }

  // Copy the solutions out
  for (unsigned int system_var = 0; system_var < num_systems; system_var++)
  {
    LinearImplicitSystem & u_system = *_systems[system_var];

    MoosePreconditioner::copyVarValues(
        mesh, u_system.number(), 0, *u_system.solution, _nl.system().number(), system_var, y);
  }

  y.close();
}