|
[Sponsors] |
February 17, 2020, 10:26 |
how to output the volVectorField correctly?
|
#1 |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
hi everyone!
i recently try to output a volVectorField CC_ in a turbulent moedel DCMM.C but when i complie .c programm, it show show the following error: HTML Code:
DCmM.C: In member function ‘virtual void Foam::incompressible::LESNonlinearModels::DCMM::correct(const Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>
>&)’:DCMM.C:291:6: error: expected primary-expression before ‘)’ token
);
HTML Code:
void DCMM::correct
(
const tmp<volTensorField>& gradU
)
{
LESNonlinearModel::correct(gradU);
updateSubGridScaleFields(gradU());
const volVectorField CC_=CC(gradU); // CC is a function of gradU, also is a volVectorField
CC_
(
IOobject
(
"CC_",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
); // expected primary-expression?? why??
}
i need help thanks |
|
February 17, 2020, 17:16 |
|
#2 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
You try to construct CC_ twice?
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
February 17, 2020, 20:50 |
|
#3 |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
hi HPE
thanks for your reply! how can i "construct" twice? i am a newer in openfoam, i can't understand what's your saying best wishes ziyang |
|
February 18, 2020, 03:21 |
|
#4 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
An object with the same name and the same type cannot be constructed more than once in its scope in C++. Pay attention to the two opers you did for CC_.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror |
|
February 19, 2020, 17:22 |
|
#5 | |
New Member
Akash Patel
Join Date: Dec 2018
Location: Champaign, IL, USA
Posts: 20
Rep Power: 8 |
Quote:
volVectorField CC_ ( IOobject ( "CC_", runTime_.timeName(), mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh_, dimensionedVector("0",dimLength/dimTime,Zero) ); This will create empty volVectorField defined on mesh with all fields as zero and dimension as m/s. If you need dimension less fields simply swap "dimLength/dimTime" by "dimless" Also it seems that you have already declared volVectorField CC_ in the line above which constructs an object named CC_. You cannot create another object with same name immediately below. |
||
February 25, 2020, 03:23 |
|
#6 |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
thanks for your reply! akashpatel95
i will try again best wishes ziyang |
|
February 25, 2020, 11:08 |
|
#7 | ||
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Quote:
Code:
myFunction(a,b, ) What you should do is something like, as akashpatel95 said: Quote:
Code:
//then, you fill it with the output of your function CC_=CC(gradU); //then you write it manually CC_.write(); // this write directly the fields, so most of the time at each time step => to use only in the debugging steps |
|||
February 27, 2020, 00:00 |
output the field every 0.001s
|
#8 |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
thanks for your reply! frobaux
it works well according to your guidance! but i want to output the CC_ fields based on ControlDict , for example, output CC_ every 0.001s i try to insert the code " if (runTime.writeTime())" ,but produce the error "error: ‘runTime’ was not declared in this scope if (runTime.outputTime())" i think i may be need insert the "creatTime.H" and "writeTime.H" how can i output the field every 0.001s? best wishes ziyang |
|
February 27, 2020, 00:33 |
|
#9 | |
New Member
Akash Patel
Join Date: Dec 2018
Location: Champaign, IL, USA
Posts: 20
Rep Power: 8 |
Quote:
Foam::Time runTime(Foam::Time::controlDictName, args); Then, you can use it like this (This will make sure that your CC_ field is only written when you want according to controlDict, in this case, every 0.001 seconds). if(runTime.write()) { CC_.write(); }
__________________
We are developing an open-source software for constructing reduced order models for your CFD simulations in OpenFOAM that runs several magnitude faster. Visit the link below to learn more. AccelerateCFD - OpenFOAM based reduced order model solver for CFD using Proper Orthogonal Decomposition. |
||
February 27, 2020, 05:56 |
|
#10 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Well, I'm not sure of that but
- if you used the IOobject::AUTO_WRITE options, it should work automatically according to the main parameters of your controlDict (writeControl and writeInterval) - you can also add a subdictionnary in your controlDict file Code:
functions { myOutputObject { type writeObjects; functionObjectLibs ( "libutilityFunctionObjects.so" ); objects ( "CC_" ); writeControl adjustableRunTime; writeInterval 0.001; } } But where is that part of code located/ called? |
|
February 27, 2020, 09:11 |
|
#11 | |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
Quote:
my code is in a new SGS turbulent model. The code i present to you is a part of DCNM .C programm (this new turbulent model) the code is as follows: Code:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void DCNM::correct ( const tmp<volTensorField>& gradU ) { { //int main(int argc, char *argv[]) // #include "setRootCase.H" // #include "createTime.H" volVectorField CC_ ( IOobject ( "CC_", runTime_.timeName(), mesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh_, dimensionedVector ("CC_",dimless,vector(0,0,0)) ); CC_=CC(gradU); // CC is a function of gradU, it has been calculated in private member function section Foam::Time runTime(Foam::Time::controlDictName, args); if(runTime.write()) { CC_.write(); } } LESNonlinearModel::correct(gradU); updateSubGridScaleFields(gradU()); } Code:
error: ‘args’ was not declared in this scope Foam::Time runTime(Foam::Time::controlDictName, args); and i also think akashpatel95's advice is right, but how can i solve the error ? do i need insert any code to my program? best wishes! ziyang |
||
February 27, 2020, 09:43 |
|
#12 |
Member
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 8 |
Hey, if this inside a turbulence model, you should be able to access the Time object with the following line (no need to create a new Time object, it is already present so lets use it):
Code:
const Time& t = this->time(); Code:
if(t.writeTime()) // or t.outputTime() { CC_.write(); } |
|
February 27, 2020, 12:34 |
|
#13 |
New Member
Akash Patel
Join Date: Dec 2018
Location: Champaign, IL, USA
Posts: 20
Rep Power: 8 |
If your code is inside a turbulence model, then you cannot create runTime object. The syntax I provided for runTime is for process happening inside main() function.
I think for source code, AUTO_WRITE should work just fine while declaring volVectorField
__________________
We are developing an open-source software for constructing reduced order models for your CFD simulations in OpenFOAM that runs several magnitude faster. Visit the link below to learn more. AccelerateCFD - OpenFOAM based reduced order model solver for CFD using Proper Orthogonal Decomposition. |
|
February 27, 2020, 13:34 |
|
#14 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Well, args is not defined in your scope.
Did you try to add what I suggest in your controlDict? Not sure because I'm also quite a beginer in openFoam, but you have acess to time trough db or mesh_, so maybe try Code:
if(db().time().write()) // or mesh_.time().write() { ... } |
|
March 10, 2020, 00:09 |
my view
|
#15 |
New Member
王子阳
Join Date: Aug 2019
Posts: 29
Rep Power: 7 |
hi! frobaux and akashpate95
very thanks for your reply, and i also very sorry the late reply according to your suggestions, i have solve my question, i want to share the solution here first, it shoulid note that i work in of2.3, my purpose is to output the volVectorField CC_ in turbulence model program (eg Smagorinsky.C) the first step, in priviate member faction, i insert the cord as followsin "updateSubGridScaleFields" part) CC_=CC(gradU); CC_.correctBoundaryConditions(); and i also define a volVectorField named CC in this part,and it will return the value to CC. the second part, in Constructors part, insert the CC_ write code.(the code is memtioned before) the last part,in Member faction part, insert the code " CC_=CC(gradU); " meanwhile, in .H programe , CC and CC_ should declare. ziyang best wishes! |
|
Tags |
ioobject |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Projected area to output parameters | Daniil85 | Fluent UDF and Scheme Programming | 1 | March 16, 2016 16:44 |
CGNS Output file parameters | ant0wn | SU2 | 1 | August 19, 2013 15:47 |
[ANSYS Meshing] ICEM output precision | papis | ANSYS Meshing & Geometry | 4 | July 9, 2013 10:54 |
[Other] Output Format of MetaMesh | t42 | OpenFOAM Meshing & Mesh Conversion | 0 | August 3, 2007 05:28 |
Output from the Monitor point command | swapnil | CFX | 0 | November 20, 2002 23:08 |