Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 59f0c65c authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

moved to current dune version

parent 9b0f4bf7
Pipeline #901 passed with stage
in 13 minutes and 7 seconds
......@@ -30,8 +30,8 @@ namespace AMDiS
{
public:
template <class Predicate, class Values,
class = std::enable_if_t< Concepts::Functor<Predicate, bool(WorldVector)> &&
Concepts::Functor<Values, double(WorldVector)> > >
std::enable_if_t< Concepts::Functor<Predicate, bool(WorldVector)> &&
Concepts::Functor<Values, double(WorldVector)>, int*> = nullptr>
DirichletBC(Predicate&& predicate, Values&& values)
: predicate(std::forward<Predicate>(predicate))
, values(std::forward<Values>(values))
......@@ -40,16 +40,16 @@ namespace AMDiS
template <class Matrix, class VectorX, class VectorB>
void init(bool apply,
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
template <class Matrix, class VectorX, class VectorB>
void finish(bool apply,
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
Matrix& matrix,
VectorX& rhs,
VectorB& solution);
private:
std::function<bool(WorldVector)> predicate;
......
......@@ -7,7 +7,7 @@
#include <dune/grid/io/file/vtk/vtkwriter.hh>
#include <dune/grid/io/file/vtk/vtksequencewriter.hh>
#include <dune/geometry/genericgeometry/referenceelements.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/amdis/Initfile.hpp>
#include <dune/amdis/common/Loops.hpp>
......@@ -19,22 +19,22 @@ namespace AMDiS
class FileWriter
{
private: // typedefs and static constants
using Mesh = typename Traits::Mesh;
using MeshView = typename Mesh::LeafGridView;
/// Dimension of the mesh
static constexpr int dim = Traits::dim;
/// Dimension of the world
static constexpr int dow = Traits::dimworld;
/// Number of problem components
static constexpr int nComponents = Traits::nComponents;
public:
/// Constructor.
FileWriter(std::string base, MeshView const& meshView, std::vector<std::string> const& names_)
: meshView(meshView)
......@@ -44,26 +44,26 @@ namespace AMDiS
Parameters::get(base + "->filename", filename);
dir = "output";
Parameters::get(base + "->output directory", dir);
vtkWriter = make_shared<Dune::VTKWriter<MeshView>>(meshView);
vtkSeqWriter = make_shared<Dune::VTKSequenceWriter<MeshView>>(vtkWriter, filename, dir, "");
}
/// default write method for time-depended data
template <class SystemVectorType>
void write(double time, SystemVectorType const& solutions)
{
vtkWriter->clear();
// copy dofvector to vertex data
for_<0, nComponents>([this, &solutions](const auto _i)
for_<0, nComponents>([this, &solutions](const auto _i)
{
this->dofVector2vertexVector(solutions[_i], std::get<_i>(data_vectors));
vtkSeqWriter->addVertexData(std::get<_i>(data_vectors), names[_i]);
});
vtkSeqWriter->write(time/*, Dune::VTK::appendedraw*/);
}
/// default write method for stationary data
template <class SystemVectorType>
......@@ -71,48 +71,48 @@ namespace AMDiS
{
vtkWriter->clear();
// copy dofvector to vertex data
for_<0, nComponents>([this, &solutions](const auto _i)
for_<0, nComponents>([this, &solutions](const auto _i)
{
this->dofVector2vertexVector(solutions[_i], std::get<_i>(data_vectors));
vtkWriter->addVertexData(std::get<_i>(data_vectors), names[_i]);
});
vtkWriter->pwrite(filename, dir, "" /*, Dune::VTK::appendedraw*/);
}
protected:
template <class DOFVector, class Vector>
void dofVector2vertexVector(DOFVector const& dofvector, Vector& data)
{
using Geometry = typename MeshView::template Codim<0>::Geometry;
using RefElements = Dune::ReferenceElements<typename Geometry::ctype, Geometry::mydimension>;
data.resize(meshView.size(dim));
auto const& indexSet = meshView.indexSet();
auto const& feSpace = dofvector.getFeSpace();
auto localView = feSpace.localView();
auto localIndexSet = feSpace.localIndexSet();
// copy data to P1-vector
for (auto const& element : elements(meshView)) {
localView.bind(element);
localIndexSet.bind(localView);
auto const& localBasis = localView.tree().finiteElement().localBasis();
auto const& refElement = RefElements::general(element.type());
std::vector<Dune::FieldVector<double,1> > shapeValues;
size_t nVertices = element.subEntities(dim);
for (size_t i = 0; i < nVertices; ++i) {
auto const& v = element.template subEntity<dim>(i);
auto pos = refElement.position(i, dim);
localBasis.evaluateFunction(pos, shapeValues);
size_t idx = indexSet.index(v);
data[idx] = 0.0;
for (size_t j = 0; j < shapeValues.size(); ++j) {
......@@ -127,10 +127,10 @@ namespace AMDiS
MeshView const& meshView;
shared_ptr<Dune::VTKWriter<MeshView>> vtkWriter;
shared_ptr<Dune::VTKSequenceWriter<MeshView>> vtkSeqWriter;
std::vector<std::string> names;
std::array<std::vector<double>, nComponents> data_vectors;
std::string filename;
std::string dir;
};
......
......@@ -7,7 +7,7 @@
#include <array>
#include <memory>
#include <dune/common/array.hh>
#include <dune/common/filledarray.hh>
#include <dune/common/fvector.hh>
#include <dune/grid/albertagrid.hh>
......@@ -149,10 +149,10 @@ namespace AMDiS
msg("L = ", L);
auto s = Dune::fill_array<int,dim>(2); // number of cells on coarse mesh in each direction
auto s = Dune::filledArray<std::size_t(dim)>(2); // number of cells on coarse mesh in each direction
Parameters::get(meshName + "->num cells", s);
// TODO: add more parameters for yasp-grid (see constructor)
// TODO: add more parameters for yasp-grid (see constructor)
return make_unique<Grid>(L, s);
}
......@@ -171,10 +171,10 @@ namespace AMDiS
Parameters::get(meshName + "->min corner", lowerleft);
Parameters::get(meshName + "->max corner", upperright);
auto s = Dune::fill_array<int,dim>(2); // number of cells on coarse mesh in each direction
auto s = Dune::filledArray<std::size_t(dim)>(2); // number of cells on coarse mesh in each direction
Parameters::get(meshName + "->num cells", s);
// TODO: add more parameters for yasp-grid (see constructor)
// TODO: add more parameters for yasp-grid (see constructor)
return make_unique<Grid>(lowerleft, upperright, s);
}
......
......@@ -196,9 +196,25 @@ namespace AMDiS
/// Return the \ref linearSolver
auto getSolver() { return linearSolver; }
void setSolver(std::shared_ptr<LinearSolverType> const& solver_)
{
linearSolver = solver_;
}
/// Return the \ref mesh
auto getMesh() { return mesh; }
void setMesh(std::shared_ptr<Mesh> const& mesh_)
{
mesh = mesh_;
meshView = make_shared<MeshView>(mesh->leafGridView());
createFeSpaces();
createMatricesAndVectors();
createFileWriter();
}
/// Return the \ref meshView
auto getMeshView() { return meshView; }
......@@ -380,32 +396,32 @@ namespace AMDiS
VectorEntries<double*> vectorFactors;
std::map< int, bool > vectorAssembled; // if false, do reassemble
std::map< int, bool > vectorChanging; // if true, or vectorAssembled false, do reassemble
template <int r, int c>
struct MatrixData
struct MatrixData
{
using DOFMatrixType =
using DOFMatrixType =
std::tuple_element_t<c, std::tuple_element_t<r, typename SystemMatrixType::DOFMatrices>>;
DOFMatrixType& matrix;
std::list<shared_ptr<OperatorType>>& operators;
std::list<double*> const& factors;
bool assemble;
std::pair<int,int> row_col = {r, c};
};
template <int r>
struct VectorData
{
using DOFVectorType =
using DOFVectorType =
std::tuple_element_t<r, typename SystemVectorType::DOFVectors>;
DOFVectorType& vector;
std::list<shared_ptr<OperatorType>>& operators;
std::list<double*> const& factors;
bool assemble;
int row = r;
};
};
......
......@@ -275,8 +275,9 @@ namespace AMDiS
rhs->getVector(_r) = 0.0;
}
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector, _r](auto const _c)
For<0, nComponents>::loop([this, &nnz, asmMatrix_, asmVector, r=_r](auto const _c)
{
auto const _r = r;
using MatrixData = typename ProblemStatSeq<Traits>::template MatrixData<_r, _c>;
using VectorData = typename ProblemStatSeq<Traits>::template VectorData<_r>;
......
......@@ -20,67 +20,67 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
StokesProblem prob("stokes");
prob.initialize(INIT_ALL);
double viscosity = 1.0;
Parameters::get("stokes->viscosity", viscosity);
// define the differential operators
using Op = StokesProblem::OperatorType;
for_<0,DOW>([&](auto _i)
{
for_<0,DOW>([&](auto _i)
{
// <viscosity*grad(u_i), grad(v_i)>
Op* opL = new Op;
opL->addSOT( constant(viscosity) );
opL->addSOT( constant(viscosity) );
prob.addMatrixOperator(*opL, _i, _i);
// <p, d_i(v_i)>
Op* opB = new Op;
opB->addFOT( constant(1.0), _i, GRD_PSI );
prob.addMatrixOperator(*opB, _i, DOW);
opB->addFOT( constant(1.0), _i, GRD_PSI );
prob.addMatrixOperator(*opB, _i, DOW);
// <d_i(u_i), q>
Op* opDiv = new Op;
Op* opDiv = new Op;
opDiv->addFOT( constant(1.0), _i, GRD_PHI );
prob.addMatrixOperator(*opDiv, DOW, _i);
prob.addMatrixOperator(*opDiv, DOW, _i);
});
Op* opZero = new Op;
Op* opZero = new Op;
opZero->addZOT( constant(0.0) );
prob.addMatrixOperator(*opZero, DOW, DOW);
prob.addMatrixOperator(*opZero, DOW, DOW);
// define boundary regions
auto left = [](auto const& x) { return x[0] < 1.e-8; };
auto box = [](auto const& x) { return x[0] > 1.0 - 1.e-8 || x[1] < 1.e-8 || x[1] > 1.0 - 1.e-8; };
// define boundary values
auto zero = [](auto const& x) { return 0.0; };
auto parabolic = [](auto const& x) { return x[1]*(1.0 - x[1]); };
// set boundary conditions
for (size_t i = 0; i < DOW; ++i)
prob.addDirichletBC(box, i, i, zero);
prob.addDirichletBC(left, 0, 0, zero);
prob.addDirichletBC(left, 1, 1, parabolic);
prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8 && x[1] < 1.e-8; }, 2, 2, zero);
// set initial values for the solver (maybe not necessary)
*prob.getSolution() = 0.0;
AdaptInfo adaptInfo("adapt", prob.getNumComponents());
// assemble and solve system
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.solve(adaptInfo);
// output solution
prob.writeFiles(adaptInfo);
AMDiS::finalize();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment