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

Introduction of multi-mesh method for gradients of basis function. Some code...

Introduction of multi-mesh method for gradients of basis function. Some code refactoring, removed NEW and DELETE macros.
parent 42675765
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
const Flag HL_SignedDist::VEL_EXT = 0X01L; const Flag HL_SignedDist::VEL_EXT = 0X01L;
const Flag HL_SignedDist::VEL_EXT_FROM_VEL_FIELD = 0X02L; const Flag HL_SignedDist::VEL_EXT_FROM_VEL_FIELD = 0X02L;
void void HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_,
HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_, const DOFVector<double> *lS_DOF_,
const DOFVector<double> *lS_DOF_, DOFVector<double> *sD_DOF_,
DOFVector<double> *sD_DOF_, ElementFunction<double> *elFct)
ElementFunction<double> *elFct)
{ {
adaptInfo = adaptInfo_; adaptInfo = adaptInfo_;
...@@ -31,8 +30,8 @@ HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_, ...@@ -31,8 +30,8 @@ HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_,
// ===== Create DOF vector to mark boundary vertices. ===== // ===== Create DOF vector to mark boundary vertices. =====
if (bound_DOF) if (bound_DOF)
DELETE bound_DOF; delete bound_DOF;
bound_DOF = NEW DOFVector<double>(feSpace, "bound_DOF"); bound_DOF = new DOFVector<double>(feSpace, "bound_DOF");
bound_DOF->set(0.0); bound_DOF->set(0.0);
// ===== Boundary vertex and boundary value initialization. ===== // ===== Boundary vertex and boundary value initialization. =====
...@@ -52,30 +51,28 @@ HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_, ...@@ -52,30 +51,28 @@ HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_,
printSignedDistFct(); printSignedDistFct();
} }
void
HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_, void HL_SignedDist::calcSignedDistFct(AdaptInfo *adaptInfo_, DOFVector<double> *lS_DOF_)
DOFVector<double> *lS_DOF_)
{ {
TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n"); TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n");
sD_DOF = NEW DOFVector<double>(lS_DOF_->getFESpace(), "sD_DOF"); sD_DOF = new DOFVector<double>(lS_DOF_->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, NULL); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, NULL);
// lS_DOF_->copy(*sD_DOF);
*lS_DOF_ = *sD_DOF; *lS_DOF_ = *sD_DOF;
DELETE sD_DOF; delete sD_DOF;
} }
void
HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, void HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
DOFVector<double> *origVel_DOF_, DOFVector<double> *origVel_DOF_,
DOFVector<double> *vel_DOF_, DOFVector<double> *vel_DOF_,
const DOFVector<double> *lS_DOF_, const DOFVector<double> *lS_DOF_,
DOFVector<double> *sD_DOF_, DOFVector<double> *sD_DOF_,
bool calcSDFct, bool calcSDFct,
ElementFunction<double> *elFct) ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n"); TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n");
TEST_EXIT(velExt)("velExt not defined !\n"); TEST_EXIT(velExt)("velExt not defined !\n");
...@@ -86,27 +83,26 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, ...@@ -86,27 +83,26 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
if (calcSDFct || sD_DOF_ != NULL) { if (calcSDFct || sD_DOF_ != NULL) {
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct);
} } else {
else {
TEST_EXIT(vel_DOF_)("illegal level set function lS_DOF_ !\n"); TEST_EXIT(vel_DOF_)("illegal level set function lS_DOF_ !\n");
sD_DOF = NEW DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF"); sD_DOF = new DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
DELETE sD_DOF; delete sD_DOF;
} }
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
} }
void
HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, void HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
DOFVector<double> *vel_DOF_, DOFVector<double> *vel_DOF_,
DOFVector<double> *lS_DOF_, DOFVector<double> *lS_DOF_,
bool calcSDFct, bool calcSDFct,
ElementFunction<double> *elFct) ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n"); TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n");
TEST_EXIT(velExt)("velExt not defined !\n"); TEST_EXIT(velExt)("velExt not defined !\n");
...@@ -116,42 +112,40 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, ...@@ -116,42 +112,40 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n"); TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n");
DOFVector<double> *newVel_DOF_ = DOFVector<double> *newVel_DOF_ =
NEW DOFVector<double>(vel_DOF_->getFESpace(), "vel_DOF_"); new DOFVector<double>(vel_DOF_->getFESpace(), "vel_DOF_");
velExt->setVelocity(vel_DOF_, newVel_DOF_); velExt->setVelocity(vel_DOF_, newVel_DOF_);
velExt->printOrigVelDOF(adaptInfo_); velExt->printOrigVelDOF(adaptInfo_);
if (calcSDFct && elFct == NULL) if (calcSDFct && elFct == NULL) {
calcSignedDistFct(adaptInfo_, lS_DOF_); calcSignedDistFct(adaptInfo_, lS_DOF_);
else { } else {
sD_DOF = new DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF");
sD_DOF = NEW DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
if (calcSDFct) if (calcSDFct)
lS_DOF_->copy(*sD_DOF); lS_DOF_->copy(*sD_DOF);
DELETE sD_DOF; delete sD_DOF;
} }
vel_DOF_->copy(*newVel_DOF_); vel_DOF_->copy(*newVel_DOF_);
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
DELETE newVel_DOF_; delete newVel_DOF_;
} }
void
HL_SignedDist::calcVelocityExt( void HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
AdaptInfo *adaptInfo_, std::vector<DOFVector<double> *> origVel_DOF_,
std::vector<DOFVector<double> *> origVel_DOF_, std::vector<DOFVector<double> *> vel_DOF_,
std::vector<DOFVector<double> *> vel_DOF_, const DOFVector<double> *lS_DOF_,
const DOFVector<double> *lS_DOF_, DOFVector<double> *sD_DOF_,
DOFVector<double> *sD_DOF_, bool calcSDFct,
bool calcSDFct, ElementFunction<double> *elFct)
ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n"); TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n");
TEST_EXIT(velExt)("velExt not defined !\n"); TEST_EXIT(velExt)("velExt not defined !\n");
...@@ -162,27 +156,26 @@ HL_SignedDist::calcVelocityExt( ...@@ -162,27 +156,26 @@ HL_SignedDist::calcVelocityExt(
if (calcSDFct || sD_DOF_ != NULL) { if (calcSDFct || sD_DOF_ != NULL) {
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct);
} } else {
else {
TEST_EXIT(vel_DOF_[0])("illegal level set function lS_DOF_ !\n"); TEST_EXIT(vel_DOF_[0])("illegal level set function lS_DOF_ !\n");
sD_DOF = NEW DOFVector<double>(vel_DOF_[0]->getFESpace(), "sD_DOF"); sD_DOF = new DOFVector<double>(vel_DOF_[0]->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
DELETE sD_DOF; delete sD_DOF;
} }
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
} }
void
HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, void HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
std::vector<DOFVector<double> *> vel_DOF_, std::vector<DOFVector<double> *> vel_DOF_,
DOFVector<double> *lS_DOF_, DOFVector<double> *lS_DOF_,
bool calcSDFct, bool calcSDFct,
ElementFunction<double> *elFct) ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n"); TEST_EXIT(velExtType.isSet(VEL_EXT))("illegal velocity extension type !\n");
TEST_EXIT(velExt)("velExt not defined !\n"); TEST_EXIT(velExt)("velExt not defined !\n");
...@@ -193,30 +186,27 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, ...@@ -193,30 +186,27 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n"); TEST_EXIT(lS_DOF_)("illegal level set function lS_DOF_ !\n");
std::vector<DOFVector<double> *> newVel_DOF_(nVelDOFs); std::vector<DOFVector<double> *> newVel_DOF_(nVelDOFs);
for (int nV=0; nV<nVelDOFs; ++nV) { for (int nV = 0; nV < nVelDOFs; ++nV) {
TEST_EXIT(vel_DOF_[nV])("velocity vector vel_DOF_ not defined !\n");
TEST_EXIT(vel_DOF_[nV])("velocity vector vel_DOF_ not defined !\n");
newVel_DOF_[nV] = new DOFVector<double>((vel_DOF_[nV])->getFESpace(), "vel_DOF_");
newVel_DOF_[nV] =
NEW DOFVector<double>((vel_DOF_[nV])->getFESpace(), "vel_DOF_");
} }
velExt->setVelocity(vel_DOF_, newVel_DOF_); velExt->setVelocity(vel_DOF_, newVel_DOF_);
velExt->printOrigVelDOF(adaptInfo_); velExt->printOrigVelDOF(adaptInfo_);
if (calcSDFct && elFct == NULL) if (calcSDFct && elFct == NULL) {
calcSignedDistFct(adaptInfo_, lS_DOF_); calcSignedDistFct(adaptInfo_, lS_DOF_);
else { } else {
sD_DOF = new DOFVector<double>(vel_DOF_[0]->getFESpace(), "sD_DOF");
sD_DOF = NEW DOFVector<double>(vel_DOF_[0]->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
if (calcSDFct) if (calcSDFct)
lS_DOF_->copy(*sD_DOF); lS_DOF_->copy(*sD_DOF);
DELETE sD_DOF; delete sD_DOF;
} }
for (int nV=0; nV<nVelDOFs; ++nV) for (int nV=0; nV<nVelDOFs; ++nV)
...@@ -224,19 +214,18 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_, ...@@ -224,19 +214,18 @@ HL_SignedDist::calcVelocityExt(AdaptInfo *adaptInfo_,
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
for (int nV=0; nV<nVelDOFs; ++nV) for (int nV = 0; nV < nVelDOFs; ++nV)
DELETE newVel_DOF_[nV]; delete newVel_DOF_[nV];
} }
void
HL_SignedDist::calcVelocityExtFromVelocityField( void HL_SignedDist::calcVelocityExtFromVelocityField(AdaptInfo *adaptInfo_,
AdaptInfo *adaptInfo_, std::vector<DOFVector<double> *> &velField_,
std::vector<DOFVector<double> *> &velField_, DOFVector<double> *vel_DOF_,
DOFVector<double> *vel_DOF_, const DOFVector<double> *lS_DOF_,
const DOFVector<double> *lS_DOF_, DOFVector<double> *sD_DOF_,
DOFVector<double> *sD_DOF_, bool calcSDFct,
bool calcSDFct, ElementFunction<double> *elFct)
ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT_FROM_VEL_FIELD)) TEST_EXIT(velExtType.isSet(VEL_EXT_FROM_VEL_FIELD))
("illegal velocity extension type !\n"); ("illegal velocity extension type !\n");
...@@ -247,29 +236,27 @@ HL_SignedDist::calcVelocityExtFromVelocityField( ...@@ -247,29 +236,27 @@ HL_SignedDist::calcVelocityExtFromVelocityField(
if (calcSDFct) { if (calcSDFct) {
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF_, elFct);
} } else {
else {
TEST_EXIT(vel_DOF_)("illegal velocity vector vel_DOF_ !\n"); TEST_EXIT(vel_DOF_)("illegal velocity vector vel_DOF_ !\n");
sD_DOF = NEW DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF"); sD_DOF = new DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
DELETE sD_DOF; delete sD_DOF;
} }
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
} }
void
HL_SignedDist::calcVelocityExtFromVelocityField( void HL_SignedDist::calcVelocityExtFromVelocityField(AdaptInfo *adaptInfo_,
AdaptInfo *adaptInfo_, std::vector<DOFVector<double> *> &velField_,
std::vector<DOFVector<double> *> &velField_, DOFVector<double> *vel_DOF_,
DOFVector<double> *vel_DOF_, DOFVector<double> *lS_DOF_,
DOFVector<double> *lS_DOF_, bool calcSDFct,
bool calcSDFct, ElementFunction<double> *elFct)
ElementFunction<double> *elFct)
{ {
TEST_EXIT(velExtType.isSet(VEL_EXT_FROM_VEL_FIELD)) TEST_EXIT(velExtType.isSet(VEL_EXT_FROM_VEL_FIELD))
("illegal velocity extension type !\n"); ("illegal velocity extension type !\n");
...@@ -283,44 +270,42 @@ HL_SignedDist::calcVelocityExtFromVelocityField( ...@@ -283,44 +270,42 @@ HL_SignedDist::calcVelocityExtFromVelocityField(
if (calcSDFct && elFct == NULL) { if (calcSDFct && elFct == NULL) {
calcSignedDistFct(adaptInfo_, lS_DOF_); calcSignedDistFct(adaptInfo_, lS_DOF_);
} } else {
else {
TEST_EXIT(vel_DOF_)("illegal velocity vector vel_DOF_ !\n"); TEST_EXIT(vel_DOF_)("illegal velocity vector vel_DOF_ !\n");
sD_DOF = NEW DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF"); sD_DOF = new DOFVector<double>(vel_DOF_->getFESpace(), "sD_DOF");
calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct); calcSignedDistFct(adaptInfo_, lS_DOF_, sD_DOF, elFct);
if (calcSDFct) if (calcSDFct)
lS_DOF_->copy(*sD_DOF); lS_DOF_->copy(*sD_DOF);
DELETE sD_DOF; delete sD_DOF;
} }
velExt->printVelDOF(adaptInfo_); velExt->printVelDOF(adaptInfo_);
} }
void
HL_SignedDist::initialize(ElementFunction<double> *elFct) void HL_SignedDist::initialize(ElementFunction<double> *elFct)
{ {
if (elUpdate) if (elUpdate)
DELETE elUpdate; delete elUpdate;
if (bndElDist) if (bndElDist)
DELETE bndElDist; delete bndElDist;
if (elLS) if (elLS)
DELETE elLS; delete elLS;
if (phi) if (phi)
DELETE phi; delete phi;
// ===== Create ElementLevelSet. ===== // ===== Create ElementLevelSet. =====
if (elFct == NULL) { if (elFct == NULL) {
phi = NEW ElementFunctionDOFVec<double>(lS_DOF); phi = new ElementFunctionDOFVec<double>(lS_DOF);
elLS = NEW ElementLevelSet("ElementLevelSet", phi, feSpace->getMesh()); elLS = new ElementLevelSet("ElementLevelSet", phi, feSpace->getMesh());
} } else {
else { elLS = new ElementLevelSet("ElementLevelSet", elFct, feSpace->getMesh());
elLS = NEW ElementLevelSet("ElementLevelSet", elFct, feSpace->getMesh());
} }
...@@ -329,13 +314,13 @@ HL_SignedDist::initialize(ElementFunction<double> *elFct) ...@@ -329,13 +314,13 @@ HL_SignedDist::initialize(ElementFunction<double> *elFct)
GET_PARAMETER(0, name + "->boundary initialization", "%d", GET_PARAMETER(0, name + "->boundary initialization", "%d",
&boundInitFlag); &boundInitFlag);
switch(boundInitFlag) { switch(boundInitFlag) {
case 0: bndElDist = NEW BoundaryElementLevelSetDist(elLS, dim); case 0: bndElDist = new BoundaryElementLevelSetDist(elLS, dim);
break; break;
case 1: bndElDist = NEW BoundaryElementTopDist(elLS, dim, velExt); case 1: bndElDist = new BoundaryElementTopDist(elLS, dim, velExt);
break; break;
case 2: bndElDist = NEW BoundaryElementEdgeDist(elLS, dim); case 2: bndElDist = new BoundaryElementEdgeDist(elLS, dim);
break; break;
case 3: bndElDist = NEW BoundaryElementNormalDist(elLS, dim); case 3: bndElDist = new BoundaryElementNormalDist(elLS, dim);
break; break;
default: ERROR_EXIT("illegal boundary initialization !\n"); default: ERROR_EXIT("illegal boundary initialization !\n");
break; break;
...@@ -346,30 +331,23 @@ HL_SignedDist::initialize(ElementFunction<double> *elFct) ...@@ -346,30 +331,23 @@ HL_SignedDist::initialize(ElementFunction<double> *elFct)
("velocity extension only works with topological boundary element initialization method !\n"); ("velocity extension only works with topological boundary element initialization method !\n");
switch(dim) { switch(dim) {
case 2: elUpdate = NEW ElementUpdate_2d(velExt); case 2: elUpdate = new ElementUpdate_2d(velExt);
break; break;
case 3: elUpdate = NEW ElementUpdate_3d(velExt); case 3: elUpdate = new ElementUpdate_3d(velExt);
break; break;
default: ERROR_EXIT("illegal dimension !\n"); default: ERROR_EXIT("illegal dimension !\n");
break; break;
} }
} }
void
HL_SignedDist::setSign() void HL_SignedDist::setSign()
{ {
DOFVector<double>::Iterator it_sD(const_cast<DOFVector<double> *>(sD_DOF), DOFVector<double>::Iterator it_sD(const_cast<DOFVector<double> *>(sD_DOF), USED_DOFS);
USED_DOFS); DOFVector<double>::Iterator it_lS(const_cast<DOFVector<double> *>(lS_DOF), USED_DOFS);
DOFVector<double>::Iterator it_lS(const_cast<DOFVector<double> *>(lS_DOF),
USED_DOFS); // Vertex lies inside the zero level set ?
for (it_sD.reset(), it_lS.reset(); !it_sD.end(); ++it_sD, ++it_lS)
for(it_sD.reset(), it_lS.reset(); if ((*it_lS) < 0)
!it_sD.end(); (*it_sD) *= -1;
++it_sD, ++it_lS) {
// Vertex lies inside the zero level set ?
if ((*it_lS) < 0) {
(*it_sD) *= -1;
}
}
} }
...@@ -31,13 +31,13 @@ public: ...@@ -31,13 +31,13 @@ public:
TEST_EXIT(i < velDOF.size())("illegal index !\n"); TEST_EXIT(i < velDOF.size())("illegal index !\n");
FileWriter *fileWriter = NEW FileWriter( FileWriter *fileWriter = new FileWriter(
"VelocityExt->velocity output", "VelocityExt->velocity output",
(velDOF[i])->getFESpace()->getMesh(), (velDOF[i])->getFESpace()->getMesh(),
const_cast<DOFVector<double> *>(velDOF[i])); const_cast<DOFVector<double> *>(velDOF[i]));
fileWriter->writeFiles(adaptInfo, false); fileWriter->writeFiles(adaptInfo, false);
DELETE fileWriter; delete fileWriter;
} }
/// Print origVelDOF to file. /// Print origVelDOF to file.
...@@ -47,13 +47,13 @@ public: ...@@ -47,13 +47,13 @@ public:
TEST_EXIT(i < origVelDOF.size())("illegal index !\n"); TEST_EXIT(i < origVelDOF.size())("illegal index !\n");
FileWriter *fileWriter = NEW FileWriter( FileWriter *fileWriter = new FileWriter(
"VelocityExt->interface velocity output", "VelocityExt->interface velocity output",
(origVelDOF[i])->getFESpace()->getMesh(), (origVelDOF[i])->getFESpace()->getMesh(),
const_cast<DOFVector<double> *>(origVelDOF[i])); const_cast<DOFVector<double> *>(origVelDOF[i]));
fileWriter->writeFiles(adaptInfo, false); fileWriter->writeFiles(adaptInfo, false);
DELETE fileWriter; delete fileWriter;
}; };
/** /**
......