Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
set(pluginName ConvectionDiffusion)
set(SOURCES convection_diffusion_base.cpp
fv1/convection_diffusion_fv1.cpp
bnd/outflow_base.cpp
fv1/bnd/outflow_fv1.cpp
fe/convection_diffusion_fe.cpp
fe/convection_diffusion_stab_fe.cpp
fvcr/convection_diffusion_fvcr.cpp
Expand Down Expand Up @@ -98,4 +100,4 @@ if(USE_PYBIND11)
# CPack
set_target_properties(pyconvectiondiffusion PROPERTIES INSTALL_RPATH "$ORIGIN/..:$ORIGIN/../../../lib")
install(TARGETS pyconvectiondiffusion LIBRARY DESTINATION ug4py COMPONENT pymodules)
endif(USE_PYBIND11)
endif(USE_PYBIND11)
136 changes: 136 additions & 0 deletions bnd/outflow_base.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2012-2013: G-CSC, Goethe University Frankfurt
* Authors: Daniel Gonzalez
* Based on the modules by Dmitry Logashenko, Andreas Vogel
*
* This file is part of UG4.
*
* UG4 is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License version 3 (as published by the
* Free Software Foundation) with the following additional attribution
* requirements (according to LGPL/GPL v3 §7):
*
* (1) The following notice must be displayed in the Appropriate Legal Notices
* of covered and combined works: "Based on UG4 (www.ug4.org/license)".
*
* (2) The following notice must be displayed at a prominent place in the
* terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
*
* (3) The following bibliography is recommended for citation and must be
* preserved in all covered files:
* "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
* parallel geometric multigrid solver on hierarchically distributed grids.
* Computing and visualization in science 16, 4 (2013), 151-164"
* "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
* flexible software system for simulating pde based models on high performance
* computers. Computing and visualization in science 16, 4 (2013), 165-179"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/


#include "outflow_base.h"

#include "common/util/provider.h"
#include "lib_disc/spatial_disc/disc_util/fv1_geom.h"

namespace ug{
namespace ConvectionDiffusionPlugin{

/**
* converts the subset names where the BC is imposed to the corresponding subset
* indices (i.e. m_vScheduledBndSubSets -> m_vBndSubSetIndex):
*/
template<typename TDomain>
void ConvectionDiffusionOutflowBase<TDomain>::extract_scheduled_data()
{
// clear all extracted data
m_vBndSubSetIndex.clear();

// loop all scheduled subsets
for(size_t i = 0; i < m_vScheduledBndSubSets.size(); ++i)
{
// create Subset Group
SubsetGroup subsetGroup;

// convert strings
try{
subsetGroup = this->approx_space()->subset_grp_by_name(m_vScheduledBndSubSets[i].c_str());
}UG_CATCH_THROW("'OutflowBase:extract_scheduled_data':"
" Subsets '" <<m_vScheduledBndSubSets[i].c_str() <<"' not"
" all contained in ApproximationSpace.");

// get subsethandler
const ISubsetHandler& rSH = *this->function_pattern()->subset_handler();

// loop subsets
for(size_t si = 0; si < subsetGroup.size(); ++si)
{
// get subset index
const int subsetIndex = subsetGroup[si];

// check that subsetIndex is valid
if(subsetIndex < 0 || subsetIndex >= rSH.num_subsets())
{
UG_LOG("ERROR in 'OutflowBase:extract_scheduled_data':"
" Invalid subset Index " << subsetIndex <<
". (Valid is 0, .. , " << rSH.num_subsets() <<").\n");
return;
}

// save the index
m_vBndSubSetIndex.push_back(subsetIndex);
}
}
}

/**
* The add method for the boundary subsets:
*/
template<typename TDomain>
void ConvectionDiffusionOutflowBase<TDomain>::add
(
const char* subsets // string with the ','-separated names of the subsets
)
{
m_vScheduledBndSubSets.push_back(subsets);
}

////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////

template<typename TDomain>
ConvectionDiffusionOutflowBase<TDomain>::
ConvectionDiffusionOutflowBase(SmartPtr< ConvectionDiffusionBase<TDomain> > spMaster)
: IElemDisc<TDomain>(spMaster->symb_fcts(), spMaster->symb_subsets()),
m_spMaster (spMaster)
{
// check number of functions
if(this->num_fct() != 1)
UG_THROW("Wrong number of functions: The ElemDisc 'ConvectionDiffusion'"
" needs exactly "<<1<<" symbolic function.");

// yet no boundary subsets
m_vBndSubSetIndex.clear ();
}

////////////////////////////////////////////////////////////////////////////////
// explicit template instantiations
////////////////////////////////////////////////////////////////////////////////

#ifdef UG_DIM_1
template class ConvectionDiffusionOutflowBase<Domain1d>;
#endif
#ifdef UG_DIM_2
template class ConvectionDiffusionOutflowBase<Domain2d>;
#endif
#ifdef UG_DIM_3
template class ConvectionDiffusionOutflowBase<Domain3d>;
#endif

} // namespace ConvectionDiffusionPlugin
} // namespace ug
115 changes: 115 additions & 0 deletions bnd/outflow_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright (c) 2012-2013: G-CSC, Goethe University Frankfurt
* Authors: Daniel Gonzalez
* Based on the modules by Dmitry Logashenko, Andreas Vogel
*
* This file is part of UG4.
*
* UG4 is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License version 3 (as published by the
* Free Software Foundation) with the following additional attribution
* requirements (according to LGPL/GPL v3 §7):
*
* (1) The following notice must be displayed in the Appropriate Legal Notices
* of covered and combined works: "Based on UG4 (www.ug4.org/license)".
*
* (2) The following notice must be displayed at a prominent place in the
* terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
*
* (3) The following bibliography is recommended for citation and must be
* preserved in all covered files:
* "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
* parallel geometric multigrid solver on hierarchically distributed grids.
* Computing and visualization in science 16, 4 (2013), 151-164"
* "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
* flexible software system for simulating pde based models on high performance
* computers. Computing and visualization in science 16, 4 (2013), 165-179"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/

#ifndef __H__UG__PLUGINS__CONVECTION_DIFFUSION__CONVECTION_DIFFUSION_FV1__BND__OUTFLOW_BASE__
#define __H__UG__PLUGINS__CONVECTION_DIFFUSION__CONVECTION_DIFFUSION_FV1__BND__OUTFLOW_BASE__
// other ug4 modules
#include "common/common.h"
#include "lib_grid/lg_base.h"

// library intern headers
#include "lib_disc/spatial_disc/elem_disc/elem_disc_interface.h"
#include "lib_disc/spatial_disc/user_data/data_export.h"
#include "lib_disc/spatial_disc/user_data/data_import.h"

#include "../convection_diffusion_base.h"

namespace ug{
namespace ConvectionDiffusionPlugin{


/// \ingroup lib_disc_elem_disc
/// @{

/// The zero-stress (neutral) outflow boundary condition for the incompressible NS equation
/**
* This class implements the so-called neutral boundary condition for outflow
* boundaries. Note that this class can be used only with the stabilized
* vertex-centered discretization of the Navier-Stokes equations.
*
* This boundary condition imposes two equations on the unknown functions
* at the outflow boundary \f$ F \f$:
* <ul>
* <li> \f$ \int_F p ds = 0 \f$, and
* <li> \f$ \sigma \vec{n} \cdot \vec{n} = 0 \f$ on \f$ F \f$.
* </ul>
* where \f$ \vec{n} \f$ is the outer normal at \f$ F \f$ and
* \f$ \sigma = \mu (\nabla \vec{u} + (\nabla \vec{u})^T) \f$ the stress tensor.
*/
template< typename TDomain>
class ConvectionDiffusionOutflowBase
: public IElemDisc<TDomain>
{
protected:
/// Base class type
typedef IElemDisc<TDomain> base_type;

/// own type
typedef ConvectionDiffusionOutflowBase<TDomain> this_type;

public:
/// World dimension
static const int dim = base_type::dim;

public:
/// Constructor (setting default values)
ConvectionDiffusionOutflowBase(SmartPtr< ConvectionDiffusionBase<TDomain> > spMaster);

/// adds a boundary segment
void add(const char* subsets);

protected:
/// sets the kinematic viscosity
virtual void set_velocity(SmartPtr<CplUserData<MathVector<dim>, dim> > data) = 0;

public:
/// returns if local time series is needed
virtual bool requests_local_time_series() {return true;}

protected:
/// The master discretization:
SmartPtr< ConvectionDiffusionBase<TDomain> > m_spMaster;

/// The boundary subsets:
std::vector<std::string> m_vScheduledBndSubSets; // names
std::vector<int> m_vBndSubSetIndex; // indices

void extract_scheduled_data(); // convert m_vScheduledBndSubSets -> m_vBndSubSetIndex
};

/// @}

} // namespace NavierStokes
} // end namespace ug

#endif /*_H__UG__PLUGINS__CONVECTION_DIFFUSION__CONVECTION_DIFFUSION_FV1__BND__OUTFLOW_BASE__*/
2 changes: 2 additions & 0 deletions convection_diffusion_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class ConvectionDiffusionBase
void set_velocity(LuaFunctionHandle fct);
#endif
/// \}
/// /// returns velocity
virtual SmartPtr<CplUserData<MathVector<dim>, dim> > velocity() = 0;

/// sets the flux
/**
Expand Down
21 changes: 21 additions & 0 deletions convection_diffusion_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "convection_diffusion_base.h"
#include "convection_diffusion_sss.h"
#include "fv1/convection_diffusion_fv1.h"
#include "fv1/bnd/outflow_fv1.h"
#include "fe/convection_diffusion_fe.h"
#include "fe/convection_diffusion_stab_fe.h"
#include "fvcr/convection_diffusion_fvcr.h"
Expand Down Expand Up @@ -193,6 +194,26 @@ static void Domain(TRegistry& reg, string grp)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "ConvectionDiffusionFV1", tag);
}

// Convection Diffusion FV1 Outflow boundary condition base
{
typedef ConvectionDiffusionOutflowBase<TDomain> T;
typedef IElemDisc<TDomain> TBase;
string name = string("ConvectionDiffusionOutflowBase").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.add_method("add", &T::add, "", "Subset(s)");
reg.add_class_to_group(name, "ConvectionDiffusionOutflowBase", tag);
}
// Convection Diffusion FV1 Outflow boundary condition
{
typedef ConvectionDiffusionOutflowFV1<TDomain> T;
typedef ConvectionDiffusionOutflowBase<TDomain> TBase;
string name = string("ConvectionDiffusionOutflowFV1").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr< ConvectionDiffusionBase<TDomain> >)>("MasterDisc")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "ConvectionDiffusionOutflowFV1", tag);
}

// Convection Diffusion FE
{
Expand Down
4 changes: 3 additions & 1 deletion fe/convection_diffusion_fe.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class ConvectionDiffusionFE : public ConvectionDiffusionBase<TDomain>

/// sets the quad order
void set_quad_order(size_t order);


/// returns velocity
SmartPtr<CplUserData<MathVector<dim>, dim> > velocity() {return m_imVelocity.user_data ();}
private:
/// prepares the loop over all elements
/**
Expand Down
3 changes: 3 additions & 0 deletions fractfv1/convection_diffusion_fractfv1.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class ConvectionDiffusionFractFV1 : public ConvectionDiffusionBase<TDomain>
}
#endif

/// returns velocity
SmartPtr<CplUserData<MathVector<dim>, dim> > velocity() {return m_imVelocity.user_data ();}

void set_ortho_velocity(SmartPtr<CplUserData<number, dim> > user)
{
m_imOrthoVelocity.set_data(user);
Expand Down
2 changes: 2 additions & 0 deletions fv/convection_diffusion_fv.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class ConvectionDiffusionFV : public ConvectionDiffusionBase<TDomain>

/// sets the quad order
void set_quad_order(size_t order);
/// returns velocity
SmartPtr<CplUserData<MathVector<dim>, dim> > velocity() {return m_imVelocity.user_data ();}

protected:
/// current shape function set
Expand Down
Loading