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

decomposePar for custom solvers and boundary conditions

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 31, 2015, 01:56
Default decomposePar for custom solvers and boundary conditions
  #1
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 96
Rep Power: 9
cfdopenfoam is on a distinguished road
dear foamers,

I am grateful that you are interested in parallel computing and the decomposePar utility. I now encounter 2 problems when parallelizing mySlover:

(1) the custom boundary conditions. In the 0 or latestTime directory, one of the patch is as follows (before decomposePar):
Code:
myPatchName
{
    type    myBC;  // does decomposePar know myBC after its compilation?
    phi      phi;
    rho      rho;
    volumeFlux 100;
    value   nonuniform List<vector> 2((0.6 -0.7 0) (0.1 -0.2 0));
}
after decomposePar, in processor0 directory it becomes:
Code:
myPatchName
{
    type    myBC;  
    phi      phi;
    rho      rho;
    volumeFlux 0; // myPatch is indeed in the computational domain of processor0. why becomes 0???
    value   nonuniform List<vector> 2((0.6 -0.7 0) (0.1 -0.2 0));
}
in other processor* directories that do not contain this patch, give:
Code:
{
    type    myBC;  
    phi      phi;
    rho      rho;
    volumeFlux 0; // myPatch is not in this computational domain
    value   nonuniform 0(); // myPatch is not in this computational domain
}
after some time steps, in processor0 directory it gives:
Code:
myPatchName
{
    type    myBC;  
    phi      phi;
    rho      rho;
    volumeFlux 99.5; // this is normal
    value   nonuniform List<vector> 2((0.4 -0.5 0) (0.4 -0.5 0));
}
however after reconstuctPar, in the corresponding time folder gives:
Code:
myPatchName
{
    type    myBC;  
    phi      phi;
    rho      rho;
    volumeFlux 0;  // why 0??? shouldn't it be 99.5???
    value   nonuniform List<vector> 2((0.4 -0.5 0) (0.4 -0.5 0)); // this is normal
}
why the decomposePar and reconstructPar could not give right volumeFlux values? or i do something wrong? the current results mean that I must check the volumeFlux and the value in different directories. Is this normal or I've missed something?

(2) as you may have known, the above is for the 2D case. while mySolver is the one that coupling 1D and 2D computation. So should I only make the 2D computing parallelizable or both the 1D and 2D? and if possible, how could i make the implementation?

I am very appreciated if someone understands my problem and kindly gives some hints. and also, feel free to remedy my mistakes.
thanks a lot!

/karelke
cfdopenfoam is offline   Reply With Quote

Old   October 31, 2015, 07:49
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,962
Blog Entries: 45
Rep Power: 125
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick answers:

For the first issue, without seeing the source code, the best I can do is suggest that you take a better look at OpenFOAM's own boundary conditions for ideas on how these variables are handled in the constructors and in the "write" method. In addition, see this post for more ideas: http://www.cfd-online.com/Forums/ope...tml#post567594 - post #8

For the second issue, I can't figure out what you're asking from your description Please provide more details.
__________________
wyldckat is offline   Reply With Quote

Old   October 31, 2015, 08:21
Default
  #3
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 96
Rep Power: 9
cfdopenfoam is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Quick answers:

For the first issue, without seeing the source code, the best I can do is suggest that you take a better look at OpenFOAM's own boundary conditions for ideas on how these variables are handled in the constructors and in the "write" method. In addition, see this post for more ideas: http://www.cfd-online.com/Forums/ope...tml#post567594 - post #8

For the second issue, I can't figure out what you're asking from your description Please provide more details.
thanks very much for your reply and I am really sorry for the unclarified problem.

for the first issue, myBC is attached.
for the second one, i mean that the 1D solver is totally user-developed. its framework is not exactly confirm to the OF convention, especially for the 1D mesh and solution schemes. so I feel quit difficult to make my coupled solver parallelizable. besides, I think that the 1D calculation is not very time-consuming. so is it possible to only parallel computing the 2D problem? and how this will effect the 1D solution?
hope i've made that clear. thanks for your attention.
cfdopenfoam is offline   Reply With Quote

Old   October 31, 2015, 09:05
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,962
Blog Entries: 45
Rep Power: 125
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick answers:

