Newer
Older

Thomas Witkowski
committed
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.
#include "AdaptStationary.h"
#include "Initfile.h"
#include "est/Estimator.h"
#include "ProblemIterationInterface.h"
#include <math.h>
#if HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/MeshDistributor.h"
#include <petsc.h>
#endif
ProblemIterationInterface *prob,
: AdaptBase(name, prob, info)
{
FUNCNAME("AdaptStationary::AdaptStationary()");
MSG("You make use of the obsolete constructor AdaptStationary::AdaptStationary(...)!\n");
MSG("Please use the constructor that uses references instead of pointers!\n");
initialize();
}
AdaptStationary::AdaptStationary(std::string name,
ProblemIterationInterface& prob,
AdaptInfo& info)
: AdaptBase(name, &prob, &info)
{
int AdaptStationary::adapt()
{
FUNCNAME("AdaptStationary::adapt()");
#if HAVE_PARALLEL_DOMAIN_AMDIS
MeshDistributor::globalMeshDistributor->initParallelization();
#endif
problemIteration->beginIteration(adaptInfo);
problemIteration->oneIteration(adaptInfo, NO_ADAPTION);
problemIteration->endIteration(adaptInfo);
while (!adaptInfo->spaceToleranceReached() &&
(adaptInfo->getSpaceIteration() < adaptInfo->getMaxSpaceIteration() ||
adaptInfo->getMaxSpaceIteration() < 0) ) {

Thomas Witkowski
committed
problemIteration->beginIteration(adaptInfo);
Flag adapted = problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration->endIteration(adaptInfo);
#if HAVE_PARALLEL_DOMAIN_AMDIS
int recvAllValues = 0;
int isAdapted = static_cast<bool>(adapted);
MPI::COMM_WORLD.Allreduce(&isAdapted, &recvAllValues, 1, MPI_INT, MPI_SUM);
if (recvAllValues == 0)
break;
#else

Thomas Witkowski
committed
if (!adapted)
break;

Thomas Witkowski
committed

Thomas Witkowski
committed
}
void AdaptStationary::initialize()
{
FUNCNAME("AdaptStationary::initialize()");
Parameters::get(name + "->info", info);