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

programming a new solver

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

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 21, 2012, 09:48
Default programming a new solver
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear all,

I am trying to embed the Field Source functionality (see here) in the buoyantSimpleFoam solver.

My new solver is attached.

When I compile it, I get the following error:
Code:
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/buoyantSimpleFoam_Epta$ wmake
Making dependency list for source file buoyantSimpleFoam_Epta.C
could not open file singlePhaseTransportModel.H for source file buoyantSimpleFoam_Epta.C
could not open file cellSet.H for source file buoyantSimpleFoam_Epta.C
SOURCE=buoyantSimpleFoam_Epta.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/buoyantSimpleFoam_Epta.o
buoyantSimpleFoam_Epta.C:36:39: error: singlePhaseTransportModel.H: No such file or directory
In file included from /opt/openfoam210/src/finiteVolume/lnInclude/basicSourceList.H:41,
                 from /opt/openfoam210/src/finiteVolume/lnInclude/IObasicSourceList.H:38,
                 from buoyantSimpleFoam_Epta.C:38:
/opt/openfoam210/src/finiteVolume/lnInclude/basicSource.H:49:21: error: cellSet.H: No such file or directory
make: *** [Make/linux64GccDPOpt/buoyantSimpleFoam_Epta.o] Error 1
. Do you know how I can solve it?

Thanks a lot,

Samuele
Attached Files
File Type: gz buoyantSimpleFoam_Epta.tar.gz (6.8 KB, 22 views)
samiam1000 is offline   Reply With Quote

Old   March 21, 2012, 10:18
Default
  #2
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 219
Rep Power: 21
kwardle is on a distinguished road
Take a look at the .dep file in the original solver and see where it is looking for these files. Perhaps it is using a relative path and you have moved the new solver somewhere else so it can't find the files. You will need to update your Make/options file accordingly so it knows where to look.
kwardle is offline   Reply With Quote

Old   March 21, 2012, 10:55
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear Kent,

thanks a lot for answering.

Well, I understand what you say, but I would like to let you know that I have doubled the simpleFoam solver (calling it my_simpleFoam) and I saved it in the same directory with buoyantSimpleFoam_Epta.

When I compile the my_simpleFoam, everything works properly. reading the 2 .dep files, in the my_simpleFoam.dep the cellSets.H appears
Code:
.
.
.
my_simpleFoam.dep: $(WM_PROJECT_DIR)/src/finiteVolume/lnInclude/basicSource.H
my_simpleFoam.dep: $(WM_PROJECT_DIR)/src/meshTools/lnInclude/cellSet.H
my_simpleFoam.dep: $(WM_PROJECT_DIR)/src/meshTools/lnInclude/topoSet.H
my_simpleFoam.dep: $(WM_PROJECT_DIR)/src/finiteVolume/lnInclude/basicSourceI.H
my_simpleFoam.dep: $(WM_PROJECT_DIR)/src/finiteVolume/lnInclude/basicSourceListTemplates.C
.
.
.
, while in the buoyantSimpleFoam, it doesn't.

Any idea??
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 07:04
Default The compilation is now ok
  #4
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear all,

the compilation of the solver I am trying to set is ok.

The point is that I can use it. When I try it on a case that usually works I get this error message:
Code:
--> FOAM FATAL ERROR: 
incompatible dimensions for operation 
    [U[1 -2 -2 0 0 0 0] ] == [U[0 1 -2 0 0 0 0] ]

    From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)
    in file /opt/openfoam210/src/finiteVolume/lnInclude/fvMatrix.C at line 1313.
The meaning is pretty clear, but the point is that I don't know where the problem is.

Can anyone help?
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 07:08
Default
  #5
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 18
ata is on a distinguished road
Hi
May be I do not understand you correctly but I think any solver need its .dep file independent of where the solver is copied. So, the .dep file of two solvers are different.
Good luck
ata is offline   Reply With Quote

Old   March 22, 2012, 07:16
Default
  #6
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear Ata,

thanks for your answer.

Actually, I have compiled my new solver (I forgot the attachement, here it is)..

Now I do have a problem when I try to use it. And the problem is the one posted above.

Could you help?

Thanks,

Samuele
Attached Files
File Type: gz buoyantSimpleFoam_Epta.tar.gz (6.3 KB, 22 views)
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 10:41
Default
  #7
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 219
Rep Power: 21
kwardle is on a distinguished road
It is complaining that the units for the equation UEqn don't match on the LHS and RHS somewhere. Looks like you've got kg/m2s2 on the left and m/s2 on the right somewhere U is being called. So what's missing? Looks like density on RHS (multiply by kg/m3 and ...).

