xolotl/solver/src/monitor/Monitor3D.cpp
/**
 * This is a monitoring method that looks at the largest cluster concentration
 */
This is a monitoring method that looks at the largest cluster concentration
This is a monitoring method that looks at the largest cluster concentration
PetscErrorCode
monitorLargest3D(TS ts, PetscInt timestep, PetscReal time, Vec solution, void*)
{
	PetscErrorCode ierr;
	double ****solutionArray, *gridPointSolution;
	IdType xs, xm, Mx, ys, ym, My, zs, zm, Mz;
	PetscFunctionBeginUser;
	DM da;
	ierr = TSGetDM(ts, &da);
	CHKERRQ(ierr);
	ierr = DMDAVecGetArrayDOF(da, solution, &solutionArray);
	CHKERRQ(ierr);
	auto& solverHandler = PetscSolver::getSolverHandler();
	solverHandler.getLocalCoordinates(xs, xm, Mx, ys, ym, My, zs, zm, Mz);
	for (auto k = zs; k < zs + zm; k++)
		for (auto j = ys; j < ys + ym; j++)
			for (auto i = xs; i < xs + xm; i++) {
				gridPointSolution = solutionArray[k][j][i];
				if (gridPointSolution[largestClusterId3D] >
					largestThreshold3D) {
					ierr = TSSetConvergedReason(ts, TS_CONVERGED_USER);
					CHKERRQ(ierr);
					throw std::runtime_error(
						"\nxolotlSolver::Monitor3D: The largest "
						"cluster concentration is too high!!");
				}
			}
	ierr = DMDAVecRestoreArrayDOF(da, solution, &solutionArray);
	CHKERRQ(ierr);
	PetscFunctionReturn(0);
}
PetscErrorCode monitorLargest3D ( TS ts , PetscInt timestep , PetscReal time , Vec solution , void * ) { PetscErrorCode ierr ; double * * * * solutionArray , * gridPointSolution ; IdType xs , xm , Mx , ys , ym , My , zs , zm , Mz ; PetscFunctionBeginUser ; DM da ; ierr = TSGetDM ( ts , & da ) ; CHKERRQ ( ierr ) ; ierr = DMDAVecGetArrayDOF ( da , solution , & solutionArray ) ; CHKERRQ ( ierr ) ; auto & solverHandler = PetscSolver :: getSolverHandler ( ) ; solverHandler . getLocalCoordinates ( xs , xm , Mx , ys , ym , My , zs , zm , Mz ) ; for ( auto k = zs ; k < zs + zm ; k ++ ) for ( auto j = ys ; j < ys + ym ; j ++ ) for ( auto i = xs ; i < xs + xm ; i ++ ) { gridPointSolution = solutionArray [ k ] [ j ] [ i ] ; if ( gridPointSolution [ largestClusterId3D ] > largestThreshold3D ) { ierr = TSSetConvergedReason ( ts , TS_CONVERGED_USER ) ; CHKERRQ ( ierr ) ; throw std :: runtime_error ( " \n " " " ) ; } } ierr = DMDAVecRestoreArrayDOF ( da , solution , & solutionArray ) ; CHKERRQ ( ierr ) ; PetscFunctionReturn ( 0 ) ; }
This is a monitoring method that looks at the largest cluster concentration
This is a monitoring method that looks at the largest cluster concentration
// Initial declaration // Get the da from ts // Get the solutionArray // Get the solver handler and local coordinates // Loop on the local grid // Get the pointer to the beginning of the solution data for // this grid point // Check the concentration // Send an error // Restore the solutionArray