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

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

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