ComputeFullJacobianThread::ComputeFullJacobianThread(FEProblem & fe_problem, NonlinearSystem & sys, SparseMatrix<Number> & jacobian) :
    ComputeJacobianThread(fe_problem, sys, jacobian),
    _integrated_bcs(sys.getIntegratedBCWarehouse()),
    _dg_kernels(sys.getDGKernelWarehouse()),
    _kernels(sys.getKernelWarehouse())
{
}
예제 #2
0
ComputeJacobianThread::ComputeJacobianThread(FEProblem & fe_problem, NonlinearSystem & sys, SparseMatrix<Number> & jacobian) :
    ThreadedElementLoop<ConstElemRange>(fe_problem, sys),
    _jacobian(jacobian),
    _sys(sys),
    _num_cached(0),
    _integrated_bcs(sys.getIntegratedBCWarehouse()),
    _dg_kernels(sys.getDGKernelWarehouse()),
    _interface_kernels(sys.getInterfaceKernelWarehouse()),
    _kernels(sys.getKernelWarehouse())
{
}
예제 #3
0
void petscSetupDM (NonlinearSystem & nl) {
#if !PETSC_VERSION_LESS_THAN(3,3,0)
  PetscErrorCode  ierr;

  // Initialize the part of the DM package that's packaged with Moose; in the PETSc source tree this call would be in DMInitializePackage()
  ierr = DMMooseRegisterAll();
  CHKERRABORT(nl.comm().get(),ierr);
  // Create and set up the DM that will consume the split options and deal with block matrices.
  PetscNonlinearSolver<Number> *petsc_solver = dynamic_cast<PetscNonlinearSolver<Number> *>(nl.sys().nonlinear_solver.get());
  SNES snes = petsc_solver->snes();
  /* FIXME: reset the DM, do not recreate it anew every time? */
  DM dm = PETSC_NULL;
  ierr = DMCreateMoose(nl.comm().get(), nl, &dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMSetFromOptions(dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMSetUp(dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = SNESSetDM(snes,dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMDestroy(&dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = SNESSetUpdate(snes,SNESUpdateDMMoose);
  CHKERRABORT(nl.comm().get(),ierr);
#endif
}
예제 #4
0
ComputeDampingThread::ComputeDampingThread(FEProblem & feproblem,
                                           NonlinearSystem & sys) :
    ThreadedElementLoop<ConstElemRange>(feproblem, sys),
    _damping(1.0),
    _nl(sys),
    _dampers(sys.getDamperWarehouse())
{
}
예제 #5
0
파일: PetscSupport.C 프로젝트: garvct/Moose
void
petscSetupDM (NonlinearSystem & nl) {
#if !PETSC_VERSION_LESS_THAN(3,3,0)
  PetscErrorCode  ierr;
  PetscBool       ismoose;
  DM              dm = PETSC_NULL;

  // Initialize the part of the DM package that's packaged with Moose; in the PETSc source tree this call would be in DMInitializePackage()
  ierr = DMMooseRegisterAll();
  CHKERRABORT(nl.comm().get(),ierr);
  // Create and set up the DM that will consume the split options and deal with block matrices.
  PetscNonlinearSolver<Number> *petsc_solver = dynamic_cast<PetscNonlinearSolver<Number> *>(nl.sys().nonlinear_solver.get());
  SNES snes = petsc_solver->snes();
  // if there exists a DMMoose object, not to recreate a new one
  ierr = SNESGetDM(snes, &dm);
  CHKERRABORT(nl.comm().get(), ierr);
  if (dm)
  {
    ierr = PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose);
    CHKERRABORT(nl.comm().get(), ierr);
    if (ismoose)
      return;
  }
  ierr = DMCreateMoose(nl.comm().get(), nl, &dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMSetFromOptions(dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMSetUp(dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = SNESSetDM(snes,dm);
  CHKERRABORT(nl.comm().get(),ierr);
  ierr = DMDestroy(&dm);
  CHKERRABORT(nl.comm().get(),ierr);
  // We temporarily comment out this updating function because
  // we lack an approach to check if the problem
  // structure has been changed from the last iteration.
  // The indices will be rebuilt for every timestep.
  // TODO: figure out a way to check the structure changes of the
  // matrix
  // ierr = SNESSetUpdate(snes,SNESUpdateDMMoose);
  // CHKERRABORT(nl.comm().get(),ierr);
#endif
}
예제 #6
0
ComputeResidualThread::ComputeResidualThread(FEProblem & fe_problem, NonlinearSystem & sys, Moose::KernelType type) :
    ThreadedElementLoop<ConstElemRange>(fe_problem, sys),
    _sys(sys),
    _kernel_type(type),
    _num_cached(0),
    _integrated_bcs(sys.getIntegratedBCWarehouse()),
    _dg_kernels(sys.getDGKernelWarehouse()),
    _interface_kernels(sys.getInterfaceKernelWarehouse()),
    _kernels(sys.getKernelWarehouse()),
    _time_kernels(sys.getTimeKernelWarehouse()),
    _non_time_kernels(sys.getNonTimeKernelWarehouse())
{
}
예제 #7
0
int main( )
{
    const size_t systemSize = 2;

    // Declare equations of system.

    NonlinearSystem<systemSize> sys;
    equation_type eq1 = []( const vector_type& x) {
        return 1.0 - x[0];
    };
    sys.assign_equation( eq1, 0);
    equation_type eq2 = []( const vector_type& x) {
        return 10 * (x[1] - x[0] * x[0] );
    };
    sys.assign_equation( eq2, 1 );

    // Now intialize the system with initial input vector x..
    array<double, systemSize> init = { -10, -5 };
    sys.initialize( init );

    cout << sys.to_string() << endl;
    sys.find_roots_gnewton( );
    cout << sys.to_string() << endl;
    

    // Another system
    eq1 = []( const vector_type& x) {
        return 1.0 - sin(x[0]);
    };
    sys.assign_equation( eq1, 0);
    eq2 = []( const vector_type& x) {
        return 10 * cos(x[1]);
    };
    sys.assign_equation( eq2, 1 );

    // Now intialize the system with initial input vector x..
    init = { -10, -5 };
    sys.initialize( init );

    cout << sys.to_string() << endl;
    sys.find_roots_gnewton( );
    cout << sys.to_string() << endl;

    cerr << " A system with 3-dimen" << endl;
    NonlinearSystem<3> sys3;
    equation_type e1 = []( const vector_type& x) {
        return 3*x[0] - cos( x[1] * x[2] ) - 1.5;
    };
    equation_type e2 = []( const vector_type& x) {
        return 4*x[0]*x[0] - 625* x[1] * x[1] + 2*x[1]- 1;
    };
    equation_type e3 = []( const vector_type& x) {
        return exp(- x[0] * x[1]) + 20 * x[2] + (31.1416 - 3)/3 ;
    };

    sys3.assign_equation( e1, 0 );
    sys3.assign_equation( e2, 1 );
    sys3.assign_equation( e3, 2 );

    array< double, 3> init3 = {{ 0.0, 0.0, 0.0 }};
    sys3.initialize( init3 );

    sys3.find_roots_gnewton( );
    cout  << sys3.to_string() << endl;

    // Another system
    NonlinearSystem<2> sA;
    

    return 0;
}