Skip to content
Snippets Groups Projects
Commit ec03ab8b authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Andreas' last changes, but now with AMDiS code style.

parent 2f4c9a9a
No related branches found
No related tags found
No related merge requests found
...@@ -209,7 +209,7 @@ namespace AMDiS { ...@@ -209,7 +209,7 @@ namespace AMDiS {
inline void setName(std::string n) inline void setName(std::string n)
{ {
name=n; name = n;
} }
inline BoundaryManager* getBoundaryManager() const inline BoundaryManager* getBoundaryManager() const
......
...@@ -531,8 +531,9 @@ namespace AMDiS { ...@@ -531,8 +531,9 @@ namespace AMDiS {
inline WorldVector<double> operator*(double d, const WorldVector<double>& v) inline WorldVector<double> operator*(double d, const WorldVector<double>& v)
{ {
return v*d; return v * d;
} }
inline WorldVector<double> operator+(const WorldVector<double>& v1, inline WorldVector<double> operator+(const WorldVector<double>& v1,
const WorldVector<double>& v2) const WorldVector<double>& v2)
{ {
......
...@@ -2,56 +2,56 @@ ...@@ -2,56 +2,56 @@
namespace AMDiS { namespace AMDiS {
namespace calcspace { namespace calcspace {
void readDofvec(std::istream& in, DOFVector< double >* vec, Mesh* mesh) void readDofvec(std::istream& in, DOFVector<double>* vec, Mesh* mesh)
{ {
long size = mesh->getNumberOfVertices(); long size = mesh->getNumberOfVertices();
std::string buf; std::string buf;
getline(in, buf); getline(in, buf);
while(buf != "vertex values: solution") getline(in, buf); while (buf != "vertex values: solution")
for(long i = 0; i < size; i++) getline(in, buf);
{ for (long i = 0; i < size; i++) {
in >> buf; in >> buf;
(*vec)[i] = atof(buf.c_str()); (*vec)[i] = atof(buf.c_str());
} }
} }
void readR(std::istream& inStream, double eps, void readR(std::istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1, DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet, DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh) Mesh* mesh)
{ {
readDofvec(inStream, r, mesh); readDofvec(inStream, r, mesh);
std::vector< double >& vecR = r->getVector(); std::vector<double>& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector(); std::vector<double>& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector(); std::vector<double>& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector(); std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() && bool checkSize =
vecPhi2.size() != vecR.size(); vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
TEST_EXIT(checkSize)("something went wrong\n"); TEST_EXIT(checkSize)("something went wrong\n");
for (int i = vecR.size()-1; i >= 0; --i) for (int i = vecR.size() - 1; i >= 0; --i) {
{
vecPhi1[i] = Phi1(vecR[i], eps); vecPhi1[i] = Phi1(vecR[i], eps);
vecPhi2[i] = Phi2(vecR[i], eps); vecPhi2[i] = Phi2(vecR[i], eps);
vecLevelSet[i] = LevelSet(vecR[i]); vecLevelSet[i] = LevelSet(vecR[i]);
} }
} }
void readPhi1(istream& inStream, double eps, void readPhi1(istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1, DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet, DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh) Mesh* mesh)
{ {
readDofvec(inStream, phi1, mesh); readDofvec(inStream, phi1, mesh);
std::vector< double >& vecR = r->getVector(); std::vector<double>& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector(); std::vector<double>& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector(); std::vector<double>& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector(); std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() && bool checkSize =
vecPhi2.size() != vecR.size(); vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
TEST_EXIT(checkSize)("something went wrong\n"); TEST_EXIT(checkSize)("something went wrong\n");
for (int i = vecR.size()-1; i>= 0; --i) for (int i = vecR.size() - 1; i>= 0; --i) {
{
vecR[i] = Phi1ToR(vecPhi1[i], eps); vecR[i] = Phi1ToR(vecPhi1[i], eps);
//vecPhi2[i] = Phi2(vecR[i], eps); //vecPhi2[i] = Phi2(vecR[i], eps);
vecPhi2[i] = 1 - vecPhi1[i]; vecPhi2[i] = 1 - vecPhi1[i];
...@@ -59,32 +59,30 @@ namespace AMDiS { ...@@ -59,32 +59,30 @@ namespace AMDiS {
} }
} }
void readPhi2(istream& inStream, double eps, void readPhi2(istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1, DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet, DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh) Mesh* mesh)
{ {
readDofvec(inStream, phi2, mesh); readDofvec(inStream, phi2, mesh);
std::vector< double >& vecR = r->getVector(); std::vector<double>& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector(); std::vector<double>& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector(); std::vector<double>& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector(); std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() && bool checkSize = vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
vecPhi2.size() != vecR.size();
TEST_EXIT(checkSize)("something went wrong\n"); TEST_EXIT(checkSize)("something went wrong\n");
for (int i = vecR.size()-1; i >= 0; --i) for (int i = vecR.size() - 1; i >= 0; --i) {
{
vecR[i] = Phi2ToR(vecPhi2[i], eps); vecR[i] = Phi2ToR(vecPhi2[i], eps);
//vecPhi1[i] = Phi1(vecR[i], eps); //vecPhi1[i] = Phi1(vecR[i], eps);
vecPhi1[i] = 1 - vecPhi2[i]; vecPhi1[i] = 1 - vecPhi2[i];
vecLevelSet[i] = LevelSet(vecR[i]); vecLevelSet[i] = LevelSet(vecR[i]);
} }
} }
} }
bool ProblemImplicitScal::createImplicitMesh() bool ProblemImplicitScal::createImplicitMesh()
{ {
std::string meshFilename(""); std::string meshFilename("");
...@@ -98,14 +96,14 @@ namespace AMDiS { ...@@ -98,14 +96,14 @@ namespace AMDiS {
if (dofFilename.length() == 0) if (dofFilename.length() == 0)
return false; return false;
double eps(-1); double eps(-1.0);
GET_PARAMETER(0, name + "->implicit mesh->eps", "%d", &eps); GET_PARAMETER(0, name + "->implicit mesh->eps", "%d", &eps);
if (eps<0) if (eps < 0)
return false; return false;
int serType(-1); int serType(-1);
GET_PARAMETER(0, name + "->implicit mesh->type", "%d", &serType); GET_PARAMETER(0, name + "->implicit mesh->type", "%d", &serType);
if (serType<0) if (serType < 0)
return false; return false;
TEST_EXIT(mesh != NULL)("the mesh was not created\n"); TEST_EXIT(mesh != NULL)("the mesh was not created\n");
...@@ -139,16 +137,18 @@ namespace AMDiS { ...@@ -139,16 +137,18 @@ namespace AMDiS {
return true; return true;
} }
void ProblemImplicitScal::initialize(Flag initFlag, void ProblemImplicitScal::initialize(Flag initFlag,
ProblemScal* adaptProblem, Flag adoptFlag) ProblemScal* adaptProblem, Flag adoptFlag)
{ {
FUNCNAME("ImplicitScal::initialize()"); FUNCNAME("ProblemImplicitScal::initialize()");
ProblemScal::initialize(CREATE_MESH); ProblemScal::initialize(CREATE_MESH);
createImplicitMesh(); createImplicitMesh();
initFlag = initFlag & ~CREATE_MESH; initFlag = initFlag & ~CREATE_MESH;
ProblemScal::initialize(initFlag); ProblemScal::initialize(initFlag);
} }
bool ProblemImplicitVec::createImplicitMesh() bool ProblemImplicitVec::createImplicitMesh()
{ {
//check each mesh if it's an implicit one //check each mesh if it's an implicit one
...@@ -156,15 +156,15 @@ namespace AMDiS { ...@@ -156,15 +156,15 @@ namespace AMDiS {
phi1.resize(meshes.size()); phi1.resize(meshes.size());
phi2.resize(meshes.size()); phi2.resize(meshes.size());
levelSet.resize(meshes.size()); levelSet.resize(meshes.size());
for(int i=0;i<meshes.size();++i) { for (int i = 0; i < meshes.size(); ++i)
createImplicitMesh(i); createImplicitMesh(i);
}
} }
bool ProblemImplicitVec::createImplicitMesh(int p) bool ProblemImplicitVec::createImplicitMesh(int p)
{ {
std::string path=name + "->implicit mesh[" + std::string path =
boost::lexical_cast< std::string >(p) + "]->"; name + "->implicit mesh[" + boost::lexical_cast< std::string >(p) + "]->";
std::string meshFilename(""); std::string meshFilename("");
GET_PARAMETER(0, path + "mesh file", &meshFilename); GET_PARAMETER(0, path + "mesh file", &meshFilename);
//if no file name is given, there's no implicit mesh //if no file name is given, there's no implicit mesh
...@@ -175,10 +175,10 @@ namespace AMDiS { ...@@ -175,10 +175,10 @@ namespace AMDiS {
if (dofFilename.length() == 0) if (dofFilename.length() == 0)
return false; return false;
double eps(-1); double eps(-1.0);
GET_PARAMETER(0, path + "eps", "%d", &eps); GET_PARAMETER(0, path + "eps", "%d", &eps);
if(eps < 0) if (eps < 0.0)
return false; return false;
int serType(-1); int serType(-1);
GET_PARAMETER(0, path + "type", "%d", &serType); GET_PARAMETER(0, path + "type", "%d", &serType);
if (serType < 0) if (serType < 0)
...@@ -194,31 +194,31 @@ namespace AMDiS { ...@@ -194,31 +194,31 @@ namespace AMDiS {
phi2[p] = new DOFVector<double>(getFeSpace(p), "phi2"); phi2[p] = new DOFVector<double>(getFeSpace(p), "phi2");
levelSet[p] = new DOFVector< double >(getFeSpace(p), "levelSet"); levelSet[p] = new DOFVector< double >(getFeSpace(p), "levelSet");
inStream.open(dofFilename.c_str()); inStream.open(dofFilename.c_str());
switch (serType) switch (serType) {
{ case 0:
case 0: calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p],
calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p], levelSet[p], meshes[p]);
levelSet[p], meshes[p]); break;
break; case 1:
case 1: calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p],
calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p], levelSet[p], meshes[p]);
levelSet[p], meshes[p]); break;
break; case 2:
case 2: calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p],
calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p], levelSet[p], meshes[p]);
levelSet[p], meshes[p]); break;
break; default:
default: WARNING("unknown implicit mesh type\n");
WARNING("unknown implicit mesh type\n");
} }
inStream.close(); inStream.close();
return true; return true;
} }
void ProblemImplicitVec::initialize(Flag initFlag, void ProblemImplicitVec::initialize(Flag initFlag,
ProblemScal* adaptProblem, Flag adoptFlag) ProblemScal* adaptProblem, Flag adoptFlag)
{ {
FUNCNAME("ImplicitScal::initialize()"); FUNCNAME("ProblemImplicitVec::initialize()");
ProblemVec::initialize(CREATE_MESH); ProblemVec::initialize(CREATE_MESH);
createImplicitMesh(); createImplicitMesh();
initFlag = initFlag & ~CREATE_MESH; initFlag = initFlag & ~CREATE_MESH;
......
// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==
// ============================================================================
// == ==
// == TU Dresden ==
// == ==
// == Institut fr Wissenschaftliches Rechnen ==
// == Zellescher Weg 12-14 ==
// == 01069 Dresden ==
// == germany ==
// == ==
// ============================================================================
// == ==
// == https://gforge.zih.tu-dresden.de/projects/amdis/ ==
// == ==
// ============================================================================
/** \file ProblemImplicit.h */
#ifndef AMDIS_PROBLEMIMPLICIT_H #ifndef AMDIS_PROBLEMIMPLICIT_H
#define AMDIS_PROBLEMIMPLICIT_H #define AMDIS_PROBLEMIMPLICIT_H
...@@ -8,7 +29,6 @@ ...@@ -8,7 +29,6 @@
namespace AMDiS { namespace AMDiS {
class ProblemImplicitScal : public ProblemScal class ProblemImplicitScal : public ProblemScal
{ {
public: public:
ProblemImplicitScal(std::string name, ProblemIterationInterface* pis = NULL) ProblemImplicitScal(std::string name, ProblemIterationInterface* pis = NULL)
: ProblemScal(name, pis), : ProblemScal(name, pis),
...@@ -37,17 +57,17 @@ namespace AMDiS { ...@@ -37,17 +57,17 @@ namespace AMDiS {
protected: protected:
/// DOFVector for a signed distance /// DOFVector for a signed distance
DOFVector< double > *r; DOFVector<double> *r;
/// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps)) /// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps))
DOFVector< double > *phi1; DOFVector<double> *phi1;
/// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps)) /// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps))
DOFVector< double > *phi2; DOFVector<double> *phi2;
/// DOFVector for the levelset function /// DOFVector for the levelset function
/// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0) /// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0)
DOFVector< double > *levelSet; DOFVector<double> *levelSet;
}; };
...@@ -61,27 +81,27 @@ namespace AMDiS { ...@@ -61,27 +81,27 @@ namespace AMDiS {
phi1(0), phi1(0),
phi2(0), phi2(0),
levelSet(0) levelSet(0)
{} {}
virtual bool createImplicitMesh(); virtual bool createImplicitMesh();
virtual void initialize(Flag initFlag, ProblemScal *adoptProblem=NULL, virtual void initialize(Flag initFlag, ProblemScal *adoptProblem=NULL,
Flag adoptFlag = INIT_NOTHING); Flag adoptFlag = INIT_NOTHING);
protected: protected:
bool createImplicitMesh(int p); bool createImplicitMesh(int p);
/// DOFVector for a signed distance /// DOFVector for a signed distance
std::vector< DOFVector< double >* > r; std::vector<DOFVector<double>*> r;
/// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps)) /// DOFVector for the phasefield function 0.5*(1-tanh(3*r/eps))
std::vector< DOFVector< double >* > phi1; std::vector<DOFVector<double>*> phi1;
/// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps)) /// DOFVector for the phasefield function 0.5*(1+tanh(3*r/eps))
std::vector< DOFVector< double >* > phi2; std::vector<DOFVector<double>*> phi2;
/// DOFVector for the levelset function /// DOFVector for the levelset function
/// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0) /// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0)
std::vector< DOFVector< double >* > levelSet; std::vector<DOFVector<double>*> levelSet;
}; };
} }
......
...@@ -15,8 +15,9 @@ namespace AMDiS { ...@@ -15,8 +15,9 @@ namespace AMDiS {
grdInterpolFct(grdFct) grdInterpolFct(grdFct)
{ {
Flag adoptFlag = INIT_SYSTEM | INIT_MESH | INIT_FE_SPACE; Flag adoptFlag = INIT_SYSTEM | INIT_MESH | INIT_FE_SPACE;
Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER; Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER &
if(initFlag.isSet(CREATE_MESH)) ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
if (initFlag.isSet(CREATE_MESH))
WARNING("CREATE_MESH is set\n"); WARNING("CREATE_MESH is set\n");
initialize(initFlag, spaceProblem, adoptFlag); initialize(initFlag, spaceProblem, adoptFlag);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment