CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

write fields in openfoam database in boundary patch

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By medmast

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 2, 2016, 09:46
Default write fields in openfoam database in boundary patch
  #1
New Member
 
Join Date: Mar 2016
Location: Germany
Posts: 8
Rep Power: 10
medmast is on a distinguished road
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";


         }
Here I have error that Pressure field constant it, and when I try to define it as volScalarField, I can't define it with objectRegistry.
has anyone the idea, how i can change internal fields U,P and T within a boundary patch?
Thank you
iman
atulkjoy likes this.
medmast is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 10:05.