From 6ee1c6b603a6354df911b803c703b1319cbd9b29 Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Fri, 1 Feb 2013 15:00:12 +0000 Subject: [PATCH] some updates of extensions --- extensions/ExtendedProblemStat.h | 7 ++++ extensions/Refinement_Level.h | 14 +------ extensions/VtuReader.hh | 3 ++ extensions/base_problems/BaseProblem.hh | 56 ++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 17 deletions(-) diff --git a/extensions/ExtendedProblemStat.h b/extensions/ExtendedProblemStat.h index 06359ad6..c9c0abe1 100644 --- a/extensions/ExtendedProblemStat.h +++ b/extensions/ExtendedProblemStat.h @@ -323,6 +323,9 @@ protected: // erase the rows for all first indices for (size_t i = 0; i < indices.size(); i++) { + if (indices[i].first == indices[i].second) + continue; + if (asmMatrix) { c_type cursor(begin<tag::row>(m)+indices[i].first); for (ic_type icursor(begin<tag::nz>(cursor)), icend(end<tag::nz>(cursor)); icursor != icend; ++icursor) { @@ -341,11 +344,15 @@ protected: matrix::inserter<Matrix, update_plus<double> > ins(m); if (row == col) { for (size_t i = 0; i < indices.size(); i++) { + if (indices[i].first == indices[i].second) + continue; ins[indices[i].first][indices[i].first] << 1.0; ins[indices[i].first][indices[i].second] << -1.0; } } for (size_t i = 0; i < indices.size(); i++) { + if (indices[i].first == indices[i].second) + continue; for (size_t j = 0; j < row_values[i].size(); j++) { ins[indices[i].second][row_values[i][j].first] << row_values[i][j].second; } diff --git a/extensions/Refinement_Level.h b/extensions/Refinement_Level.h index e1e5e608..9872fed4 100644 --- a/extensions/Refinement_Level.h +++ b/extensions/Refinement_Level.h @@ -247,16 +247,8 @@ public: void markElements(Flag &markFlag) { - FUNCNAME("RefinementLevelDOF::markElements()"); - - const DOFAdmin* admin = feSpace->getAdmin(); - const BasisFunction *basFcts = feSpace->getBasisFcts(); - int numBasFcts = basFcts->getNumber(); - - DegreeOfFreedom *localIndices = new DegreeOfFreedom[numBasFcts]; - FixVec<WorldVector<double>, VERTEX> coords(mesh->getDim(), NO_INIT); - double meanValue; - + FUNCNAME("RefinementLevelDOFList::markElements()"); + bool elMarkRefine = false, elMarkCoarsen = false; std::vector<ElementFunctionDOFVec<double>*> elFcts; @@ -291,8 +283,6 @@ public: markFlag= 1; if(elMarkCoarsen) markFlag|= 2; - - delete [] localIndices; }; private: std::vector<DOFVector<double>*> vecs; diff --git a/extensions/VtuReader.hh b/extensions/VtuReader.hh index 298172ba..5187b7b2 100644 --- a/extensions/VtuReader.hh +++ b/extensions/VtuReader.hh @@ -113,6 +113,9 @@ namespace AMDiS { (*it_results[i])++; } } + + + MSG("VTU file read from: %s\n", filename.c_str()); } } // end namespace VtuReader diff --git a/extensions/base_problems/BaseProblem.hh b/extensions/base_problems/BaseProblem.hh index 90d155d1..6cbe92fe 100644 --- a/extensions/base_problems/BaseProblem.hh +++ b/extensions/base_problems/BaseProblem.hh @@ -47,7 +47,7 @@ Flag BaseProblem<ProblemType>::initDataFromFile(AdaptInfo *adaptInfo) std::string readFormat = "arh"; Initfile::get(name + "->read format", readFormat, 2); - if (readFormat != "arh" && readFormat != "dat" && readFormat != "vtu") { + if (readFormat != "arh" && readFormat != "dat" && readFormat != "vtu" && readFormat != "multi-vtu") { WARNING("You can not read data from formats other than .arh, .dat or .vtu! The .arh-format is selected.\n"); } @@ -98,17 +98,63 @@ Flag BaseProblem<ProblemType>::initDataFromFile(AdaptInfo *adaptInfo) if (arh_idx >= 0) { ArhReader::read(filenames[arh_idx], prob->getMesh()); } - if (vtu_idx >= 0) { + if (vtu_idx >= 0) { + std::vector<int> readComponents; + Initfile::get(name + "->read components", readComponents); + if (readComponents.size() == 0) + for (size_t i = 0; i < prob->getNumComponents(); i++) + readComponents.push_back(i); + std::vector<DOFVector<double>*> solutions; std::vector<std::string> names; - for (size_t i = 0; i < prob->getNumComponents(); i++) { - solutions.push_back(prob->getSolution()->getDOFVector(i)); - names.push_back(prob->getComponentName(i)); + for (size_t i = 0; i < readComponents.size(); i++) { + solutions.push_back(prob->getSolution()->getDOFVector(readComponents[i])); + names.push_back(prob->getComponentName(readComponents[i])); } VtuReader::readValue(filenames[vtu_idx], prob->getMesh(), solutions, names); } else throw(std::runtime_error("You have to specify a .vtu file!")); } + else if (readFormat == "multi-vtu") { + size_t numFiles = 0; + Initfile::get(name + "->number of files", numFiles); + for (size_t n; n < numFiles; n++) { + std::vector<std::string> filenames; + Initfile::get(name + "->value file[" + boost::lexical_cast<std::string>(n) + "]", filenames); + if (filenames.size() == 0) + return initFlag; + int arh_idx = -1, vtu_idx = -1; + for (size_t i = 0; i < filenames.size(); i++) { + if (!file_exists(filenames[i])) + throw(std::runtime_error("The file '" + filenames[i] + "' does not exist!")); + if (filenames[i].find(".vtu") != std::string::npos) + vtu_idx = i; + else if (filenames[i].find(".arh") != std::string::npos) + arh_idx = i; + else + throw(std::runtime_error("The file '" + filenames[i] + "' must have the extension .arh or .vtu!")); + } + if (arh_idx >= 0) { + ArhReader::read(filenames[arh_idx], prob->getMesh()); + } + if (vtu_idx >= 0) { + std::vector<int> readComponents; + Initfile::get(name + "->read components[" + boost::lexical_cast<std::string>(n) + "]", readComponents); + if (readComponents.size() == 0) + for (size_t i = 0; i < prob->getNumComponents(); i++) + readComponents.push_back(i); + + std::vector<DOFVector<double>*> solutions; + std::vector<std::string> names; + for (size_t i = 0; i < readComponents.size(); i++) { + solutions.push_back(prob->getSolution()->getDOFVector(readComponents[i])); + names.push_back(prob->getComponentName(readComponents[i])); + } + VtuReader::readValue(filenames[vtu_idx], prob->getMesh(), solutions, names); + } else + throw(std::runtime_error("You have to specify a .vtu file!")); + } + } else { throw(std::runtime_error("Parameter 'read data from file' set to 'true', but no parameter 'read format' specified!")); } -- GitLab