Commit ec46c0fa authored by Thomas Witkowski's avatar Thomas Witkowski

Valuereader works now also for vectorial problems.

parent 6c8471f5
This diff is collapsed.
......@@ -412,13 +412,12 @@ namespace AMDiS {
std::string valueFilename("");
GET_PARAMETER(0, mesh->getName() + "->value file name", &valueFilename);
if (valueFilename.length()) {
ValueReader::readValue(valueFilename.c_str(),
ValueReader::readValue(valueFilename,
mesh,
solution,
mesh->getMacroFileInfo());
mesh->clearMacroFileInfo();
}
// === do global refinements ===
if (initFlag.isSet(INIT_GLOBAL_REFINES)) {
......
......@@ -26,6 +26,7 @@
#include "Flag.h"
#include "TraverseParallel.h"
#include "VtkWriter.h"
#include "ValueReader.h"
namespace AMDiS {
......@@ -191,14 +192,25 @@ namespace AMDiS {
&globalRefinements);
// Initialize the meshes if there is no serialization file.
for (int i = 0; i < static_cast<int>(meshes.size()); i++) {
if (initFlag.isSet(INIT_MESH) &&
meshes[i] &&
!(meshes[i]->isInitialized())) {
for (int i = 0; i < static_cast<int>(meshes.size()); i++)
if (initFlag.isSet(INIT_MESH) && meshes[i] && !(meshes[i]->isInitialized()))
meshes[i]->initialize();
// === read value file and use it for the mesh values ===
std::string valueFilename("");
GET_PARAMETER(0, meshes[0]->getName() + "->value file name", &valueFilename);
if (valueFilename.length()) {
ValueReader::readValue(valueFilename,
meshes[0],
solution->getDOFVector(0),
meshes[0]->getMacroFileInfo());
meshes[0]->clearMacroFileInfo();
}
// === do global refinements ===
for (int i = 0; i < static_cast<int>(meshes.size()); i++)
if (initFlag.isSet(INIT_MESH) && meshes[i])
refinementManager->globalRefine(meshes[i], globalRefinements);
}
}
}
}
......
......@@ -12,16 +12,14 @@ namespace AMDiS {
* macroFileInfo. The function now reads the corresponding value file and
* copies the values to the correct positions in the DOF vector.
*/
void ValueReader::readValue(const char *filename,
void ValueReader::readValue(const std::string filename,
Mesh *mesh,
DOFVector<double> *dofVector,
MacroInfo *macroFileInfo)
{
FUNCNAME("ValueReader::readValue()");
TEST_EXIT(filename)("no file specified; filename NULL pointer\n");
TEST_EXIT(strlen(filename) < static_cast<unsigned int>(127))
("can only handle filenames up to 127 characters\n");
TEST_EXIT(filename != "")("Filename not specified!\n");
TEST_EXIT(mesh)("no mesh specified\n");
TEST_EXIT(dofVector)("no DOF vector specified\n");
TEST_EXIT(macroFileInfo)("no MacroInfo specified\n");
......@@ -29,7 +27,7 @@ namespace AMDiS {
std::string line;
// open the file and read the data to the vector values.
std::ifstream file(filename, std::ifstream::in);
std::ifstream file(filename.c_str(), std::ifstream::in);
while (!file.eof()) {
getline(file, line);
......
......@@ -28,10 +28,6 @@
namespace AMDiS {
// ===========================================================================
// ===== class ValueReader ===================================================
// ===========================================================================
/** \ingroup Input
*
* \brief
......@@ -41,10 +37,8 @@ namespace AMDiS {
class ValueReader
{
public:
/** \brief
* Copies the values of a value file to a DOF vector.
*/
static void readValue(const char *filename,
/// Copies the values of a value file to a DOF vector.
static void readValue(const std::string filename,
Mesh *mesh,
DOFVector<double> *dofVector,
MacroInfo *macroFileInfo);
......
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