Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
truncated_monotone_transfer_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3 * Author: Raphael Prohl
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__TRUNCATED_MONOTONE_MG__TRUNCATED_MONOTONE_TRANSFER_IMPL_H_
34#define __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__TRUNCATED_MONOTONE_MG__TRUNCATED_MONOTONE_TRANSFER_IMPL_H_
35
37
38namespace ug{
39
40template <typename TDomain, typename TAlgebra>
41void
43set_levels(GridLevel coarseLevel, GridLevel fineLevel)
44{
45 m_bInit = false;
46 m_fineLevel = fineLevel;
47 m_coarseLevel = coarseLevel;
48
49 if(m_fineLevel.level () - m_coarseLevel.level () != 1)
50 UG_THROW("TruncatedMonotoneTransfer: Can only project between successive level.");
51}
52
53template <typename TDomain, typename TAlgebra>
54void
56init()
57{
58
59 // Done:
60 m_bInit = true;
61}
62
63template <typename TDomain, typename TAlgebra>
66prolongation(const GridLevel& fineGL, const GridLevel& coarseGL,
68{
69 SmartPtr<matrix_type> stdP = base_type::prolongation(fineGL, coarseGL, spApproxSpace);
70
71 return stdP;
72}
73
74template <typename TDomain, typename TAlgebra>
77restriction(const GridLevel& coarseGL, const GridLevel& fineGL,
79{
80 SmartPtr<matrix_type> stdR = base_type::restriction(coarseGL, fineGL, spApproxSpace);
81
82 //TODO: modify stdR for activeDofs! IConstraint::adjust_restriction?
83 // or only for the special case IObstacleConstraint?
84 // (only for the "finest grid to (finest-1) grid-transfer; then: canonical)
85
86 int topLev = spApproxSpace->num_levels() - 1;
87 if(topLev == fineGL.level())
88 {
89 UG_LOG("on topLevel: " <<topLev<<"\n");
90
91 ConstSmartPtr<DoFDistribution> spCoarseDD = spApproxSpace->dof_distribution(coarseGL);
92 ConstSmartPtr<DoFDistribution> spFineDD = spApproxSpace->dof_distribution(fineGL);
93
94 #ifdef UG_PARALLEL
95 stdR->set_storage_type(PST_CONSISTENT);
96 #endif
97
98 // adjust using constraints
99 for(size_t i = 0; i < m_vConstraint.size(); ++i)
100 if(m_vConstraint[i]->type() == CT_CONSTRAINTS)
101 {
102 UG_LOG("is CT_CONSTRAINT")
103 m_vConstraint[i]->adjust_restriction(*stdR, spCoarseDD, spFineDD, CT_CONSTRAINTS);
104 }
105 }
106
107 //TODO: restrict the obstacle-value in a monotone way! (in every level-transfer)
108 return stdR;
109}
110
111template <typename TDomain, typename TAlgebra>
114clone()
115{
117 for(size_t i = 0; i < m_vConstraint.size (); ++i)
118 op->add_constraint (m_vConstraint[i]);
119
120 //TODO: should anything else be done for cloning?!
121 return op;
122}
123
124} // end namespace ug
125
126#endif /* __H__UG__LIB_DISC__OPERATOR__NON_LINEAR_OPERATOR__TRUNCATED_MONOTONE_MG__TRUNCATED_MONOTONE_TRANSFER_IMPL_H_ */
Definition smart_pointer.h:296
Definition smart_pointer.h:108
base class for approximation spaces without type of algebra or dof distribution
Definition approximation_space.h:279
Definition grid_level.h:42
int level() const
returns the level
Definition grid_level.h:74
Definition truncated_monotone_transfer.h:43
SmartPtr< ITransferOperator< TDomain, TAlgebra > > clone()
Clone.
Definition truncated_monotone_transfer_impl.h:114
void init()
initialize the operator
Definition truncated_monotone_transfer_impl.h:56
SmartPtr< matrix_type > restriction(const GridLevel &coarseGL, const GridLevel &fineGL, ConstSmartPtr< ApproximationSpace< TDomain > > spApproxSpace)
returns restriction as a matrix
Definition truncated_monotone_transfer_impl.h:77
SmartPtr< matrix_type > prolongation(const GridLevel &fineGL, const GridLevel &coarseGL, ConstSmartPtr< ApproximationSpace< TDomain > > spApproxSpace)
returns prolongation as a matrix
Definition truncated_monotone_transfer_impl.h:66
void set_levels(GridLevel coarseLevel, GridLevel fineLevel)
Set Levels for Prolongation coarse -> fine.
Definition truncated_monotone_transfer_impl.h:43
@ PST_CONSISTENT
Definition parallel_storage_type.h:68
#define UG_THROW(msg)
Definition error.h:57
#define UG_LOG(msg)
Definition log.h:367
the ug namespace
@ CT_CONSTRAINTS
Definition ass_tuner.h:58