[Multivec 4/5]: BoomerAMG partially supports vector with multiple components (#695)
* Extend BoomerAMG with L1-Jacobi to vector with multiple components. * Add ParVectorSetLocalSize calls to MGR.
This commit is contained in:
parent
71cdcc89f7
commit
ce3ecb0daf
@ -523,376 +523,343 @@ HYPRE_Int
|
||||
hypre_BoomerAMGDestroy( void *data )
|
||||
{
|
||||
hypre_ParAMGData *amg_data = (hypre_ParAMGData*) data;
|
||||
HYPRE_Int num_levels = hypre_ParAMGDataNumLevels(amg_data);
|
||||
HYPRE_Int smooth_num_levels = hypre_ParAMGDataSmoothNumLevels(amg_data);
|
||||
HYPRE_Solver *smoother = hypre_ParAMGDataSmoother(amg_data);
|
||||
void *amg = hypre_ParAMGDataCoarseSolver(amg_data);
|
||||
MPI_Comm new_comm = hypre_ParAMGDataNewComm(amg_data);
|
||||
HYPRE_Int i;
|
||||
HYPRE_Int *grid_relax_type = hypre_ParAMGDataGridRelaxType(amg_data);
|
||||
|
||||
HYPRE_ANNOTATE_FUNC_BEGIN;
|
||||
if (amg_data)
|
||||
{
|
||||
HYPRE_Int num_levels = hypre_ParAMGDataNumLevels(amg_data);
|
||||
HYPRE_Int smooth_num_levels = hypre_ParAMGDataSmoothNumLevels(amg_data);
|
||||
HYPRE_Solver *smoother = hypre_ParAMGDataSmoother(amg_data);
|
||||
void *amg = hypre_ParAMGDataCoarseSolver(amg_data);
|
||||
MPI_Comm new_comm = hypre_ParAMGDataNewComm(amg_data);
|
||||
HYPRE_Int *grid_relax_type = hypre_ParAMGDataGridRelaxType(amg_data);
|
||||
HYPRE_Int i;
|
||||
|
||||
#ifdef HYPRE_USING_DSUPERLU
|
||||
// if (hypre_ParAMGDataDSLUThreshold(amg_data) > 0)
|
||||
if (hypre_ParAMGDataDSLUSolver(amg_data) != NULL)
|
||||
{
|
||||
hypre_SLUDistDestroy(hypre_ParAMGDataDSLUSolver(amg_data));
|
||||
hypre_ParAMGDataDSLUSolver(amg_data) = NULL;
|
||||
}
|
||||
// if (hypre_ParAMGDataDSLUThreshold(amg_data) > 0)
|
||||
if (hypre_ParAMGDataDSLUSolver(amg_data) != NULL)
|
||||
{
|
||||
hypre_SLUDistDestroy(hypre_ParAMGDataDSLUSolver(amg_data));
|
||||
hypre_ParAMGDataDSLUSolver(amg_data) = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hypre_ParAMGDataMaxEigEst(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataMaxEigEst(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataMaxEigEst(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataMinEigEst(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataMinEigEst(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataMinEigEst(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataNumGridSweeps(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataNumGridSweeps(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataNumGridSweeps(amg_data) = NULL;
|
||||
}
|
||||
if (grid_relax_type)
|
||||
{
|
||||
HYPRE_Int num_levels = hypre_ParAMGDataNumLevels(amg_data);
|
||||
if (grid_relax_type[1] == 15 || grid_relax_type[3] == 15 )
|
||||
if (hypre_ParAMGDataMaxEigEst(amg_data))
|
||||
{
|
||||
if (grid_relax_type[1] == 15)
|
||||
for (i = 0; i < num_levels; i++)
|
||||
hypre_TFree(hypre_ParAMGDataMaxEigEst(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataMaxEigEst(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataMinEigEst(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataMinEigEst(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataMinEigEst(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataNumGridSweeps(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataNumGridSweeps(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataNumGridSweeps(amg_data) = NULL;
|
||||
}
|
||||
if (grid_relax_type)
|
||||
{
|
||||
HYPRE_Int num_levels = hypre_ParAMGDataNumLevels(amg_data);
|
||||
if (grid_relax_type[1] == 15 || grid_relax_type[3] == 15 )
|
||||
{
|
||||
if (grid_relax_type[1] == 15)
|
||||
{
|
||||
HYPRE_ParCSRPCGDestroy(smoother[i]);
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
HYPRE_ParCSRPCGDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
if (grid_relax_type[3] == 15 && grid_relax_type[1] != 15)
|
||||
{
|
||||
HYPRE_ParCSRPCGDestroy(smoother[num_levels - 1]);
|
||||
if (grid_relax_type[3] == 15 && grid_relax_type[1] != 15)
|
||||
{
|
||||
HYPRE_ParCSRPCGDestroy(smoother[num_levels - 1]);
|
||||
}
|
||||
hypre_TFree(smoother, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(smoother, HYPRE_MEMORY_HOST);
|
||||
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxType(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataGridRelaxType(amg_data) = NULL;
|
||||
}
|
||||
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxType(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataGridRelaxType(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataRelaxWeight(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataRelaxWeight(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataRelaxWeight(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataOmega(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataOmega(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataOmega(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataNonGalTolArray(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataNonGalTolArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataNonGalTolArray(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataDofFunc(amg_data))
|
||||
{
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataDofFunc(amg_data));
|
||||
hypre_ParAMGDataDofFunc(amg_data) = NULL;
|
||||
}
|
||||
for (i = 1; i < num_levels; i++)
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataFArray(amg_data)[i]);
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataUArray(amg_data)[i]);
|
||||
|
||||
if (hypre_ParAMGDataAArray(amg_data)[i])
|
||||
if (hypre_ParAMGDataRelaxWeight(amg_data))
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataAArray(amg_data)[i]);
|
||||
hypre_TFree(hypre_ParAMGDataRelaxWeight(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataRelaxWeight(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataPArray(amg_data)[i - 1])
|
||||
if (hypre_ParAMGDataOmega(amg_data))
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataPArray(amg_data)[i - 1]);
|
||||
hypre_TFree(hypre_ParAMGDataOmega(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataOmega(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
if (hypre_ParAMGDataNonGalTolArray(amg_data))
|
||||
{
|
||||
if (hypre_ParAMGDataRArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataRArray(amg_data)[i - 1]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataNonGalTolArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataNonGalTolArray(amg_data) = NULL;
|
||||
}
|
||||
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataCFMarkerArray(amg_data)[i - 1]);
|
||||
|
||||
/* get rid of any block structures */
|
||||
if (hypre_ParAMGDataABlockArray(amg_data)[i])
|
||||
if (hypre_ParAMGDataDofFunc(amg_data))
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataABlockArray(amg_data)[i]);
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataDofFunc(amg_data));
|
||||
hypre_ParAMGDataDofFunc(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataPBlockArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataPBlockArray(amg_data)[i - 1]);
|
||||
}
|
||||
|
||||
/* RL */
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
{
|
||||
if (hypre_ParAMGDataRBlockArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataRBlockArray(amg_data)[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hypre_ParAMGDataGridRelaxPoints(amg_data))
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxPoints(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxPoints(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataGridRelaxPoints(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataLambda(amg_data))
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataLambda(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataAtilde(amg_data))
|
||||
{
|
||||
hypre_ParCSRMatrix *Atilde = hypre_ParAMGDataAtilde(amg_data);
|
||||
hypre_CSRMatrixDestroy(hypre_ParCSRMatrixDiag(Atilde));
|
||||
hypre_CSRMatrixDestroy(hypre_ParCSRMatrixOffd(Atilde));
|
||||
hypre_TFree(Atilde, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataXtilde(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataXtilde(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataRtilde(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataRtilde(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataL1Norms(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_SeqVectorDestroy(hypre_ParAMGDataL1Norms(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataL1Norms(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataChebyCoefs(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
if (hypre_ParAMGDataChebyCoefs(amg_data)[i])
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataChebyCoefs(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataChebyCoefs(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataChebyDS(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_SeqVectorDestroy(hypre_ParAMGDataChebyDS(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataChebyDS(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataDinv(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataDinv(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
/* get rid of a fine level block matrix */
|
||||
if (hypre_ParAMGDataABlockArray(amg_data))
|
||||
if (hypre_ParAMGDataABlockArray(amg_data)[0])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataABlockArray(amg_data)[0]);
|
||||
}
|
||||
|
||||
|
||||
/* see comments in par_coarsen.c regarding special case for CF_marker */
|
||||
if (num_levels == 1)
|
||||
{
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataCFMarkerArray(amg_data)[0]);
|
||||
}
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataVtemp(amg_data));
|
||||
hypre_TFree(hypre_ParAMGDataFArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataUArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataABlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataPBlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataPArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataCFMarkerArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
|
||||
if (hypre_ParAMGDataRtemp(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataRtemp(amg_data));
|
||||
}
|
||||
if (hypre_ParAMGDataPtemp(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataPtemp(amg_data));
|
||||
}
|
||||
if (hypre_ParAMGDataZtemp(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataZtemp(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataDofFuncArray(amg_data))
|
||||
{
|
||||
for (i = 1; i < num_levels; i++)
|
||||
{
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataDofFuncArray(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataDofFuncArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataDofFuncArray(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataRBlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataRArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataRArray(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataDofPointArray(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataDofPointArray(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataDofPointArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataDofPointArray(amg_data) = NULL;
|
||||
}
|
||||
if (hypre_ParAMGDataPointDofMapArray(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataPointDofMapArray(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataPointDofMapArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataPointDofMapArray(amg_data) = NULL;
|
||||
}
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataFArray(amg_data)[i]);
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataUArray(amg_data)[i]);
|
||||
|
||||
if (smooth_num_levels)
|
||||
{
|
||||
if ( hypre_ParAMGDataSmoothType(amg_data) == 7 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 17 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
if (hypre_ParAMGDataAArray(amg_data)[i])
|
||||
{
|
||||
HYPRE_ParCSRPilutDestroy(smoother[i]);
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataAArray(amg_data)[i]);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataPArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataPArray(amg_data)[i - 1]);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
{
|
||||
if (hypre_ParAMGDataRArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataRArray(amg_data)[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataCFMarkerArray(amg_data)[i - 1]);
|
||||
|
||||
/* get rid of any block structures */
|
||||
if (hypre_ParAMGDataABlockArray(amg_data)[i])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataABlockArray(amg_data)[i]);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataPBlockArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataPBlockArray(amg_data)[i - 1]);
|
||||
}
|
||||
|
||||
/* RL */
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
{
|
||||
if (hypre_ParAMGDataRBlockArray(amg_data)[i - 1])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataRBlockArray(amg_data)[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 8 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 18 )
|
||||
if (hypre_ParAMGDataGridRelaxPoints(amg_data))
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
HYPRE_ParCSRParaSailsDestroy(smoother[i]);
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxPoints(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataGridRelaxPoints(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataGridRelaxPoints(amg_data) = NULL;
|
||||
}
|
||||
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataLambda(amg_data));
|
||||
|
||||
if (hypre_ParAMGDataAtilde(amg_data))
|
||||
{
|
||||
hypre_ParCSRMatrix *Atilde = hypre_ParAMGDataAtilde(amg_data);
|
||||
hypre_CSRMatrixDestroy(hypre_ParCSRMatrixDiag(Atilde));
|
||||
hypre_CSRMatrixDestroy(hypre_ParCSRMatrixOffd(Atilde));
|
||||
hypre_TFree(Atilde, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataXtilde(amg_data));
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataRtilde(amg_data));
|
||||
|
||||
if (hypre_ParAMGDataL1Norms(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_SeqVectorDestroy(hypre_ParAMGDataL1Norms(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataL1Norms(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataChebyCoefs(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
if (hypre_ParAMGDataChebyCoefs(amg_data)[i])
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataChebyCoefs(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataChebyCoefs(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataChebyDS(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_SeqVectorDestroy(hypre_ParAMGDataChebyDS(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataChebyDS(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
hypre_TFree(hypre_ParAMGDataDinv(amg_data), HYPRE_MEMORY_HOST);
|
||||
|
||||
/* get rid of a fine level block matrix */
|
||||
if (hypre_ParAMGDataABlockArray(amg_data))
|
||||
{
|
||||
if (hypre_ParAMGDataABlockArray(amg_data)[0])
|
||||
{
|
||||
hypre_ParCSRBlockMatrixDestroy(hypre_ParAMGDataABlockArray(amg_data)[0]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 9 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 19 )
|
||||
|
||||
/* see comments in par_coarsen.c regarding special case for CF_marker */
|
||||
if (num_levels == 1)
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_EuclidDestroy(smoother[i]);
|
||||
}
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataCFMarkerArray(amg_data)[0]);
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 4 )
|
||||
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataVtemp(amg_data));
|
||||
hypre_TFree(hypre_ParAMGDataFArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataUArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataABlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataPBlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataPArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataCFMarkerArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataRtemp(amg_data));
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataPtemp(amg_data));
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataZtemp(amg_data));
|
||||
|
||||
if (hypre_ParAMGDataDofFuncArray(amg_data))
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
for (i = 1; i < num_levels; i++)
|
||||
{
|
||||
HYPRE_FSAIDestroy(smoother[i]);
|
||||
hypre_IntArrayDestroy(hypre_ParAMGDataDofFuncArray(amg_data)[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataDofFuncArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataDofFuncArray(amg_data) = NULL;
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 5 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 15 )
|
||||
if (hypre_ParAMGDataRestriction(amg_data))
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_ILUDestroy(smoother[i]);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataRBlockArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataRArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataRArray(amg_data) = NULL;
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 6 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 16 )
|
||||
if (hypre_ParAMGDataDofPointArray(amg_data))
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
HYPRE_SchwarzDestroy(smoother[i]);
|
||||
hypre_TFree(hypre_ParAMGDataDofPointArray(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataDofPointArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataDofPointArray(amg_data) = NULL;
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataSmoother(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
if ( hypre_ParAMGDataResidual(amg_data) )
|
||||
{
|
||||
/* jfp: was... hypre_TFree( hypre_ParAMGDataResidual(amg_data) );*/
|
||||
hypre_ParVectorDestroy( hypre_ParAMGDataResidual(amg_data) );
|
||||
if (hypre_ParAMGDataPointDofMapArray(amg_data))
|
||||
{
|
||||
for (i = 0; i < num_levels; i++)
|
||||
{
|
||||
hypre_TFree(hypre_ParAMGDataPointDofMapArray(amg_data)[i], HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataPointDofMapArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_ParAMGDataPointDofMapArray(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (smooth_num_levels)
|
||||
{
|
||||
if ( hypre_ParAMGDataSmoothType(amg_data) == 7 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 17 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_ParCSRPilutDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 8 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 18 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_ParCSRParaSailsDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 9 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 19 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_EuclidDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 4 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_FSAIDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 5 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 15 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_ILUDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
else if ( hypre_ParAMGDataSmoothType(amg_data) == 6 ||
|
||||
hypre_ParAMGDataSmoothType(amg_data) == 16 )
|
||||
{
|
||||
for (i = 0; i < smooth_num_levels; i++)
|
||||
{
|
||||
HYPRE_SchwarzDestroy(smoother[i]);
|
||||
}
|
||||
}
|
||||
hypre_TFree(hypre_ParAMGDataSmoother(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataResidual(amg_data));
|
||||
hypre_ParAMGDataResidual(amg_data) = NULL;
|
||||
}
|
||||
|
||||
if (hypre_ParAMGInterpVecVariant(amg_data) > 0
|
||||
&& hypre_ParAMGNumInterpVectors(amg_data) > 0)
|
||||
{
|
||||
|
||||
HYPRE_Int j;
|
||||
HYPRE_Int num_vecs = hypre_ParAMGNumInterpVectors(amg_data);
|
||||
hypre_ParVector **sm_vecs;
|
||||
HYPRE_Int num_il;
|
||||
num_il = hypre_min(hypre_ParAMGNumLevelsInterpVectors(amg_data), num_levels);
|
||||
|
||||
/* don't destroy lev = 0 - this was user input */
|
||||
for (i = 1; i < num_il; i++)
|
||||
if ( hypre_ParAMGInterpVecVariant(amg_data) > 0 &&
|
||||
hypre_ParAMGNumInterpVectors(amg_data) > 0)
|
||||
{
|
||||
sm_vecs = hypre_ParAMGInterpVectorsArray(amg_data)[i];
|
||||
for (j = 0; j < num_vecs; j++)
|
||||
HYPRE_Int num_vecs = hypre_ParAMGNumInterpVectors(amg_data);
|
||||
hypre_ParVector **sm_vecs;
|
||||
HYPRE_Int j, num_il;
|
||||
|
||||
num_il = hypre_min(hypre_ParAMGNumLevelsInterpVectors(amg_data), num_levels);
|
||||
|
||||
/* don't destroy lev = 0 - this was user input */
|
||||
for (i = 1; i < num_il; i++)
|
||||
{
|
||||
hypre_ParVectorDestroy(sm_vecs[j]);
|
||||
sm_vecs = hypre_ParAMGInterpVectorsArray(amg_data)[i];
|
||||
for (j = 0; j < num_vecs; j++)
|
||||
{
|
||||
hypre_ParVectorDestroy(sm_vecs[j]);
|
||||
}
|
||||
hypre_TFree(sm_vecs, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree(sm_vecs, HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGInterpVectorsArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
}
|
||||
hypre_TFree( hypre_ParAMGInterpVectorsArray(amg_data), HYPRE_MEMORY_HOST);
|
||||
|
||||
}
|
||||
|
||||
if (amg) { hypre_BoomerAMGDestroy(amg); }
|
||||
|
||||
if (hypre_ParAMGDataACoarse(amg_data))
|
||||
{
|
||||
hypre_BoomerAMGDestroy(amg);
|
||||
hypre_ParCSRMatrixDestroy(hypre_ParAMGDataACoarse(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataUCoarse(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataUCoarse(amg_data));
|
||||
}
|
||||
|
||||
if (hypre_ParAMGDataFCoarse(amg_data))
|
||||
{
|
||||
hypre_ParVectorDestroy(hypre_ParAMGDataFCoarse(amg_data));
|
||||
|
||||
/* destroy input CF_marker data */
|
||||
hypre_TFree(hypre_ParAMGDataCPointsMarker(amg_data), HYPRE_MEMORY_DEVICE);
|
||||
hypre_TFree(hypre_ParAMGDataCPointsLocalMarker(amg_data), HYPRE_MEMORY_DEVICE);
|
||||
hypre_TFree(hypre_ParAMGDataFPointsMarker(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataIsolatedFPointsMarker(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAMat(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAInv(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataBVec(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataCommInfo(amg_data), HYPRE_MEMORY_HOST);
|
||||
|
||||
if (new_comm != hypre_MPI_COMM_NULL)
|
||||
{
|
||||
hypre_MPI_Comm_free(&new_comm);
|
||||
}
|
||||
|
||||
hypre_TFree(amg_data, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
/* destroy input CF_marker data */
|
||||
hypre_TFree(hypre_ParAMGDataCPointsMarker(amg_data), HYPRE_MEMORY_DEVICE);
|
||||
hypre_TFree(hypre_ParAMGDataCPointsLocalMarker(amg_data), HYPRE_MEMORY_DEVICE);
|
||||
hypre_TFree(hypre_ParAMGDataFPointsMarker(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataIsolatedFPointsMarker(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAMat(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataAInv(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataBVec(amg_data), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(hypre_ParAMGDataCommInfo(amg_data), HYPRE_MEMORY_HOST);
|
||||
|
||||
if (new_comm != hypre_MPI_COMM_NULL)
|
||||
{
|
||||
hypre_MPI_Comm_free (&new_comm);
|
||||
}
|
||||
|
||||
hypre_TFree(amg_data, HYPRE_MEMORY_HOST);
|
||||
|
||||
HYPRE_ANNOTATE_FUNC_END;
|
||||
|
||||
return hypre_error_flag;
|
||||
|
||||
@ -34,6 +34,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
hypre_ParAMGData *amg_data = (hypre_ParAMGData*) amg_vdata;
|
||||
|
||||
/* Data Structure variables */
|
||||
HYPRE_Int num_vectors;
|
||||
hypre_ParCSRMatrix **A_array;
|
||||
hypre_ParVector **F_array;
|
||||
hypre_ParVector **U_array;
|
||||
@ -308,6 +309,22 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
|
||||
grid_relax_type[3] = hypre_ParAMGDataUserCoarseRelaxType(amg_data);
|
||||
|
||||
/* Get the number of vector components when LHS/RHS are passed in */
|
||||
if ((f != NULL) && (u != NULL))
|
||||
{
|
||||
/* Verify that the number of vectors held by f and u match */
|
||||
if (hypre_ParVectorNumVectors(f) != hypre_ParVectorNumVectors(u))
|
||||
{
|
||||
hypre_error_w_msg(HYPRE_ERROR_GENERIC, "Error: num_vectors for RHS and LHS do not match!\n");
|
||||
return hypre_error_flag;
|
||||
}
|
||||
num_vectors = hypre_ParVectorNumVectors(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_vectors = 1;
|
||||
}
|
||||
|
||||
HYPRE_ANNOTATE_FUNC_BEGIN;
|
||||
|
||||
/* change in definition of standard and multipass interpolation, by
|
||||
@ -756,6 +773,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
Vtemp = hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[0]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[0]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[0]));
|
||||
hypre_ParVectorNumVectors(Vtemp) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(Vtemp, memory_location);
|
||||
hypre_ParAMGDataVtemp(amg_data) = Vtemp;
|
||||
|
||||
@ -769,6 +787,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
Ptemp = hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[0]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[0]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[0]));
|
||||
hypre_ParVectorNumVectors(Ptemp) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(Ptemp, memory_location);
|
||||
hypre_ParAMGDataPtemp(amg_data) = Ptemp;
|
||||
|
||||
@ -780,6 +799,7 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
Rtemp = hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[0]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[0]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[0]));
|
||||
hypre_ParVectorNumVectors(Rtemp) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(Rtemp, memory_location);
|
||||
hypre_ParAMGDataRtemp(amg_data) = Rtemp;
|
||||
}
|
||||
@ -939,12 +959,14 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[level]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[level]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[level]));
|
||||
hypre_ParVectorNumVectors(F_array[level]) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(F_array[level], memory_location);
|
||||
|
||||
U_array[level] =
|
||||
hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[level]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[level]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[level]));
|
||||
hypre_ParVectorNumVectors(U_array[level]) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(U_array[level], memory_location);
|
||||
}
|
||||
}
|
||||
@ -2482,27 +2504,27 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
hypre_Vector *Vtemp_local = hypre_ParVectorLocalVector(Vtemp);
|
||||
hypre_TFree(hypre_VectorData(Vtemp_local), memory_location);
|
||||
hypre_VectorSize(Vtemp_local) = local_P_sz;
|
||||
hypre_VectorData(Vtemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz, memory_location);
|
||||
hypre_VectorData(Vtemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz * num_vectors, memory_location);
|
||||
if (Ztemp)
|
||||
{
|
||||
hypre_Vector *Ztemp_local = hypre_ParVectorLocalVector(Ztemp);
|
||||
hypre_TFree(hypre_VectorData(Ztemp_local), memory_location);
|
||||
hypre_VectorSize(Ztemp_local) = local_P_sz;
|
||||
hypre_VectorData(Ztemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz, memory_location);
|
||||
hypre_VectorData(Ztemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz * num_vectors, memory_location);
|
||||
}
|
||||
if (Ptemp)
|
||||
{
|
||||
hypre_Vector *Ptemp_local = hypre_ParVectorLocalVector(Ptemp);
|
||||
hypre_TFree(hypre_VectorData(Ptemp_local), memory_location);
|
||||
hypre_VectorSize(Ptemp_local) = local_P_sz;
|
||||
hypre_VectorData(Ptemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz, memory_location);
|
||||
hypre_VectorData(Ptemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz * num_vectors, memory_location);
|
||||
}
|
||||
if (Rtemp)
|
||||
{
|
||||
hypre_Vector *Rtemp_local = hypre_ParVectorLocalVector(Rtemp);
|
||||
hypre_TFree(hypre_VectorData(Rtemp_local), memory_location);
|
||||
hypre_VectorSize(Rtemp_local) = local_P_sz;
|
||||
hypre_VectorData(Rtemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz, memory_location);
|
||||
hypre_VectorData(Rtemp_local) = hypre_CTAlloc(HYPRE_Complex, local_P_sz * num_vectors, memory_location);
|
||||
}
|
||||
}
|
||||
/*if (hypre_ParCSRMatrixGlobalNumRows(A_array[0]) < hypre_ParCSRMatrixGlobalNumCols(P))
|
||||
@ -3050,12 +3072,14 @@ hypre_BoomerAMGSetup( void *amg_vdata,
|
||||
hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[level]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[level]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[level]));
|
||||
hypre_ParVectorNumVectors(F_array[level]) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(F_array[level], memory_location);
|
||||
|
||||
U_array[level] =
|
||||
hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[level]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[level]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[level]));
|
||||
hypre_ParVectorNumVectors(U_array[level]) = num_vectors;
|
||||
hypre_ParVectorInitialize_v2(U_array[level], memory_location);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,22 +24,22 @@ hypre_BoomerAMGSolve( void *amg_vdata,
|
||||
hypre_ParVector *f,
|
||||
hypre_ParVector *u )
|
||||
{
|
||||
MPI_Comm comm = hypre_ParCSRMatrixComm(A);
|
||||
|
||||
hypre_ParAMGData *amg_data = (hypre_ParAMGData*) amg_vdata;
|
||||
MPI_Comm comm = hypre_ParCSRMatrixComm(A);
|
||||
hypre_ParAMGData *amg_data = (hypre_ParAMGData*) amg_vdata;
|
||||
|
||||
/* Data Structure variables */
|
||||
|
||||
HYPRE_Int amg_print_level;
|
||||
HYPRE_Int amg_logging;
|
||||
HYPRE_Int cycle_count;
|
||||
HYPRE_Int num_levels;
|
||||
/* HYPRE_Int num_unknowns; */
|
||||
HYPRE_Int converge_type;
|
||||
HYPRE_Real tol;
|
||||
|
||||
HYPRE_Int block_mode;
|
||||
|
||||
HYPRE_Int amg_print_level;
|
||||
HYPRE_Int amg_logging;
|
||||
HYPRE_Int cycle_count;
|
||||
HYPRE_Int num_levels;
|
||||
HYPRE_Int converge_type;
|
||||
HYPRE_Int block_mode;
|
||||
HYPRE_Int additive;
|
||||
HYPRE_Int mult_additive;
|
||||
HYPRE_Int simple;
|
||||
HYPRE_Int min_iter;
|
||||
HYPRE_Int max_iter;
|
||||
HYPRE_Real tol;
|
||||
|
||||
hypre_ParCSRMatrix **A_array;
|
||||
hypre_ParVector **F_array;
|
||||
@ -47,38 +47,30 @@ hypre_BoomerAMGSolve( void *amg_vdata,
|
||||
|
||||
hypre_ParCSRBlockMatrix **A_block_array;
|
||||
|
||||
|
||||
/* Local variables */
|
||||
HYPRE_Int j;
|
||||
HYPRE_Int Solve_err_flag;
|
||||
HYPRE_Int num_procs, my_id;
|
||||
HYPRE_Real alpha = 1.0;
|
||||
HYPRE_Real beta = -1.0;
|
||||
HYPRE_Real cycle_op_count;
|
||||
HYPRE_Real total_coeffs;
|
||||
HYPRE_Real total_variables;
|
||||
HYPRE_Real *num_coeffs;
|
||||
HYPRE_Real *num_variables;
|
||||
HYPRE_Real cycle_cmplxty = 0.0;
|
||||
HYPRE_Real operat_cmplxty;
|
||||
HYPRE_Real grid_cmplxty;
|
||||
HYPRE_Real conv_factor = 0.0;
|
||||
HYPRE_Real resid_nrm = 1.0;
|
||||
HYPRE_Real resid_nrm_init = 0.0;
|
||||
HYPRE_Real relative_resid;
|
||||
HYPRE_Real rhs_norm = 0.0;
|
||||
HYPRE_Real old_resid;
|
||||
HYPRE_Real ieee_check = 0.;
|
||||
|
||||
HYPRE_Int j;
|
||||
HYPRE_Int Solve_err_flag;
|
||||
HYPRE_Int min_iter;
|
||||
HYPRE_Int max_iter;
|
||||
HYPRE_Int num_procs, my_id;
|
||||
HYPRE_Int additive;
|
||||
HYPRE_Int mult_additive;
|
||||
HYPRE_Int simple;
|
||||
|
||||
HYPRE_Real alpha = 1.0;
|
||||
HYPRE_Real beta = -1.0;
|
||||
HYPRE_Real cycle_op_count;
|
||||
HYPRE_Real total_coeffs;
|
||||
HYPRE_Real total_variables;
|
||||
HYPRE_Real *num_coeffs;
|
||||
HYPRE_Real *num_variables;
|
||||
HYPRE_Real cycle_cmplxty = 0.0;
|
||||
HYPRE_Real operat_cmplxty;
|
||||
HYPRE_Real grid_cmplxty;
|
||||
HYPRE_Real conv_factor = 0.0;
|
||||
HYPRE_Real resid_nrm = 1.0;
|
||||
HYPRE_Real resid_nrm_init = 0.0;
|
||||
HYPRE_Real relative_resid;
|
||||
HYPRE_Real rhs_norm = 0.0;
|
||||
HYPRE_Real old_resid;
|
||||
HYPRE_Real ieee_check = 0.;
|
||||
|
||||
hypre_ParVector *Vtemp;
|
||||
hypre_ParVector *Residual;
|
||||
hypre_ParVector *Vtemp;
|
||||
hypre_ParVector *Residual;
|
||||
|
||||
HYPRE_ANNOTATE_FUNC_BEGIN;
|
||||
hypre_MPI_Comm_size(comm, &num_procs);
|
||||
@ -86,11 +78,10 @@ hypre_BoomerAMGSolve( void *amg_vdata,
|
||||
|
||||
amg_print_level = hypre_ParAMGDataPrintLevel(amg_data);
|
||||
amg_logging = hypre_ParAMGDataLogging(amg_data);
|
||||
if ( amg_logging > 1 )
|
||||
if (amg_logging > 1)
|
||||
{
|
||||
Residual = hypre_ParAMGDataResidual(amg_data);
|
||||
}
|
||||
/* num_unknowns = hypre_ParAMGDataNumUnknowns(amg_data); */
|
||||
num_levels = hypre_ParAMGDataNumLevels(amg_data);
|
||||
A_array = hypre_ParAMGDataAArray(amg_data);
|
||||
F_array = hypre_ParAMGDataFArray(amg_data);
|
||||
@ -103,23 +94,20 @@ hypre_BoomerAMGSolve( void *amg_vdata,
|
||||
additive = hypre_ParAMGDataAdditive(amg_data);
|
||||
simple = hypre_ParAMGDataSimple(amg_data);
|
||||
mult_additive = hypre_ParAMGDataMultAdditive(amg_data);
|
||||
block_mode = hypre_ParAMGDataBlockMode(amg_data);
|
||||
A_block_array = hypre_ParAMGDataABlockArray(amg_data);
|
||||
Vtemp = hypre_ParAMGDataVtemp(amg_data);
|
||||
|
||||
A_array[0] = A;
|
||||
F_array[0] = f;
|
||||
U_array[0] = u;
|
||||
|
||||
block_mode = hypre_ParAMGDataBlockMode(amg_data);
|
||||
|
||||
A_block_array = hypre_ParAMGDataABlockArray(amg_data);
|
||||
|
||||
|
||||
/* Vtemp = hypre_ParVectorCreate(hypre_ParCSRMatrixComm(A_array[0]),
|
||||
hypre_ParCSRMatrixGlobalNumRows(A_array[0]),
|
||||
hypre_ParCSRMatrixRowStarts(A_array[0]));
|
||||
hypre_ParVectorInitialize(Vtemp);
|
||||
hypre_ParAMGDataVtemp(amg_data) = Vtemp;
|
||||
*/
|
||||
Vtemp = hypre_ParAMGDataVtemp(amg_data);
|
||||
/* Verify that the number of vectors held by f and u match */
|
||||
if (hypre_ParVectorNumVectors(f) != hypre_ParVectorNumVectors(u))
|
||||
{
|
||||
hypre_error_w_msg(HYPRE_ERROR_GENERIC, "Error: num_vectors for RHS and LHS do not match!\n");
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Write the solver parameters
|
||||
@ -163,7 +151,7 @@ hypre_BoomerAMGSolve( void *amg_vdata,
|
||||
hypre_ParVectorCopy(F_array[0], Residual );
|
||||
if (tol > 0)
|
||||
{
|
||||
hypre_ParCSRMatrixMatvec(alpha, A_array[0], U_array[0], beta, Residual );
|
||||
hypre_ParCSRMatrixMatvec(alpha, A_array[0], U_array[0], beta, Residual);
|
||||
}
|
||||
resid_nrm = sqrt(hypre_ParVectorInnerProd( Residual, Residual ));
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ hypre_BoomerAMGCycle( void *amg_vdata,
|
||||
if (num_levels > 1)
|
||||
{
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)) = local_size;
|
||||
hypre_ParVectorSetLocalSize(Vtemp, local_size);
|
||||
|
||||
if (smooth_num_levels <= level)
|
||||
{
|
||||
@ -306,9 +306,10 @@ hypre_BoomerAMGCycle( void *amg_vdata,
|
||||
}
|
||||
else if (smooth_type > 9)
|
||||
{
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Ztemp)) = local_size;
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Rtemp)) = local_size;
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Ptemp)) = local_size;
|
||||
hypre_ParVectorSetLocalSize(Ztemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Rtemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Ptemp, local_size);
|
||||
|
||||
Ztemp_data = hypre_VectorData(hypre_ParVectorLocalVector(Ztemp));
|
||||
Ptemp_data = hypre_VectorData(hypre_ParVectorLocalVector(Ptemp));
|
||||
hypre_ParVectorSetConstantValues(Ztemp, 0);
|
||||
@ -452,7 +453,8 @@ hypre_BoomerAMGCycle( void *amg_vdata,
|
||||
smooth_type == 8 || smooth_type == 18 ||
|
||||
smooth_type == 9 || smooth_type == 19) )
|
||||
{
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Utemp)) = local_size;
|
||||
hypre_ParVectorSetLocalSize(Utemp, local_size);
|
||||
|
||||
alpha = -1.0;
|
||||
beta = 1.0;
|
||||
hypre_ParCSRMatrixMatvecOutOfPlace(alpha, A_array[level],
|
||||
|
||||
@ -352,7 +352,8 @@ hypre_MGRFrelaxVcycle ( void *Frelax_vdata, hypre_ParVector *f, hypre_ParVecto
|
||||
|
||||
/* (Re)set local_size for Vtemp */
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[0]));
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)) = local_size;
|
||||
hypre_ParVectorSetLocalSize(Vtemp, local_size);
|
||||
|
||||
/* smoother on finest level:
|
||||
* This is separated from subsequent levels since the finest level matrix
|
||||
* may be larger than what is needed for the vcycle solve
|
||||
@ -425,6 +426,11 @@ hypre_MGRFrelaxVcycle ( void *Frelax_vdata, hypre_ParVector *f, hypre_ParVecto
|
||||
/* update level */
|
||||
++level;
|
||||
|
||||
/* Update scratch vector sizes */
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_ParVectorSetLocalSize(Vtemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Ztemp, local_size);
|
||||
|
||||
CF_marker = NULL;
|
||||
if (CF_marker_array[level])
|
||||
{
|
||||
@ -439,8 +445,6 @@ hypre_MGRFrelaxVcycle ( void *Frelax_vdata, hypre_ParVector *f, hypre_ParVecto
|
||||
}
|
||||
else
|
||||
{
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)) = local_size;
|
||||
Aux_F = F_array[level];
|
||||
Aux_U = U_array[level];
|
||||
/* relax and visit next coarse grid */
|
||||
@ -472,8 +476,6 @@ hypre_MGRFrelaxVcycle ( void *Frelax_vdata, hypre_ParVector *f, hypre_ParVecto
|
||||
else
|
||||
{
|
||||
// solve with relaxation
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)) = local_size;
|
||||
Aux_F = F_array[level];
|
||||
Aux_U = U_array[level];
|
||||
for (j = 0; j < num_sweeps; j++)
|
||||
@ -515,9 +517,10 @@ hypre_MGRFrelaxVcycle ( void *Frelax_vdata, hypre_ParVector *f, hypre_ParVecto
|
||||
cycle_param = 2;
|
||||
if (level == 0) { cycle_param = 99; }
|
||||
|
||||
// reset vtemp size
|
||||
/* Update scratch vector sizes */
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)) = local_size;
|
||||
hypre_ParVectorSetLocalSize(Vtemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Ztemp, local_size);
|
||||
//hypre_printf("Vcycle smoother (up cycle): vtemp size = %d, level = %d \n", hypre_VectorSize(hypre_ParVectorLocalVector(Vtemp)), level);
|
||||
}
|
||||
else
|
||||
@ -538,6 +541,7 @@ hypre_MGRCycle( void *mgr_vdata,
|
||||
MPI_Comm comm;
|
||||
hypre_ParMGRData *mgr_data = (hypre_ParMGRData*) mgr_vdata;
|
||||
|
||||
HYPRE_Int local_size;
|
||||
HYPRE_Int Solve_err_flag;
|
||||
HYPRE_Int level;
|
||||
HYPRE_Int coarse_grid;
|
||||
@ -614,6 +618,12 @@ hypre_MGRCycle( void *mgr_vdata,
|
||||
/***** Main loop ******/
|
||||
while (Not_Finished)
|
||||
{
|
||||
/* Update scratch vector sizes */
|
||||
local_size = hypre_VectorSize(hypre_ParVectorLocalVector(F_array[level]));
|
||||
hypre_ParVectorSetLocalSize(Vtemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Ztemp, local_size);
|
||||
hypre_ParVectorSetLocalSize(Utemp, local_size);
|
||||
|
||||
/* Do coarse grid correction solve */
|
||||
if (cycle_type == 3)
|
||||
{
|
||||
@ -787,7 +797,7 @@ hypre_MGRCycle( void *mgr_vdata,
|
||||
hypre_ParCSRMatrixMatvecOutOfPlace(-1.0, A_array[level],
|
||||
U_array[level], 1.0, F_array[level], Vtemp);
|
||||
|
||||
resnorm = hypre_ParVectorInnerProd(Vtemp, Vtemp);
|
||||
resnorm = sqrt(hypre_ParVectorInnerProd(Vtemp, Vtemp));
|
||||
init_resnorm = resnorm;
|
||||
rhs_norm = sqrt(hypre_ParVectorInnerProd(F_array[level], F_array[level]));
|
||||
|
||||
@ -824,7 +834,7 @@ hypre_MGRCycle( void *mgr_vdata,
|
||||
old_resnorm = resnorm;
|
||||
hypre_ParCSRMatrixMatvecOutOfPlace(-1.0, A_array[level],
|
||||
U_array[level], 1.0, F_array[level], Vtemp);
|
||||
resnorm = hypre_ParVectorInnerProd(Vtemp, Vtemp);
|
||||
resnorm = sqrt(hypre_ParVectorInnerProd(Vtemp, Vtemp));
|
||||
|
||||
if (old_resnorm) { conv_factor = resnorm / old_resnorm; }
|
||||
else { conv_factor = resnorm; }
|
||||
|
||||
@ -1729,4 +1729,3 @@ hypre_BoomerAMGRelax12TwoStageGaussSeidel( hypre_ParCSRMatrix *A,
|
||||
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
|
||||
@ -1123,6 +1123,7 @@ HYPRE_Int hypre_ParVectorInitialize ( hypre_ParVector *vector );
|
||||
HYPRE_Int hypre_ParVectorInitialize_v2( hypre_ParVector *vector,
|
||||
HYPRE_MemoryLocation memory_location );
|
||||
HYPRE_Int hypre_ParVectorSetDataOwner ( hypre_ParVector *vector, HYPRE_Int owns_data );
|
||||
HYPRE_Int hypre_ParVectorSetLocalSize ( hypre_ParVector *vector, HYPRE_Int local_size );
|
||||
HYPRE_Int hypre_ParVectorSetNumVectors ( hypre_ParVector *vector, HYPRE_Int num_vectors );
|
||||
HYPRE_Int hypre_ParVectorSetComponent ( hypre_ParVector *vector, HYPRE_Int component );
|
||||
hypre_ParVector *hypre_ParVectorRead ( MPI_Comm comm, const char *file_name );
|
||||
|
||||
@ -178,6 +178,21 @@ hypre_ParVectorSetDataOwner( hypre_ParVector *vector,
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* hypre_ParVectorSetLocalSize
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
HYPRE_Int
|
||||
hypre_ParVectorSetLocalSize( hypre_ParVector *vector,
|
||||
HYPRE_Int local_size )
|
||||
{
|
||||
hypre_Vector *local_vector = hypre_ParVectorLocalVector(vector);
|
||||
|
||||
hypre_SeqVectorSetSize(local_vector, local_size);
|
||||
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* hypre_ParVectorSetNumVectors
|
||||
* call before calling hypre_ParVectorInitialize
|
||||
|
||||
@ -498,6 +498,7 @@ HYPRE_Int hypre_ParVectorInitialize ( hypre_ParVector *vector );
|
||||
HYPRE_Int hypre_ParVectorInitialize_v2( hypre_ParVector *vector,
|
||||
HYPRE_MemoryLocation memory_location );
|
||||
HYPRE_Int hypre_ParVectorSetDataOwner ( hypre_ParVector *vector, HYPRE_Int owns_data );
|
||||
HYPRE_Int hypre_ParVectorSetLocalSize ( hypre_ParVector *vector, HYPRE_Int local_size );
|
||||
HYPRE_Int hypre_ParVectorSetNumVectors ( hypre_ParVector *vector, HYPRE_Int num_vectors );
|
||||
HYPRE_Int hypre_ParVectorSetComponent ( hypre_ParVector *vector, HYPRE_Int component );
|
||||
hypre_ParVector *hypre_ParVectorRead ( MPI_Comm comm, const char *file_name );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user