OpenLB 1.7
Loading...
Searching...
No Matches
superLatticeRefinementMetricF2D.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_2D_HH
25#define SUPER_LATTICE_REFINEMENT_METRIC_F_2D_HH
26
29
30
31namespace olb {
32
33
34template<typename T, typename DESCRIPTOR>
37 : SuperLatticeF2D<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
49
50
51template<typename T, typename DESCRIPTOR>
54 const UnitConverter<T, DESCRIPTOR>& converter)
55 : SuperLatticeF2D<T, DESCRIPTOR>(lattice, 1)
56{
57 this->getName() = "refinementMetricKnudsen";
58
59 for (int iC = 0; iC < lattice.getLoadBalancer().size(); ++iC) {
60 this->_blockF.emplace_back(
62 lattice.getBlock(iC), converter)
63 );
64 }
65}
66
67template<typename T, typename DESCRIPTOR>
69{
70 auto& load = this->_sLattice.getLoadBalancer();
71
72 if (load.isLocal(glob)) {
73 const int loc = load.loc(glob);
74
75 return this->getBlockF(loc)(output);
76 }
77 else {
78 return false;
79 }
80}
81
82
83
84template<typename T, typename DESCRIPTOR>
86{
87 const int nC = this->_sLattice.getCuboidGeometry().getNc();
88
89 std::vector<T> factors(nC, T{});
90 T output[1] = { };
91
92 auto& load = this->_sLattice.getLoadBalancer();
93
94 for (int iC = 0; iC < load.size(); ++iC) {
95 this->getBlockF(iC)(output, iC);
96
97 factors[load.glob(iC)] = output[0];
98 }
99
100 OstreamManager clout(std::cout, "refinement");
101
102 for (int i = 0; i < nC; ++i) {
103#ifdef PARALLEL_MODE_MPI
104 singleton::mpi().sendToMaster(&factors[i], 1, load.isLocal(i));
105#endif
106
107 clout << "factors[" << i << "]: " << factors[i] << std::endl;
108 }
109}
110
111
112}
113
114#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< BlockF2D< T > > > _blockF
Super functors may consist of several BlockF2D<W> derived functors.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLatticeKnudsen2D(SuperLattice< T, DESCRIPTOR > &lattice)
SuperLatticeRefinementMetricKnudsen2D(SuperLattice< T, DESCRIPTOR > &lattice, const UnitConverter< T, DESCRIPTOR > &converter)
Constructor.
void print()
Convenience method for printing per-block refinement factors.
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.