Quote:
Originally Posted by cfdopenfoam View Post
for the first issue, myBC is attached.
You have this constructor that is incorrect:
Code:
timeVaryingVolumeFluxInletDPUWFvPatchVectorField::
timeVaryingVolumeFluxInletDPUWFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchField<vector>(p, iF, dict),
    timeDataFileName_(fileName(dict.lookup("timeDataFileName")).expand()),
    timeDataPtr_(NULL),
    volumeFlux_(0),
    phiName_("phi"),
    rhoName_("rho")
{
    if (dict.found("phi"))
    {
        dict.lookup("phi") >> phiName_;
    }

    if (dict.found("rho"))
    {
        dict.lookup("rho") >> rhoName_;
    }    
}
It should be:
Code:
timeVaryingVolumeFluxInletDPUWFvPatchVectorField::
timeVaryingVolumeFluxInletDPUWFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchField<vector>(p, iF, dict),
    timeDataFileName_(fileName(dict.lookup("timeDataFileName")).expand()),
    timeDataPtr_(NULL),
    volumeFlux_(readScalar(dict.lookup("volumeFlux"))),
    phiName_("phi"),
    rhoName_("rho")
{
    if (dict.found("phi"))
    {
        dict.lookup("phi") >> phiName_;
    }

    if (dict.found("rho"))
    {
        dict.lookup("rho") >> rhoName_;
    }    
}
Although I'm not 100% certain that this will fix the problem...


Quote:
Originally Posted by cfdopenfoam View Post
for the second one, i mean that the 1D solver is totally user-developed. its framework is not exactly confirm to the OF convention, especially for the 1D mesh and solution schemes. so I feel quit difficult to make my coupled solver parallelizable. besides, I think that the 1D calculation is not very time-consuming. so is it possible to only parallel computing the 2D problem? and how this will effect the 1D solution?
hope i've made that clear.
Ah, OK, now I understand what you mean.
OpenFOAM relies in using the boundary condition "empty" for neutralizing a direction. Therefore, if you have a 1D problem, then your mesh should only be 1 cell of width over 2 directions and on those directions you should use the "empty" boundary condition.
As for the equations, you should define them the same way as OpenFOAM does for other solvers.

As for coupling... it depends on the type of coupling you're trying to do. For example, "chtMultiRegionFoam" is a complex solver that serves as an example on how OpenFOAM and handle coupling between semi-independent mesh regions. But there is also the coupling that can be done at the matrix solver level: http://www.openfoam.org/version2.2.0/matrix-solvers.php

Last edited by wyldckat; October 31, 2015 at 09:06. Reason: corrected the constructor
wyldckat is offline   Reply With Quote

Old   October 31, 2015, 10:05
Default
  #5
Member
 
Karelke Yu
Join Date: Dec 2014
Posts: 96
Rep Power: 9
cfdopenfoam is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Quick answers:

You have this constructor that is incorrect:
thanks very much! your directions exactly fix the problem. but i wrote as:
Code:
timeVaryingVolumeFluxInletDPUWFvPatchVectorField::
timeVaryingVolumeFluxInletDPUWFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    fixedValueFvPatchField<vector>(p, iF, dict),
    timeDataFileName_(fileName(dict.lookup("timeDataFileName")).expand()),
    timeDataPtr_(NULL),
    volumeFlux_(0),
    phiName_("phi"),
    rhoName_("rho")
{
    if (dict.found("volumeFlux"))
    {
        dict.lookup("volumeFlux") >> volumeFlux_; // these fix the problem
    }

    if (dict.found("phi"))
    {
        dict.lookup("phi") >> phiName_;
    }

    if (dict.found("rho"))
    {
        dict.lookup("rho") >> rhoName_;
    }    
}
thank you for your valuable time and now what confuses me is another coding problem.
it seems that the setFields utility could make it. but is there more tips about this tool or other ways to do that? there is only one region in the tutorial interFoam.
thanks for your help and i hope i do not make personal foul.
cfdopenfoam is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Issues on the simulation of high-speed compressible flow within turbomachinery dowlee OpenFOAM Running, Solving & CFD 11 August 6, 2021 07:40
How the boundary conditions are called in the OpenFOAM solvers? openfoammaofnepo OpenFOAM Programming & Development 15 February 11, 2020 05:28
Tutorial on compiling new solvers, utilities, boundary conditions, etc. lordvon OpenFOAM Programming & Development 2 May 13, 2015 10:06
several fields modified by single boundary condition schröder OpenFOAM Programming & Development 3 April 21, 2015 06:09
Need help with boundary conditions: open to atmosphere Wolle OpenFOAM 2 April 11, 2011 08:32


All times are GMT -4. The time now is 03:49.