Perhaps the problem is in the momentumPredictor section, do you have momentumPredictor on? Something may need to be changed in that if statement in UEqn.H to make it work with sources, but I am not sure offhand. Try turning off momentumPredictor in fvSolution to check if that indeed is the problem.
kwardle is offline   Reply With Quote

Old   March 22, 2012, 10:53
Default
  #8
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Dear Kent,

thanks again for answering.

Well, I solved this point and now - in my buoyantSimplFoam_Epta I can fix the velocity in a certain region.

What I can not still do is to fix the temperature. I think I have to edit (adding the source) the hEqn.H file.

Is that a good way to proceed, to you?

I am attaching the working solver (where you can impose the U) and the tmp version, where I am trying (without success, so far!) to be able to impose the temperature.

Any idea?
Attached Files
File Type: gz buoyantSimpleFoam_Epta.tar.gz (6.3 KB, 18 views)
File Type: gz buoyantSimpleFoam_Epta_tmp.tar.gz (6.5 KB, 10 views)
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 10:58
Default
  #9
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 219
Rep Power: 21
kwardle is on a distinguished road
Yes, you need to add sources(h) in to HEqn as you did for UEqn. Of course, in this case you already have some other source term there on the RHS. Add it in along with that one as +sources(h) and see if it works.
kwardle is offline   Reply With Quote

Old   March 22, 2012, 11:02
Default
  #10
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
I've edited my hEqn.H file like this
Code:
{
    fvScalarMatrix hEqn
    (
        fvm::div(phi, h)
      - fvm::Sp(fvc::div(phi), h)
      - fvm::laplacian(turbulence->alphaEff(), h)
     ==
      - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")
      + sources(h)
    );

    hEqn.relax();
    sources.constrain(hEqn()); 
    hEqn.solve();

    thermo.correct();
}
and when I try to compile it I get the following error:

Code:
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/buoyantSimpleFoam_Epta_tmp$ wclean
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/buoyantSimpleFoam_Epta_tmp$ wmake
Making dependency list for source file buoyantSimpleFoam_Epta_tmp.C
SOURCE=buoyantSimpleFoam_Epta_tmp.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/buoyantSimpleFoam_Epta_tmp.o
In file included from buoyantSimpleFoam_Epta_tmp.C:63:
hEqn.H: In function ‘int main(int, char**)’:
hEqn.H:13: error: no match for call to ‘(Foam::fvScalarMatrix) ()’
make: *** [Make/linux64GccDPOpt/buoyantSimpleFoam_Epta_tmp.o] Error 1
Could you figure out what's wrong and what I should do?

Thanks a lot!
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 11:14
Default
  #11
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 219
Rep Power: 21
kwardle is on a distinguished road
should be

sources.constrain(hEqn);

I think. Does that work?
kwardle is offline   Reply With Quote

Old   March 22, 2012, 11:17
Default
  #12
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
It doesnt. If I add such a line, like:

Code:
{
    fvScalarMatrix hEqn
    (
        fvm::div(phi, h)
      - fvm::Sp(fvc::div(phi), h)
      - fvm::laplacian(turbulence->alphaEff(), h)
     ==
      - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")
      //+ sources(h)
    );

    hEqn.relax();
    sources.constrain(hEqn()); 
    hEqn.solve();

    thermo.correct();
}
it says:

Code:
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/buoyantSimpleFoam_Epta_tmp$ wclean
lab@lab-laptop:~/OpenFOAM/lab-2.1.0/applications/solvers/buoyantSimpleFoam_Epta_tmp$ wmake
Making dependency list for source file buoyantSimpleFoam_Epta_tmp.C
SOURCE=buoyantSimpleFoam_Epta_tmp.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam210/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam210/src/turbulenceModels -I/opt/openfoam210/src/turbulenceModels/compressible/RAS/lnInclude -I/opt/openfoam210/src/finiteVolume/cfdTools -I/opt/openfoam210/src/finiteVolume/lnInclude -I/opt/openfoam210/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/buoyantSimpleFoam_Epta_tmp.o
In file included from buoyantSimpleFoam_Epta_tmp.C:63:
hEqn.H: In function ‘int main(int, char**)’:
hEqn.H:13: error: no match for call to ‘(Foam::fvScalarMatrix) ()’
make: *** [Make/linux64GccDPOpt/buoyantSimpleFoam_Epta_tmp.o] Error 1
I am trying to find an example with fixed temperature/entalphy, but I can't find it!
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 12:07
Default
  #13
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
WoW: it works, now. Just a small bug that I would like to solve, i.e. I'd like to impose the temperature and not the enthalpy..
But to get my goal this is not very important: it's just to have a `more practical' solver..

If you have any suggestion, please let me know.

