Commit c8cd584a authored by Naumann, Andreas's avatar Naumann, Andreas

speicherfehler in robinbc, ausgabe bei zu kleinem element in 1d, compiler...

speicherfehler in robinbc, ausgabe bei zu kleinem element in 1d, compiler fehler in rosenbrock und itl_oemsolver.hh
parent 9a7aa655
This diff is collapsed.
......@@ -133,7 +133,7 @@ namespace AMDiS {
double adet2 = e * e;
if (adet2 < 1.0E-15) {
MSG("det*det = %lf\n", adet2);
MSG("det*det = %g\n", adet2);
grd_lam[0] = grd_lam[1] = 0.0;
} else {
grd_lam[1] = e * (1.0 / adet2);
......
......@@ -70,7 +70,7 @@ namespace AMDiS {
TEST_EXIT(preconPair.l != NULL)("there is no left preconditioner");
TEST_EXIT(preconPair.r != NULL)("there is no right preconditioner");
mtl::dense_vector<typename Matrix::value_type> r(A * x - b);
Vector r(A * x - b);
itl::cyclic_iteration<typename Vector::value_type> iter(r, oem.getMaxIterations(), oem.getRelative(),
oem.getTolerance(), oem.getPrint_cycle());
......@@ -105,7 +105,7 @@ namespace AMDiS {
TEST_EXIT(preconPair.l != NULL)("there is no left preconditioner");
TEST_EXIT(preconPair.r != NULL)("there is no right preconditioner");
mtl::dense_vector<typename Matrix::value_type> r(A * x - b);
Vector r(A * x - b);
itl::cyclic_iteration<typename Matrix::value_type> iter(r, oem.getMaxIterations(), oem.getRelative(),
oem.getTolerance(), oem.getPrint_cycle());
......
......@@ -149,15 +149,17 @@ namespace AMDiS {
}
}
neumannOperators = new DimVec<SurfaceOperator*>(dim, NO_INIT);
robinOperators = new DimVec<SurfaceOperator*>(dim, NO_INIT);
for (int i = 0; i < dim + 1; i++) {
if (jOp)
if (jOp) {
neumannOperators = new DimVec<SurfaceOperator*>(dim, NO_INIT);
for (int i = 0; i < dim + 1; i++)
(*neumannOperators)[i] = new SurfaceOperator(jOp, *coords[i]);
if (alphaOp)
}
if (alphaOp) {
robinOperators = new DimVec<SurfaceOperator*>(dim, NO_INIT);
for (int i = 0; i < dim + 1; i++)
(*robinOperators)[i] = new SurfaceOperator(alphaOp, *coords[i]);
}
}
}
......
......@@ -65,7 +65,8 @@ namespace AMDiS {
{}
void Mtl4Solver::solve(AdaptInfo* adaptInfo, bool fixedMatrix)
void Mtl4Solver::solve(AdaptInfo* adaptInfo, bool createMatrixData,
bool storeMatrixData)
{
FUNCNAME("Mtl4Solver::solve()");
......
......@@ -46,7 +46,8 @@ namespace AMDiS {
{}
void solve(AdaptInfo *adaptInfo, bool fixedMatrix = false);
void solve(AdaptInfo *adaptInfo, bool createMatrixData = true,
bool storeMatrixData = false );
void createPrecon();
void createSolver();
};
......
......@@ -22,12 +22,14 @@ namespace AMDiS {
}
size_type row(size_type r_)
{
size_type ret = md.mapLocalToGlobal(r_)*nComponents+r;
//size_type ret = md.mapLocalToGlobal(r_)*nComponents+r;
size_type ret = md.mapLocalToGlobal(r_)+r*md.getNumberOverallDofs() ;
return ret;
}
size_type col(size_type c_)
{
size_type ret = md.mapLocalToGlobal(c_)*nComponents+c;
//size_type ret = md.mapLocalToGlobal(c_)*nComponents+c;
size_type ret = md.mapLocalToGlobal(c_)+c*md.getNumberOverallDofs() ;
return ret ;
}
......
......@@ -29,8 +29,12 @@
#include "time/RosenbrockMethod.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
#include "parallel/PetscProblemStat.h"
#endif
#endif
namespace AMDiS {
......
project(tests)
add_subdirectory(Meshtest)
add_subdirectory(demoimpl)
add_subdirectory(demotest EXCLUDE_FROM_ALL)
add_subdirectory(datacreation EXCLUDE_FROM_ALL)
project(Meshtest)
add_executable(Meshtest src/Meshtest.cpp)
target_link_libraries(Meshtest ${AMDiS_LIBS})
add_test(Meshtest Meshtest)
#include "Mesh.h"
#include "Parameters.h"
#include "ProblemScal.h"
#include <sstream>
#include <string>
#include <stdexcept>
typedef std::vector< std::string > StringVector ;
template< typename Test >
void require(Test l, Test r, int line, std::string message) {
if(l != r) {
std::stringstream ss;
ss<< "Condition for "<<message<<" is wrong\n";
ss<< "l: "<<l<<"\n"<<"r: "<<r<<"\n";
throw std::runtime_error(ss.str());
}
}
template< typename Test >
void require(Test l, Test r, std::string message, StringVector& res) {
if(l != r) {
std::stringstream ss;
ss<< "Condition for "<<message<<" is wrong\n";
ss<< "l: "<<l<<"\n"<<"r: "<<r<<"\n";
res.push_back(ss.str());
}
}
using namespace AMDiS;
void testMesh(int dim, int nrEls, int nrVert , int nrMacro, StringVector& res) {
std::stringstream ss;
ss<< dim;
Parameters::addGlobalParameter(0, "dimension of world", ss.str());
Global::init();
Mesh mesh("testMesh", dim);
DimVec< int > ln_dof(dim, DEFAULT_VALUE, 0);
ln_dof[VERTEX]=1;
mesh.createDOFAdmin("vertex_dofs", ln_dof);
mesh.initialize();
require(mesh.getDim(), dim, __LINE__, "mesh dimension");
std::stringstream ss2;
ss2<<"\ncurrent dimension: "<<dim<<"\n";
require(mesh.getNumberOfMacros(), nrMacro, ss2.str() + "number of macro elements",res);
require(mesh.getNumberOfElements() , nrEls, ss2.str() + "number of elements",res);
require(mesh.getNumberOfVertices(), nrVert, ss2.str() + "number of vertices",res);
}
int main(int argc, char** argv) {
//cannot use Parameters::addGlobalParameter(...) because of some string errors
Parameters::addGlobalParameter(0,"testMesh1->macro file name","macro/macro.stand.1d");
Parameters::addGlobalParameter(0,"testMesh2->macro file name","macro/macro.stand.2d");
Parameters::addGlobalParameter(0,"testMesh3->macro file name","macro/macro.stand.3d");
StringVector errorMessages;
testMesh(1,0,2,1, errorMessages);
testMesh(2,0,5,4, errorMessages);
testMesh(3,0,8,6, errorMessages);
if(errorMessages.size() > 0)
std::cout<<" got errors: \n";
for(StringVector::size_type i=0; i< errorMessages.size();++i)
std::cout<<errorMessages[i]<<"\n";
if (errorMessages.size() != 0)
return 1;
return 0;
}
project(testdatacreation)
include_directories(${AMDiS_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../demoimpl/src)
file(GLOB PROJECTFILES ${CMAKE_CURRENT_SOURCE_DIR}/../demoimpl/src/*Project.cpp)
set(CREATELINE "")
foreach(projectfile ${PROJECTFILES})
#create creatorname
get_filename_component(CppName ${projectfile} NAME_WE)
string(REPLACE "Project" "" creatorsuffix ${CppName})
set(PROJECTINCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../demoimpl/src/${CppName}.h")
set(CURRENTPROJECTTYPE "${creatorsuffix}demo")
string(TOLOWER "${creatorsuffix}" creatorsuffix_lower)
set(BASENAME "${creatorsuffix_lower}")
configure_file(src/creator_base.cpp src/creator${creatorsuffix}.cpp @ONLY)
add_executable(creator${creatorsuffix} src/creator${creatorsuffix}.cpp src/ProjectList.cpp)
target_link_libraries(creator${creatorsuffix} ${AMDiS_LIBS} demoimpl)
file(GLOB initfiles RELATIVE ${CMAKE_CURRENT_BINARY_DIR} init/${creatorsuffix_lower}*.dat*)
foreach(initfile ${initfiles})
get_filename_component(initfile_ext ${initfile} EXT)
string(REPLACE ".dat." "" initfile_ext "${initfile_ext}")
set(curoutputdatafile "../testdata/${creatorsuffix_lower}_${initfile_ext}.arh")
set(CREATELINE "${CREATELINE}./creator${creatorsuffix} ${initfile} ${curoutputdatafile}\n")
endforeach(initfile)
endforeach(projectfile)
configure_file(create_base.sh create.sh)
../testdata/init
\ No newline at end of file
../testdata/macro
\ No newline at end of file
#include "Project.h"
#include "io/ArhWriter.h"
#include "io/ArhReader.h"
#include <vector>
using namespace AMDiS;
void write(SolutionInformation& info, std::string filename) {
if(info.sysVec != NULL) {
std::vector< DOFVector< double >* > data(info.sysVec->getNumVectors());
Mesh* mesh = info.sysVec->getDOFVector(0)->getFeSpace()->getMesh();
for(int i=0; i < info.sysVec->getNumVectors(); ++i) {
data[i] = info.sysVec->getDOFVector(i);
}
ArhWriter::write(filename, mesh, data);
}else if(info.dofVec != NULL) {
Mesh* mesh = info.dofVec->getFeSpace()->getMesh();
ArhWriter::write(filename, mesh, info.dofVec);
}else
assert(false);
}
#include "Parameters.h"
#include "Project.h"
#include "@PROJECTINCLUDE@"
typedef @CURRENTPROJECTTYPE@ ProjectType;
std::string basename="@BASENAME@";
void write(SolutionInformation& info, std::string filename);
int main(int argc, char** argv) {
if(argc < 2) {
std::cout<<" need initfile "<<basename<<"*\n";
return 1;
}
if(argc < 3) {
std::cout<<" also need a destination file "<<basename<<"*\n";
return 2;
}
std::string initfile(argv[1]);
std::string destinationfile(argv[2]);
AMDiS::Parameters::init(false, initfile);
ProjectType project;
ProjectInfo info(&project, initfile, destinationfile);
info.create();
SolutionInformation solinfo;
info.solve(solinfo);
write(solinfo, info.getFilename());
return 0;
}
project(demoimpl)
include_directories(${AMDiS_SOURCE_DIR})
file(GLOB PROJECTFILES src/*Project.cpp)
add_library(demoimpl ${PROJECTFILES})
#include "BallProject.h"
#include "AdaptStationary.h"
/// Dirichlet boundary function
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
return exp(-10.0 * (x * x));
}
};
/// RHS function
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
int dim = x.getSize();
double r2 = x * x;
double ux = exp(-10.0*r2);
return -(400.0 * r2 - 20.0 * dim) * ux;
}
};
Balldemo::Balldemo():
ball("ball"),
ballCenter(NULL),
adaptInfo(NULL),
adapt(NULL),
matrixOperator(NULL),
rhsOperator(NULL)
{
}
Balldemo::~Balldemo() {
if(matrixOperator != NULL)
delete matrixOperator;
if(rhsOperator != NULL)
delete rhsOperator;
if(ballCenter != NULL)
delete ballCenter;
if(adapt != NULL)
delete adapt;
if(adaptInfo != NULL)
delete adaptInfo;
}
void Balldemo::create(std::string& filename) {
// ===== init parameters =====
Parameters::init(false, filename);
ballCenter = new WorldVector< double >();
ballCenter->set(0.0);
// ===== create projection =====
new AMDiS::BallProject(1,
BOUNDARY_PROJECTION,
*ballCenter,
1.0);
// ===== create and init the scalar problem =====
ball.initialize(INIT_ALL);
// === create adapt info ===
adaptInfo = new AdaptInfo("ball->adapt");
// === create adapt ===
adapt = new AdaptStationary("ball->adapt", &ball, adaptInfo);
// ===== create matrix operator =====
matrixOperator=new Operator(ball.getFeSpace());
matrixOperator->addSecondOrderTerm(new Laplace_SOT);
ball.addMatrixOperator(matrixOperator);
// ===== create rhs operator =====
int degree = ball.getFeSpace()->getBasisFcts()->getDegree();
rhsOperator = new Operator(ball.getFeSpace());
rhsOperator->addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
ball.addVectorOperator(rhsOperator);
// ===== add boundary conditions =====
ball.addDirichletBC(1, new G);
}
int Balldemo::solve(SolutionInformation& solinfo) {
assert(adaptInfo!=NULL);
assert(adapt!=NULL);
assert(matrixOperator!=NULL);
assert(rhsOperator!=NULL);
int retCode = adapt->adapt();
solinfo.dofVec = ball.getSolution();
//ball.writeFiles(adaptInfo,true);
return retCode;
}
#ifndef BALLPROJECT_H
#define BALLPROJECT_H
#include "Project.h"
#include "FixVec.h"
#include "ProblemScal.h"
using namespace AMDiS;
class Balldemo : public Project {
ProblemScal ball;
WorldVector< double >* ballCenter;
AdaptInfo* adaptInfo;
AdaptStationary* adapt;
Operator* matrixOperator;
Operator* rhsOperator;
public:
Balldemo() ;
~Balldemo() ;
void create(std::string& ) ;
int solve(SolutionInformation&);
};
#endif
#include "BunnyProject.h"
#include "AdaptStationary.h"
/// RHS function
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
return -2 * x[0];
}
};
/// boundary
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
return 10000.0;
}
};
Bunnydemo::Bunnydemo():
bunny("bunny"),
ballCenter(NULL),
adaptInfo(NULL),
adapt(NULL),
matrixOperator(NULL),
rhsOperator(NULL)
{}
Bunnydemo::~Bunnydemo() {
if(ballCenter != NULL)
delete ballCenter;
if(adaptInfo != NULL)
delete adaptInfo;
if(adapt != NULL)
delete adapt;
if(matrixOperator != NULL)
delete matrixOperator;
if(rhsOperator != NULL)
delete rhsOperator;
}
void Bunnydemo::create(string& filename) {
// ===== init parameters =====
Parameters::init(false, filename);
// ===== create projection =====
ballCenter = new WorldVector< double > ();
ballCenter->set(0.0);
new BallProject(1, VOLUME_PROJECTION, *ballCenter, 1.0);
// ===== create and init the scalar problem =====
bunny.initialize(INIT_ALL);
// === create adapt info ===
adaptInfo = new AdaptInfo("bunny->adapt");
// === create adapt ===
adapt = new AdaptStationary("bunny->adapt", &bunny, adaptInfo);
// ===== create matrix operator =====
matrixOperator = new Operator(bunny.getFeSpace());
matrixOperator->addSecondOrderTerm(new Laplace_SOT);
bunny.addMatrixOperator(matrixOperator);
// ===== create rhs operator =====
rhsOperator = new Operator(bunny.getFeSpace());
int degree = bunny.getFeSpace()->getBasisFcts()->getDegree();
rhsOperator->addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
bunny.addVectorOperator(rhsOperator);
}
int Bunnydemo::solve(SolutionInformation& info) {
int retCode = adapt->adapt();
info.dofVec = bunny.getSolution();
return retCode;
}
#ifndef BUNNYPROJECT_H
#define BUNNYPROJECT_H
#include "Project.h"
#include "FixVec.h"
#include "ProblemScal.h"
class Bunnydemo : public Project {
ProblemScal bunny;
WorldVector< double >* ballCenter;
AdaptInfo* adaptInfo;
AdaptStationary* adapt;
Operator* matrixOperator;
Operator* rhsOperator;
public:
Bunnydemo();
~Bunnydemo();
void create(string& filename);
int solve(SolutionInformation&);
};
#endif
#include "ElliptProject.h"
#include "AdaptStationary.h"
/// Dirichlet boundary function
class G : public AbstractFunction<double, WorldVector<double> >
{
public:
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
return exp(-10.0 * (x * x));
}
};
/// RHS function
class F : public AbstractFunction<double, WorldVector<double> >
{
public:
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
/// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
{
int dow = x.getSize();
double r2 = (x * x);
double ux = exp(-10.0 * r2);
return -(400.0 * r2 - 20.0 * dow) * ux;
}
};
Elliptdemo::Elliptdemo():
ellipt("ellipt"),
adaptInfo(NULL),
adapt(NULL),
matrixOperator(NULL),
rhsOperator(NULL)
{}
Elliptdemo::~Elliptdemo() {
if(matrixOperator != NULL)
delete matrixOperator;
if(rhsOperator != NULL)
delete rhsOperator;
if(adapt != NULL)
delete adapt;
if(adaptInfo != NULL)
delete adaptInfo;
}
void Elliptdemo::create(std::string& filename) {
// ===== init parameters =====
Parameters::init(true, filename);
// ===== create and init the scalar problem =====
ellipt.initialize(INIT_ALL);
// === create adapt info ===
adaptInfo = new AdaptInfo("ellipt->adapt");