Commit 793a6125 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

some small errors and warnings corrected

parent c7d79308
...@@ -213,7 +213,7 @@ transformDOF_mm(Term term, DOFVector<T>* result) ...@@ -213,7 +213,7 @@ transformDOF_mm(Term term, DOFVector<T>* result)
assigned.set(0); assigned.set(0);
temp.set(tmp); temp.set(tmp);
while (cont) { while (cont) {
term.initElement(&ot, dualElInfo.colElInfo, NULL, NULL, basisFcts); term.initElement(&ot, dualElInfo.colElInfo, NULL, NULL, basisFcts);
basisFcts->getLocalIndices(dualElInfo.rowElInfo->getElement(), resultFeSpace->getAdmin(), localIndices); basisFcts->getLocalIndices(dualElInfo.rowElInfo->getElement(), resultFeSpace->getAdmin(), localIndices);
...@@ -245,6 +245,8 @@ transformDOF_mm(Term term, DOFVector<T>* result) ...@@ -245,6 +245,8 @@ transformDOF_mm(Term term, DOFVector<T>* result)
*resultIter = (*tempIter); *resultIter = (*tempIter);
*resultIter/= (*assignedIter); *resultIter/= (*assignedIter);
} }
delete lambda_1;
} }
} // end namespace AMDiS } // end namespace AMDiS
...@@ -1461,9 +1461,10 @@ namespace AMDiS { ...@@ -1461,9 +1461,10 @@ namespace AMDiS {
else else
{ {
ERROR_EXIT("Parallel model only support dim = 2 or 3.\n"); ERROR_EXIT("Parallel model only support dim = 2 or 3.\n");
return;
} }
refManager->globalRefine(&testMesh, nParallelPreRefinements); refManager->globalRefine(&testMesh, nParallelPreRefinements);
delete refManager; delete refManager;
Lagrange* basFcts = Lagrange::getLagrange(dim, 1); Lagrange* basFcts = Lagrange::getLagrange(dim, 1);
......
...@@ -178,20 +178,23 @@ namespace AMDiS { ...@@ -178,20 +178,23 @@ namespace AMDiS {
if (adoptProblem && if (adoptProblem &&
(adoptFlag.isSet(INIT_MESH) || (adoptFlag.isSet(INIT_MESH) ||
adoptFlag.isSet(INIT_SYSTEM) || adoptFlag.isSet(INIT_SYSTEM) ||
adoptFlag.isSet(INIT_FE_SPACE))) { adoptFlag.isSet(INIT_FE_SPACE)))
{
meshes = adoptProblem->getMeshes(); meshes = adoptProblem->getMeshes();
componentMeshes = adoptProblem->componentMeshes; if (meshes.size() == 1)
componentMeshes.resize(nComponents, meshes[0]);
TEST_EXIT(adoptProblem->getNumAddComponents() + nAddComponents > 0) else if (adoptProblem->getNumComponents() >= nComponents) {
("Not yet implemented.\n");
// If the adopt problem has fewer components than this problem, but only one
// mesh for all component, than scal up the componentMeshes array.
if (adoptProblem->getNumComponents() < nComponents) {
TEST_EXIT(meshes.size() == 1)("Daran muss ich noch arbeiten!\n");
componentMeshes.resize(nComponents); componentMeshes.resize(nComponents);
for (int i = adoptProblem->getNumComponents(); i < nComponents; i++) std::copy(adoptProblem->componentMeshes.begin(),
componentMeshes[i] = componentMeshes[0]; adoptProblem->componentMeshes.begin() + nComponents,
componentMeshes.begin());
} else {
componentMeshes.resize(nComponents, meshes[0]);
WARNING("componentMeshes may not be derived correctly from the adoptProblem. You have to do this manually!\n");
}
if (nAddComponents > 0) {
WARNING("Additional meshed can not be adopted from adoptProblem. You have to initialize these meshes manually!\n");
} }
} }
} }
...@@ -229,24 +232,26 @@ namespace AMDiS { ...@@ -229,24 +232,26 @@ namespace AMDiS {
createFeSpace(NULL); createFeSpace(NULL);
if (adoptProblem && if (adoptProblem &&
(adoptFlag.isSet(INIT_FE_SPACE) || adoptFlag.isSet(INIT_SYSTEM))) { (adoptFlag.isSet(INIT_FE_SPACE) || adoptFlag.isSet(INIT_SYSTEM)))
{
feSpaces = adoptProblem->getFeSpaces(); feSpaces = adoptProblem->getFeSpaces();
componentSpaces = adoptProblem->componentSpaces;
traverseInfo = adoptProblem->traverseInfo; traverseInfo = adoptProblem->traverseInfo;
TEST_EXIT(adoptProblem->getNumAddComponents() + nAddComponents > 0) if (feSpaces.size() == 1)
("Not yet implemented.\n"); componentSpaces.resize(nComponents, feSpaces[0]);
else if (adoptProblem->getNumComponents() >= nComponents) {
// If the adopt problem has fewer components than this problem, but only one
// fe space for all component, than scal up the componentSpaces array.
if (adoptProblem->getNumComponents() < nComponents) {
TEST_EXIT(feSpaces.size() == 1)("Daran muss ich noch arbeiten!\n");
componentSpaces.resize(nComponents); componentSpaces.resize(nComponents);
for (int i = adoptProblem->getNumComponents(); i < nComponents; i++) std::copy(adoptProblem->componentSpaces.begin(),
componentSpaces[i] = componentSpaces[0]; adoptProblem->componentSpaces.begin() + nComponents,
componentSpaces.begin());
} else {
componentSpaces.resize(nComponents, feSpaces[0]);
WARNING("componentSpaces may not be derived correctly from the adoptProblem. You have to do this manually!\n");
}
if (nAddComponents > 0) {
WARNING("Additional feSpaces can not be adopted from adoptProblem. You have to initialize these fespaces manually!\n");
} }
} }
} }
...@@ -276,10 +281,8 @@ namespace AMDiS { ...@@ -276,10 +281,8 @@ namespace AMDiS {
} }
} }
// #ifndef HAVE_PARALLEL_DOMAIN_AMDIS
if (!solver) if (!solver)
WARNING("no solver created\n"); WARNING("no solver created\n");
// #endif
// === create estimator === // === create estimator ===
if (initFlag.isSet(INIT_ESTIMATOR)) if (initFlag.isSet(INIT_ESTIMATOR))
......
...@@ -147,17 +147,6 @@ namespace AMDiS { ...@@ -147,17 +147,6 @@ namespace AMDiS {
void dualAssemble(AdaptInfo *adaptInfo, Flag flag, void dualAssemble(AdaptInfo *adaptInfo, Flag flag,
bool asmMatrix = true, bool asmVector = true); bool asmMatrix = true, bool asmVector = true);
/// Determines the execution order of the single adaption steps. If adapt is
/// true, mesh adaption will be performed. This allows to avoid mesh adaption,
/// e.g. in timestep adaption loops of timestep adaptive strategies.
Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION) override;
/// Returns number of managed problems
int getNumProblems() override
{
return 1;
}
/// Implementation of ProblemStatBase::getNumComponents(), TODO: Wrong!! /// Implementation of ProblemStatBase::getNumComponents(), TODO: Wrong!!
virtual int getNumComponents() virtual int getNumComponents()
{ {
...@@ -169,13 +158,6 @@ namespace AMDiS { ...@@ -169,13 +158,6 @@ namespace AMDiS {
return nAddComponents; return nAddComponents;
} }
/// Returns the problem with the given number. If only one problem
/// is managed by this master problem, the number hasn't to be given.
ProblemStatBase *getProblem(int number = 0) override
{
return this;
}
/// Writes output files. TODO: Make obsolete. /// Writes output files. TODO: Make obsolete.
void writeFiles(AdaptInfo *adaptInfo, bool force); void writeFiles(AdaptInfo *adaptInfo, bool force);
...@@ -557,11 +539,13 @@ namespace AMDiS { ...@@ -557,11 +539,13 @@ namespace AMDiS {
return fileWriters; return fileWriters;
} }
/// Returns \ref solutionTime.
double getSolutionTime() double getSolutionTime()
{ {
return solutionTime; return solutionTime;
} }
/// Returns \ref buildTime.
double getBuildTime() double getBuildTime()
{ {
return buildTime; return buildTime;
...@@ -687,36 +671,64 @@ namespace AMDiS { ...@@ -687,36 +671,64 @@ namespace AMDiS {
std::map<Operator*, std::vector<OperatorPos> > operators; std::map<Operator*, std::vector<OperatorPos> > operators;
/// time needed to solve the linear system
double solutionTime; double solutionTime;
/// time needed to assemble the linear system
double buildTime; double buildTime;
template <class> friend class detail::CouplingProblemStat; template <class> friend class detail::CouplingProblemStat;
}; };
#ifndef HAVE_PARALLEL_DOMAIN_AMDIS namespace detail
struct ProblemStat : public ProblemStatSeq,
public StandardProblemIteration
{ {
typedef ProblemStatSeq super; template <class ProblemStatType>
using super::getName; struct ProblemStat : public ProblemStatType,
public StandardProblemIteration
ProblemStat(std::string nameStr,
ProblemIterationInterface *problemIteration = NULL)
: super(nameStr, problemIteration),
StandardProblemIteration(this)
{ }
Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo)
{ {
for (int i = 0; i < getNumComponents(); i++) using ProblemStatType::getName;
if (adaptInfo->spaceToleranceReached(i))
adaptInfo->allowRefinement(false, i); /// Constructor
else ProblemStat(std::string nameStr,
adaptInfo->allowRefinement(true, i); ProblemIterationInterface *problemIteration = NULL)
: ProblemStatType(nameStr, problemIteration),
return StandardProblemIteration::oneIteration(adaptInfo, toDo); StandardProblemIteration(this)
} { }
};
/// Returns number of managed problems
// implements StandardProblemIteration::getNumProblems()
virtual int getNumProblems() override
{
return 1;
}
/// Returns the problem with the given number. If only one problem
/// is managed by this master problem, the number hasn't to be given.
// implements StandardProblemIteration::getProblem(int)
virtual ProblemStatBase *getProblem(int number = 0) override
{
return this;
}
/// Determines the execution order of the single adaption steps. If adapt is
/// true, mesh adaption will be performed. This allows to avoid mesh adaption,
/// e.g. in timestep adaption loops of timestep adaptive strategies.
// implements StandardProblemIteration::oneIteration(AdaptInfo*, Flag)
virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION) override
{
for (int i = 0; i < ProblemStatType::getNumComponents(); i++)
if (adaptInfo->spaceToleranceReached(i))
adaptInfo->allowRefinement(false, i);
else
adaptInfo->allowRefinement(true, i);
return StandardProblemIteration::oneIteration(adaptInfo, toDo);
}
};
}
#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
typedef detail::ProblemStat<ProblemStatSeq> ProblemStat;
#endif #endif
} }
......
...@@ -35,16 +35,16 @@ namespace AMDiS { namespace io { ...@@ -35,16 +35,16 @@ namespace AMDiS { namespace io {
file.read(const_cast<char*>(typeId.data()), 4); file.read(const_cast<char*>(typeId.data()), 4);
TEST_EXIT(typeId == id) TEST_EXIT(typeId == id)
("Cannot read Arh2 format: this file is not \"arh2\" format.\n"); ("Cannot read Arh format: this file is not \"%s\" format.\n", id.c_str());
file.read(reinterpret_cast<char*>(&major_), 1); file.read(reinterpret_cast<char*>(&major_), 1);
TEST_EXIT(major == major_) TEST_EXIT(major == major_)
("Cannot read Arh2 format: Arh2Reader major version is %i, the file major version is %i. \n", ("Cannot read Arh format: Arh2Reader major version is %i, the file major version is %i. \n",
major, major_); major, major_);
file.read(reinterpret_cast<char*>(&minor_), 1); file.read(reinterpret_cast<char*>(&minor_), 1);
TEST_EXIT(minor <= minor_) TEST_EXIT(minor <= minor_)
("Cannot read Arh2 format: Arh2Reader minor version is %i is smaller than the file minor version %i.\n", ("Cannot read Arh format: ArhReader minor version is %i is smaller than the file minor version %i.\n",
minor, minor_); minor, minor_);
} }
...@@ -344,7 +344,7 @@ namespace AMDiS { namespace io { ...@@ -344,7 +344,7 @@ namespace AMDiS { namespace io {
if ((*nDOF)[0] != feSpaceDOFs[vecsFeSpaceNum[i]][3]) if ((*nDOF)[0] != feSpaceDOFs[vecsFeSpaceNum[i]][3])
matchdof = false; matchdof = false;
else { else {
for(size_t j = 1; j < nDOF->getSize(); j++) { for(int j = 1; j < nDOF->getSize(); j++) {
if((*nDOF)[j] != feSpaceDOFs[vecsFeSpaceNum[i]][j-1]){ if((*nDOF)[j] != feSpaceDOFs[vecsFeSpaceNum[i]][j-1]){
matchdof = false; matchdof = false;
break; break;
...@@ -373,7 +373,7 @@ namespace AMDiS { namespace io { ...@@ -373,7 +373,7 @@ namespace AMDiS { namespace io {
TEST_EXIT((*nDOF)[0] == feSpaceDOFs[vecsFeSpaceNum[i]][3]) TEST_EXIT((*nDOF)[0] == feSpaceDOFs[vecsFeSpaceNum[i]][3])
("The fespace of vec number %i is not equal to the correspond fespace.\n", i+1); ("The fespace of vec number %i is not equal to the correspond fespace.\n", i+1);
for(size_t j = 1; j < nDOF->getSize(); j++) for(int j = 1; j < nDOF->getSize(); j++)
TEST_EXIT((*nDOF)[j] == feSpaceDOFs[vecsFeSpaceNum[i]][j-1]) TEST_EXIT((*nDOF)[j] == feSpaceDOFs[vecsFeSpaceNum[i]][j-1])
("The fespace of vec number %i is not equal to the correspond fespace.\n", i+1); ("The fespace of vec number %i is not equal to the correspond fespace.\n", i+1);
} }
...@@ -498,12 +498,13 @@ namespace AMDiS { namespace io { ...@@ -498,12 +498,13 @@ namespace AMDiS { namespace io {
template<typename T> template<typename T>
void readValues(stringstream& file, vector<double>& values) void readValues(stringstream& file, vector<double>& values)
{ {
int size = values.size(); size_t size = values.size();
T data[size]; T* data = new T[size];
file.read(reinterpret_cast<char*>(&data[0]), sizeof(T) * size); file.read(reinterpret_cast<char*>(&data[0]), sizeof(T) * size);
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
values[i] = static_cast<double>(data[i]); values[i] = static_cast<double>(data[i]);
delete data;
} }
void readFile(string filename, Mesh *mesh, void readFile(string filename, Mesh *mesh,
...@@ -585,11 +586,13 @@ namespace AMDiS { namespace io { ...@@ -585,11 +586,13 @@ namespace AMDiS { namespace io {
nMacros = mesh->getNumberOfMacros(); nMacros = mesh->getNumberOfMacros();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
Parallel::mpi::globalAdd(nMacros); Parallel::mpi::globalAdd(nMacros);
if(MPI::COMM_WORLD.Get_rank() == 0) if(MPI::COMM_WORLD.Get_rank() == 0)
#endif #endif
{
TEST_EXIT(nMacros == nMacros_) TEST_EXIT(nMacros == nMacros_)
("Number of macro elements in parallel ARH files doesn't match to the current runtime. %d vs %d\n", ("Number of macro elements in parallel ARH files doesn't match to the current runtime. %d vs %d\n",
nMacros, nMacros_); nMacros, nMacros_);
}
if (!parh) { if (!parh) {
for (int i = 0; i < nProcs; i++) { for (int i = 0; i < nProcs; i++) {
...@@ -818,7 +821,7 @@ namespace AMDiS { namespace io { ...@@ -818,7 +821,7 @@ namespace AMDiS { namespace io {
file.read(const_cast<char*>(macroFilename.data()), macroFile_nl); file.read(const_cast<char*>(macroFilename.data()), macroFile_nl);
uint32_t rank = 0; uint32_t rank = 0;
for (size_t i = 0; i < nMacros; i++) { for (int i = 0; i < nMacros; i++) {
file.read(reinterpret_cast<char*>(&rank), 4); file.read(reinterpret_cast<char*>(&rank), 4);
partition.push_back(rank); partition.push_back(rank);
} }
......
...@@ -120,9 +120,7 @@ namespace AMDiS { namespace io { ...@@ -120,9 +120,7 @@ namespace AMDiS { namespace io {
Mesh* mesh_ = mesh ? mesh : vecs[0]->getFeSpace()->getMesh(); Mesh* mesh_ = mesh ? mesh : vecs[0]->getFeSpace()->getMesh();
if (MPI::COMM_WORLD.Get_rank() == 0) { if (MPI::COMM_WORLD.Get_rank() == 0) {
writeParallelFile(name + ".parh", writeParallelFile(name + ".parh", mesh_, filenameType);
mesh ? mesh : vecs[0]->getFeSpace()->getMesh(),
filenameType);
} }
TEST_EXIT(filenameType == "cont")("Only filename type \"cont\".\n"); TEST_EXIT(filenameType == "cont")("Only filename type \"cont\".\n");
...@@ -195,7 +193,7 @@ namespace AMDiS { namespace io { ...@@ -195,7 +193,7 @@ namespace AMDiS { namespace io {
string dataformat) string dataformat)
{ {
FUNCNAME("Arh3Writer::detail::writeHeader()"); FUNCNAME("Arh3Writer::detail::writeHeader()");
int nbits = boost::lexical_cast<int>(dataformat.substr(2, 2)); // int nbits = boost::lexical_cast<int>(dataformat.substr(2, 2));
TEST_EXIT(file.is_open())("the file is not open. should not happen.\n"); TEST_EXIT(file.is_open())("the file is not open. should not happen.\n");
map<const FiniteElemSpace*, string> AFEDfileName; map<const FiniteElemSpace*, string> AFEDfileName;
...@@ -277,11 +275,11 @@ namespace AMDiS { namespace io { ...@@ -277,11 +275,11 @@ namespace AMDiS { namespace io {
file.write(nameStr.c_str(), nameStrLen); file.write(nameStr.c_str(), nameStrLen);
DimVec<int>* nDOF = feSpaceIt->first->getBasisFcts()->getNumberOfDofs(); DimVec<int>* nDOF = feSpaceIt->first->getBasisFcts()->getNumberOfDofs();
// //
for(size_t j = 1; j < nDOF->getSize(); j++) { for(int j = 1; j < nDOF->getSize(); j++) {
posDOFs = (*nDOF)[j]; posDOFs = (*nDOF)[j];
file.write(reinterpret_cast<char*>(&posDOFs), 4); file.write(reinterpret_cast<char*>(&posDOFs), 4);
} }
for(size_t j = nDOF->getSize(); j < 4 ; j++) { for(int j = nDOF->getSize(); j < 4 ; j++) {
posDOFs = 0; posDOFs = 0;
file.write(reinterpret_cast<char*>(&posDOFs), 4); file.write(reinterpret_cast<char*>(&posDOFs), 4);
} }
...@@ -537,12 +535,13 @@ namespace AMDiS { namespace io { ...@@ -537,12 +535,13 @@ namespace AMDiS { namespace io {
template<typename T> template<typename T>
int writeValues(stringstream& file, vector<double>& values) int writeValues(stringstream& file, vector<double>& values)
{ {
int size = values.size(); size_t size = values.size();
T data[size]; T* data = new T[size];
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
data[i] = static_cast<T>(values[i]); data[i] = static_cast<T>(values[i]);
file.write(reinterpret_cast<char*>(&data[0]), sizeof(T) * size); file.write(reinterpret_cast<char*>(&data[0]), sizeof(T) * size);
delete data;
return sizeof(T) * size; return sizeof(T) * size;
} }
......
...@@ -88,7 +88,7 @@ namespace AMDiS { namespace Parallel { ...@@ -88,7 +88,7 @@ namespace AMDiS { namespace Parallel {
std::vector<const FiniteElemSpace*> tmpFeSpaces, tmpComponentSpaces(getComponentSpaces().begin(), std::vector<const FiniteElemSpace*> tmpFeSpaces, tmpComponentSpaces(getComponentSpaces().begin(),
getComponentSpaces().begin() + getNumComponents()); getComponentSpaces().begin() + getNumComponents());
for (int i = 0; i < tmpComponentSpaces.size(); i++) for (size_t i = 0; i < tmpComponentSpaces.size(); i++)
if (std::find(tmpFeSpaces.begin(), tmpFeSpaces.end(), tmpComponentSpaces[i]) == tmpFeSpaces.end()) if (std::find(tmpFeSpaces.begin(), tmpFeSpaces.end(), tmpComponentSpaces[i]) == tmpFeSpaces.end())
tmpFeSpaces.push_back(tmpComponentSpaces[i]); tmpFeSpaces.push_back(tmpComponentSpaces[i]);
......
...@@ -77,29 +77,7 @@ namespace AMDiS ...@@ -77,29 +77,7 @@ namespace AMDiS
} // end namespace Parallel } // end namespace Parallel
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
struct ProblemStat : public Parallel::ParallelProblemStat, typedef detail::ProblemStat<Parallel::ParallelProblemStat> ProblemStat;
public StandardProblemIteration
{
typedef Parallel::ParallelProblemStat super;
using super::getName;
ProblemStat(std::string nameStr,
ProblemIterationInterface *problemIteration = NULL)
: super(nameStr, problemIteration),
StandardProblemIteration(this)
{ }
Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo)
{
for (int i = 0; i < getNumComponents(); i++)
if (adaptInfo->spaceToleranceReached(i))
adaptInfo->allowRefinement(false, i);
else
adaptInfo->allowRefinement(true, i);
return StandardProblemIteration::oneIteration(adaptInfo, toDo);
}
};
#endif #endif
} // end namespace AMDiS } // end namespace AMDiS
......
...@@ -633,7 +633,7 @@ namespace AMDiS { namespace Parallel { ...@@ -633,7 +633,7 @@ namespace AMDiS { namespace Parallel {
void StdMpiHelper<vector<Matrix<int> > >::createBuffer(vector<Matrix<int> > &data, int *buf) void StdMpiHelper<vector<Matrix<int> > >::createBuffer(vector<Matrix<int> > &data, int *buf)
{ {
int dimOfWorld = Global::getGeo(WORLD); // int dimOfWorld = Global::getGeo(WORLD);
int pos = 0; int pos = 0;
buf[pos++] = data.size() > 0 ? data[0].getNumRows() : 0; buf[pos++] = data.size() > 0 ? data[0].getNumRows() : 0;
buf[pos++] = data.size() > 0 ? data[0].getNumCols() : 0; buf[pos++] = data.size() > 0 ? data[0].getNumCols() : 0;
......
...@@ -30,7 +30,7 @@ namespace AMDiS { namespace extensions { ...@@ -30,7 +30,7 @@ namespace AMDiS { namespace extensions {
template<typename T> template<typename T>
T Box::evalAtPoint(const DOFVector<T>& vec, const PointType& x, int strategy, int nrOfPoints) T Box::evalAtPoint(const DOFVector<T>& vec, const PointType& x, int strategy, int nrOfPoints)
{ {
T value; T value = 0;
switch (strategy) { switch (strategy) {
case 0: case 0:
value = evalAtPoint_simple(vec, x); value = evalAtPoint_simple(vec, x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment