OpenLB 1.7
Loading...
Searching...
No Matches
superLatticeRefinementMetricF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2018 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SUPER_LATTICE_REFINEMENT_METRIC_F_3D_HH
25#define SUPER_LATTICE_REFINEMENT_METRIC_F_3D_HH
26
29
30
31namespace olb {
32
33
34template<typename T, typename DESCRIPTOR>
37 : SuperLatticeF3D<T, DESCRIPTOR>(lattice, 1)
38{
39 this->getName() = "knudsen";
40
41 for (int iC = 0; iC < lattice.getLoadBalancer().size(); ++iC) {
42 this->_blockF.emplace_back(
44 );
45 }
46}
47
48
49template<typename T, typename DESCRIPTOR>
52 const UnitConverter<T, DESCRIPTOR>& converter)
53 : SuperLatticeF3D<T, DESCRIPTOR>(lattice, 1)
54{
55 this->getName() = "refinementMetricKnudsen";
56
57 for (int iC = 0; iC < lattice.getLoadBalancer().size(); ++iC) {
58 this->_blockF.emplace_back(
60 lattice.getBlock(iC), converter)
61 );
62 }
63}
64
65template<typename T, typename DESCRIPTOR>
67{
68 auto& load = this->_sLattice.getLoadBalancer();
69
70 if (load.isLocal(glob)) {
71 const int loc = load.loc(glob);
72
73 return static_cast<BlockLatticeRefinementMetricKnudsen3D<T,DESCRIPTOR>&>(this->getBlockF(loc))(output);
74 }
75 else {
76 return false;
77 }
78}
79
80template<typename T, typename DESCRIPTOR>
82{
83 const int nC = this->_sLattice.getCuboidGeometry().getNc();
84
85 std::vector<T> factors(nC, T{});
86 T output[1] = { };
87
88 auto& load = this->_sLattice.getLoadBalancer();
89
90 for (int iC = 0; iC < load.size(); ++iC) {
91 this->getBlockF(iC)(output, iC);
92
93 factors[load.glob(iC)] = output[0];
94 }
95
96 OstreamManager clout(std::cout, "refinement");
97
98 for (int i = 0; i < nC; ++i) {
99#ifdef PARALLEL_MODE_MPI
100 singleton::mpi().sendToMaster(&factors[i], 1, load.isLocal(i));
101#endif
102
103 clout << "factors[" << i << "]: " << factors[i] << std::endl;
104 }
105}
106
107
108template<typename T, typename DESCRIPTOR>
111 : SuperLatticeF3D<T, DESCRIPTOR>(lattice, 1)
112{
113 this->getName() = "high_order_knudsen";
114
115 for (int iC = 0; iC < lattice.getLoadBalancer().size(); ++iC) {
116 this->_blockF.emplace_back(
118 );
119 }
120}
121
122
123}
124
125#endif
std::string & getName()
read and write access to name
Definition genericF.hh:51
class for marking output with some text
std::vector< std::unique_ptr< BlockF3D< T > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLatticeHighOrderKnudsen3D(SuperLattice< T, DESCRIPTOR > &lattice)
SuperLatticeKnudsen3D(SuperLattice< T, DESCRIPTOR > &lattice)
void print()
Convenience method for printing per-block refinement factors.
SuperLatticeRefinementMetricKnudsen3D(SuperLattice< T, DESCRIPTOR > &lattice, const UnitConverter< T, DESCRIPTOR > &converter)
Constructor.
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Conversion between physical and lattice units, as well as discretization.
void sendToMaster(T *sendBuf, int sendCount, bool iAmRoot, MPI_Comm comm=MPI_COMM_WORLD)
Sends data to master processor.
MpiManager & mpi()
Top level namespace for all of OpenLB.