summaryrefslogtreecommitdiff
path: root/src/dynamics/descriptorBase.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-06-24 14:43:36 +0200
committerAdrian Kummerlaender2019-06-24 14:43:36 +0200
commit94d3e79a8617f88dc0219cfdeedfa3147833719d (patch)
treec1a6894679563e271f5c6ea7a17fa3462f7212a3 /src/dynamics/descriptorBase.h
downloadgrid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar.gz
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar.bz2
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar.lz
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar.xz
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.tar.zst
grid_refinement_openlb-94d3e79a8617f88dc0219cfdeedfa3147833719d.zip
Initialize at openlb-1-3
Diffstat (limited to 'src/dynamics/descriptorBase.h')
-rw-r--r--src/dynamics/descriptorBase.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/dynamics/descriptorBase.h b/src/dynamics/descriptorBase.h
new file mode 100644
index 0000000..962156d
--- /dev/null
+++ b/src/dynamics/descriptorBase.h
@@ -0,0 +1,110 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2019 Adrian Kummerlaender
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ * <http://www.openlb.net/>
+ *
+ * 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 2
+ * 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, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DESCRIPTOR_BASE_H
+#define DESCRIPTOR_BASE_H
+
+#include "descriptorTag.h"
+#include "descriptorField.h"
+
+namespace olb {
+
+namespace descriptors {
+
+/// \defgroup descriptor
+//@{
+
+/// Base descriptor of a D-dimensional lattice with Q directions and a list of additional fields
+template <unsigned D, unsigned Q, typename... FIELDS>
+struct DESCRIPTOR_BASE {
+
+ /// Deleted constructor to enforce pure usage as type and prevent implicit narrowing conversions
+ DESCRIPTOR_BASE() = delete;
+
+ /// Tag that describes the category of the descriptor
+ /**
+ * e.g. tag::RTLBM for RTLBM descriptors or tag::DEFAULT if no category tag-field is found.
+ *
+ * This is needed to enable tag-dispatching of descriptor function overloads.
+ **/
+ using category_tag = tag::field_with_base<tag::CATEGORY, tag::DEFAULT, FIELDS...>;
+
+ /// Number of dimensions
+ static constexpr int d = D;
+ /// Number of velocities
+ static constexpr int q = Q;
+
+ /// Returns index of WANTED_FIELD
+ /**
+ * Fails compilation if WANTED_FIELD is not contained in FIELDS.
+ * Branching that depends on this information can be realized using `provides`.
+ **/
+ template <typename WANTED_FIELD>
+ static constexpr int index(const unsigned localIndex=0)
+ {
+ return getIndexFromFieldList<D,Q,WANTED_FIELD,FIELDS...>()
+ + WANTED_FIELD::template getLocalIndex<D,Q>(localIndex);
+ }
+
+ /// Returns size of FIELD
+ /**
+ * Works for all fields, even if they are not provided by this instantiation of DESCRIPTOR_BASE.
+ **/
+ template <
+ typename FIELD = void,
+ utilities::meta::enable_if_t<!std::is_same<FIELD,void>::value, int> = 0
+ >
+ static constexpr int size()
+ {
+ return FIELD::template size<D,Q>();
+ }
+
+ /// Returns total size of descriptor
+ /**
+ * This implements DESCRIPTOR_BASE::size()
+ **/
+ template <
+ typename FIELD = void,
+ utilities::meta::enable_if_t<std::is_same<FIELD,void>::value, int> = 0
+ >
+ static constexpr int size()
+ {
+ return getFieldListSize<D,Q,FIELDS...>();
+ }
+
+ /// Returns whether WANTED_FIELD is contained in FIELDS
+ template <typename WANTED_FIELD>
+ static constexpr bool provides()
+ {
+ return utilities::meta::list_contains_item<WANTED_FIELD,FIELDS...>::type::value;
+ }
+
+};
+
+//@}
+
+}
+
+}
+
+#endif