CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Editing chtMultiRegionFoam to not solve velocity field (https://www.cfd-online.com/Forums/openfoam/86920-editing-chtmultiregionfoam-not-solve-velocity-field.html)

tH3f0rC3 April 6, 2011 07:29

Editing chtMultiRegionFoam to not solve velocity field
 
Hi,

I'm using the chtMulti-solvers. Finally I want to use chtMultiRegionRadFoam. But the chtMulti-solvers are very simillar, thus I'm using chtMultiRegionSimpleFoam at the moment, because I didn't get started chtMultiRegionFoam and chtMultiRegionRadFoam yet.

I want to model a heat transfer with a "frozen" velocity field. In my case I can define the velocity field as steady state. The heat transfer shall be solved transient.
To reduce solving-time I think about editing the solver to solve only the energy equation and not the velocity equation.
Does someone know if this is possible in general, or does someone has done that before?

So I thought about the time the machine needs to solve the case.
Does someone know if it is also possible to switch off the solving of the velocity field?

(Another question:
Does someone know if it is possible to solve incompressible insteat of compressible?
Maybe just by switching the density variation to zero? But where do I change that?)


Best Regards,
tH3f0rC3

mvoss April 7, 2011 04:31

Import the U-Filed with the
"NO_WRITE"-Option and comment out every u/p-related #include in the solver.

tH3f0rC3 April 7, 2011 08:14

Quote:

Originally Posted by neewbie (Post 302610)
Import the U-Filed with the
"NO_WRITE"-Option and comment out every u/p-related #include in the solver.

Hi thanks for the answer.
Sounds very easy.
Where can I change these settings?

Best Regards,
tH3f0rC3

sebonator April 7, 2011 17:23

Hi tH3f0rC3,

these aren't actually settings you can switch on or off anywhere. You will have to edit the sourcecodes of the solver you want to modify.

I gave somebody else a short introduction on how to create a customized solver that is based on some standard solver of openfoam. Have a look at this thread:

http://www.cfd-online.com/Forums/ope...-function.html

The interesting part for you starts with post number 5. At the moment I don't really know how to help you contentwise with your problem, but the thread mentioned above will help you with the general procedure of customizing any of openfoams executables.

Maybe neewbie is able to help you contentwise. It seems as if he knows about the codes.

Good luck!
Greetings Sebastian

mvoss April 11, 2011 08:08

hi,

Sebastian is right about the steps. You need to do some changing in the source-code.
The NO_write option in the u-field is what it says: no writing means not changing the initial velocity-field, thatīs what i thought about making it "frozen". and since you donīt need to do fvm-clalc. to solve for "u" you can delete/comment the appropriate lines in the solver source code. Just add an "//" at the beginning of the line. This is for the speed up.
If you feel like adding some "user-friendlieness" you can add a dictionary-line to the source code and ask for an entry "solve vel."
Code:

IOdictionary solveFor
    (
        IOobject
        (
            "solveFor",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

Code:

 
bool solveVel = false;
    if (solveFor.found("solveVel"))
    {
        solveVel = Switch(solveFor.lookup("solveVel"));
    }

and then wrap the lines where to solve for "u" with
Code:

if(solveVel){
...
}

These lines will only be executed if there is an entry:
Code:

solveVel true;
in the dictionary named solveFor.

But you can do the same also for an existing dictionary in the cht-solver. Check the "../fluid/readFluidMultiRegionSIMPLEControls.H"

neewbie

tH3f0rC3 April 17, 2011 08:48

Hey neewbiw,

many thanks to your suggestion.
I will try as soon as possible!

Do you think it is necessary to first copy the solver with a new name to not making a change in the original solver source code?
Did you do some source code changing in the original solvers before?
I'm a little bit scared of editing in the original source code of a solver. I don't want to destroy the function of an original solver.

Best Regards,
tH3f0rC3

sebonator April 17, 2011 12:43

Hi tH3f0rC3,

did you not read my post? If you take a look at my post above you will find a link to a thread were I gave somebody a step by step description on how to make a copy of an original solver and how to edit it afterwards.

You should not work inside the original folders! If you compile anything there, the original executable file will be replaced with your modified one and the original solver will therefore not be available anymore. You should always work on copy! Take a look at my link above, because OpenFOAM offers a very comfortable way of using customized functions.

Greetings Sebastian

tH3f0rC3 April 17, 2011 13:02

Hey Sebastian,

I have read your post, but not that detailed. I'm sorry for that!
I still have tried to copy a solver before, but it hasn't worked. That depends on the installation of OF which was made on my computer.

I will have to solve this problem first. But that was the reason for my question, if it is relly necessary to copy a solver.
But your argument is cogent.

Best Regards,
tH3f0rC3


Quote:

Originally Posted by sebonator (Post 303945)
Hi tH3f0rC3,

did you not read my post? If you take a look at my post above you will find a link to a thread were I gave somebody a step by step description on how to make a copy of an original solver and how to edit it afterwards.

You should not work inside the original folders! If you compile anything there, the original executable file will be replaced with your modified one and the original solver will therefore not be available anymore. You should always work on copy! Take a look at my link above, because OpenFOAM offers a very comfortable way of using customized functions.

Greetings Sebastian


tH3f0rC3 April 18, 2011 04:29

Hi,

I have now copied the solver and now want to make a change in the source code.
I'm afraid I don't can find the dictionary named solveFor.
Or where are the codes copied from? From which file in which directory?

Best Regards,
tH3f0rC3

Quote:

Originally Posted by neewbie (Post 303083)
hi,

Sebastian is right about the steps. You need to do some changing in the source-code.
The NO_write option in the u-field is what it says: no writing means not changing the initial velocity-field, thatīs what i thought about making it "frozen". and since you donīt need to do fvm-clalc. to solve for "u" you can delete/comment the appropriate lines in the solver source code. Just add an "//" at the beginning of the line. This is for the speed up.
If you feel like adding some "user-friendlieness" you can add a dictionary-line to the source code and ask for an entry "solve vel."
Code:

IOdictionary solveFor
    (
        IOobject
        (
            "solveFor",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

Code:

 
bool solveVel = false;
    if (solveFor.found("solveVel"))
    {
        solveVel = Switch(solveFor.lookup("solveVel"));
    }

and then wrap the lines where to solve for "u" with
Code:

if(solveVel){
...
}

These lines will only be executed if there is an entry:
Code:

solveVel true;
in the dictionary named solveFor.

But you can do the same also for an existing dictionary in the cht-solver. Check the "../fluid/readFluidMultiRegionSIMPLEControls.H"

neewbie


mvoss April 18, 2011 04:55

thatīs totally normal. you have to create that dictionary like every other dictionary e.g. thermoPhysicalProperties, RASProperties. Take the following as the top of the new file.
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM Extend Project: Open Source CFD        |
|  \\    /  O peration    | Version:  1.6-ext                              |
|  \\  /    A nd          | Web:      www.extend-project.de                |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object    solveFor; //instead of transportProperties
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solveVel true;

// ******************************************************* //

Name it solveFor or whatever you like in the ../constant-folder.
Code:

IOdictionary solveFor //name
    (
        IOobject
        (
            "solveFor", //internalName in OF C++ Environment
            runTime.constant(),//where to search for
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

You have 3 kinds of names/objects:
  • the file in runtime.constant(),
  • the object "solveFor" and
  • the actual entry "solveVel" which is hold by the "solveFor"-IOobject.

Hopefully thatīs not totally rubbish in terms of C++-speech.
Please feel free to correct if not right.

neewbie

tH3f0rC3 April 18, 2011 14:41

Ok, I ave understood to create a file named solvefor.
But I miss the change in source code.
So what do I have to change in the source code? I think I have to edit the choosen file name "solveFor" somewhere in the source code.

You wrote:
Quote:

to solve for "u" you can delete/comment the appropriate lines in the solver source code
But where can I do that?

I also didn't get you at this point:
Quote:

You have 3 kinds of names/objects:
  • the file in runtime.constant(),
  • the object "solveFor" and
  • the actual entry "solveVel" which is hold by the "solveFor"-IOobject.

I will search for these files tomorrow in the source code of the solver. Maybe I will understand better than.
Are all the codes you pasted here for the solveFor-file?

Best Regards,
tH3f0rC3

tH3f0rC3 April 19, 2011 07:29

what I have found in the createFluidFields.H - file in /fluid/ is the following:

Info<< " Adding to UFluid\n" << endl;
UFluid.set
(
i,
new volVectorField
(
IOobject
(
"U",
runTime.timeName(),
fluidRegions[i],
IOobject::MUST_READ,
IOobject::NO_WRITE //this is what I have changed
),
fluidRegions[i]
)
);

I don't even understand the necessarity of the solveFor-file.
Maybe you can give me a more detailed description of what I have to do to not let the solver calculate the velocity field to speed up.

Best Regards,
tH3f0rC3

mvoss April 19, 2011 09:55

hi,

the "solveFor" was just an easy way to enable/disable the solving of U.
You actually donīt need it. Just forget about it.

I would guess that since you have chosen NO_WRITE for the U-field, thatīs it. You have frozen the U-field. No writing. And since U is not changing there is no need for iterating and i think the solver detects this.
You can set the iterations to, lets say 0 by setting the tolerance to 10 and youīre done.

To disable the solving itself for the speedup just comment out the part in the solver which contains the solving for U.
If you donīt solve for U, you donīt need any of the flow related calculations. in the solver C-file try
Code:

...
// #include "solveFluid.H"
....

Honestly, what do you think could a happen if you donīt use a file called "solveFluid.H"? Thatīs kind-of obvious, isnīt it?

The real task is set in UEqn.H
Code:

eqnResidual=solve
(
...
).initialResidual()

and is wrapped with the residual-output, like you can see.

There could be some errors about missing fields for turbulence, thermophysicalProp.and residuals and so one. You have to decide whether you need them or not.

neewbie

tH3f0rC3 April 20, 2011 09:14

It's kind of weird.

I have changed something in the source code and wanted to see what happens.
When I have regenerated the former status, before the change, the solver still does the same.
I have now even re-changed my test-solver into chtMultiRegionSimpleFoam. But the solver doesn't work like it. The new solver still works like the changed one.
I have started a new terminal, restarted OF and even wmake-ed the solver.

:eek:

Does someone have a clue?

Best Regards,
Dirk

mvoss April 20, 2011 09:18

Did you change the "files"-file EXE statement to point to FOAM_USER_APPBIN ? And also gave it a new name?

tH3f0rC3 April 20, 2011 09:40

Quote:

Originally Posted by neewbie (Post 304410)
Did you change the "files"-file EXE statement to point to FOAM_USER_APPBIN ? And also gave it a new name?

Yes, I have edited the files - file in the Make directory to:

derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
chtMultiRegionSimpleFoam_novelocity.C

EXE = $(FOAM_USER_APPBIN)/chtMultiRegionSimpleFoam_novelocity

Do I have to wmake the solver after changing something in the source code?

mvoss April 20, 2011 10:53

yes. Type wmake within the source-folder and type chtMultiRegionSimpleFoam_novelocity in your run directory.
You can check also by only typing
chtMultiRegionS and than tab to get an overview over all possibilities found. If everything is okay this should also show your new solver.

mm66 January 14, 2020 09:04

Energy only (no flow) in chtMultiRegionSimpleFoam
 
Hi Foamers,

I am facing the same problem. Currently am trying to simulate the same geometry several times with different inlet temperatures. The flow is converged and I want to change the inlet temperature. I was thinking of changing the under relaxation factor to zero for all the fields except for energy so that it is the only one being solved. Do you think this strategy would result in what I am seeking?

Thanks

mm66 January 24, 2020 16:39

Quote:

Originally Posted by mm66 (Post 754621)
Hi Foamers,

I am facing the same problem. Currently am trying to simulate the same geometry several times with different inlet temperatures. The flow is converged and I want to change the inlet temperature. I was thinking of changing the under relaxation factor to zero for all the fields except for energy so that it is the only one being solved. Do you think this strategy would result in what I am seeking?

Thanks

Any ideas/hints will be greatly appreciated :)


All times are GMT -4. The time now is 18:34.