|
[Sponsors] |
June 28, 2020, 20:53 |
CodedSource controlled by a different region
|
#1 |
New Member
Alex
Join Date: May 2020
Posts: 2
Rep Power: 0 |
Hey all, ive been stuck at this problem for a while and am looking for your insight. I have a multi region conjugate heat transfer problem where I have a heater generating heat in its own region (Through scalar coded source / semi implicit source). I want to be able to turn the heater on/off based on the temperature read in a cell in a different region. (Thermostat controlling the heater)
The problem is it seems like I can only access the mesh inside the region the fvoptions file lives in for the coded source (The heater). Therefore I cant pull the temperature of a specific cell in a different region to use for my thermostat control. This is my coded source so far, its really just copied parts from other forum users so far. The thermostat if conditions aren't there yet, because I need to figure out how to get the conditional thermostat into the coded source first. Code:
test { type scalarCodedSource; active true; name sourceTime; scalarCodedSourceCoeffs { selectionMode all; fields (h); codeInclude #{ #}; codeCorrect #{ Pout<< "**codeCorrect**" << endl; #}; codeAddSup #{ scalar Tvol = 0; //const Time& time = mesh().time(); const volScalarField& Tm = mesh_.lookupObject<volScalarField>("T"); // Look up temperature //Tvol = Tm.weightedAverage(mesh_.V()).value(); //averageValue of the volScalarField //const fvMesh& help = Tm.mesh().time(); const vectorField& C = mesh_.C(); //List of cellcentres const scalarField& V = mesh_.V(); //const scalarField& num = mesh_.C().size(); scalarField& hSource = eqn.source(); //defining source forAll(C, i) { //hSource[i] = (Tvol - 310)*2400*V[i] ; hSource[i] = (Tm[2] - 310)*2400*V[i] ; } // Calling the mesh.C().size() method therefore yields the total size of the mesh. Pout << V << endl; Pout << "***codeAddSup***" << endl; #}; codeSetValue #{ Pout<< "**codeSetValue**" << endl; #}; // Dummy entry. Make dependent on above to trigger recompilation code #{ $codeInclude $codeCorrect $codeAddSup $codeSetValue #}; } sourceTimeCoeffs { $scalarCodedSourceCoeffs; } } I have a couple of ideas on how to fix my problem, though I'm not very familiar with c++ so its difficult to really read all the source code and understand what methods I have at my disposal.
Any input on how to solve my problem would be very appreciated, thanks. |
|
August 31, 2020, 23:02 |
I am also stuck with similar problem
|
#2 |
Senior Member
KGN
Join Date: Oct 2009
Location: Chennai, India
Posts: 121
Rep Power: 16 |
hi,
My problem is also similar to your.. I want to apply MFR at source point. To calculate MFR, pressure drop calculation has to be used, for this i need to get pressure at different locations and calculate MFR and then apply MFR at one of the location. in fvOptions i can specify only one point where MFR has to be specified. Did you able to found a way to do this? Last edited by mecbe2002; September 1, 2020 at 01:45. |
|
September 8, 2020, 14:27 |
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
From mesh_ you can access the time database, from there you have access to the various mesh regions.
|
|
September 8, 2020, 23:27 |
Let me explain my problem in detail.
|
#4 |
Senior Member
KGN
Join Date: Oct 2009
Location: Chennai, India
Posts: 121
Rep Power: 16 |
Objective of my work is to replace small diameter pipe (dia <0.5 mm) with source and sink terms i.e. inlet of the pipe will be sink and outlet of the pipe is source. I have to use pressure drop across the pipe to calculate the mass flow rate; for this i need to get pressure at inlet and exit of the pipe.
Code:
codeAddSup #{ const volScalarField& rhoJet = mesh_.lookupObject<volScalarField>("rho"); const volVectorField& velJet = mesh_.lookupObject<volVectorField>("v1"); scalarField& massSource1 = eqn.source(); const labelList& cellIDs = cells(); forAll(cellIDs, i) { label cellSource = cellIDs[i]; massSource1[cellSource] += rhoJet[cellSink]*mag(velJet[cellSink])*6.28319*1e-6; } #}; |
|
August 9, 2021, 07:34 |
|
#5 |
New Member
walter white
Join Date: Jul 2021
Posts: 10
Rep Power: 4 |
Did you guys find a solution.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error when solving p_rgh | bob94 | OpenFOAM | 0 | March 17, 2020 08:12 |
Problem simulating the temperature rise in a composite material (chtMultiRegionFoam) | Adam_K | OpenFOAM Running, Solving & CFD | 2 | March 27, 2019 06:51 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 18:57 |
[Commercial meshers] Using starToFoam | clo | OpenFOAM Meshing & Mesh Conversion | 33 | September 26, 2012 04:04 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 08:19 |