From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 24 Jun 2019 14:43:36 +0200 Subject: Initialize at openlb-1-3 --- src/dynamics/advectionDiffusionMomenta.hh | 159 ++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 src/dynamics/advectionDiffusionMomenta.hh (limited to 'src/dynamics/advectionDiffusionMomenta.hh') diff --git a/src/dynamics/advectionDiffusionMomenta.hh b/src/dynamics/advectionDiffusionMomenta.hh new file mode 100644 index 0000000..319a87f --- /dev/null +++ b/src/dynamics/advectionDiffusionMomenta.hh @@ -0,0 +1,159 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * 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. +*/ + +/** \file + * A collection of dynamics classes (e.g. BGK) with which a Cell object + * can be instantiated -- generic implementation. + */ +#ifndef ADVECTION_DIFFUSION_MOMENTA_HH +#define ADVECTION_DIFFUSION_MOMENTA_HH + +#include "advectionDiffusionMomenta.h" +#include "lbHelpers.h" + +namespace olb { + +////////////////////// Class AdvectionDiffusionBulkMomenta ////////////////////////// + +template +T AdvectionDiffusionBulkMomenta::computeRho(Cell const& cell) const +{ + return lbHelpers::computeRho(cell); +} + +template +void AdvectionDiffusionBulkMomenta::computeU(Cell const& cell, T u[DESCRIPTOR::d]) const +{ + const T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u[iD] = u_[iD]; + } +} + +template +void AdvectionDiffusionBulkMomenta::computeJ(Cell const& cell, T j[DESCRIPTOR::d]) const +{ + lbHelpers::computeJ(cell, j); +} + +template +void AdvectionDiffusionBulkMomenta::computeStress ( + Cell const& cell, + T rho, const T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const +{ +} + +template +void AdvectionDiffusionBulkMomenta::computeRhoU ( + Cell const& cell, + T& rho, T u[DESCRIPTOR::d] ) const +{ + rho = cell.computeRho(); + const T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u[iD] = u_[iD]; + } +} + +template +void AdvectionDiffusionBulkMomenta::computeAllMomenta ( + Cell const& cell, + T& rho, T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const +{ + rho = cell.computeRho(); + const T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u[iD] = u_[iD]; + } +} + +template +void AdvectionDiffusionBulkMomenta::defineRho(Cell& cell, T rho) +{ + T *u = cell.template getFieldPointer(); + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + cell[iPop] = lbHelpers::equilibriumFirstOrder( iPop, rho, u ); + } +} + +template +void AdvectionDiffusionBulkMomenta::defineU ( + Cell& cell, + const T u[DESCRIPTOR::d]) +{ + T rho = cell.computeRho(); + T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u_[iD] = u[iD]; + } + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + cell[iPop] = lbHelpers::equilibriumFirstOrder( iPop, rho, u ); + } +} + +template +void AdvectionDiffusionBulkMomenta::defineRhoU ( + Cell& cell, + T rho, const T u[DESCRIPTOR::d]) +{ + T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u_[iD] = u[iD]; + } + for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) { + cell[iPop] = lbHelpers::equilibriumFirstOrder( iPop, rho, u ); + } +} + +template +void AdvectionDiffusionBulkMomenta::defineAllMomenta ( + Cell& cell, + T rho, const T u[DESCRIPTOR::d], + const T pi[util::TensorVal::n] ) +{ + T *u_ = cell.template getFieldPointer(); + for (int iD = 0; iD < DESCRIPTOR::d; ++iD) { + u_[iD] = u[iD]; + } + for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) { + cell[iPop] = lbHelpers::equilibriumFirstOrder( iPop, rho, u ); + } +} + +/////////////// Singletons ////////////////////////////////// + +namespace instances { + +template +AdvectionDiffusionBulkMomenta& getAdvectionDiffusionBulkMomenta() +{ + static AdvectionDiffusionBulkMomenta bulkMomentaSingleton; + return bulkMomentaSingleton; +} +} + +} + +#endif -- cgit v1.2.3