20 <<
": Initializing Diffusion solver ";
29 auto sdm_string =
basic_options_(
"discretization_method").StringValue();
32 if (sdm_string ==
"PWLC")
39 else if (sdm_string ==
"PWLD_MIP")
47 throw std::invalid_argument(
TextName() +
48 ": Invalid spatial discretization method, " +
49 sdm_string +
", specified.");
53 for (
const auto& cell :
grid_ptr_->local_cells)
60 const auto ghost_global_ids =
grid_ptr_->cells.GetGhostGlobalIDs();
61 for (
const uint64_t global_id : ghost_global_ids)
63 const auto& cell_mapping =
83 std::string solver_name;
86 std::string text_name = solver_name +
"phi";
89 auto initial_field_function =
90 std::make_shared<chi_physics::FieldFunctionGridBased>(
101 std::vector<int64_t> nodal_nnz_in_diag;
102 std::vector<int64_t> nodal_nnz_off_diag;
103 sdm->BuildSparsityPattern(
107 <<
": Diffusion Solver initialization time "
108 << t_init.
GetTime() / 1000.0 << std::endl;
111 ierr_ = VecCreate(PETSC_COMM_WORLD, &
x_);
113 ierr_ = PetscObjectSetName((PetscObject)
x_,
"Solution");
119 ierr_ = VecSetType(
x_, VECMPI);
128 ierr_ = MatCreate(PETSC_COMM_WORLD, &
A_);
136 ierr_ = MatSetType(
A_, MATMPIAIJ);
141 MatMPIAIJSetPreallocation(
142 A_, 0, nodal_nnz_in_diag.data(), 0, nodal_nnz_off_diag.data());
143 MatSetOption(
A_, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
144 MatSetOption(
A_, MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
148 ierr_ = KSPCreate(PETSC_COMM_WORLD, &
ksp_);
154 PCSetType(
pc_, PCHYPRE);
156 PCHYPRESetType(
pc_,
"boomeramg");
163 auto first_cell = &
grid_ptr_->local_cells[0];
167 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_agg_nl 1");
168 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_P_max 4");
169 PetscOptionsInsertString(
nullptr,
170 "-pc_hypre_boomeramg_grid_sweeps_coarse 1");
172 PetscOptionsInsertString(
nullptr,
173 "-pc_hypre_boomeramg_grid_sweeps_coarse 1");
174 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_max_levels 25");
175 PetscOptionsInsertString(
176 nullptr,
"-pc_hypre_boomeramg_relax_type_all symmetric-SOR/Jacobi");
177 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_coarsen_type HMIS");
178 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_interp_type ext+i");
180 PetscOptionsInsertString(
nullptr,
"-options_left");
184 PetscOptionsInsertString(
nullptr,
185 "-pc_hypre_boomeramg_strong_threshold 0.6");
188 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_P_max 4");
190 PetscOptionsInsertString(
nullptr,
191 "-pc_hypre_boomeramg_grid_sweeps_coarse 1");
192 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_max_levels 25");
193 PetscOptionsInsertString(
194 nullptr,
"-pc_hypre_boomeramg_relax_type_all symmetric-SOR/Jacobi");
195 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_coarsen_type HMIS");
196 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_interp_type ext+i");
198 PetscOptionsInsertString(
nullptr,
"-options_left");
202 PetscOptionsInsertString(
nullptr,
203 "-pc_hypre_boomeramg_strong_threshold 0.8");
205 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_agg_nl 1");
206 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_P_max 4");
208 PetscOptionsInsertString(
nullptr,
209 "-pc_hypre_boomeramg_grid_sweeps_coarse 1");
210 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_max_levels 25");
211 PetscOptionsInsertString(
212 nullptr,
"-pc_hypre_boomeramg_relax_type_all symmetric-SOR/Jacobi");
213 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_coarsen_type HMIS");
214 PetscOptionsInsertString(
nullptr,
"-pc_hypre_boomeramg_interp_type ext+i");
217 PCSetFromOptions(
pc_);
224 KSPSetConvergenceTest(
232 ierr_ = KSPSetInitialGuessNonzero(
ksp_, PETSC_TRUE);
static std::vector< chi_physics::FieldFunctionPtr > field_function_stack
static chi::Timer program_timer
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
std::string GetTimeString() const
std::map< uint64_t, UnitIntegralContainer > unit_integrals_
void Initialize() override
chi_mesh::MeshContinuumPtr grid_ptr_
void InitializeCommonItems()
bool common_items_initialized_
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
std::string options_string_
chi_math::UnknownManager unknown_manager_
static UnitIntegralContainer Make(const chi_math::CellMapping &cell_mapping)
unsigned int AddUnknown(UnknownType unk_type, unsigned int dimension=0)
static std::shared_ptr< PieceWiseLinearContinuous > New(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order=QuadratureOrder::SECOND, CoordinateSystemType cs_type=CoordinateSystemType::CARTESIAN)
static std::shared_ptr< PieceWiseLinearDiscontinuous > New(const chi_mesh::MeshContinuum &grid, QuadratureOrder q_order=QuadratureOrder::SECOND, CoordinateSystemType cs_type=CoordinateSystemType::CARTESIAN)
std::vector< std::shared_ptr< FieldFunctionGridBased > > field_functions_
std::string TextName() const
BasicOptions basic_options_
PetscErrorCode DiffusionConvergenceTestNPT(KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *convergedReason, void *monitordestroy)
PetscErrorCode KSPMonitorAChiTech(KSP ksp, PetscInt n, PetscReal rnorm, void *monitordestroy)