Plugins
Loading...
Searching...
No Matches
inout_bnd.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
3 * SPDX-License-Identifier: EUPL-1.2
4 * SPDX-FileContributor: Dmitry Logashenko
5 * SPDX-FileContributor: Goethe Universität Frankfurt
6 * SPDX-FileType: SOURCE
7 *
8 * This file is part of d3f++.
9 * d3f++ is an extension for UG4. Licensing information and citation requirements of UG4 are provided in LICENSES/UG4-LGPL_2.1
10 */
11
12
13/*
14 * Implementation of the outflow and inflow/outflow boundary conditions
15 */
16#ifndef __H__UG__PLUGINS__D3F__INOUT_BND__
17#define __H__UG__PLUGINS__D3F__INOUT_BND__
18
19#include <map>
20#include <vector>
21
22// ug4 headers
23#include "common/common.h"
24
25// library-specific headers
26#include "lib_grid/lg_base.h"
32#ifdef UG_FOR_LUA
34#endif
35
36// d3f headers
37#include "extravol.h"
38
39namespace ug {
40namespace d3f {
41
49template <typename TDomain, typename TAlgebra>
51 : public IDomainConstraint<TDomain, TAlgebra>
52{
54
55public:
58
60 typedef TDomain domain_type;
61
63 static const int dim = domain_type::dim;
64
66 typedef TAlgebra algebra_type;
67
69 typedef typename algebra_type::matrix_type matrix_type;
70
72 typedef typename algebra_type::vector_type vector_type;
73
74private:
77
79 typedef std::map<std::string, std::vector<std::string> > bc_data_map_type;
80
82 typedef std::map<std::string, number> fct_name_scaling_map_type;
83
84public:
85// Management
86
88 OutFlowBC () {};
89
92 (
94 )
95 {
96 m_spVolStabData = spVolStabData;
97 if (spVolStabData.valid ())
98 spVolStabData->activate_flux ();
99 }
100
102 void add
103 (
104 std::string ss_names,
105 std::string fct_names
106 );
107
109 void scale
110 (
111 std::string fct_names,
112 number scaling
113 );
114
115public:
116// The interface:
117
119 void adjust_jacobian
120 (
121 matrix_type & J,
122 const vector_type & u,
124 int type,
125 number time = 0.0,
127 const number s_a0 = 1.0
128 );
129
131 void adjust_defect
132 (
133 vector_type & d,
134 const vector_type & u,
136 int type,
137 number time = 0.0,
139 const std::vector<number> * vScaleMass = NULL,
140 const std::vector<number> * vScaleStiff = NULL
141 );
142
145 (
146 vector_type & u,
148 int type,
149 number time = 0.0
150 )
151 {}; // nothing to do for this boundary condition
152
155 (
156 matrix_type & A,
157 vector_type & b,
159 int type,
160 number time = 0.0
161 )
162 {
163 this_type::adjust_jacobian (A, b, dd, time); // the 2nd arg. is dummy: A does not depend on u
164 };
165
168 (
169 vector_type & b,
170 const vector_type & u,
172 int type,
173 number time = 0.0
174 )
175 {}; // nothing to do for this boundary condition
176
178 int type () const {return CT_DIRICHLET;}
179
180private:
183 (
184 const FunctionPattern * fct_pattern,
185 std::vector<number> & v_scaling
186 ) const;
187
188private:
189
192
195
198};
199
212template <typename TDomain, typename TAlgebra>
214 : public IDomainConstraint<TDomain, TAlgebra>
215{
217
218public:
221
223 typedef TDomain domain_type;
224
226 static const int dim = domain_type::dim;
227
229 typedef TAlgebra algebra_type;
230
232 typedef typename algebra_type::matrix_type matrix_type;
233
235 typedef typename algebra_type::vector_type vector_type;
236
237private:
240
247
249 typedef std::map<std::string, std::map<std::string, t_inDirichlet> > bc_data_map_type;
250
252 typedef std::map<std::string, number> fct_name_scaling_map_type;
253
255 void add_spec
256 (
257 std::string ss_names,
258 std::string fct_names,
259 number val,
261 );
262
263public:
264// Management
265
268
271 (
273 )
274 {
275 m_spVolStabData = spVolStabData;
276 if (spVolStabData.valid ())
277 {
278 spVolStabData->activate_flux ();
279 spVolStabData->activate_flags ();
280 }
281 }
282
284 void add
285 (
286 std::string ss_names,
287 std::string fct_names,
288 number value
289 )
290 {
291 add_spec (ss_names, fct_names, value, SPNULL);
292 }
293
295 void add
296 (
297 std::string ss_names,
298 std::string fct_names,
300 )
301 {
302 add_spec (ss_names, fct_names, 0 /* dummy value */, func);
303 }
304
305 #ifdef UG_FOR_LUA
306 void add
307 (
308 std::string ss_names,
309 std::string fct_names,
310 const char* fctName
311 )
312 {
313 add(ss_names, fct_names, LuaUserDataFactory<number,dim>::create(fctName));
314 }
315
316 void add
317 (
318 std::string ss_names,
319 std::string fct_names,
321 )
322 {
323 add(ss_names, fct_names, make_sp(new LuaUserData<number,dim>(fct)));
324 }
325 #endif
326
328 void scale
329 (
330 std::string fct_names,
331 number scaling
332 );
333
334public:
335// The interface:
336
338 void adjust_jacobian
339 (
340 matrix_type & J,
341 const vector_type & u,
343 int type,
344 number time = 0.0,
345 ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = SPNULL,
346 const number s_a0 = 1.0
347 );
348
350 void adjust_defect
351 (
352 vector_type & d,
353 const vector_type & u,
355 int type,
356 number time = 0.0,
357 ConstSmartPtr<VectorTimeSeries<vector_type> > vSol = SPNULL,
358 const std::vector<number> * vScaleMass = NULL,
359 const std::vector<number> * vScaleStiff = NULL
360 );
361
363 void adjust_solution
364 (
365 vector_type & u,
367 int type,
368 number time = 0.0
369 );
370
373 (
374 matrix_type & A,
375 vector_type & b,
377 int type,
378 number time = 0.0
379 )
380 {
381 this_type::adjust_jacobian (A, b, dd, time); // the 2nd arg. is dummy: A does not depend on u
383 };
384
387 (
388 vector_type & b,
389 const vector_type & u,
391 int type,
392 number time = 0.0
393 )
394 {
396 };
397
399 int type () const {return CT_DIRICHLET;}
400
401private:
404 (
405 const FunctionPattern * fct_pattern,
406 std::vector<number> & v_scaling
407 ) const;
408
409private:
410
413
416
419};
420
421} // namespace d3f
422} // end namespace ug
423
424#include "inout_bnd_impl.h"
425
426#endif // __H__UG__PLUGINS__D3F__INOUT_BND__
427
428/* End of File */
429
ConstSmartPtr< DoFDistribution > dd(const GridLevel &gl) const
Definition extravol.h:27
Definition inout_bnd.h:215
std::map< std::string, number > fct_name_scaling_map_type
scaling specification map (for the names of the functions)
Definition inout_bnd.h:252
fct_name_scaling_map_type m_mFtoM
specification of the scaling for the equations
Definition inout_bnd.h:418
void adjust_jacobian(matrix_type &J, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const number s_a0=1.0)
sets a unity row at the inflow vertices and apply the volume stabilization otherwise
Definition inout_bnd_impl.h:312
void set_volume_stabilization(SmartPtr< FlowVolStabData< domain_type > > spVolStabData)
sets the volume stabilization object
Definition inout_bnd.h:271
TAlgebra algebra_type
type of algebra
Definition inout_bnd.h:229
void names_to_ids_in_scaling(const FunctionPattern *fct_pattern, std::vector< number > &v_scaling) const
transform the scaling specification from the names to the id's
Definition inout_bnd_impl.h:283
void add(std::string ss_names, std::string fct_names, number value)
adds a combination of subsets, functions and a constant value to the condition
Definition inout_bnd.h:285
void adjust_rhs(vector_type &b, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
sets the dirichlet value in the right-hand side
Definition inout_bnd.h:387
void adjust_linear(matrix_type &A, vector_type &b, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
sets unity rows in A and dirichlet values in right-hand side b
Definition inout_bnd.h:373
IDomainConstraint< TDomain, TAlgebra > base_type
base type
Definition inout_bnd.h:220
static const int dim
world dimension
Definition inout_bnd.h:226
DoFDistribution::traits< Vertex >::const_iterator t_vert_iterator
iterator over vertices
Definition inout_bnd.h:239
InOutFlowBC< TDomain, TAlgebra > this_type
Definition inout_bnd.h:216
TDomain domain_type
type of domain
Definition inout_bnd.h:223
void adjust_defect(vector_type &d, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
sets a zero value in the defect at the inflow vertices and apply the volume stabilization otherwise
Definition inout_bnd_impl.h:394
int type() const
returns the type of the constraints
Definition inout_bnd.h:399
bc_data_map_type m_mStoF
specification of the boundary faces and the corresponding functions
Definition inout_bnd.h:415
void adjust_solution(vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
sets the dirichlet value in the solution at the inflow vertices
Definition inout_bnd_impl.h:477
void add_spec(std::string ss_names, std::string fct_names, number val, SmartPtr< UserData< number, dim > > func)
adds a boundary condition data specification
Definition inout_bnd_impl.h:236
void add(std::string ss_names, std::string fct_names, SmartPtr< UserData< number, dim > > func)
adds a combination of subsets, functions and user data to the condition
Definition inout_bnd.h:296
void scale(std::string fct_names, number scaling)
sets scaling for a given functions
Definition inout_bnd_impl.h:267
algebra_type::vector_type vector_type
type of algebra vector
Definition inout_bnd.h:235
InOutFlowBC()
class constructor
Definition inout_bnd.h:267
algebra_type::matrix_type matrix_type
type of algebra matrix
Definition inout_bnd.h:232
std::map< std::string, std::map< std::string, t_inDirichlet > > bc_data_map_type
specification map
Definition inout_bnd.h:249
SmartPtr< FlowVolStabData< domain_type > > m_spVolStabData
accumulated defect of the flow equation
Definition inout_bnd.h:412
Definition inout_bnd.h:52
OutFlowBC< TDomain, TAlgebra > this_type
Definition inout_bnd.h:53
std::map< std::string, std::vector< std::string > > bc_data_map_type
boundary specification map
Definition inout_bnd.h:79
IDomainConstraint< TDomain, TAlgebra > base_type
base type
Definition inout_bnd.h:57
std::map< std::string, number > fct_name_scaling_map_type
scaling specification map (for the names of the functions)
Definition inout_bnd.h:82
void names_to_ids_in_scaling(const FunctionPattern *fct_pattern, std::vector< number > &v_scaling) const
transform the scaling specification from the names to the id's
Definition inout_bnd_impl.h:68
static const int dim
world dimension
Definition inout_bnd.h:63
SmartPtr< FlowVolStabData< domain_type > > m_spVolStabData
accumulated defect of the flow equation
Definition inout_bnd.h:191
void scale(std::string fct_names, number scaling)
sets scaling for a given functions
Definition inout_bnd_impl.h:52
void adjust_jacobian(matrix_type &J, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const number s_a0=1.0)
apply the volume stabilization to the Jacobian
Definition inout_bnd_impl.h:97
algebra_type::matrix_type matrix_type
type of algebra matrix
Definition inout_bnd.h:69
TDomain domain_type
type of domain
Definition inout_bnd.h:60
algebra_type::vector_type vector_type
type of algebra vector
Definition inout_bnd.h:72
DoFDistribution::traits< Vertex >::const_iterator t_vert_iterator
iterator over vertices
Definition inout_bnd.h:76
void adjust_solution(vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
correct the values of the solution
Definition inout_bnd.h:145
fct_name_scaling_map_type m_mFtoM
specification of the scaling for the equations
Definition inout_bnd.h:197
TAlgebra algebra_type
type of algebra
Definition inout_bnd.h:66
void adjust_linear(matrix_type &A, vector_type &b, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
apply the volume stabilization to the matrix A
Definition inout_bnd.h:155
void adjust_defect(vector_type &d, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0, ConstSmartPtr< VectorTimeSeries< vector_type > > vSol=SPNULL, const std::vector< number > *vScaleMass=NULL, const std::vector< number > *vScaleStiff=NULL)
apply the volume stabilization to the defect
Definition inout_bnd_impl.h:164
void add(std::string ss_names, std::string fct_names)
adds a combination of subsets and functions to the condition
Definition inout_bnd_impl.h:27
int type() const
returns the type of the constraints
Definition inout_bnd.h:178
OutFlowBC()
class constructor
Definition inout_bnd.h:88
void adjust_rhs(vector_type &b, const vector_type &u, ConstSmartPtr< DoFDistribution > dd, int type, number time=0.0)
sets the dirichlet value in the right-hand side
Definition inout_bnd.h:168
bc_data_map_type m_mStoF
specification of the boundary faces and the corresponding functions
Definition inout_bnd.h:194
void set_volume_stabilization(SmartPtr< FlowVolStabData< domain_type > > spVolStabData)
sets the volume stabilization object
Definition inout_bnd.h:92
const NullSmartPtr SPNULL
double number
CT_DIRICHLET
SmartPtr< T, FreePolicy > make_sp(T *inst)
auxiliary class for the Dirichlet values
Definition inout_bnd.h:243
number val
constant value (if specified)
Definition inout_bnd.h:244
SmartPtr< UserData< number, dim > > func
value as a function (if not SPNULL)
Definition inout_bnd.h:245