|
[Sponsors] |
How to exchange information within coded fvpatchfield between different fields |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 16, 2022, 05:25 |
How to exchange information within coded fvpatchfield between different fields
|
#1 |
New Member
Join Date: May 2020
Posts: 14
Rep Power: 6 |
Dear foamers,
I want to define a field within a volScalarField called psi and access it within another volVectorField named psiVector. I have followed the thread objectRegistry::lookupObject<scalar>. I defined an IOdictionary within createField.H, and tried to modify it within psi field. However, when I tried to access the IOdictionary object within psiVector, the IOdictionary I accessed from the registry was empty. In order to illustrate it more clearly, there are the codes and output. 1. Define an IOobject within createFields.H file. Code:
IOdictionary regedDictionary ( IOobject ( "regedDictionary", runTime.constant(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ) ); Code:
left { type codedFixedValue; name leftCodedVal; value uniform 0.2; code #{ const Time &runTime = this->db().time(); const fvMesh &mesh = this->patch().boundaryMesh().mesh(); Info << "time = " << runTime.value() << endl; IOdictionary ®edDict = mesh.lookupObjectRef<IOdictionary>("regedDictionary"); dictionary scalardict; scalardict.set("value",2 * runTime.value()); regedDict.set("scalardict",scalardict); dictionary vectordict; vectordict.set("value",3 * runTime.value()); regedDict.set("vectordict", vectordict); const IOdictionary &searchRegDict = this->db().lookupObject<IOdictionary>("regedDictionary"); Info << "IOdictionary regedDictionary from psi:" << endl << searchRegDict << endl; #}; } Code:
left { type codedFixedValue; value uniform (0.2 0.2 0.2); name leftVecCodedVal; code #{ const IOdictionary ®edDict = this->db().lookupObject<IOobject>("regedDictionary"); Info << "IOdictionary regedDictionary from psiVector: " << endl << regedDict << endl; #}; } Code:
IOdictionary regedDictionary from psi: { scalardict { value 4; } vectordict { value 6; } } IOdictionary regedDictionary from psiVector: { } |
|
May 16, 2022, 06:05 |
|
#2 |
New Member
Join Date: May 2020
Posts: 14
Rep Power: 6 |
The problem has been solved. Sorry for my foolish error. The error came from the definition of the IOdictionary within createFields.H. The definition should be like this:
Code:
IOdictionary regedDictionary ( IOobject ( "regedDictionary", runTime.constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ); So the value of dictionary could be updated within psiVector. By the way, is it possible to define a new variable or dictionary within psi that can be accessed within psiVector. So the modification of the original solver can be avoided. Do you have any ideals? I have tried the following: psi: Code:
left { type codedFixedValue; name leftCodedVal; value uniform 0.2; code #{ this->operator == (0.2); const Time &runTime = this->db().time(); const fvMesh &mesh = this->patch().boundaryMesh().mesh(); Info << "time = " << runTime.value() << endl; vectorIOField regVectorField ( IOobject ( "regVectorField", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), vectorField(this->size(),vector(0,0,0)) ); IOdictionary testDict ( IOobject ( "testDict", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ) ); Info << "db().name() = " << this->db().names() << endl; #}; } psiVector: Code:
left { type codedFixedValue; value uniform (0.2 0.2 0.2); name leftVecCodedVal; code #{ Info << "psiVector Fields " << endl << this->db().names() << endl; #}; } I got the following output: Code:
time = 2 db().name() = 18 ( solutionControl points neighbour psi faces psiVector fvSchemes fvOptions faceZones fvSolution owner data regedDictionary cellZones boundary regVectorField testDict pointZones ) psiVector Fields 16 ( solutionControl points neighbour psi faces psiVector fvSchemes fvOptions faceZones fvSolution owner data regedDictionary cellZones boundary pointZones ) Neither the IOdictionary testDict nor the vectorIOField regVectorField could be accessed from psiVectoer. Any suggestions would be appreciated. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Extracting ParaView Data into Python Arrays | Jeffzda | ParaView | 30 | November 6, 2023 21:00 |
ERROR #001100279 has occurred in subroutine ErrAction. | smnaryal | CFX | 11 | December 20, 2017 16:32 |
OpenFOAM 2D simulation - Freelancer Job- Information will be provided | sanjar | CFD Freelancers | 0 | March 7, 2017 09:45 |
libz.so.1: no version information available | dmaz | OpenFOAM Running, Solving & CFD | 3 | January 4, 2015 16:54 |
Terrible Mistake In Fluid Dynamics History | Abhi | Main CFD Forum | 12 | July 8, 2002 09:11 |