|
[Sponsors] |
differentiate between dimensionles and non-dimensionles fields |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 26, 2012, 08:46 |
differentiate between dimensionles and non-dimensionles fields
|
#1 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16 |
Hi guys,
I want to use the same template for dimensionless and non-dimensionless fields (an a MULES modification). For the beginning I have Code:
template<class RhoType> void .... ( const RhoType& rho ) So I want to do something like: Code:
const dimensionedScalar dimRho("dimRho", rho.dimensions(), 1.0); a*rho/dimRho Code:
a*rho How can I check if rho has a member 'dimensions'? Best regards, Illya |
|
April 26, 2012, 11:43 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21 |
Not sure I understand the problem.
Do you actually have two types defined? Or, are they both RhoTypes, one of which has dimensions defined, and the other does not? Instead of a*rho/dimRho, you could use a*rho.value().
__________________
~~~ Follow me on twitter @DavidGaden |
|
April 26, 2012, 13:06 |
|
#3 | ||
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16 |
Hi David,
Quote:
Quote:
This is a minimum requirement. But since it is a template, the formulation should be as universal as possible. It would be nice, if it would be valid also for other types of rho. Because it sounds too abstract, here is some code. Here is the equation to be solved (originates from MULESTemplates.C): Code:
fvScalarMatrix psiConvectionDiffusion ( fvm::ddt(rho, psi) + fv::gaussConvectionScheme<scalar>(mesh, phi, UDs).fvmDiv(phi, psi) - fvm::Sp(Sp, psi) - Su ); But before solving the equation, this coefficient is to be computed: Code:
tmp<surfaceScalarField> Cof = mesh.time().deltaT()*mesh.surfaceInterpolation::deltaCoeffs() *mag(phi)/mesh.magSf() So I have to somehow modify it, to have dimensions (0,0,0,0,0,0,0), no mater which type of rho do I have. Best regards, Illya |
|||
April 26, 2012, 13:20 |
|
#4 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21 |
I see, it's a template, and it changes behaviour depending on which type is used. You can accomplish this with template specialization. You can define different implementations of the same function given a specific template parameter. OpenFOAM does this routinely. For example, Field. Field defines the generic functions, scalarField redefines many of these functions for use specifically with scalars.
__________________
~~~ Follow me on twitter @DavidGaden |
|
April 27, 2012, 06:15 |
|
#5 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16 |
I know that templates can be specified, but I don't know how to do it in an elegant way. Copying the whole MULES::implicitSolve and than changing only one line in it doesn't seem to be a good approach. In this case I would have the same function twice with an only little difference in implementation.
|
|
April 27, 2012, 09:02 |
|
#6 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16 |
are you sure the is no possibility to check if rho has a member named "dimensions"? It would make everything much easier.
Best regards, Illya |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|