Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konto der externen Nutzer:innen sind über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab. The administrators

Commit ec03ab8b authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

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

parent 2f4c9a9a
......@@ -209,7 +209,7 @@ namespace AMDiS {
inline void setName(std::string n)
{
name=n;
name = n;
}
inline BoundaryManager* getBoundaryManager() const
......
......@@ -531,8 +531,9 @@ namespace AMDiS {
inline WorldVector<double> operator*(double d, const WorldVector<double>& v)
{
return v*d;
return v * d;
}
inline WorldVector<double> operator+(const WorldVector<double>& v1,
const WorldVector<double>& v2)
{
......
......@@ -2,56 +2,56 @@
namespace AMDiS {
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();
std::string buf;
getline(in, buf);
while(buf != "vertex values: solution") getline(in, buf);
for(long i = 0; i < size; i++)
{
while (buf != "vertex values: solution")
getline(in, buf);
for (long i = 0; i < size; i++) {
in >> buf;
(*vec)[i] = atof(buf.c_str());
}
}
void readR(std::istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet,
Mesh* mesh)
DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh)
{
readDofvec(inStream, r, mesh);
std::vector< double >& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() &&
vecPhi2.size() != vecR.size();
std::vector<double>& vecR = r->getVector();
std::vector<double>& vecPhi1 = phi1->getVector();
std::vector<double>& vecPhi2 = phi2->getVector();
std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize =
vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
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);
vecPhi2[i] = Phi2(vecR[i], eps);
vecLevelSet[i] = LevelSet(vecR[i]);
}
}
void readPhi1(istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet,
Mesh* mesh)
DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh)
{
readDofvec(inStream, phi1, mesh);
std::vector< double >& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector();
std::vector<double>& vecR = r->getVector();
std::vector<double>& vecPhi1 = phi1->getVector();
std::vector<double>& vecPhi2 = phi2->getVector();
std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() &&
vecPhi2.size() != vecR.size();
bool checkSize =
vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
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);
//vecPhi2[i] = Phi2(vecR[i], eps);
vecPhi2[i] = 1 - vecPhi1[i];
......@@ -59,32 +59,30 @@ namespace AMDiS {
}
}
void readPhi2(istream& inStream, double eps,
DOFVector< double >* r, DOFVector< double >* phi1,
DOFVector< double >* phi2, DOFVector< double >* levelSet,
DOFVector<double>* r, DOFVector<double>* phi1,
DOFVector<double>* phi2, DOFVector<double>* levelSet,
Mesh* mesh)
{
readDofvec(inStream, phi2, mesh);
std::vector< double >& vecR = r->getVector();
std::vector< double >& vecPhi1 = phi1->getVector();
std::vector< double >& vecPhi2 = phi2->getVector();
std::vector< double >& vecLevelSet = levelSet->getVector();
std::vector<double>& vecR = r->getVector();
std::vector<double>& vecPhi1 = phi1->getVector();
std::vector<double>& vecPhi2 = phi2->getVector();
std::vector<double>& vecLevelSet = levelSet->getVector();
bool checkSize = vecR.size() != vecPhi1.size() &&
vecPhi2.size() != vecR.size();
bool checkSize = vecR.size() != vecPhi1.size() && vecPhi2.size() != vecR.size();
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);
//vecPhi1[i] = Phi1(vecR[i], eps);
vecPhi1[i] = 1 - vecPhi2[i];
vecLevelSet[i] = LevelSet(vecR[i]);
}
}
}
bool ProblemImplicitScal::createImplicitMesh()
{
std::string meshFilename("");
......@@ -98,14 +96,14 @@ namespace AMDiS {
if (dofFilename.length() == 0)
return false;
double eps(-1);
double eps(-1.0);
GET_PARAMETER(0, name + "->implicit mesh->eps", "%d", &eps);
if (eps<0)
if (eps < 0)
return false;
int serType(-1);
GET_PARAMETER(0, name + "->implicit mesh->type", "%d", &serType);
if (serType<0)
if (serType < 0)
return false;
TEST_EXIT(mesh != NULL)("the mesh was not created\n");
......@@ -139,16 +137,18 @@ namespace AMDiS {
return true;
}
void ProblemImplicitScal::initialize(Flag initFlag,
ProblemScal* adaptProblem, Flag adoptFlag)
{
FUNCNAME("ImplicitScal::initialize()");
FUNCNAME("ProblemImplicitScal::initialize()");
ProblemScal::initialize(CREATE_MESH);
createImplicitMesh();
initFlag = initFlag & ~CREATE_MESH;
ProblemScal::initialize(initFlag);
}
bool ProblemImplicitVec::createImplicitMesh()
{
//check each mesh if it's an implicit one
......@@ -156,15 +156,15 @@ namespace AMDiS {
phi1.resize(meshes.size());
phi2.resize(meshes.size());
levelSet.resize(meshes.size());
for(int i=0;i<meshes.size();++i) {
createImplicitMesh(i);
}
for (int i = 0; i < meshes.size(); ++i)
createImplicitMesh(i);
}
bool ProblemImplicitVec::createImplicitMesh(int p)
{
std::string path=name + "->implicit mesh[" +
boost::lexical_cast< std::string >(p) + "]->";
std::string path =
name + "->implicit mesh[" + boost::lexical_cast< std::string >(p) + "]->";
std::string meshFilename("");
GET_PARAMETER(0, path + "mesh file", &meshFilename);
//if no file name is given, there's no implicit mesh
......@@ -175,10 +175,10 @@ namespace AMDiS {
if (dofFilename.length() == 0)
return false;
double eps(-1);
double eps(-1.0);
GET_PARAMETER(0, path + "eps", "%d", &eps);
if(eps < 0)
return false;
if (eps < 0.0)
return false;
int serType(-1);
GET_PARAMETER(0, path + "type", "%d", &serType);
if (serType < 0)
......@@ -194,31 +194,31 @@ namespace AMDiS {
phi2[p] = new DOFVector<double>(getFeSpace(p), "phi2");
levelSet[p] = new DOFVector< double >(getFeSpace(p), "levelSet");
inStream.open(dofFilename.c_str());
switch (serType)
{
case 0:
calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
case 1:
calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
case 2:
calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
default:
WARNING("unknown implicit mesh type\n");
switch (serType) {
case 0:
calcspace::readR(inStream, eps,r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
case 1:
calcspace::readPhi1(inStream, eps, r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
case 2:
calcspace::readPhi2(inStream,eps, r[p], phi1[p], phi2[p],
levelSet[p], meshes[p]);
break;
default:
WARNING("unknown implicit mesh type\n");
}
inStream.close();
return true;
}
void ProblemImplicitVec::initialize(Flag initFlag,
ProblemScal* adaptProblem, Flag adoptFlag)
{
FUNCNAME("ImplicitScal::initialize()");
FUNCNAME("ProblemImplicitVec::initialize()");
ProblemVec::initialize(CREATE_MESH);
createImplicitMesh();
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
#define AMDIS_PROBLEMIMPLICIT_H
......@@ -8,7 +29,6 @@
namespace AMDiS {
class ProblemImplicitScal : public ProblemScal
{
public:
ProblemImplicitScal(std::string name, ProblemIterationInterface* pis = NULL)
: ProblemScal(name, pis),
......@@ -37,17 +57,17 @@ namespace AMDiS {
protected:
/// DOFVector for a signed distance
DOFVector< double > *r;
DOFVector<double> *r;
/// 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< double > *phi2;
DOFVector<double> *phi2;
/// DOFVector for the levelset function
/// (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 {
phi1(0),
phi2(0),
levelSet(0)
{}
{}
virtual bool createImplicitMesh();
virtual void initialize(Flag initFlag, ProblemScal *adoptProblem=NULL,
Flag adoptFlag = INIT_NOTHING);
protected:
bool createImplicitMesh(int p);
/// 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))
std::vector< DOFVector< double >* > phi1;
std::vector<DOFVector<double>*> phi1;
/// 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
/// (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 {
grdInterpolFct(grdFct)
{
Flag adoptFlag = INIT_SYSTEM | INIT_MESH | INIT_FE_SPACE;
Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER & ~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
if(initFlag.isSet(CREATE_MESH))
Flag initFlag = INIT_ALL & ~adoptFlag & ~INIT_SOLVER &
~INIT_ESTIMATOR & ~CREATE_MESH & ~INIT_FILEWRITER;
if (initFlag.isSet(CREATE_MESH))
WARNING("CREATE_MESH is set\n");
initialize(initFlag, spaceProblem, adoptFlag);
}
......
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