Skip to content

Commit 3d0abd3

Browse files
author
Arne Naegel
committed
Option to provide UserData objects for singular sources
1 parent 1eafd7d commit 3d0abd3

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

convection_diffusion_plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ static void Dimension(Registry& reg, string grp)
259259
reg.add_class_<TPointSSS>(point_name, grp)
260260
.template add_constructor<void (*) (const std::vector<number>&)> ()
261261
.add_method ("set", static_cast<void (TPointSSS::*) (number)> (&TPointSSS::set))
262+
.add_method ("set", static_cast<void (TPointSSS::*) (typename TPointSSS::user_data_type)> (&TPointSSS::set))
263+
#ifdef UG_FOR_LUA
262264
.add_method ("set", static_cast<void (TPointSSS::*) (LuaFunctionHandle)> (&TPointSSS::set))
265+
#endif
263266
.set_construct_as_smart_pointer(true);
264267
reg.add_class_to_group(point_name, "CDPointSourcesSink", dimTag);
265268

convection_diffusion_sss.h

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,24 @@ namespace ConvectionDiffusionPlugin {
5353
template <int dim>
5454
class cd_sss_data
5555
{
56+
public:
57+
typedef SmartPtr<CplUserData<number, dim> > user_data_type;
5658
/** the data for the source/sink:
5759
* [0]: total contaminant flux through the point
5860
*/
59-
MathVector<1> m_values;
61+
protected:
62+
//MathVector<1> m_values;
63+
number m_values;
6064

61-
SmartPtr<UserData<MathVector<1>, dim> > m_spData; ///< an alternative method to specify the data
65+
user_data_type m_spData; ///< an alternative method to specify the data
6266

6367
public:
6468

6569
/// class construction (there must exist a 'dummy' constructor!)
66-
cd_sss_data () {m_values [0] = 0;}
70+
cd_sss_data () {m_values = 0;}
6771

6872
/// returns the flux
69-
number flux () {return m_values [0];}
73+
number flux () {return m_values ;}
7074

7175
/// computes the data from the user data object
7276
void compute
@@ -83,21 +87,22 @@ class cd_sss_data
8387
/// sets the data
8488
void set (number flux)
8589
{
86-
m_values[0] = flux;
90+
m_values = flux;
8791
m_spData = SPNULL;
8892
}
8993

9094
/// sets the data by an object
91-
void set (SmartPtr<UserData<MathVector<1>, dim> > spData)
95+
void set (user_data_type spData)
9296
{
9397
m_spData = spData;
9498
}
95-
99+
100+
#ifdef UG_FOR_LUA
96101
/// set as a LUA function
97102
void set (LuaFunctionHandle func)
98-
{
99-
m_spData = make_sp (new LuaUserData<MathVector<1>, dim> (func));
100-
}
103+
{ m_spData = make_sp (new LuaUserData<number, dim> (func)); }
104+
#endif
105+
101106
};
102107

103108
/** Class for markers of the point sources and sinks
@@ -186,7 +191,10 @@ template <int dim> class cd_line_sss_data : public cd_sss_data<dim>, public line
186191
template <int dim>
187192
class CDSingularSourcesAndSinks
188193
: public FVSingularSourcesAndSinks<dim, cd_point_sss_data<dim>, cd_line_sss_data<dim> >
189-
{};
194+
{
195+
public:
196+
typedef cd_point_sss_data<dim> user_data_type;
197+
};
190198

191199
} // namespace ConvectionDiffusionPlugin
192200
} // end namespace ug

0 commit comments

Comments
 (0)