Commits (11)
......@@ -82,6 +82,16 @@ void SaveLoad::close() {
file = nullptr;
}
bool SaveLoad::FileExists(const char *name, int i) {
char namebuffer[128];
pNumberName(name, namebuffer, i);
return PPM->And(file_exists(namebuffer));
}
bool SaveLoad::PFileExists(const char *name) {
return FileExists(name, PPM->size());
}
Saver &Saver::operator<<(bool i) {
bool_t tmp = i;
xdr_bool(xdr(), &tmp);
......
......@@ -34,6 +34,10 @@ public:
void close();
static bool FileExists(const char *name, int i = -1);
static bool PFileExists(const char *name);
protected:
void open(const char *name, const char *mode, int i = -1);
......
......@@ -100,6 +100,8 @@ public:
Mesh(const Mesh &mesh, const MapGeometry &);
std::string Name() const { return meshName; }
void Fill(const CoarseGeometry &geometry, const MapGeometry &Map);
void Fill(const string &geoName, const MapGeometry &Map);
......
......@@ -109,23 +109,26 @@ void SerialVtuPlot::addPointData(const string &name, const Vector &data) {
Point z;
E.Receive(q) >> z;
PointData newData(dim);
PointData newData(dataDim(dim));
for (int i = 0; i < dim; i++) {
double a;
E.Receive(q) >> a;
newData.AddData(i, a);
}
for(int i = dim; i < 3; i++){
for (int i = dim; i < dataDim(dim); i++) {
newData.AddData(i, 0.0);
}
newPointData->insert({z, newData});
}
pointData[name] = newPointData;
pointDataSize[name] = dim;
pointDataSize[name] = dataDim(dim);
if (activeArrays.first.empty()) activeArrays.first = name;
}
int SerialVtuPlot::dataDim(int dim) const { return (dim > 1 ? 3 : 1); }
void SerialVtuPlot::addCellData(const string &name, const Vector &data) {
checkMesh(data.GetMesh());
......@@ -146,13 +149,13 @@ void SerialVtuPlot::addCellData(const string &name, const Vector &data) {
Point z;
E.Receive(q) >> z;
PointData newData(dim);
PointData newData(dataDim(dim));
for (int i = 0; i < dim; i++) {
double a;
E.Receive(q) >> a;
newData.AddData(i, a);
}
for(int i = dim; i < 3; i++){
for(int i = dim; i < dataDim(dim); i++){
newData.AddData(i, 0.0);
}
newCellData->insert({z, newData});
......@@ -160,7 +163,7 @@ void SerialVtuPlot::addCellData(const string &name, const Vector &data) {
}
cellData[name] = newCellData;
cellDataSize[name] = dim;
cellDataSize[name] = dataDim(dim);
if (activeArrays.second.empty()) activeArrays.second = name;
}
......
......@@ -117,8 +117,12 @@ string VtuPlot::FileString() {
<< R"(<DataArray type="Float32" Name=")" << cData.first
<< R"(" NumberOfComponents=")" << cellDataSize.at(cData.first)
<< R"(" format="ascii">)";
int dataSize = cellDataSize.at(cData.first);
for (int i = 0; i < cellN; i++) {
out << plotLineBreak(i, lineBreakZ, 5) + to_string(cData.second->at(cells[i]).GetData(0));
for (int j = 0; j < dataSize; j++)
out << plotLineBreak(i + j, lineBreakZ, 5)
<< to_string(cData.second->at(cells[i]).GetData(j));
}
out << "\n" << plotIndent(4) << "</DataArray>" << "\n";
}
......
......@@ -214,6 +214,8 @@ public:
void AddSubdomain(const Mesh &grid) override;
void AddProcLoad(const Mesh &grid) override;
int dataDim(int dim) const;
};
// TODO: Reimplement
......
......@@ -88,7 +88,9 @@ public:
* Can be used to print information about your assembled system.
*/
virtual void PrintInfo() const {
Exit("void PrintInfo() not implemented in your assembling.")
mout.PrintInfo("Assemble", verbose,
PrintInfoEntry("Name", this->Name(), 0)
);
}
virtual void PrintInfo(const Vector &u) const {
......
......@@ -131,9 +131,14 @@ void ENewton::operator()(const IAssemble &A, Vector &u) {
mout.EndBlock();
}
bool NewtonMethod(IAssemble *assemble, Vector &u) {
bool NewtonMethod(IAssemble &assemble, Vector &u) {
Newton newton;
newton.PrintInfo();
newton.operator()(*assemble, u);
assemble.PrintInfo();
newton.operator()(assemble, u);
return newton.converged();
}
bool NewtonMethod(IAssemble *assemble, Vector &u) {
return NewtonMethod(*assemble, u);
}
......@@ -121,6 +121,9 @@ public:
std::string Name() const override { return "Newton"; }
};
bool NewtonMethod(IAssemble &assemble, Vector &u);
/// Note that the assemble is not deleted here!
bool NewtonMethod(IAssemble *assemble, Vector &u);
class ENewton : public Newton {
......