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

source term modification in poisson equation does not affect results

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2016, 18:11
Default
  #21
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Tobi,

I added those under relaxation coefficients to fvSolution as well.

Unfortunately, it still diverges, even for values of \beta less than 9.
babakflame is offline   Reply With Quote

Old   September 25, 2016, 01:46
Default
  #22
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Dear Fellows

The equation \nabla^2 \varphi = \beta \sinh \varphi

written with the following snippet :
Code:
 solve
        (
              fvm::laplacian(phi)  == beta * sinh(phi) 
//          fvm::laplacian(phi) - beta * (phi + (1/6)*pow(phi,3) + (1/120)*pow(phi,5) + (1/362880)*pow(phi,9) + (1/39916800)*pow(phi,11))
        );
crashes for large values of \beta

The following ideas didn't resolve the crashing issue:
1) relaxing the steady equation
2) Solving the transient form (adding time derivative)
3) relaxing the transient form
4) refining the grid
5) replacing \sinh with its polynomial counterpart

At the moment, I have found that some people have solved the above equation in a weak variational form in a Galerkin projection:
A Newton iteration strategy is used:

[\nabla^2 - \beta \cosh (\varphi^n)] (\varphi^{n+1}) = \beta \sinh (\varphi^n) - \beta \varphi^n cosh(\varphi^n)

Here n shows the iteration number.

I tried to write the above formulation in OpenFoam 2.1.x using the following snippet:



Code:
    solve (fvm::laplacian(phi)   == beta * sinh(phi));
    while (runTime.loop())
    {
        Info<< "Iteration = " << runTime.timeName() << nl << endl;


        (fvm::laplacian(phi) - beta * cosh(phi.oldTime()) * phi  == beta * sinh(phi.oldTime())  - beta * cosh(phi.oldTime()) * phi.oldTime();
        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
As you can see, I used the oldTime() member function to have access to previous iterations and solved the real equation once before the loop to have phi.oldTime() available for the loop. The code compiles correctly, However crashes during simulation with same
error as before.
I have a feeling that I am not implementing correctly the above iterative equation.

Any hint is appreciated
babakflame is offline   Reply With Quote

Old   September 30, 2016, 12:32
Default
  #23
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22
Zeppo will become famous soon enough
Quote:
Originally Posted by babakflame View Post
Code:
    solve (fvm::laplacian(phi)   == beta * sinh(phi));
    while (runTime.loop())
    {
        Info<< "Iteration = " << runTime.timeName() << nl << endl;


        (fvm::laplacian(phi) - beta * cosh(phi.oldTime()) * phi  == beta * sinh(phi.oldTime())  - beta * cosh(phi.oldTime()) * phi.oldTime();
        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
Just a note to let you know.
Instead of this
Code:
(fvm::laplacian(phi) - beta * cosh(phi.oldTime()) * phi  == beta * sinh(phi.oldTime())  - beta * cosh(phi.oldTime()) * phi.oldTime();
you can apply some relaxation to a field phi by this
Code:
(fvm::laplacian(phi) == beta * sinh(phi)).solve();
phi.relax();
relax() will read the relaxation coefficient from system/fvSolution dictionary
Code:
//- system/fvSolution
relaxationFactors
{
    fields
    {
         phi       0.3;
     }
}
Code:
//- src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::relax()
{
    word name = this->name();

    if
    (
        this->mesh().data::template lookupOrDefault<bool>
        (
            "finalIteration",
            false
        )
    )
    {
        name += "Final";
    }

    if (this->mesh().relaxField(name))
    {
        relax(this->mesh().fieldRelaxationFactor(name));
    }
}
and another relax(relaxFactor) is then invoked
Code:
//- src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::relax(const scalar alpha)
{
    if (debug)
    {
        InfoInFunction
           << "Relaxing" << endl << this->info() << " by " << alpha << endl;
    }

    operator==(prevIter() + alpha*(*this - prevIter()));
}
babakflame and ruloz like this.
Zeppo is offline   Reply With Quote

Old   October 1, 2016, 17:15
Default
  #24
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Dear Sergei

Many thanks for your reply. Actually, I had applied the under-relaxation in a correct way.
http://www.cfd-online.com/Forums/ope...tml#post618146
Either my value was not small enough (0.3) or a specific algorithm for iterating is needed, however, I solved my problem through employing the following solver in fvSolution file:

Code:
solver smoothSolver;
    smoother GaussSeidel;
    preconditioner DIC;
    tolerance 1e-11;
    relTol 0.2;
Cuopling the above solver and refinement made me capable of increasing the value of \beta in my non-linear equation.
babakflame is offline   Reply With Quote

Old   October 1, 2016, 17:28
Default
  #25
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22
Zeppo will become famous soon enough
Hi, Bobi
Glad to hear you solved your problem.
babakflame likes this.
Zeppo is offline   Reply With Quote

Old   October 1, 2016, 17:34
Default
  #26
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Thanks Bro.
babakflame is offline   Reply With Quote

Reply


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
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
implicit - scalar product source term in momentum equation vinch OpenFOAM Running, Solving & CFD 0 October 28, 2014 15:57
UDF for source term in momentum equation Enrico FLUENT 9 May 30, 2014 12:34
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59


All times are GMT -4. The time now is 19:04.