Commit 6640e0b5 authored by Thomas Witkowski's avatar Thomas Witkowski

* VTK Output possible for Lagrange elements of second order

parent 8f323098
......@@ -96,14 +96,14 @@ namespace AMDiS {
* compares two BasisFunction objects.
*/
virtual bool operator==(const BasisFunction& a) const {
return a.getName()==name;
return a.getName() == name;
};
/** \brief
* Returns !(*this == b)
*/
inline bool operator!=(const BasisFunction& b) const {
return !operator==(b);
return !(operator == (b));
};
/** \brief
......
......@@ -303,18 +303,21 @@ namespace AMDiS {
}
const int DOFAdmin::getNumberOfPreDOFs(int i) const {
TEST_EXIT((0<=i)&&(4>i))("");
TEST_EXIT((0 <= i) && (4 > i))("");
return nr0DOF[i];
}
void DOFAdmin::setNumberOfDOFs(int i,int v) {
TEST_EXIT((0<=i)&&(4>i))("");
nrDOF[i]=v;
TEST_EXIT((0 <= i) && (4 > i))("");
nrDOF[i] = v;
}
void DOFAdmin::setNumberOfPreDOFs(int i, int v) {
TEST_EXIT((0<=i)&&(4>i))("");
nr0DOF[i]=v;
TEST_EXIT((0 <= i) && (4 > i))("");
nr0DOF[i] = v;
}
DOFAdmin::~DOFAdmin()
......
......@@ -13,7 +13,7 @@ namespace AMDiS {
bool (*writeElem)(ElInfo*))
: writeElem_(writeElem)
{
FUNCNAME("DataCollector::DataCollector");
FUNCNAME("DataCollector::DataCollector()");
TEST_EXIT(feSpace)("no feSpace\n");
TEST_EXIT(values)("no value Vector\n");
......@@ -27,6 +27,7 @@ namespace AMDiS {
// === create vertex info vector ===
vertexInfos_ = NEW DOFVector< ::std::list<VertexInfo> >(feSpace, "vertex infos");
interpPointInd_ = NEW DOFVector<int>(feSpace, "interpolation point indices");
interpPointCoords_ = NEW DOFVector< ::std::list<WorldVector<double> > >(feSpace, "interpolation point coordinates");
dofCoords_ = NEW DOFVector< ::std::list<WorldVector<double> > >(feSpace, "dof coords");
dim_ = mesh_->getDim();
......@@ -51,12 +52,13 @@ namespace AMDiS {
{
DELETE vertexInfos_;
DELETE interpPointInd_;
DELETE interpPointCoords_;
DELETE dofCoords_;
}
int DataCollector::startCollectingElementData()
{
FUNCNAME("DataCollector::startCollectingElementData");
FUNCNAME("DataCollector::startCollectingElementData()");
Flag flag = traverseFlag_;
flag |=
......@@ -71,16 +73,16 @@ namespace AMDiS {
// Traverse elements to create continuous element indices
ElInfo *elInfo = stack.traverseFirst(mesh_, level_, flag);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo))
while (elInfo) {
if (!writeElem_ || writeElem_(elInfo))
outputIndices_[elInfo->getElement()->getIndex()] = nElements_++;
elInfo = stack.traverseNext(elInfo);
}
// Traverse elements to create element information
elInfo = stack.traverseFirst(mesh_, level_, flag);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo))
while (elInfo) {
if (!writeElem_ || writeElem_(elInfo))
addElementData(elInfo);
elInfo = stack.traverseNext(elInfo);
}
......@@ -92,10 +94,10 @@ namespace AMDiS {
int DataCollector::startCollectingValueData()
{
FUNCNAME("DataCollector::startCollectingValueData");
FUNCNAME("DataCollector::startCollectingValueData()");
DOFVector<int>::Iterator intPointIt(interpPointInd_, USED_DOFS);
for(intPointIt.reset(); !intPointIt.end(); ++intPointIt) {
for (intPointIt.reset(); !intPointIt.end(); ++intPointIt) {
(*intPointIt) = -1;
}
......@@ -109,7 +111,7 @@ namespace AMDiS {
level_,
traverseFlag_ | Mesh::FILL_COORDS);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo))
if (!writeElem_ || writeElem_(elInfo))
addValueData(elInfo);
elInfo = stack.traverseNext(elInfo);
}
......@@ -117,16 +119,16 @@ namespace AMDiS {
// Remove all interpolation marks and, instead, set to each
// interpolation point its continous index starting from 0.
int i = 0;
for(intPointIt.reset(); !intPointIt.end(); ++intPointIt) {
if(*intPointIt == -3) {
for (intPointIt.reset(); !intPointIt.end(); ++intPointIt) {
if (*intPointIt == -3) {
*intPointIt = i++;
}
}
// Traverse elements to create interpolation values.
elInfo = stack.traverseFirst(mesh_, level_, traverseFlag_);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo))
while (elInfo) {
if (!writeElem_ || writeElem_(elInfo))
addInterpData(elInfo);
elInfo = stack.traverseNext(elInfo);
}
......@@ -138,22 +140,21 @@ namespace AMDiS {
int DataCollector::startCollectingPeriodicData()
{
FUNCNAME("DataCollector::startCollectingPeriodicData");
FUNCNAME("DataCollector::startCollectingPeriodicData()");
periodicConnections_.clear();
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(mesh_, level_, traverseFlag_);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo)) {
while (elInfo) {
if (!writeElem_ || writeElem_(elInfo)) {
LeafDataPeriodic *ldp = dynamic_cast<LeafDataPeriodic*>
(elInfo->getElement()->
getElementData()->
getElementData(PERIODIC));
if(ldp) {
nConnections_ +=
dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().size();
if (ldp) {
nConnections_ += dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().size();
}
periodicConnections_.push_back(DimVec<bool>(dim_, DEFAULT_VALUE, false));
......@@ -173,8 +174,8 @@ namespace AMDiS {
Mesh::FILL_BOUND;
elInfo = stack.traverseFirst(mesh_, level_, flag);
while(elInfo) {
if(!writeElem_ || writeElem_(elInfo))
while (elInfo) {
if (!writeElem_ || writeElem_(elInfo))
addPeriodicData(elInfo);
elInfo = stack.traverseNext(elInfo);
}
......@@ -186,9 +187,8 @@ namespace AMDiS {
int DataCollector::addElementData(ElInfo* elInfo)
{
FUNCNAME("DataCollector::addElementData");
FUNCNAME("DataCollector::addElementData()");
int i;
const DegreeOfFreedom **dof = elInfo->getElement()->getDOF();
DegreeOfFreedom vertexDOF;
WorldVector<double> vertexCoords;
......@@ -197,10 +197,9 @@ namespace AMDiS {
ElementInfo elementInfo(dim_);
// read element region
ElementData *ed =
elInfo->getElement()->getElementData(ELEMENT_REGION);
ElementData *ed = elInfo->getElement()->getElementData(ELEMENT_REGION);
if(ed) {
if (ed) {
elementInfo.elementRegion = dynamic_cast<ElementRegion_ED*>(ed)->getRegion();
} else {
elementInfo.elementRegion = -1;
......@@ -211,14 +210,14 @@ namespace AMDiS {
elementInfo.surfaceRegions.set(-1);
while(ed) {
while (ed) {
SurfaceRegion_ED *sr = dynamic_cast<SurfaceRegion_ED*>(ed);
elementInfo.surfaceRegions[sr->getSide()] = sr->getRegion();
ed = ed->getDecorated(SURFACE_REGION);
}
// for all vertices
for(i = 0; i < dim_ + 1; i++) {
for (int i = 0; i < dim_ + 1; i++) {
// get coords of this vertex
vertexCoords = elInfo->getCoord(i);
......@@ -232,7 +231,7 @@ namespace AMDiS {
vertexCoords);
// coords not yet in list?
if(it == (*vertexInfos_)[vertexDOF].end()) {
if (it == (*vertexInfos_)[vertexDOF].end()) {
// create new vertex info and increment number of vertices
VertexInfo newVertexInfo = {vertexCoords, nVertices_};
......@@ -255,7 +254,7 @@ namespace AMDiS {
-1;
}
if(dim_ == 3) {
if (dim_ == 3) {
elementInfo.type = (dynamic_cast<ElInfo3d*>(elInfo)->getType());
}
......@@ -267,16 +266,14 @@ namespace AMDiS {
int DataCollector::addValueData(ElInfo *elInfo)
{
FUNCNAME("DataCollector::addValueData");
FUNCNAME("DataCollector::addValueData()");
int i, j, k;
int node_offset, dof_offset, num_dofs, node, dof_index;
const DegreeOfFreedom **dof = elInfo->getElement()->getDOF();
/* vertex dofs */
dof_offset = localAdmin_->getNumberOfPreDOFs(VERTEX);
for (i = 0; i < mesh_->getGeo(VERTEX); i++) {
int dof_offset = localAdmin_->getNumberOfPreDOFs(VERTEX);
for (int i = 0; i < mesh_->getGeo(VERTEX); i++) {
(*interpPointInd_)[dof[i][dof_offset]] = -2; // mark as vertex
// get coords of this vertex
......@@ -289,53 +286,76 @@ namespace AMDiS {
vertexCoords);
// coords not yet in list?
if(it == (*dofCoords_)[dof[i][dof_offset]].end()) {
if (it == (*dofCoords_)[dof[i][dof_offset]].end()) {
// add new coords to list
(*dofCoords_)[dof[i][dof_offset]].push_back(vertexCoords);
}
}
for(i = 1; i <= dim_; i++) {
num_dofs = localAdmin_->getNumberOfDOFs(INDEX_OF_DIM(i, dim_));
node_offset = mesh_->getNode(INDEX_OF_DIM(i, dim_));
dof_offset = localAdmin_->getNumberOfPreDOFs(INDEX_OF_DIM(i, dim_));
for (j = 0; j < mesh_->getGeo(INDEX_OF_DIM(i, dim_)); j++) {
node = node_offset + j;
for(k = 0; k < num_dofs; k++) {
dof_index = dof_offset + k;
int nInterpPoints = 0;
const BasisFunction *basisFcts = feSpace_->getBasisFcts();
for (int i = 1; i <= dim_; i++) {
int num_dofs = localAdmin_->getNumberOfDOFs(INDEX_OF_DIM(i, dim_));
int node_offset = mesh_->getNode(INDEX_OF_DIM(i, dim_));
dof_offset = localAdmin_->getNumberOfPreDOFs(INDEX_OF_DIM(i, dim_));
for (int j = 0; j < mesh_->getGeo(INDEX_OF_DIM(i, dim_)); j++) {
int node = node_offset + j;
for (int k = 0; k < num_dofs; k++) {
int dof_index = dof_offset + k;
WorldVector<double> interpolCoords;
elInfo->coordToWorld((*basisFcts->getCoords(mesh_->getGeo(VERTEX) + nInterpPoints)),
&interpolCoords);
nInterpPoints++;
if ((*interpPointInd_)[dof[node][dof_index]] == -1) {
// mark as interp. point
// mark as interpolation point
(*interpPointInd_)[dof[node][dof_index]] = -3;
// search for interpolation point coordinates, and insert them to the
// dof-entry, if not contained in the list
::std::list<WorldVector<double> >::iterator it =
find((*interpPointCoords_)[dof[node][dof_index]].begin(),
(*interpPointCoords_)[dof[node][dof_index]].end(),
interpolCoords);
if (it == (*interpPointCoords_)[dof[node][dof_index]].end()) {
(*interpPointCoords_)[dof[node][dof_index]].push_back(interpolCoords);
}
nInterpPoints_++;
}
}
}
}
return(0);
}
int DataCollector::addInterpData(ElInfo *elInfo)
{
FUNCNAME("DataCollector::addInterpData");
FUNCNAME("DataCollector::addInterpData()");
int i, j, k;
int node_offset, dof_offset, num_dofs, node, dof_index;
const DegreeOfFreedom **dof = elInfo->getElement()->getDOF();
::std::list<int> elemInterpPoints;
::std::vector<int> elemInterpPoints;
elemInterpPoints.clear();
for(i = 1; i <= dim_; i++) {
num_dofs = localAdmin_->getNumberOfDOFs(INDEX_OF_DIM(i, dim_));
node_offset = mesh_->getNode(INDEX_OF_DIM(i, dim_));
dof_offset = localAdmin_->getNumberOfPreDOFs(INDEX_OF_DIM(i, dim_));
for (j = 0; j < mesh_->getGeo(INDEX_OF_DIM(i, dim_)); j++) {
node = node_offset + j;
for(k = 0; k < num_dofs; k++) {
dof_index = dof_offset + k;
for (int i = 1; i <= dim_; i++) {
int num_dofs = localAdmin_->getNumberOfDOFs(INDEX_OF_DIM(i, dim_));
int node_offset = mesh_->getNode(INDEX_OF_DIM(i, dim_));
int dof_offset = localAdmin_->getNumberOfPreDOFs(INDEX_OF_DIM(i, dim_));
for (int j = 0; j < mesh_->getGeo(INDEX_OF_DIM(i, dim_)); j++) {
int node = node_offset + j;
for (int k = 0; k < num_dofs; k++) {
int dof_index = dof_offset + k;
elemInterpPoints.push_back((*interpPointInd_)[dof[node][dof_index]]);
}
......@@ -355,57 +375,54 @@ namespace AMDiS {
getElementData()->
getElementData(PERIODIC));
if(ldp) {
if (ldp) {
::std::list<LeafDataPeriodic::PeriodicInfo>::iterator it;
for(it = dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().begin();
it != dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().end();
++it)
{
int outputIndex = outputIndices_[elInfo->getElement()->getIndex()];
int neighIndex = outputIndices_[elInfo->
getNeighbour(it->elementSide)->
getIndex()];
for (it = dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().begin();
it != dynamic_cast<LeafDataPeriodic*>(ldp)->getInfoList().end();
++it) {
int outputIndex = outputIndices_[elInfo->getElement()->getIndex()];
int neighIndex = outputIndices_[elInfo->
getNeighbour(it->elementSide)->
getIndex()];
if (!periodicConnections_[outputIndex][it->elementSide]) {
PeriodicInfo periodicInfo;
if(!periodicConnections_[outputIndex][it->elementSide]) {
PeriodicInfo periodicInfo;
periodicInfo.mode = it->periodicMode;
periodicInfo.type = it->type;
periodicInfo.outputIndex = outputIndex;
periodicInfo.neighIndex = neighIndex;
periodicInfo.vertexMap.clear();
periodicConnections_[outputIndex][it->elementSide] = true;
periodicConnections_
[neighIndex][elInfo->getOppVertex(it->elementSide)] = true;
int index1, index2, dof1, dof2, i, j;
for(i = 0; i < dim_; i++) {
index1 =
elInfo->getElement()->getVertexOfPosition(INDEX_OF_DIM(dim_ - 1, dim_),
it->elementSide,
i);
dof1 = elInfo->getElement()->getDOF(index1, nPreDofs_);
for(j = 0; j < dim_; j++) {
index2 =
elInfo->getElement()->getVertexOfPosition(INDEX_OF_DIM(dim_ - 1, dim_),
elInfo->getOppVertex(it->elementSide),
j);
dof2 = elInfo->getNeighbour(it->elementSide)->getDOF(index2, nPreDofs_);
if((dof1 == dof2) || (mesh_->associated(dof1, dof2))) {
periodicInfo.vertexMap[index1] = index2;
break;
}
}
periodicInfo.mode = it->periodicMode;
periodicInfo.type = it->type;
periodicInfo.outputIndex = outputIndex;
periodicInfo.neighIndex = neighIndex;
periodicInfo.vertexMap.clear();
periodicConnections_[outputIndex][it->elementSide] = true;
periodicConnections_
[neighIndex][elInfo->getOppVertex(it->elementSide)] = true;
for (int i = 0; i < dim_; i++) {
int index1 = elInfo->getElement()->getVertexOfPosition(INDEX_OF_DIM(dim_ - 1, dim_),
it->elementSide,
i);
int dof1 = elInfo->getElement()->getDOF(index1, nPreDofs_);
for (int j = 0; j < dim_; j++) {
int index2 = elInfo->getElement()->getVertexOfPosition(INDEX_OF_DIM(dim_ - 1, dim_),
elInfo->getOppVertex(it->elementSide),
j);
int dof2 = elInfo->getNeighbour(it->elementSide)->getDOF(index2, nPreDofs_);
if ((dof1 == dof2) || (mesh_->associated(dof1, dof2))) {
periodicInfo.vertexMap[index1] = index2;
break;
}
}
periodicInfos_.push_back(periodicInfo);
}
periodicInfos_.push_back(periodicInfo);
}
}
}
return(0);
......@@ -511,7 +528,16 @@ namespace AMDiS {
return interpPointInd_;
}
::std::list< ::std::list<int> >* DataCollector::getInterpPoints()
DOFVector< ::std::list<WorldVector<double> > >* DataCollector::getInterpPointCoords()
{
if (!valueDataCollected_) {
startCollectingValueData();
}
return interpPointCoords_;
}
::std::vector< ::std::vector<int> >* DataCollector::getInterpPoints()
{
if (!valueDataCollected_) {
startCollectingValueData();
......
......@@ -92,10 +92,15 @@ namespace AMDiS {
*/
DOFVector<int>* getInterpPointInd();
/** \brief
*
*/
DOFVector< ::std::list<WorldVector<double> > >* getInterpPointCoords();
/** \brief
* Returns list of interpolation point information.
*/
::std::list< ::std::list<int> >* getInterpPoints();
::std::vector< ::std::vector<int> >* getInterpPoints();
/** \brief
* Returns list of information about periodics.
......@@ -237,7 +242,12 @@ namespace AMDiS {
/** \brief
* Stores for each simplex the interpolation points.
*/
::std::list< ::std::list<int> > interpPoints_;
::std::vector< ::std::vector<int> > interpPoints_;
/** \brief
*
*/
DOFVector< ::std::list<WorldVector<double> > > *interpPointCoords_;
/** \brief
* list of coords for each dof
......
......@@ -71,7 +71,7 @@ namespace AMDiS {
double c = l[0];
for (int j = 0; j < dimOfWorld; j++)
(*ret)[j] = c*v[j];
(*ret)[j] = c * v[j];
int vertices = Global::getGeo(VERTEX, dim);
......@@ -79,7 +79,7 @@ namespace AMDiS {
v = (*coords)[i];
c = l[i];
for (int j = 0; j < dimOfWorld; j++)
(*ret)[j] += c*v[j];
(*ret)[j] += c * v[j];
}
return ret;
}
......
......@@ -368,15 +368,15 @@ namespace AMDiS {
void testFlag(const Flag& flag) const;
/** \brief
* Returns a pointer to a vector, wich contains the world coordinates
* Returns a pointer to a vector, which contains the world coordinates
* of a point in barycentric coordinates lambda with respect to \ref element.
* If world is not NULL the world coordinates are stored in this vector.
* Otherwise the function itself provides memory for this vector. In this
* case the vector is overwritten during the next call of coordToWorld.
*/
virtual const WorldVector<double>
*coordToWorld(const DimVec<double>& lambda,
WorldVector<double>* world) const;
*coordToWorld(const DimVec<double>& lambda,
WorldVector<double>* world) const;
/** \brief
......
......@@ -77,9 +77,15 @@ namespace AMDiS {
* Element type. Used in 3d.
*/
unsigned char type;
/** \brief
*
*/
int elementRegion;
/** \brief
*
*/
DimVec<int> surfaceRegions;
};
......
......@@ -209,13 +209,17 @@ namespace AMDiS {
}
if (writeParaViewFormat) {
VtkWriter::writeFile(&dc, const_cast<char*>( (fn + paraViewFileExt).c_str()));
VtkWriter vtkWriter(&dc);
vtkWriter.writeFile(const_cast<char*>( (fn + paraViewFileExt).c_str()));
MSG("ParaView file written to %s\n", (fn + paraViewFileExt).c_str());
}
if (writeParaViewAnimation) {
VtkWriter::updateAnimationFile(fn + paraViewFileExt,
&paraViewAnimationFrames_,
VtkWriter vtkWriter(&dc);
vtkWriter.updateAnimationFile(fn + paraViewFileExt,
&paraViewAnimationFrames_,
const_cast<char*>( (filename + ".pvd").c_str()));
}
......
......@@ -61,10 +61,10 @@ namespace AMDiS {
/** \brief
*
*/
static FiniteElemSpace *provideFESpace(DOFAdmin *admin,
static FiniteElemSpace *provideFESpace(DOFAdmin *admin,
const BasisFunction *basFcts,
Mesh *mesh,
const ::std::string& name_="");
Mesh *mesh,
const ::std::string& name_ = "");
/** \brief
* destructor
......@@ -74,22 +74,30 @@ namespace AMDiS {
/** \brief
* Returns \ref name
*/
inline ::std::string getName() const { return name;};
inline ::std::string getName() const {
return name;
};
/** \brief
* Returns \ref admin
*/
inline DOFAdmin* getAdmin() const { return admin;};