The Wayback Machine - http://web-wp.archive.org/web/20230308211248/https://www.researchgate.net/post/Is_it_possible_to_extract_the_value_of_a_variable_from_a_template
Is it possible to extract the value of a variable from a template?
Dear all;
I am trying to simulate non-Newtonian fluid flow in porous media with the help of Palabos software. Palabos is a C+++ open-source library that solves flow problems with the lattice Boltzmann method. I am not familiar with object-oriented programming and I want to extract a value from a template that is used in every iteration. To be more precise; I want to print Omega (which is an (Nx-1)*(Ny-1) dimensional matrix) in every 250 iterations in the form of gif or data to validate my result. I added pcout to print variable in this function and it works but it is repeated every iteration which generates too much data ( imagine 200*200 lattice and 10000 iterations!).
I will be really glad if you could help me through this. the code is provided below. also, I uploaded
.h and .hh file to this message
Many thanks;
Elahe;
template<typename T, template<typename U> class Descriptor,int N>
T CarreauDynamics<T,Descriptor,N>::
getOmegaFromPiAndRhoBar(Array<T,SymmetricTensor<T,Descriptor>::n> const& PiNeq, T rhoBar) const
{
T nu0_nuInfoverCs2 = (global::CarreauParameters().getNu0()-global::CarreauParameters().getNuInf())*Descriptor<T>::invCs2;
T nuInfoverCs2 = global::CarreauParameters().getNuInf()*Descriptor<T>::invCs2;
T nMinusOneOverTwo = (global::CarreauParameters().getExponent() - (T)1)/(T)2;
T lambdaOverCs2sqr = global::CarreauParameters().getLambda()*Descriptor<T>::invCs2;
lambdaOverCs2sqr *= lambdaOverCs2sqr;
T piNeqNormSqr = SymmetricTensor<T,Descriptor>::tensorNormSqr(PiNeq);
I searched among some examples and I figured out that an output image for omega could be easily generated by adding these few lines to the writeGifs function in the CPP file.
I have asked some questions in the Palabos forum but unfortunately, my questions do not gain any views and replies.
I checked cavity3d.cpp examples and I think there was a mistake in the name of the file. This image belongs to vorticity, not omega. If you could take a look at line 111 it says:
I also added the mentioned lines to my code with constant omega and the result is attached to this answer. I think it shows vorticity because it has higher values in corners.
I searched among some examples and I figured out that an output image for omega could be easily generated by adding these few lines to the writeGifs function in the CPP file.
Until recently, fluid mechanics was largely outside of the expertise of materials engineers or metallurgists. However, with the major advances in computational hardware and software, fluid flow tools are becoming broadly accessible to the metallurgical/materials community.
In the interdisciplinary field of data-driven models and computational fluid mechanics, the reduced-order model for flow field prediction is mainly constructed by a convolutional neural network (CNN) in recent years. However, the standard CNN is only applicable to data with Euclidean spatial structure, while data with non-Euclidean properties can o...
The similarity between fluid mechanism and electromagnetics leads to the similarity between the governing equations of steady fluid flow, electrostatic field and static magnetic field, and there are some similar rules in numerical calculation. All these equations are expressed in terms of convection, diffusion and source, and the numerical method i...