Commit 6d7303aa authored by Santiago Ospina's avatar Santiago Ospina

Construction of the raviart thomas working (not solving anything yet)

Signed-off-by: Santiago Ospina De Los Ríos's avatarSantiago Ospina <santiago.ospina@iup.uni-heidelberg.de>
parent b253adf6
......@@ -142,18 +142,18 @@ int main(int argc, char** argv)
sim.run();
break;
}
case 2:{
Sim<Simplex<2,2>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 3:{
Sim<Simplex<2,3>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
// case 2:{
// Sim<Simplex<2,2>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 3:{
// Sim<Simplex<2,3>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......@@ -168,18 +168,18 @@ int main(int argc, char** argv)
sim.run();
break;
}
case 2:{
Sim<CubeAdaptive<2,2>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 3:{
Sim<CubeAdaptive<2,3>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
// case 2:{
// Sim<CubeAdaptive<2,2>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 3:{
// Sim<CubeAdaptive<2,3>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......@@ -187,21 +187,21 @@ int main(int argc, char** argv)
else{ // no adaptivity
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<Cube<2,1>> sim(helper,grid,inifile);
sim.run();
break;
}
case 2:{
Sim<Cube<2,2>> sim(helper,grid,inifile);
sim.run();
break;
}
case 3:{
Sim<Cube<2,3>> sim(helper,grid,inifile);
sim.run();
break;
}
// case 1:{
// Sim<Cube<2,1>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
// case 2:{
// Sim<Cube<2,2>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
// case 3:{
// Sim<Cube<2,3>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......@@ -216,24 +216,24 @@ int main(int argc, char** argv)
if (gtype == "gmsh"){
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<3>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<Simplex<3,1>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 2:{
Sim<Simplex<3,2>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 3:{
Sim<Simplex<3,3>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
// case 1:{
// Sim<Simplex<3,1>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 2:{
// Sim<Simplex<3,2>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 3:{
// Sim<Simplex<3,3>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......@@ -242,24 +242,24 @@ int main(int argc, char** argv)
if(adaptivity){
auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<3>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<CubeAdaptive<3,1>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 2:{
Sim<CubeAdaptive<3,2>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
case 3:{
Sim<CubeAdaptive<3,3>> sim(helper,grid,inifile);
sim.set_policy(adapt_policy);
sim.run();
break;
}
// case 1:{
// Sim<CubeAdaptive<3,1>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 2:{
// Sim<CubeAdaptive<3,2>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
// case 3:{
// Sim<CubeAdaptive<3,3>> sim(helper,grid,inifile);
// sim.set_policy(adapt_policy);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......@@ -267,21 +267,21 @@ int main(int argc, char** argv)
else{ // no adaptivity
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<3>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<Cube<3,1>> sim(helper,grid,inifile);
sim.run();
break;
}
case 2:{
Sim<Cube<3,2>> sim(helper,grid,inifile);
sim.run();
break;
}
case 3:{
Sim<Cube<3,3>> sim(helper,grid,inifile);
sim.run();
break;
}
// case 1:{
// Sim<Cube<3,1>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
// case 2:{
// Sim<Cube<3,2>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
// case 3:{
// Sim<Cube<3,3>> sim(helper,grid,inifile);
// sim.run();
// break;
// }
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
......
#include "richards_simulation.hh"
#include "../solver/util_flux_reconstruction.hh"
#include "../solver/flux_reconstruction/rt_projection.hh"
namespace Dune{
namespace Dorie{
......@@ -130,6 +128,8 @@ void RichardsSimulation<Traits>::operator_setup()
if (helper.rank()==0)
std::cout << " Total number of DOF: " << DOFnumber << std::endl;
}
waterfrgf = std::make_shared<GFWaterFluxReconstruction>(*go0); //FIXME!
}
template<typename Traits>
......@@ -211,6 +211,7 @@ void RichardsSimulation<Traits>::update_adapters () const
condgf = std::make_shared<GFConductivity>(gv, fparam);
waterdgf = std::make_shared<GFWaterContent>(udgf, gv, fparam);
satdgf = std::make_shared<GFSaturation>(udgf, gv, fparam);
waterfrgf->update(*u);
}
template<typename Traits>
......@@ -220,66 +221,19 @@ void RichardsSimulation<Traits>::write_data () const
{
update_adapters();
constexpr int l = 0; // FIXME! this can be 0 or 1
// RT projection code
#if 1
RaviartThomasProjection<GO0,Traits::GridGeometryType,Traits::fem_order - l> proj(*go0);
#endif
// global lifting code
#if 0
constexpr bool frimp = FluxReconstructionImplemented<typename Traits::GV,
typename Traits::RangeField,
Traits::GV::dimension,
Traits::fem_order - l,
Traits::GridGeometryType>::value;
#else
constexpr bool frimp = false;
#endif
if (inifile.get<bool>("output.vertexData")) {
vtkwriter->template addVertexData<GFMatricHead>(udgf,"head");
vtkwriter->template addVertexData<GFWaterFlux>(fluxdgf,"flux");
vtkwriter->template addVertexData<GFConductivity>(condgf,"K_0");
vtkwriter->template addVertexData<GFWaterContent>(waterdgf,"theta_w");
vtkwriter->template addVertexData<GFSaturation>(satdgf,"Theta");
if constexpr (frimp)
{
using GFFluxReconstruction = Dune::Dorie::FluxReconstruction<
typename Traits::GV,
typename Traits::RangeField,
Traits::GV::dimension,
Traits::fem_order - l,
Traits::GridGeometryType>;
std::shared_ptr<GFFluxReconstruction> frgf = std::make_shared<GFFluxReconstruction>(udgf);
vtkwriter->template addVertexData<GFFluxReconstruction>(frgf,"flux (reconstruction)");
} else {
std::cout << "WARNING: Flux reconstruction not available for this simulation!" << std::endl;
}
vtkwriter->template addVertexData<GFWaterFlux>(fluxdgf,"flux");
} else {
vtkwriter->template addCellData<GFMatricHead>(udgf,"head");
vtkwriter->template addCellData<GFWaterFlux>(fluxdgf,"flux");
vtkwriter->template addCellData<GFConductivity>(condgf,"K_0");
vtkwriter->template addCellData<GFWaterContent>(waterdgf,"theta_w");
vtkwriter->template addCellData<GFSaturation>(satdgf,"Theta");
if constexpr (frimp)
{
using GFFluxReconstruction = Dune::Dorie::FluxReconstruction<
typename Traits::GV,
typename Traits::RangeField,
Traits::GV::dimension,
Traits::fem_order - l,
Traits::GridGeometryType>;
std::shared_ptr<GFFluxReconstruction> frgf = std::make_shared<GFFluxReconstruction>(udgf);
vtkwriter->template addCellData<GFFluxReconstruction>(frgf,"flux (reconstruction)");
} else {
std::cout << "WARNING: Flux reconstruction not available for this simulation!" << std::endl;
}
}
......
......@@ -30,6 +30,7 @@
#include "../solver/adapters/saturation.hh"
#include "../solver/adapters/water_flux.hh"
#include "../solver/adapters/conductivity.hh"
#include "../solver/flux_reconstruction/rt_projection.hh"
namespace Dune{
......@@ -50,6 +51,7 @@ struct RichardsSimulationTraits : public BaseTraits
{
static constexpr int dim = BaseTraits::dim;
static constexpr int fem_order = order;
static constexpr int flux_order = order - 1; //FIXME!
using RF = typename BaseTraits::RF;
using Grid = typename BaseTraits::Grid;
using GV = typename BaseTraits::GV;
......@@ -125,7 +127,8 @@ struct RichardsSimulationTraits : public BaseTraits
using GFWaterContent = Dune::Dorie::WaterContentAdapter<BaseTraits,FlowParameters,GFMatricHead>;
/// Saturation
using GFSaturation = Dune::Dorie::SaturationAdapter<BaseTraits,FlowParameters,GFMatricHead>;
/// Water Flux reconstruction
using GFWaterFluxReconstruction = Dune::Dorie::RaviartThomasFluxReconstruction<GO0,BaseTraits::GridGeometryType,flux_order>;
// -- Utility Class Definitions -- //
/// Custom VTK output writer
......@@ -229,6 +232,8 @@ private:
using GFWaterContent = typename Traits::GFWaterContent;
/// Saturation
using GFSaturation = typename Traits::GFSaturation;
/// Water Flux reconstruction
using GFWaterFluxReconstruction = typename Traits::GFWaterFluxReconstruction;
// -- Utility Class Definitions -- //
......@@ -273,12 +278,12 @@ protected:
std::shared_ptr<U> u;
mutable std::shared_ptr<GFMatricHead> udgf;
mutable std::shared_ptr<GFWaterFlux> fluxdgf;
mutable std::shared_ptr<GFConductivity> condgf;
mutable std::shared_ptr<GFWaterContent> waterdgf;
mutable std::shared_ptr<GFSaturation> satdgf;
mutable std::shared_ptr<GFMatricHead> udgf;
mutable std::shared_ptr<GFWaterFlux> fluxdgf;
mutable std::shared_ptr<GFConductivity> condgf;
mutable std::shared_ptr<GFWaterContent> waterdgf;
mutable std::shared_ptr<GFSaturation> satdgf;
mutable std::shared_ptr<GFWaterFluxReconstruction> waterfrgf;
std::unique_ptr<Writer> vtkwriter;
std::unique_ptr<AdaptivityHandler> adaptivity;
......
......@@ -17,7 +17,7 @@ namespace Dorie{
\tparam LA The local assembler
*/
template<typename LA, typename VolumeFE, typename SkeletonFE>
template<typename LA, typename GFSVVolume, typename GFSVSkeleton>
class LocalRaviartThomasAssemblerEngine
: public Dune::PDELab::LocalAssemblerEngineBase
{
......@@ -35,24 +35,30 @@ public:
//! The type of the local operator
typedef typename LA::LocalOperator LOP;
//! The type of the residual vector
typedef typename LA::Traits::Residual Residual;
typedef typename Residual::ElementType ResidualElement;
//! The type of the prescription vector
typedef typename LA::Traits::Residual Prescription;
typedef typename Prescription::ElementType PrescriptionElement;
//! The type of the solution vector
typedef typename LA::Traits::Solution Solution;
typedef typename Solution::ElementType SolutionElement;
//! The type of the residual vector
using ResidualElement = SolutionElement;
//! The type of the mass matrix
typedef typename LA::Traits::Jacobian::ElementType MassMatrixElement;
//! The local function spaces
typedef typename LA::LFSU LFSU;
typedef typename LA::LFSUCache LFSUCache;
typedef typename LFSU::Traits::GridFunctionSpace GFSU;
typedef typename LA::LFSV LFSV;
typedef typename LA::LFSVCache LFSVCache;
typedef typename LFSV::Traits::GridFunctionSpace GFSV;
typedef typename LA::LFSV LFSW;
typedef typename LA::LFSVCache LFSWCache;
typedef typename LFSW::Traits::GridFunctionSpace GFSW;
typedef typename Solution::template ConstLocalView<LFSUCache> SolutionView;
typedef typename Residual::template LocalView<LFSVCache> ResidualView;
typedef typename Prescription::template ConstLocalView<LFSWCache> PrescriptionView;
typedef typename Solution::template LocalView<LFSUCache> SolutionView;
/**
\brief Constructor
......@@ -62,28 +68,34 @@ public:
*/
LocalRaviartThomasAssemblerEngine(
const LocalAssembler & local_assembler_,
const VolumeFE & volume_fe_,
const SkeletonFE & skeleton_fe_
const GFSVVolume & gfsv_volume_,
const GFSVSkeleton & gfsv_skeleton_
)
: local_assembler(local_assembler_),
pvolume_fe(stackobject_to_shared_ptr(volume_fe_)),
pskeleton_fe(stackobject_to_shared_ptr(skeleton_fe_)),
lop(local_assembler_.localOperator()),
rl_view(rl,1.0),
rn_view(rn,1.0)
rn_view(rn,1.0),
pgfsv_volume(stackobject_to_shared_ptr(gfsv_volume_)),
pgfsv_skeleton(stackobject_to_shared_ptr(gfsv_skeleton_)),
lfsv_volume(*pgfsv_volume),
lfsv_skeleton(*pgfsv_skeleton),
lfsv_skeleton_n(pgfsv_skeleton)
{}
LocalRaviartThomasAssemblerEngine(
const LocalAssembler & local_assembler_,
const std::shared_ptr<const VolumeFE> & volume_fe_,
const std::shared_ptr<const SkeletonFE> & skeleton_fe_
const std::shared_ptr<const GFSVVolume> & gfsv_volume_,
const std::shared_ptr<const GFSVSkeleton> & gfsv_skeleton_
)
: local_assembler(local_assembler_),
pvolume_fe(volume_fe_),
pskeleton_fe(skeleton_fe_),
lop(local_assembler_.localOperator()),
rl_view(rl,1.0),
rn_view(rn,1.0)
rn_view(rn,1.0),
lfsv_volume(*pgfsv_volume),
pgfsv_volume(gfsv_volume_),
pgfsv_skeleton(gfsv_skeleton_),
lfsv_skeleton(*pgfsv_skeleton),
lfsv_skeleton_n(pgfsv_skeleton)
{}
//! Query methods for the global grid assembler
......@@ -91,7 +103,7 @@ public:
bool requireSkeleton() const
{ return ( local_assembler.doAlphaSkeleton() || local_assembler.doLambdaSkeleton() ); }
bool requireSkeletonTwoSided() const
{ return local_assembler.doSkeletonTwoSided(); }
{ return true; }
bool requireUVVolume() const
{ return local_assembler.doAlphaVolume(); }
bool requireVVolume() const
......@@ -128,17 +140,17 @@ public:
return localAssembler().testConstraints();
}
//! Set current residual vector. Should be called prior to
//! Set current prescription vector. Should be called prior to
//! assembling.
void setResidual(Residual & residual_)
void setPrescription(const Prescription & prescription_)
{
global_rl_view.attach(residual_);
global_rn_view.attach(residual_);
global_pl_view.attach(prescription_);
global_pn_view.attach(prescription_);
}
//! Set current solution vector. Should be called prior to
//! assembling.
void setSolution(const Solution & solution_)
void setSolution(Solution & solution_)
{
global_sl_view.attach(solution_);
global_sn_view.attach(solution_);
......@@ -148,21 +160,32 @@ public:
//! global assembler.
//! @{
template<typename EG, typename LFSUC, typename LFSVC>
void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsw_cache)
{
// Check that local matrix will be conforming
assert(lfsu_cache.size() == lfsw_cache.size());
assert(lfsu_cache.size() == (lfsv_volume.size() + lfsv_skeleton.size() * eg.entity().subEntities(1)));
global_sl_view.bind(lfsu_cache);
xl.resize(lfsu_cache.size());
}
template<typename EG, typename LFSVC>
void onBindLFSV(const EG & eg, const LFSVC & lfsv_cache)
void onBindLFSV(const EG & eg, const LFSVC & lfsw_cache)
{
global_rl_view.bind(lfsv_cache);
rl.assign(lfsv_cache.size(),0.0);
global_pl_view.bind(lfsw_cache);
pl.assign(lfsw_cache.size(),0.0);
lfsv_volume.bind( eg.entity() );
lfsv_skeleton.bind( eg.entity() );
rl.assign(lfsv_volume.size(),0.0);
// TODO local matrix = 0
}
template<typename IG, typename LFSUC, typename LFSVC>
void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsw_cache)
{
global_sl_view.bind(lfsu_cache);
xl.resize(lfsu_cache.size());
......@@ -178,10 +201,10 @@ public:
}
template<typename IG, typename LFSVC>
void onBindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
void onBindLFSVInside(const IG & ig, const LFSVC & lfsw_cache)
{
global_rl_view.bind(lfsv_cache);
rl.assign(lfsv_cache.size(),0.0);
global_pl_view.bind(lfsw_cache);
rl.assign(lfsw_cache.size(),0.0);
}
template<typename IG, typename LFSVC>
......@@ -189,7 +212,7 @@ public:
const LFSVC & lfsv_s_cache,
const LFSVC & lfsv_n_cache)
{
global_rn_view.bind(lfsv_n_cache);
global_pn_view.bind(lfsv_n_cache);
rn.assign(lfsv_n_cache.size(),0.0);
}
......@@ -199,17 +222,19 @@ public:
//! discarded
//! @{
template<typename EG, typename LFSVC>
void onUnbindLFSV(const EG & eg, const LFSVC & lfsv_cache)
void onUnbindLFSV(const EG & eg, const LFSVC & lfsw_cache)
{
global_rl_view.add(rl);
global_rl_view.commit();
//FIXME
// global_pl_view.add(rl);
// global_pl_view.commit();
}
template<typename IG, typename LFSVC>
void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsw_cache)
{
global_rl_view.add(rl);
global_rl_view.commit();
//FIXME
// global_pl_view.add(rl);
// global_pl_view.commit();
}
template<typename IG, typename LFSVC>
......@@ -217,8 +242,9 @@ public:
const LFSVC & lfsv_s_cache,
const LFSVC & lfsv_n_cache)
{
global_rn_view.add(rn);
global_rn_view.commit();
//FIXME
// global_pn_view.add(rn);
// global_pn_view.commit();
}
//! @}
......@@ -227,7 +253,7 @@ public:
template<typename LFSUC>
void loadCoefficientsLFSUInside(const LFSUC & lfsu_s_cache)
{
global_sl_view.read(xl);
global_pl_view.read(pl);
}
template<typename LFSUC>
void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache)
......@@ -244,10 +270,11 @@ public:
//! Notifier functions, called immediately before and after assembling
//! @{
void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
void postAssembly(const GFSU& gfsu, const GFSW& gfsw)
{
if(local_assembler.doPostProcessing())
Dune::PDELab::constrain_residual(local_assembler.testConstraints(),global_rl_view.container());
// FIXME!
// if(local_assembler.doPostProcessing())
// Dune::PDELab::constrain_residual(local_assembler.testConstraints(),global_sl_view.container());
}
......@@ -269,19 +296,19 @@ public:
}