Skip to content
Snippets Groups Projects
Commit 6a91df81 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos Committed by Santiago Ospina De Los Ríos
Browse files

Fix vtk data manager to work with multidomain settings

parent acc6ebc9
No related branches found
No related tags found
No related merge requests found
Pipeline #33788 failed
......@@ -6,6 +6,7 @@
#include <functional>
#include <dune/common/exceptions.hh>
#include <dune/common/shared_ptr.hh>
#include <dune/common/std/functional.hh>
#include <dune/geometry/typeindex.hh>
......@@ -134,14 +135,14 @@ namespace Dune {
* @param gv grid view used for entity binding
* @param entity_transf entity transformation to the grid view used in the gfs
*/
DGFTreeCommonData(const GFS& gfs, const X& x, const GV& gv, const ET& entity_transf)
DGFTreeCommonData(std::shared_ptr<const GFS> gfs, std::shared_ptr<const X> x, const GV& gv, const ET& entity_transf)
: _entity_transf(entity_transf)
, _gv(gv)
, _lfs(gfs)
, _lfs_cache(_lfs)
, _x_view(x)
, _x_local(_lfs.maxSize())
, _index_set(gfs.entitySet().indexSet())
, _index_set(gfs->entitySet().indexSet())
, _current_cell_index(std::numeric_limits<size_type>::max())
, x(x)
{}
......@@ -156,7 +157,33 @@ namespace Dune {
* @note Only available if entity transformation is default constructible
*/
template<class T = int, class = std::enable_if_t<std::is_default_constructible_v<ET>,T>>
DGFTreeCommonData(const GFS& gfs, const X& x, const GV& gv)
DGFTreeCommonData(std::shared_ptr<const GFS> gfs, std::shared_ptr<const X> x, const GV& gv)
: DGFTreeCommonData(gfs,x,gv,ET{})
{}
/**
* @brief Construct a new DGFTreeCommonData object
*
* @param gfs grid function space
* @param x coefficient vector associated with the gfs
* @param gv grid view used for entity binding
* @param entity_transf entity transformation to the grid view used in the gfs
*/
DGFTreeCommonData(const GFS& gfs, const X& x, const GV& gv, const ET& entity_transf)
: DGFTreeCommonData(stackobject_to_shared_ptr(gfs),stackobject_to_shared_ptr(x),gv,entity_transf)
{}
/**
* @brief Construct a new DGFTreeCommonData object
*
* @param gfs grid function space
* @param x coefficient vector associated with the gfs
* @param gv grid view used for entity binding
*
* @note Only available if entity transformation is default constructible
*/
template<class T = int, class = std::enable_if_t<std::is_default_constructible_v<ET>,T>>
DGFTreeCommonData(const GFS& gfs, const X& x, const GV& gv)
: DGFTreeCommonData(gfs,x,gv,ET{})
{}
......@@ -488,6 +515,7 @@ namespace Dune {
struct add_solution_to_vtk_writer_visitor
: public TypeTree::DefaultVisitor
, public TypeTree::DynamicTraversal
, public TypeTree::VisitTreeDynamic
{
using GV = typename Data::GridView;
......@@ -505,14 +533,6 @@ namespace Dune {
};
template<typename LFS,
typename Child,
typename TreePath>
inline bool visitChild(const LFS& n, const Child& c, const TreePath& p)
{
return true;
}
//! Helper function for extracting (or building) the component name and adding
//! the component to the VTKWriter.
template<typename DGF, typename TreePath>
......@@ -552,6 +572,40 @@ namespace Dune {
// do nothing here - not a vector space
}
// **********************************************************************
// Visitor functions for adding DiscreteGridFunctions to VTKWriter
//
// The visitor functions contain a switch that will make them ignore
// function spaces with a different underlying GridView type than
// the VTKWriter.
// This cannot happen in vanilla PDELab, but is required for MultiDomain
// support
// **********************************************************************
// don't do anything if GridView types differ
template<typename LFS, typename TreePath>
typename std::enable_if<
!std::is_same<
typename LFS::Traits::GridFunctionSpace::Traits::GridView,
typename vtk_writer_traits<VTKWriter>::GridView
>::value
>::type
post(const LFS& lfs, TreePath tp)
{
}
// don't do anything if GridView types differ
template<typename LFS, typename TreePath>
typename std::enable_if<
!std::is_same<
typename LFS::Traits::GridFunctionSpace::Traits::GridView,
typename vtk_writer_traits<VTKWriter>::GridView
>::value
>::type
leaf(const LFS& lfs, TreePath tp)
{
}
//! Handle VectorGridFunctionSpace components in here.
template<typename LFS, typename TreePath>
void post(const LFS& lfs, TreePath tp)
......@@ -562,7 +616,13 @@ namespace Dune {
//! Create a standard leaf function for leaf GridFunctionSpaces.
template<typename LFS, typename TreePath>
void leaf(const LFS& lfs, TreePath tp)
typename std::enable_if<
std::is_same<
typename LFS::Traits::GridFunctionSpace::Traits::GridView,
typename vtk_writer_traits<VTKWriter>::GridView
>::value
>::type
leaf(const LFS& lfs, TreePath tp)
{
if (predicate(lfs, tp))
add_to_vtk_writer(std::make_shared<DGFTreeLeafFunction<LFS,Data,GV> >(lfs,data),tp);
......@@ -696,9 +756,27 @@ namespace Dune {
const X& x,
const NameGenerator& name_generator = vtk::defaultNameScheme(),
const Predicate& predicate = Predicate())
{
auto gfs_ptr = Dune::stackobject_to_shared_ptr(gfs);
auto x_ptr = Dune::stackobject_to_shared_ptr(x);
return addSolutionToVTKWriter(vtk_writer, gfs_ptr, x_ptr, name_generator, predicate);
}
template<typename VTKWriter,
typename GFS,
typename X,
typename NameGenerator = vtk::DefaultFunctionNameGenerator,
typename Predicate = vtk::DefaultPredicate>
auto
addSolutionToVTKWriter(VTKWriter& vtk_writer,
std::shared_ptr<GFS> gfs,
std::shared_ptr<X> x,
const NameGenerator& name_generator = vtk::defaultNameScheme(),
const Predicate& predicate = Predicate())
{
typedef vtk::DGFTreeCommonData<GFS,X,Predicate> Data;
vtk::OutputCollector<VTKWriter,Data> collector(vtk_writer,std::make_shared<Data>(gfs,x,gfs.gridView()),predicate);
vtk::OutputCollector<VTKWriter,Data> collector(vtk_writer, std::make_shared<Data>(gfs,x,gfs->gridView()),predicate);
collector.addSolution(name_generator);
return collector;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment