|
[Sponsors] |
write fields in openfoam database in boundary patch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 2, 2016, 09:46 |
write fields in openfoam database in boundary patch
|
#1 |
New Member
Join Date: Mar 2016
Location: Germany
Posts: 8
Rep Power: 10 |
Hi all,
I am trying to implement a new boundary condition that reads Internal fields U, P, and temperature from external solver and write these fields from OpenFOAM in a file for external solver. to this end, i use the "externalCoupledMixedFvPatchField" boundary patch and i edit it. i try the following code to write data in OpenFOAM fields: Code:
const volScalarField& Pressure= this->db().objectRegistry::lookupObject<volScalarField>("p"); const volVectorField& Velocity= this->db().objectRegistry::lookupObject<volVectorField>("U"); const volScalarField& Temperature= this->db().objectRegistry::lookupObject<volScalarField>("T"); forAll(this->patch(), facei) { // define mesh on patch const fvMesh& mesh = this->patch().boundaryMesh().mesh(); // cell related to current face label celli =this->patch().faceCells()[facei]; // define opposite face to patch face// label oppfacei =mesh.cells()[celli].opposingFaceLabel (facei+this->patch().patch().start(),mesh.faces()); // define neighbour cell centre cellCentreN vector cellCentreN = mesh.cellCentres()[mesh.owner()[oppfacei]]; // define patch cell centre cellCentre0 vector cellCentreO = mesh.cellCentres()[mesh.neighbour()[oppfacei]]; // cell lable of cell label CellP =mesh.findCell(cellCentreO); Pressure.internalField()[CellP] = "new value"; } has anyone the idea, how i can change internal fields U,P and T within a boundary patch? Thank you iman |
|
February 14, 2017, 15:07 |
|
#2 |
Senior Member
|
||
February 14, 2017, 15:21 |
|
#3 | |
New Member
Join Date: Mar 2016
Location: Germany
Posts: 8
Rep Power: 10 |
Quote:
|
||
February 14, 2017, 15:25 |
|
#4 |
Senior Member
|
Well, now my question is what error happens if you add const_cast to your lookups and use ref instead of internalField to set value? And, please, this time post compiler output.
|
|
February 14, 2017, 15:30 |
|
#5 | |
New Member
Join Date: Mar 2016
Location: Germany
Posts: 8
Rep Power: 10 |
Quote:
i'll post it at freiday, i don't have them right now. thank you very much |
||
February 14, 2017, 15:33 |
|
#6 |
Senior Member
|
Yes, internalField is read-only, ref is not (also you can use const_cast on internalField if you REALLY want).
|
|
February 14, 2017, 15:38 |
|
#7 | |
New Member
Join Date: Mar 2016
Location: Germany
Posts: 8
Rep Power: 10 |
Quote:
how i understood, i must define internal fields as "const_cast " , then they are not read-only anymore? and could you please a little explain about "ref"? |
||
February 14, 2017, 15:53 |
|
#8 |
Senior Member
|
You CAN not that you MUST. Post #2 contains a link to ref documentation, not quite get what additional explanations do you need.
You use const_cast to remove const from field references you look up using objectRegistry, then you use ref method to access writable lists for modification of the fields. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 07:38 |
Wind turbine simulation | Saturn | CFX | 58 | July 3, 2020 01:13 |
an odd(at least for me!) reconstructPar error on a field | immortality | OpenFOAM Running, Solving & CFD | 3 | June 3, 2013 22:36 |
[blockMesh] Cyclic BC's: Possible face ordering problem? (Channel flow) | sega | OpenFOAM Meshing & Mesh Conversion | 3 | September 28, 2010 12:46 |
RPM in Wind Turbine | Pankaj | CFX | 9 | November 23, 2009 04:05 |