Liebe Gitlab-Nutzer, 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 43cefbd6 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/replace_make_functions' into 'master'

Feature/replace make functions

See merge request !201
parents 39a573a2 d64976bf
Pipeline #4677 passed with stage
in 41 minutes
......@@ -407,16 +407,6 @@ namespace AMDiS
-> GridFunctionMarker<Grid,
TYPEOF( makeGridFunction(FWD(gf), grid->leafGridView()) )>;
// Generator function for GridFunctionMarker class
template <class Grid, class PreGridFct>
auto makeGridFunctionMarker(std::string const& name, std::shared_ptr<Grid> const& grid,
PreGridFct&& preGridFct)
{
auto gridFct = makeGridFunction(FWD(preGridFct), grid->leafGridView());
return GridFunctionMarker<Grid,TYPEOF(gridFct)>{name, grid, std::move(gridFct)};
}
} // end namespace AMDiS
#include "Marker.inc.hpp"
......@@ -96,20 +96,6 @@ namespace AMDiS
-> ProblemInstat<Traits>;
// Generator for ProblemInstat with given ProblemStat
template <class Traits>
ProblemInstat<Traits> makeProblemInstat(std::string const& name, ProblemStat<Traits>& prob)
{
return {name, prob};
}
// Generator for ProblemInstat with given ProblemStat and initialization problem
template <class Traits>
ProblemInstat<Traits> makeProblemInstat(std::string const& name, ProblemStat<Traits>& prob, ProblemStatBase& initialProb)
{
return {name, prob, initialProb};
}
// mark template as explicitly instantiated in cpp file
extern template class ProblemInstat<YaspGridBasis<2,1>>;
extern template class ProblemInstat<YaspGridBasis<2,2>>;
......
......@@ -517,14 +517,6 @@ namespace AMDiS
-> ProblemStat<DefaultProblemTraits<GlobalBasis>>;
// Generator for ProblemStat with given Grid and GlobalBasis
template <class Grid, class GlobalBasis>
ProblemStat<DefaultProblemTraits<GlobalBasis>>
makeProblemStat(std::string const& name, Grid& grid, GlobalBasis& globalBasis)
{
return {name, grid, globalBasis};
}
// mark templates as explicitly instantiated in cpp file
extern template class ProblemStat<YaspGridBasis<2,1>>;
extern template class ProblemStat<YaspGridBasis<2,2>>;
......
......@@ -91,12 +91,12 @@ namespace AMDiS
static auto create(std::string const& name, GridView const& gridView)
{
return makeGlobalBasis(name, gridView, PreBasisCreator::create());
return ParallelGlobalBasis(name, gridView, PreBasisCreator::create());
}
static auto create(GridView const& gridView)
{
return makeGlobalBasis(gridView, PreBasisCreator::create());
return ParallelGlobalBasis(gridView, PreBasisCreator::create());
}
using GlobalBasis = decltype(create(std::declval<GridView>()));
......
......@@ -37,6 +37,13 @@
namespace AMDiS
{
template <class PreBasisFactory>
using MultiIndex = std::conditional_t<
(remove_cvref_t<PreBasisFactory>::requiredMultiIndexSize == 1),
Dune::Functions::FlatMultiIndex<std::size_t>,
Dune::ReservedVector<std::size_t, remove_cvref_t<PreBasisFactory>::requiredMultiIndexSize>>;
/**
* \brief Parallel global basis defined on a (sequential) pre-basis
*
......@@ -92,11 +99,11 @@ namespace AMDiS
, comm_(CommunicationCreator<Comm>::create(static_cast<Super const&>(*this), name + "->solver"))
{}
/// Construct this global basis with empty name
template <class... Args,
Dune::Functions::enableIfConstructible<PreBasis, Args...> = 0>
ParallelGlobalBasis(Grid const& grid, Args&&... args)
: ParallelGlobalBasis(std::string(""), grid, FWD(args)...)
/// Construct this global basis with a preBasisFactory
template <class PBF>
ParallelGlobalBasis(std::string const& name, GridView const& gridView, PBF&& preBasisFactory)
: ParallelGlobalBasis(name, gridView.grid(),
preBasisFactory.template makePreBasis<MultiIndex<PBF>>(gridView))
{}
/// Converting constructor from dune-functions style basis.
......@@ -105,10 +112,16 @@ namespace AMDiS
* argument and a new communication object is built.
*/
template <class GB_,
Dune::disableCopyMove<Self, GB_> = 0,
REQUIRES(Concepts::GlobalBasis<GB_,GridView>)>
ParallelGlobalBasis(GB_&& from)
: ParallelGlobalBasis(std::string(""), from.gridView().grid(), from.preBasis())
ParallelGlobalBasis(std::string const& name, GB_&& from)
: ParallelGlobalBasis(name, from.gridView().grid(), from.preBasis())
{}
/// Construct this global basis with empty name
template <class Arg, class... Args,
REQUIRES(!std::is_same_v<std::string, remove_cvref_t<Arg>>)>
ParallelGlobalBasis(Arg&& arg, Args&&... args)
: ParallelGlobalBasis(std::string(""), FWD(arg), FWD(args)...)
{}
/// Copy constructor
......@@ -175,29 +188,15 @@ namespace AMDiS
};
template <class MultiIndex, class GV, class PBF>
auto makeGlobalBasis(std::string const& name, GV const& gridView, PBF&& preBasisFactory)
{
auto preBasis = preBasisFactory.template makePreBasis<MultiIndex>(gridView);
return ParallelGlobalBasis<TYPEOF(preBasis)>(name, gridView.grid(), std::move(preBasis));
}
// Deduction guides
template <class GV, class PBF>
auto makeGlobalBasis(std::string const& name, GV const& gridView, PBF&& preBasisFactory)
{
using RawPreBasisFactory = remove_cvref_t<PBF>;
using MultiIndex = std::conditional_t<
(RawPreBasisFactory::requiredMultiIndexSize == 1),
Dune::Functions::FlatMultiIndex<std::size_t>,
Dune::ReservedVector<std::size_t, RawPreBasisFactory::requiredMultiIndexSize>>;
return makeGlobalBasis<MultiIndex, GV, PBF>(name, gridView, FWD(preBasisFactory));
}
ParallelGlobalBasis(std::string const& name, GV const& gridView, PBF&& preBasisFactory)
-> ParallelGlobalBasis<decltype(
preBasisFactory.template makePreBasis<MultiIndex<PBF>>(gridView))>;
template <class GV, class PBF>
auto makeGlobalBasis(GV const& gridView, PBF&& preBasisFactory)
{
return makeGlobalBasis(std::string(""), gridView, FWD(preBasisFactory));
}
ParallelGlobalBasis(GV const& gridView, PBF&& preBasisFactory)
-> ParallelGlobalBasis<decltype(
preBasisFactory.template makePreBasis<MultiIndex<PBF>>(gridView))>;
} // end namespace AMDiS
......@@ -89,7 +89,7 @@ public:
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*subTree_, [&,this](auto const& node, auto const& tp)
{
auto localBasisCache = makeNodeCache(node);
NodeCache localBasisCache(node);
auto const& shapeFunctionValues = localBasisCache.evaluateFunction(localView_.element().type(), x);
std::size_t size = node.finiteElement().size();
......@@ -268,7 +268,7 @@ public:
auto&& nodeToRangeEntry = this->globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*this->subTree_, [&](auto const& node, auto const& tp)
{
auto localBasis = makeLocalToGlobalBasisAdapter(node, this->geometry());
LocalToGlobalBasisAdapter localBasis(node, this->geometry());
auto const& gradients = localBasis.gradientsAt(x);
// Get range entry associated to this node
......@@ -334,7 +334,7 @@ private:
auto&& node = *this->subTree_;
auto localBasis = makeLocalToGlobalBasisAdapter(node.child(0), this->geometry());
LocalToGlobalBasisAdapter localBasis(node.child(0), this->geometry());
auto const& gradients = localBasis.gradientsAt(x);
auto re = Dune::Functions::flatVectorView(dy);
......@@ -377,7 +377,7 @@ public:
auto&& nodeToRangeEntry = this->globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*this->subTree_, [&](auto const& node, auto const& tp)
{
auto localBasis = makeLocalToGlobalBasisAdapter(node, this->geometry());
LocalToGlobalBasisAdapter localBasis(node, this->geometry());
auto const& partial = localBasis.partialsAt(x, comp);
// Get range entry associated to this node
......
......@@ -75,11 +75,4 @@ namespace AMDiS
bool animation_ = false;
};
/// Generator function for \ref BackupWriter
template <class SystemVector>
BackupWriter<SystemVector> makeBackupWriter(std::string const& name, std::shared_ptr<SystemVector> systemVector)
{
return {name, systemVector};
}
} // end namespace AMDiS
......@@ -82,14 +82,6 @@ namespace AMDiS
bool animation_ = false;
};
/// Generator function for \ref DuneVtkWriter
template <class GridView, class GridFunction>
DuneVtkWriter<GridView, GridFunction> makeDuneVtkWriter(std::string const& name, GridView const& gridView, GridFunction const& gridFunction)
{
return {name, gridView, gridFunction};
}
} // end namespace AMDiS
#endif // HAVE_DUNE_VTK
......@@ -70,14 +70,4 @@ namespace AMDiS
bool animation_ = false;
};
/// Generator function for \ref GmshWriter
template <class GridView>
GmshWriter<GridView> makeGmshWriter(std::string const& name, GridView const& gridView,
std::vector<int> const& physicalEntities = std::vector<int>(),
std::vector<int> const& physicalBoundaries = std::vector<int>())
{
return {name, gridView, physicalEntities, physicalBoundaries};
}
} // end namespace AMDiS
......@@ -114,12 +114,4 @@ namespace AMDiS
Dune::VTK::OutputType mode_ = Dune::VTK::ascii;
};
/// Generator function for \ref VTKWriter
template <class GridView, class GridFunction>
VTKWriter<GridView, GridFunction> makeVTKWriter(std::string const& name, GridView const& gridView, GridFunction const& gridFunction)
{
return {name, gridView, gridFunction};
}
} // end namespace AMDiS
......@@ -43,7 +43,7 @@ namespace AMDiS
static_assert(Node::isLeaf, "Operator can be applied to Leaf-Nodes only.");
auto const& quad = this->getQuadratureRule(contextGeo.type(), node);
auto localBasis = makeLocalToGlobalBasisAdapter(node, contextGeo.geometry());
LocalToGlobalBasisAdapter localBasis(node, contextGeo.geometry());
for (std::size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element
......
......@@ -56,7 +56,7 @@ namespace AMDiS
std::size_t rowSize = rowLocalFE.size();
NodeQuadCache<RN> rowCache(rowLocalFE.localBasis());
auto colLocalBasis = makeLocalToGlobalBasisAdapter(colNode, contextGeo.geometry());
LocalToGlobalBasisAdapter colLocalBasis(colNode, contextGeo.geometry());
auto const& shapeValuesCache = rowCache.evaluateFunctionAtQP(contextGeo, quad);
for (std::size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element
......
......@@ -48,8 +48,8 @@ namespace AMDiS
auto const& quad = this->getQuadratureRule(contextGeo.type(), rowNode, colNode);
auto rowLocalBasis = makeLocalToGlobalBasisAdapter(rowNode, contextGeo.geometry());
auto colLocalBasis = makeLocalToGlobalBasisAdapter(colNode, contextGeo.geometry());
LocalToGlobalBasisAdapter rowLocalBasis(rowNode, contextGeo.geometry());
LocalToGlobalBasisAdapter colLocalBasis(colNode, contextGeo.geometry());
for (std::size_t iq = 0; iq < quad.size(); ++iq) {
// Position of the current quadrature point in the reference element
......
......@@ -117,13 +117,6 @@ namespace AMDiS
LocalBasisType const* localBasis_ = nullptr;
};
/// Generator function for \ref NodeCache, \relates NodeCache.
template <class Node>
NodeCache<Node> makeNodeCache(Node const& node)
{
return NodeCache<Node>{node};
}
/// \brief Cache of LocalBasis evaluations and jacobians at quadrature points
/**
* Caching is done using the ConcurrentCache data structure with a key that
......@@ -237,11 +230,4 @@ namespace AMDiS
LocalBasisType const* localBasis_ = nullptr;
};
/// Generator function for \ref NodeQuadCache, \relates NodeQuadCache.
template <class Node>
NodeQuadCache<Node> makeNodeQuadCache(Node const& node)
{
return NodeQuadCache<Node>{node};
}
} // end namespace AMDiS
......@@ -195,13 +195,4 @@ namespace AMDiS
std::size_t size_;
};
/// Generator function for the \ref LocalToGlobalBasisAdapter. \relates LocalToGlobalBasisAdapter.
template <class BasisNode, class Geometry>
LocalToGlobalBasisAdapter<BasisNode, Geometry>
makeLocalToGlobalBasisAdapter(BasisNode const& node, Geometry const& geometry)
{
return LocalToGlobalBasisAdapter<BasisNode, Geometry>{node, geometry};
}
} // namespace AMDiS
......@@ -42,7 +42,7 @@ auto basis = makeBasis(gv,
lagrange<2>(), blockedLexicographic()
));
// Create a Problem with c++17, use makeProblemStat() in pre c++17
// Create a Problem
ProblemStat prob("prob", *grid, basis);
prob.initialize(INIT_ALL);
```
......
......@@ -109,12 +109,12 @@ using Grid = Dune::YaspGrid<2>;
Grid grid({1.0, 1.0}, {2, 2});
using namespace Dune::Functions::BasisFactory;
auto basis1 = makeGlobalBasis(grid.leafGridView(), lagrange<2>());
ParallelGlobalBasis basis1(grid.leafGridView(), lagrange<2>());
DOFVector<decltype(basis1)> vec0(basis1);
DOFVector vec1(basis1); // C++17 only
auto basis2 = makeUniquePtr(makeGlobalBasis(grid.leafGridView(), lagrange<2>()));
auto basis2 = makeUniquePtr(ParallelGlobalBasis(grid.leafGridView(), lagrange<2>()));
DOFVector<Underlying_t<decltype(basis2)>> vec2(std::move(basis2));
```
......@@ -251,7 +251,7 @@ underlying type is either the `remove_cvref_t` for references, or the pointed-to
using namespace Dune::Functions::BasisFactory;
// pass a reference to the basis
auto basis1 = makeGlobalBasis(gridView, lagrange<2>());
ParallelGlobalBasis basis1(gridView, lagrange<2>());
auto vec1 = makeDOFVector<double>(basis1);
// pass a smart pointer
......@@ -391,7 +391,7 @@ Returns the const (1) or mutable (2) sub-range view of the stored DOFVector.
#### Example
```c++
auto basis = makeGlobalBasis(gridView, power<3>(lagrange<1>()));
ParallelGlobalBasis basis(gridView, power<3>(lagrange<1>()));
auto vec = makeDOFVector(basis);
auto df = makeDiscreteFunction(vec);
......@@ -452,7 +452,7 @@ Note, the range type of the expression must be compatible with the `Range` type
#### Example
```c++
auto basis = makeGlobalBasis(gridView, power<3>(lagrange<1>()));
ParallelGlobalBasis basis(gridView, power<3>(lagrange<1>()));
auto vec = makeDOFVector(basis);
auto df1 = vec.child();
......@@ -504,7 +504,7 @@ thereby given by the type of `makeTreePath(preTreePath)`.
using namespace Dune::Functions::BasisFactory;
// pass a reference to the basis
auto basis = makeGlobalBasis(gridView, power<2>(lagrange<2>()));
ParallelGlobalBasis basis(gridView, power<2>(lagrange<2>()));
auto vec = makeDOFVector<double>(basis1);
auto df1 = makeDiscreteFunction(vec);
......@@ -512,4 +512,3 @@ auto df2 = makeDiscreteFunction(vec, 1);
auto df3 = makeDiscreteFunction(vec, _1);
auto df4 = makeDiscreteFunction(vec, Dune::TypeTree::hybridTreePath(0));
```
......@@ -113,13 +113,6 @@ given in the `Traits` as `C = typename Traits::CoefficientType`.
--------------------------------|---------------------------------------------
[`oneIteration`](#function-problemstatbuildafteradapt) | A single build-solve-adapt step
### Related functions
Function | Descriptions
--------------------------------|---------------------------------------------
[`makeProblemStat`](#function-makeproblemstat) | Constructs a new problem
## function `ProblemStat::ProblemStat`
```c++
explicit ProblemStat(std::string const& name) // (1)
......@@ -173,10 +166,6 @@ ProblemStat<LagrangeBasis<Grid, 2>> prob3("prob", grid, basis);
ProblemStat prob4("prob", grid, basis);
```
#### See Also
- Generator function to construct a problem: [`makeProblemStat()`](#function-makeproblemstat)
## function `ProblemStat::initialize`
```c++
......@@ -378,45 +367,6 @@ prob.boundaryManager()->setBoxBoundary({1,2,2,2});
prob.addDirichletBC(BoundaryType{1}, 0, 0, 0.0);
```
## function `makeProblemStat`
```c++
template <class Grid, class GlobalBasis>
ProblemStat<DefaultProblemTraits<GlobalBasis>>
makeProblemStat(std::string const& name, Grid& grid, GlobalBasis& globalBasis)
```
Construct a [`ProblemStat`](#class-problemstat) with given name, grid, and basis. The `Traits` type is constructed
from the global basis type, using the wrapper `DefaultProblemTraits`
#### Arguments
`std::string name`
: The name of the problem that is used to identify parameters in the initfile.
`Grid grid`
: A grid implementing the `Dune::Grid` interface.
`GlobalBasis globalBasis`
: A basis implementing the `Dune::Functions::GlobalBasis` interface.
#### Example
```c++
using Grid = Dune::YaspGrid<2>;
Grid grid({1.0, 1.0}, {2, 2});
using namespace Dune::Functions::BasisFactory;
auto basis = makeBasis(grid.leafGridView(), lagrange<2>());
// using c++17 class template argument deduction
auto prob = makeProblemStat("prob", grid, basis);
```
#### See Also
- Class: [`ProblemStat`](#class-problemstat)
## class `ProblemInstat`
Defined in header [`<amdis/ProblemInstat.hpp>`](https://gitlab.mn.tu-dresden.de/amdis/amdis-core/blob/master/src/amdis/ProblemInstat.hpp)
......
......@@ -119,7 +119,7 @@ using namespace Dune::Functions::BasisFactory;
// create a power basis of 3 lagrange bases with local polynomial degree 2
// on the leaf elements of the grid
auto basis1 = makeGlobalBasis(grid2->leafGridView(), power<3>(lagrange<2>()));
ParallelGlobalBasis basis1(grid2->leafGridView(), power<3>(lagrange<2>()));
```
or by using some predefined wrappers:
......@@ -139,8 +139,7 @@ auto basis2 = BasisCreator::create(grid2->leafGridView());
grid refinement or by repartitioning. Additionally, it stores a communication object
to construct global DOFMappings for distributed data structured.
This `ParallelGlobalBasis` is automatically constructed with `makeGlobalBasis` and
can be converted from a `DefaultGlobalBasis` of dune-functions.
This `ParallelGlobalBasis` can be converted from a `DefaultGlobalBasis` of dune-functions.
A [`DOFVector`](../reference/DOFVector.md) takes a global basis and provides the coefficient vector as data member.
......
......@@ -50,7 +50,7 @@ int main(int argc, char** argv)
int ref_int = Parameters::get<int>("refinement->interface").value_or(10);
int ref_bulk = Parameters::get<int>("refinement->bulk").value_or(2);
auto marker = makeGridFunctionMarker("interface", prob.grid(),
GridFunctionMarker marker("interface", prob.grid(),
invokeAtQP([ref_int, ref_bulk](double phi) {
return phi > 0.05 && phi < 0.95 ? ref_int : ref_bulk;
}, phi));
......
......@@ -72,7 +72,7 @@ int main(int argc, char** argv)
auto preBasis = composite(power<2>(lagrange<2>(), flatInterleaved()),
lagrange<1>(),
flatLexicographic());
auto basis = makeGlobalBasis(gridView, preBasis);
ParallelGlobalBasis basis(gridView, preBasis);
using Basis = decltype(basis);
......
......@@ -39,7 +39,6 @@ int main(int argc, char** argv)
};
GridFunctionMarker marker("mymarker", prob.grid(), markerFunc);
auto marker2 = makeGridFunctionMarker("mymarker", prob.grid(), markerFunc);
prob.addMarker(marker);
......
......@@ -22,9 +22,9 @@ void test()
// use T as range type for basis
using namespace Dune::Functions::BasisFactory;
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
auto basis = makeGlobalBasis(grid.leafGridView(), power<1>(lagrange<1>(), flatLexicographic()));
ParallelGlobalBasis basis(grid.leafGridView(), power<1>(lagrange<1>(), flatLexicographic()));
#else
auto basis = makeGlobalBasis(grid.leafGridView(), power<1>(lagrange<1,T>(), flatLexicographic()));
ParallelGlobalBasis basis(grid.leafGridView(), power<1>(lagrange<1,T>(), flatLexicographic()));
#endif
using Basis = decltype(basis);
......
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