コード例 #1
0
ファイル: PetscSupport.C プロジェクト: AhmedAly83/moose
void
petscSetOptions(FEProblem & problem)
{
  // Reference to the options stored in FEPRoblem
  PetscOptions & petsc = problem.getPetscOptions();

  if (petsc.inames.size() != petsc.values.size())
    mooseError("PETSc names and options are not the same length");

  PetscOptionsClear();

  { // Get any options specified on the command-line
    int argc;
    char ** args;

    PetscGetArgs(&argc, &args);
    PetscOptionsInsert(&argc, &args, NULL);
  }

  setSolverOptions(problem.solverParams());

  // Add any additional options specified in the input file
  for (MooseEnumIterator it = petsc.flags.begin(); it != petsc.flags.end(); ++it)
    PetscOptionsSetValue(it->c_str(), PETSC_NULL);
  for (unsigned int i=0; i<petsc.inames.size(); ++i)
    PetscOptionsSetValue(petsc.inames[i].c_str(), petsc.values[i].c_str());

  SolverParams& solver_params = problem.solverParams();
  if (solver_params._type != Moose::ST_JFNK  &&
      solver_params._type != Moose::ST_FD &&
      !problem.getNonlinearSystem().haveFiniteDifferencedPreconditioner() &&
      problem.getNonlinearSystem().haveDecomposition())
  {
    // Set up DM only if have a decomposition. Additionally, turn DM OFF if not using FD-based solvers,
    // (both -snes_mf and -snes_fd) and FDP. This is all rather crufty, but what's a good generic rule here?
    // In principle at least, splits should be able to work with ST_FD (-snes_fd) and FDP (a coloring-based
    // version of -snes_fd), but one has to be careful about the initialization order so as not to override
    // SNESComputeJacobianDefaultColor() set up by FDP, for instance.  However, it's unlikely that splits
    // will be used when running an FD solver (debugging).
    problem.getNonlinearSystem().setupDecomposition();
    petscSetupDM(problem.getNonlinearSystem());
  } else {
    // Otherwise turn off the decomposition
    std::vector<std::string> nosplits;
    problem.getNonlinearSystem().setDecomposition(nosplits);
  }

}
コード例 #2
0
ファイル: PetscSupport.C プロジェクト: garvct/Moose
void
petscSetOptions(FEProblem & problem)
{
  // Reference to the options stored in FEPRoblem
  PetscOptions & petsc = problem.getPetscOptions();

  if (petsc.inames.size() != petsc.values.size())
    mooseError("PETSc names and options are not the same length");

#if PETSC_VERSION_LESS_THAN(3,7,0)
  PetscOptionsClear();
#else
  PetscOptionsClear(PETSC_NULL);
#endif

  setSolverOptions(problem.solverParams());

  // Add any additional options specified in the input file
  for (const auto & flag : petsc.flags)
    setSinglePetscOption(flag.c_str());
  for (unsigned int i=0; i<petsc.inames.size(); ++i)
    setSinglePetscOption(petsc.inames[i], petsc.values[i]);

  // set up DM which is required if use a field split preconditioner
  if (problem.getNonlinearSystem().haveFieldSplitPreconditioner())
    petscSetupDM(problem.getNonlinearSystem());

  // commandline options always win
  // the options from a user commandline will overwrite the existing ones if any conflicts
  { // Get any options specified on the command-line
    int argc;
    char ** args;

    PetscGetArgs(&argc, &args);
#if PETSC_VERSION_LESS_THAN(3,7,0)
    PetscOptionsInsert(&argc, &args, NULL);
#else
    PetscOptionsInsert(PETSC_NULL, &argc, &args, NULL);
#endif
  }
}