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/stochasticSGSdynamics.hh | 293 ++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 src/dynamics/stochasticSGSdynamics.hh (limited to 'src/dynamics/stochasticSGSdynamics.hh') diff --git a/src/dynamics/stochasticSGSdynamics.hh b/src/dynamics/stochasticSGSdynamics.hh new file mode 100644 index 0000000..b61958f --- /dev/null +++ b/src/dynamics/stochasticSGSdynamics.hh @@ -0,0 +1,293 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2013 Mathias J. Krause, Jonas Latt + * 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 + * MRT Dynamics with adjusted omega -- generic implementation. + */ +#ifndef STOCHASTIC_SGS_DYNAMICS_HH +#define STOCHASTIC_SGS_DYNAMICS_HH + +#include +#include +#include "stochasticSGSdynamics.h" +#include "mrtDynamics.h" +#include "mrtHelpers.h" +#include "core/cell.h" +#include "core/util.h" +#include "math.h" + +#include +#include +#include +#include + + +using namespace std; +namespace olb { + +/// Implementation of the Stochastic relaxation based on +/// " A stochastic subgrid model with application to turbulent flow and scalar mixing"; Phys. of Fluids 19; 2007 + +////////////////////// Class StochasticsSGSdynamics ////////////////////////// + +/** \param vs2_ speed of sound + * \param momenta_ a Momenta object to know how to compute velocity momenta + * \param momenta_ a Momenta object to know how to compute velocity momenta + */ + + + +template +StochasticSGSdynamics::StochasticSGSdynamics ( + T omega_, Momenta& momenta_, T turbulenceInt_, T charU_, T smagoConst_, T dx_, T dt_) + : MRTdynamics(omega_, momenta_), + turbulenceInt(turbulenceInt_), + smagoConst(smagoConst_), + charU(charU_), + preFactor(computePreFactor(omega_,smagoConst_) ) + +{ + + // T invM_S_SGS[DESCRIPTOR::q][DESCRIPTOR::q]; + // T rtSGS[DESCRIPTOR::q]; // relaxation times vector for SGS approach. + // for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) + // { + // rtSGS[iPop] = DESCRIPTOR::S[iPop]; + // } + // for (int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop) + // { + // rtSGS[DESCRIPTOR::shearViscIndexes[iPop]] = omega; + // } + // for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) + // { + // for (int jPop = 0; jPop < DESCRIPTOR::q; ++jPop) + // { + // invM_S_SGS[iPop][jPop] = T(); + // for (int kPop = 0; kPop < DESCRIPTOR::q; ++kPop) + // { + // if (kPop == jPop) + // { + // invM_S_SGS[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop] * + // rtSGS[kPop]; + // cout << "wert"<_momenta.computeAllMomenta(cell, rho, u, pi); + T newOmega = computeOmega(this->getOmega(), preFactor, rho, pi, X_lang_n); + + + T invM_S_SGS[DESCRIPTOR::q][DESCRIPTOR::q]; + T rtSGS[DESCRIPTOR::q]; // relaxation times vector for SGS approach. + for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) { + rtSGS[iPop] = DESCRIPTOR::S[iPop]; + } + for (int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop) { + rtSGS[DESCRIPTOR::shearViscIndexes[iPop]] = newOmega; + } + for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) { + for (int jPop = 0; jPop < DESCRIPTOR::q; ++jPop) { + invM_S_SGS[iPop][jPop] = T(); + for (int kPop = 0; kPop < DESCRIPTOR::q; ++kPop) { + if (kPop == jPop) { + invM_S_SGS[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop] * + rtSGS[kPop]; + //cout << "wert"<