|
[Sponsors] | |||||
|
|
|
#1 |
|
Senior Member
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 749
Rep Power: 12 ![]() |
I'm extending the foamCalc tool to calculate a volume integral of a given field. The code in the foamCalcFunctions library is templated to deal with the various field types (scalar, vector, ...). My problem is that when I define a templated variable to store the result of the computations, I'm not sure how I can initialize the variable nicely to be zero (again scalar(0), vector(0,0,0), ...). My current solution is just to misuse a value from the field and subtract it again, but of course that's not very elegant. Can anyone help me with a nicer solution?
Code:
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (header.headerClassName() == fieldType::typeName)
{
Info<< " Reading " << header.name() << endl;
fieldType field(header, mesh);
//Initialization
dimensioned<Type> volInt ("volInt", field[0]);
volInt -= field[0];
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. *Check out the scientific computing exchange http://scicomp.stackexchange.com |
|
|
|
|
|
|
|
|
#2 | |
|
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,119
Rep Power: 30 ![]() ![]() |
Quote:
|
||
|
|
|
||
|
|
|
#3 |
|
Senior Member
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 749
Rep Power: 12 ![]() |
Thanks a lot!
If anyone wants to use the code as well, I pushed it to http://code.google.com/p/foamcalcex/
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. *Check out the scientific computing exchange http://scicomp.stackexchange.com |
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 10:14 |
| Initializing reference variable of type objectRegistry | deji | OpenFOAM | 8 | August 6, 2010 13:50 |
| error in COMSOL:'ERROR:6164 Duplicate Variable' | bhushas | Main CFD Forum | 1 | May 30, 2008 04:35 |
| Env variable not set | gruber2 | OpenFOAM Installation | 5 | December 30, 2005 04:27 |
| Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 20:09 |