Also, do you know if I can share the developed sover? If so, to whom should I send it?
samiam1000 is offline   Reply With Quote

Old   March 22, 2012, 12:16
Default
  #14
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 219
Rep Power: 21
kwardle is on a distinguished road
Glad to hear it. Well, you can always just post it here for people to grab. How to 'share' things with the main distribution is one of those things that is a little nebulous...

You may also be able to get the folks who run the openfoamwiki to include it as a contrib. Not sure how to go about that myself.
kwardle is offline   Reply With Quote

Old   March 22, 2012, 12:20
Default
  #15
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Thanks!

Attached the solver. It is possible to fix either the entahlpy or the velocity.

It needs being compiled.

Have fun,

Samuele
Attached Files
File Type: gz buoyantSimpleFoam_Epta.tar.gz (2.8 KB, 29 views)
samiam1000 is offline   Reply With Quote

Old   June 1, 2012, 10:30
Default
  #16
Member
 
Tibor Nyers
Join Date: Jul 2010
Location: Hungary
Posts: 91
Rep Power: 17
Toorop is on a distinguished road
Hi,

I have a very similar problem. I would like to fix the velocity in some cells and the solver in use is buoyantBoussinesqPimpleFoam.

I made the modifications to incorporate the field source addition to the existing solver:

creatField.H
Code:
+ IObasicSourceList sources(mesh);
pEqn.H
Code:
U = rAU*(UEqn() == sources(U))().H();
...
        if (pimple.finalNonOrthogonalIter())
        {
            // Calculate the conservative fluxes
            phi -= p_rghEqn.flux();

            // Explicitly relax pressure for momentum corrector
            p_rgh.relax();

            // Correct the momentum source with the pressure gradient flux
            // calculated from the relaxed pressure
            U -= rAU*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rAUf);
            U.correctBoundaryConditions();
            sources.correct(U);
        }
UEqn.H
Code:
    // Solve the momentum equation

    tmp<fvVectorMatrix> UEqn
    (
        fvm::ddt(U)
      + fvm::div(phi, U)
      + turbulence->divDevReff(U)
    );

    UEqn().relax();
    
    sources.constrain(UEqn());

    if (pimple.momentumPredictor())
    {
        solve
        (
            UEqn()
         ==
            fvc::reconstruct
            (
                (
                  - ghf*fvc::snGrad(rhok)
                  - fvc::snGrad(p_rgh)
                )*mesh.magSf()
            )
            + sources(U)
        );
    }
The code compile without errors, but the little sample case I created blows up within a few iterations. I just made the modifications the were evident in the releases between pimpleFoam version 2.0 and 2.1, so I guess it's a bit more complicated and I think the problem may be with the pEqn.H but I have no clue about it. If you remove the sourcesProperties from constant folder the case runs without any problem.
Any help would be appreciated!
Attached Files
File Type: gz cavityBuoyantFieldSource.tar.gz (3.2 KB, 20 views)
File Type: gz buoyantBoussinesqPimpleFoamFS.tar.gz (3.1 KB, 19 views)
Annier likes this.
Toorop is offline   Reply With Quote

Old   June 1, 2012, 10:48
Default
  #17
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
I'll study your case, since it's that same thing that I'd like to do ..
samiam1000 is offline   Reply With Quote

Old   June 5, 2012, 08:56
Default
  #18
Member
 
Norbert Weber
Join Date: May 2012
Location: Dresden, Germany
Posts: 37
Rep Power: 14
dl6tud is on a distinguished road
I am working on the same problem ...

@samiam1000: Do you have an example case to try your modified solver? Thank you!!
dl6tud is offline   Reply With Quote

Old   June 5, 2012, 09:07
Default
  #19
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
For sure..

But not here. Please, give me your email and I'll share it with you asap.

Have fun,

Samuele
samiam1000 is offline   Reply With Quote

Old   June 5, 2012, 09:12
Default
  #20
Member
 
Norbert Weber
Join Date: May 2012
Location: Dresden, Germany
Posts: 37
Rep Power: 14
dl6tud is on a distinguished road
@Toorop: There may be an error in the line
Quote:
sources.correct(U);
. Without that line, I can compile it, with it, not:
Quote:
class Foam::IObasicSourceList hast no member named 'correct'
dl6tud 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
[Other] A New Solver for Supersonic Combustion nakul OpenFOAM Community Contributions 20 February 22, 2019 10:08
Quarter Burner mesh with periosic condition SamCanuck FLUENT 2 August 31, 2011 12:34
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 15:08
Programming a coupled solver didomenico OpenFOAM Running, Solving & CFD 1 March 5, 2006 04:04


All times are GMT -4. The time now is 08:45.