Commit 12fef67a authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Added automatically adaption of macro mesh files for parallel computing plus several small changes.

parent 6802b779
...@@ -225,7 +225,13 @@ namespace AMDiS { ...@@ -225,7 +225,13 @@ namespace AMDiS {
*/ */
/// Sets \ref nrDOF[i] = v /// Sets \ref nrDOF[i] = v
void setNumberOfDOFs(int i, int v); void setNumberOfDOFs(int i, int v);
/// Sets all values of \ref nrDOF
void setNumberOfDOFs(DimVec<int> v)
{
nrDOF = v;
}
/// Sets \ref nr0DOF[i] = v /// Sets \ref nr0DOF[i] = v
void setNumberOfPreDOFs(int i, int v); void setNumberOfPreDOFs(int i, int v);
......
...@@ -749,9 +749,10 @@ namespace AMDiS { ...@@ -749,9 +749,10 @@ namespace AMDiS {
TEST_EXIT_DBG(quad || quadFast)("neither quad nor quadFast defined\n"); TEST_EXIT_DBG(quad || quadFast)("neither quad nor quadFast defined\n");
if (quad && quadFast) if (quad && quadFast) {
TEST_EXIT_DBG(quad == quadFast->getQuadrature()) TEST_EXIT_DBG(quad == quadFast->getQuadrature())
("quad != quadFast->quadrature\n"); ("quad != quadFast->quadrature\n");
}
TEST_EXIT_DBG(!quadFast || quadFast->getBasisFunctions() == feSpace->getBasisFcts()) TEST_EXIT_DBG(!quadFast || quadFast->getBasisFunctions() == feSpace->getBasisFcts())
("invalid basis functions"); ("invalid basis functions");
......
...@@ -16,12 +16,18 @@ namespace AMDiS { ...@@ -16,12 +16,18 @@ namespace AMDiS {
level(l), level(l),
traverseFlag(flag), traverseFlag(flag),
feSpace(fe), feSpace(fe),
nVertices(0),
nElements(0),
nInterpPoints(0),
nConnection(0),
elementDataCollected(false),
valueDataCollected(false),
periodicDataCollected(false),
writeElem(writeElemFct) writeElem(writeElemFct)
{ {
FUNCNAME("DataCollector::DataCollector()"); FUNCNAME("DataCollector::DataCollector()");
TEST_EXIT(feSpace)("no feSpace\n"); TEST_EXIT(feSpace)("No finite elem space defined!\n");
TEST_EXIT(values)("no value Vector\n");
// === get mesh === // === get mesh ===
mesh = feSpace->getMesh(); mesh = feSpace->getMesh();
...@@ -29,36 +35,26 @@ namespace AMDiS { ...@@ -29,36 +35,26 @@ namespace AMDiS {
// === get admin === // === get admin ===
localAdmin = const_cast<DOFAdmin*>(feSpace->getAdmin()); localAdmin = const_cast<DOFAdmin*>(feSpace->getAdmin());
// === create vertex info vector === // === create vertex info vector ===
vertexInfos = new DOFVector< std::list<VertexInfo> >(feSpace, "vertex infos"); vertexInfos = new DOFVector<std::list<VertexInfo> >(feSpace, "vertex infos");
interpPointInd = new DOFVector<int>(feSpace, "interpolation point indices"); interpPointInd = new DOFVector<int>(feSpace, "interpolation point indices");
interpPointCoords = new DOFVector< std::list<WorldVector<double> > >(feSpace, "interpolation point coordinates"); interpPointCoords = new DOFVector< std::list<WorldVector<double> > >(feSpace, "interpolation point coordinates");
dofCoord = new DOFVector< std::list<WorldVector<double> > >(feSpace, "dof coords"); dofCoord = new DOFVector< std::list<WorldVector<double> > >(feSpace, "dof coords");
dim = mesh->getDim(); dim = mesh->getDim();
nPreDofs = localAdmin->getNumberOfPreDOFs(VERTEX); nPreDofs = localAdmin->getNumberOfPreDOFs(VERTEX);
nVertices = 0;
nElements = 0;
nInterpPoints = 0;
nConnection = 0;
elementDataCollected = false;
valueDataCollected = false;
periodicDataCollected = false;
vertexCoords = new WorldVector<double>;
} }
DataCollector::~DataCollector() DataCollector::~DataCollector()
{ {
delete vertexInfos; delete vertexInfos;
delete interpPointInd; delete interpPointInd;
delete interpPointCoords; delete interpPointCoords;
delete dofCoord; delete dofCoord;
delete vertexCoords;
} }
void DataCollector::fillAllData() void DataCollector::fillAllData()
{ {
if (!elementDataCollected) if (!elementDataCollected)
...@@ -71,6 +67,7 @@ namespace AMDiS { ...@@ -71,6 +67,7 @@ namespace AMDiS {
startCollectingValueData(); startCollectingValueData();
} }
void DataCollector::startCollectingElementData() void DataCollector::startCollectingElementData()
{ {
FUNCNAME("DataCollector::startCollectingElementData()"); FUNCNAME("DataCollector::startCollectingElementData()");
...@@ -107,6 +104,7 @@ namespace AMDiS { ...@@ -107,6 +104,7 @@ namespace AMDiS {
elementDataCollected = true; elementDataCollected = true;
} }
void DataCollector::startCollectingValueData() void DataCollector::startCollectingValueData()
{ {
FUNCNAME("DataCollector::startCollectingValueData()"); FUNCNAME("DataCollector::startCollectingValueData()");
...@@ -156,6 +154,7 @@ namespace AMDiS { ...@@ -156,6 +154,7 @@ namespace AMDiS {
valueDataCollected = true; valueDataCollected = true;
} }
void DataCollector::startCollectingPeriodicData() void DataCollector::startCollectingPeriodicData()
{ {
FUNCNAME("DataCollector::startCollectingPeriodicData()"); FUNCNAME("DataCollector::startCollectingPeriodicData()");
...@@ -200,6 +199,7 @@ namespace AMDiS { ...@@ -200,6 +199,7 @@ namespace AMDiS {
periodicDataCollected = true; periodicDataCollected = true;
} }
void DataCollector::addElementData(ElInfo* elInfo) void DataCollector::addElementData(ElInfo* elInfo)
{ {
FUNCNAME("DataCollector::addElementData()"); FUNCNAME("DataCollector::addElementData()");
...@@ -272,10 +272,12 @@ namespace AMDiS { ...@@ -272,10 +272,12 @@ namespace AMDiS {
elements.push_back(elementInfo); elements.push_back(elementInfo);
} }
void DataCollector::addValueData(ElInfo *elInfo) void DataCollector::addValueData(ElInfo *elInfo)
{ {
FUNCNAME("DataCollector::addValueData()"); FUNCNAME("DataCollector::addValueData()");
WorldVector<double> vertexCoords;
basisFcts->getLocalIndices(elInfo->getElement(), localAdmin, localDOFs); basisFcts->getLocalIndices(elInfo->getElement(), localAdmin, localDOFs);
// First, traverse all DOFs at the vertices of the element, determine // First, traverse all DOFs at the vertices of the element, determine
...@@ -286,18 +288,18 @@ namespace AMDiS { ...@@ -286,18 +288,18 @@ namespace AMDiS {
(*interpPointInd)[dofi] = -2; // mark as vertex (*interpPointInd)[dofi] = -2; // mark as vertex
// get coords of this vertex // get coords of this vertex
*vertexCoords = elInfo->getCoord(i); vertexCoords = elInfo->getCoord(i);
// search for coords at this dof // search for coords at this dof
std::list<WorldVector<double> >::iterator it = std::list<WorldVector<double> >::iterator it =
find((*dofCoord)[dofi].begin(), find((*dofCoord)[dofi].begin(),
(*dofCoord)[dofi].end(), (*dofCoord)[dofi].end(),
*vertexCoords); vertexCoords);
// coords not yet in list? // coords not yet in list?
if (it == (*dofCoord)[dofi].end()) { if (it == (*dofCoord)[dofi].end()) {
// add new coords to list // add new coords to list
(*dofCoord)[dofi].push_back(*vertexCoords); (*dofCoord)[dofi].push_back(vertexCoords);
} }
} }
...@@ -307,7 +309,7 @@ namespace AMDiS { ...@@ -307,7 +309,7 @@ namespace AMDiS {
for (int i = mesh->getGeo(VERTEX); i < nBasisFcts; i++) { for (int i = mesh->getGeo(VERTEX); i < nBasisFcts; i++) {
DegreeOfFreedom dofi = localDOFs[i]; DegreeOfFreedom dofi = localDOFs[i];
elInfo->coordToWorld(*basisFcts->getCoords(i), *vertexCoords); elInfo->coordToWorld(*basisFcts->getCoords(i), vertexCoords);
if ((*interpPointInd)[dofi] == -1) { if ((*interpPointInd)[dofi] == -1) {
// mark as interpolation point // mark as interpolation point
...@@ -318,16 +320,17 @@ namespace AMDiS { ...@@ -318,16 +320,17 @@ namespace AMDiS {
std::list<WorldVector<double> >::iterator it = std::list<WorldVector<double> >::iterator it =
find((*interpPointCoords)[dofi].begin(), find((*interpPointCoords)[dofi].begin(),
(*interpPointCoords)[dofi].end(), (*interpPointCoords)[dofi].end(),
*vertexCoords); vertexCoords);
if (it == (*interpPointCoords)[dofi].end()) { if (it == (*interpPointCoords)[dofi].end()) {
(*interpPointCoords)[dofi].push_back(*vertexCoords); (*interpPointCoords)[dofi].push_back(vertexCoords);
nInterpPoints++; nInterpPoints++;
} }
} }
} }
} }
void DataCollector::addInterpData(ElInfo *elInfo) void DataCollector::addInterpData(ElInfo *elInfo)
{ {
FUNCNAME("DataCollector::addInterpData()"); FUNCNAME("DataCollector::addInterpData()");
...@@ -341,6 +344,7 @@ namespace AMDiS { ...@@ -341,6 +344,7 @@ namespace AMDiS {
interpPoints.push_back(elemInterpPoints); interpPoints.push_back(elemInterpPoints);
} }
void DataCollector::addPeriodicData(ElInfo *elInfo) void DataCollector::addPeriodicData(ElInfo *elInfo)
{ {
FUNCNAME("DataCollector::addPeriodicData"); FUNCNAME("DataCollector::addPeriodicData");
...@@ -401,6 +405,7 @@ namespace AMDiS { ...@@ -401,6 +405,7 @@ namespace AMDiS {
} }
} }
std::list<ElementInfo>* DataCollector::getElementInfos() std::list<ElementInfo>* DataCollector::getElementInfos()
{ {
if (!elementDataCollected) if (!elementDataCollected)
...@@ -409,6 +414,7 @@ namespace AMDiS { ...@@ -409,6 +414,7 @@ namespace AMDiS {
return &elements; return &elements;
} }
DOFVector< std::list<VertexInfo> >* DataCollector::getVertexInfos() DOFVector< std::list<VertexInfo> >* DataCollector::getVertexInfos()
{ {
if (!elementDataCollected) if (!elementDataCollected)
...@@ -417,6 +423,7 @@ namespace AMDiS { ...@@ -417,6 +423,7 @@ namespace AMDiS {
return vertexInfos; return vertexInfos;
} }
std::list<PeriodicInfo>* DataCollector::getPeriodicInfos() std::list<PeriodicInfo>* DataCollector::getPeriodicInfos()
{ {
if (!periodicDataCollected) if (!periodicDataCollected)
...@@ -425,6 +432,7 @@ namespace AMDiS { ...@@ -425,6 +432,7 @@ namespace AMDiS {
return &periodicInfos; return &periodicInfos;
} }
int DataCollector::getNumberVertices() int DataCollector::getNumberVertices()
{ {
if (!elementDataCollected) if (!elementDataCollected)
...@@ -433,6 +441,7 @@ namespace AMDiS { ...@@ -433,6 +441,7 @@ namespace AMDiS {
return nVertices; return nVertices;
} }
int DataCollector::getNumberElements() int DataCollector::getNumberElements()
{ {
if (!elementDataCollected) if (!elementDataCollected)
...@@ -441,6 +450,7 @@ namespace AMDiS { ...@@ -441,6 +450,7 @@ namespace AMDiS {
return nElements; return nElements;
} }
int DataCollector::getNumberInterpPoints() int DataCollector::getNumberInterpPoints()
{ {
if (!valueDataCollected) if (!valueDataCollected)
...@@ -448,6 +458,7 @@ namespace AMDiS { ...@@ -448,6 +458,7 @@ namespace AMDiS {
return nInterpPoints; return nInterpPoints;
} }
int DataCollector::getNumberConnections() int DataCollector::getNumberConnections()
{ {
...@@ -457,15 +468,6 @@ namespace AMDiS { ...@@ -457,15 +468,6 @@ namespace AMDiS {
return nConnection; return nConnection;
} }
const FiniteElemSpace* DataCollector::getFeSpace()
{
return feSpace;
}
Mesh* DataCollector::getMesh()
{
return mesh;
}
DOFVector<double>* DataCollector::getValues() DOFVector<double>* DataCollector::getValues()
{ {
...@@ -475,6 +477,7 @@ namespace AMDiS { ...@@ -475,6 +477,7 @@ namespace AMDiS {
return values; return values;
} }
DOFVector< std::list<WorldVector<double> > >* DataCollector::getDofCoords() DOFVector< std::list<WorldVector<double> > >* DataCollector::getDofCoords()
{ {
if (!valueDataCollected) if (!valueDataCollected)
...@@ -483,6 +486,7 @@ namespace AMDiS { ...@@ -483,6 +486,7 @@ namespace AMDiS {
return dofCoord; return dofCoord;
} }
DOFVector<int>* DataCollector::getInterpPointInd() DOFVector<int>* DataCollector::getInterpPointInd()
{ {
if (!valueDataCollected) if (!valueDataCollected)
...@@ -491,6 +495,7 @@ namespace AMDiS { ...@@ -491,6 +495,7 @@ namespace AMDiS {
return interpPointInd; return interpPointInd;
} }
DOFVector< std::list<WorldVector<double> > >* DataCollector::getInterpPointCoords() DOFVector< std::list<WorldVector<double> > >* DataCollector::getInterpPointCoords()
{ {
if (!valueDataCollected) if (!valueDataCollected)
...@@ -499,6 +504,7 @@ namespace AMDiS { ...@@ -499,6 +504,7 @@ namespace AMDiS {
return interpPointCoords; return interpPointCoords;
} }
std::vector< std::vector<int> >* DataCollector::getInterpPoints() std::vector< std::vector<int> >* DataCollector::getInterpPoints()
{ {
if (!valueDataCollected) if (!valueDataCollected)
......
...@@ -43,7 +43,7 @@ namespace AMDiS { ...@@ -43,7 +43,7 @@ namespace AMDiS {
public: public:
/// Constructor /// Constructor
DataCollector(const FiniteElemSpace *feSpace, DataCollector(const FiniteElemSpace *feSpace,
DOFVector<double> *values, DOFVector<double> *values = NULL,
int level = -1, int level = -1,
Flag traverseFlag = Mesh::CALL_LEAF_EL, Flag traverseFlag = Mesh::CALL_LEAF_EL,
bool (*writeElem)(ElInfo*) = NULL); bool (*writeElem)(ElInfo*) = NULL);
...@@ -60,7 +60,10 @@ namespace AMDiS { ...@@ -60,7 +60,10 @@ namespace AMDiS {
DOFVector< std::list<VertexInfo> >* getVertexInfos(); DOFVector< std::list<VertexInfo> >* getVertexInfos();
/// Returns the finite element space of the problem. /// Returns the finite element space of the problem.
const FiniteElemSpace* getFeSpace(); const FiniteElemSpace* getFeSpace()
{
return feSpace;
}
/// Returns vector with value information. /// Returns vector with value information.
DOFVector<double>* getValues(); DOFVector<double>* getValues();
...@@ -93,7 +96,10 @@ namespace AMDiS { ...@@ -93,7 +96,10 @@ namespace AMDiS {
int getNumberConnections(); int getNumberConnections();
/// Returns the mesh of the problem. /// Returns the mesh of the problem.
Mesh* getMesh(); Mesh* getMesh()
{
return mesh;
}
void setMesh(Mesh *m) void setMesh(Mesh *m)
{ {
...@@ -165,16 +171,16 @@ namespace AMDiS { ...@@ -165,16 +171,16 @@ namespace AMDiS {
DOFVector<int> *interpPointInd; DOFVector<int> *interpPointInd;
/// Stores for each simplex the interpolation points. /// Stores for each simplex the interpolation points.
std::vector< std::vector<int> > interpPoints; std::vector<std::vector<int> > interpPoints;
/** \brief /** \brief
* Stores for each DOF a list of its coordinates. If there are now periodic * Stores for each DOF a list of its coordinates. If there are now periodic
* boundaries than there is also only one coordinate per DOF. * boundaries than there is also only one coordinate per DOF.
*/ */
DOFVector< std::list<WorldVector<double> > > *interpPointCoords; DOFVector<std::list<WorldVector<double> > > *interpPointCoords;
/// list of coords for each dof /// list of coords for each dof
DOFVector< std::list<WorldVector<double> > > *dofCoord; DOFVector<std::list<WorldVector<double> > > *dofCoord;
/// List that stores an ElementInfo for each element. /// List that stores an ElementInfo for each element.
std::list<ElementInfo> elements; std::list<ElementInfo> elements;
...@@ -183,7 +189,7 @@ namespace AMDiS { ...@@ -183,7 +189,7 @@ namespace AMDiS {
std::list<PeriodicInfo> periodicInfos; std::list<PeriodicInfo> periodicInfos;
/// Stores a list of vertex infos for each dof. /// Stores a list of vertex infos for each dof.
DOFVector< std::list<VertexInfo> > *vertexInfos; DOFVector<std::list<VertexInfo> > *vertexInfos;
/** \brief /** \brief
* periodicConnections[i][j] stores whether the connection at side j of * periodicConnections[i][j] stores whether the connection at side j of
......
...@@ -158,6 +158,7 @@ namespace AMDiS { ...@@ -158,6 +158,7 @@ namespace AMDiS {
} }
} }
void FileWriter::writeFiles(AdaptInfo *adaptInfo, void FileWriter::writeFiles(AdaptInfo *adaptInfo,
bool force, bool force,
int level, int level,
...@@ -170,7 +171,7 @@ namespace AMDiS { ...@@ -170,7 +171,7 @@ namespace AMDiS {
return; return;
// Containers, which store the data to be written; // Containers, which store the data to be written;
std::vector< DataCollector* > dataCollectors(solutionVecs.size()); std::vector<DataCollector* > dataCollectors(solutionVecs.size());
if (writeElem) { if (writeElem) {
for (int i = 0; i < static_cast<int>(dataCollectors.size()); i++) for (int i = 0; i < static_cast<int>(dataCollectors.size()); i++)
...@@ -219,10 +220,10 @@ namespace AMDiS { ...@@ -219,10 +220,10 @@ namespace AMDiS {
if (writeAMDiSFormat) { if (writeAMDiSFormat) {
MacroWriter::writeMacro(dataCollectors[0], MacroWriter::writeMacro(dataCollectors[0],
const_cast<char*>((fn + amdisMeshExt).c_str()), const_cast<char*>((fn + amdisMeshExt).c_str()),
adaptInfo ? adaptInfo->getTime() : 0.0); adaptInfo ? adaptInfo->getTime() : 0.0);
MSG("macro file written to %s\n", (fn + amdisMeshExt).c_str()); MSG("macro file written to %s\n", (fn + amdisMeshExt).c_str());
ValueWriter::writeValues(dataCollectors[0], ValueWriter::writeValues(dataCollectors[0],
(fn + amdisDataExt).c_str(), (fn + amdisDataExt).c_str(),
adaptInfo ? adaptInfo->getTime() : 0.0); adaptInfo ? adaptInfo->getTime() : 0.0);
......
...@@ -20,7 +20,8 @@ namespace AMDiS { ...@@ -20,7 +20,8 @@ namespace AMDiS {
{ {
FUNCNAME("FiniteElemSpace::FiniteElemSpace()"); FUNCNAME("FiniteElemSpace::FiniteElemSpace()");
TEST_EXIT(mesh)("no Mesh\n"); TEST_EXIT(mesh)("No mesh!\n");
TEST_EXIT(basFcts)("No basis functions!\n");
if (!admin) { if (!admin) {
const DOFAdmin *admin_local = NULL; const DOFAdmin *admin_local = NULL;
......
...@@ -62,7 +62,7 @@ namespace AMDiS { ...@@ -62,7 +62,7 @@ namespace AMDiS {
const ElementVector& uhAtQP, const ElementVector& uhAtQP,
const WorldVector<double> *grdUhAtQP, const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP, const WorldMatrix<double> *D2UhAtQP,
double *result, ElementVector& result,
double fac) double fac)
{ {
int dow = Global::getGeo(WORLD); int dow = Global::getGeo(WORLD);
...@@ -101,7 +101,7 @@ namespace AMDiS { ...@@ -101,7 +101,7 @@ namespace AMDiS {
const ElementVector& uhAtQP, const ElementVector& uhAtQP,
const WorldVector<double> *grdUhAtQP, const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP, const WorldMatrix<double> *D2UhAtQP,
double *result, ElementVector& result,
double f) double f)
{ {
int dow = Global::getGeo(WORLD); int dow = Global::getGeo(WORLD);
...@@ -112,6 +112,7 @@ namespace AMDiS { ...@@ -112,6 +112,7 @@ namespace AMDiS {
double resultQP = 0.0; double resultQP = 0.0;
for (int i = 0; i < dow; i++) for (int i = 0; i < dow; i++)
resultQP += grdUhAtQP[iq][i];