Syncing.cpp 4.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2017-2019 Dominik Thoennes, Nils Kohl.
 *
 * This file is part of HyTeG
 * (see https://i10git.cs.fau.de/hyteg/hyteg).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
Dominik Thoennes's avatar
Dominik Thoennes committed
20
21
#include "Syncing.hpp"

22
#include "hyteg/functions/Function.hpp"
Dominik Thoennes's avatar
Dominik Thoennes committed
23
#include "hyteg/p1functionspace/VertexDoFFunction.hpp"
24
#include "hyteg/p2functionspace/P2Function.hpp"
Dominik Thoennes's avatar
Dominik Thoennes committed
25
#include "hyteg/primitives/all.hpp"
Dominik Thoennes's avatar
Dominik Thoennes committed
26

27
namespace hyteg {
Dominik Thoennes's avatar
Dominik Thoennes committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace communication {

using walberla::uint_t;

template < typename funcType >
void syncFunctionBetweenPrimitives( const funcType& function, const uint_t& level )
{
   function.template communicate< Vertex, Edge >( level );
   function.template communicate< Edge, Face >( level );
   function.template communicate< Face, Cell >( level );

   function.template communicate< Cell, Face >( level );
   function.template communicate< Face, Edge >( level );
   function.template communicate< Edge, Vertex >( level );
}

template < typename ValueType >
void syncP2FunctionBetweenPrimitives( const P2Function< ValueType >& function, const uint_t& level )
{
47
48
   syncFunctionBetweenPrimitives< hyteg::vertexdof::VertexDoFFunction< ValueType > >( function.getVertexDoFFunction(), level );
   syncFunctionBetweenPrimitives< hyteg::EdgeDoFFunction< ValueType > >( function.getEdgeDoFFunction(), level );
Dominik Thoennes's avatar
Dominik Thoennes committed
49
50
}

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Version for VectorFunctions
template < typename vType >
void syncVectorFunctionBetweenPrimitives( const P1VectorFunction< vType >& vecFunc, const uint_t& level )
{
   for ( uint_t idx = 0; idx < vecFunc.getDimension(); ++idx )
   {
      syncFunctionBetweenPrimitives( vecFunc[idx], level );
   }
}

template < typename vType >
void syncVectorFunctionBetweenPrimitives( const P2VectorFunction< vType >& vecFunc, const uint_t& level )
{
   for ( uint_t idx = 0; idx < vecFunc.getDimension(); ++idx )
   {
      syncP2FunctionBetweenPrimitives( vecFunc[idx], level );
   }
}

Dominik Thoennes's avatar
Dominik Thoennes committed
70
template void syncP2FunctionBetweenPrimitives( const P2Function< double >& function, const uint_t& level );
71
72
template void syncP2FunctionBetweenPrimitives( const P2Function< int32_t >& function, const uint_t& level );
template void syncP2FunctionBetweenPrimitives( const P2Function< int64_t >& function, const uint_t& level );
Dominik Thoennes's avatar
Dominik Thoennes committed
73

74
template void syncFunctionBetweenPrimitives( const vertexdof::VertexDoFFunction< double >& function, const uint_t& level );
75
76
template void syncFunctionBetweenPrimitives( const vertexdof::VertexDoFFunction< int32_t >& function, const uint_t& level );
template void syncFunctionBetweenPrimitives( const vertexdof::VertexDoFFunction< int64_t >& function, const uint_t& level );
77
78

template void syncFunctionBetweenPrimitives( const EdgeDoFFunction< double >& function, const uint_t& level );
79
80
template void syncFunctionBetweenPrimitives( const EdgeDoFFunction< int32_t >& function, const uint_t& level );
template void syncFunctionBetweenPrimitives( const EdgeDoFFunction< int64_t >& function, const uint_t& level );
Dominik Thoennes's avatar
Dominik Thoennes committed
81

82
template void syncFunctionBetweenPrimitives( const P2Function< double >& function, const uint_t& level );
83
84
template void syncFunctionBetweenPrimitives( const P2Function< int32_t >& function, const uint_t& level );
template void syncFunctionBetweenPrimitives( const P2Function< int64_t >& function, const uint_t& level );
85

86
87
88
template void syncVectorFunctionBetweenPrimitives( const P1VectorFunction< double >& function, const uint_t& level );
template void syncVectorFunctionBetweenPrimitives( const P1VectorFunction< int32_t >& function, const uint_t& level );
template void syncVectorFunctionBetweenPrimitives( const P1VectorFunction< int64_t >& function, const uint_t& level );
89

90
91
92
template void syncVectorFunctionBetweenPrimitives( const P2VectorFunction< double >& function, const uint_t& level );
template void syncVectorFunctionBetweenPrimitives( const P2VectorFunction< int32_t >& function, const uint_t& level );
template void syncVectorFunctionBetweenPrimitives( const P2VectorFunction< int64_t >& function, const uint_t& level );
Dominik Thoennes's avatar
Dominik Thoennes committed
93
94

} // namespace communication
95
} // namespace hyteg