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

How to construct a system of equations from discretized equations

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Hughtong

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 15, 2021, 21:24
Default How to construct a system of equations from discretized equations
  #1
Member
 
Jun
Join Date: Nov 2015
Posts: 57
Rep Power: 10
mykkujinu2201 is on a distinguished road
Dear Forums,

I have a problem with developing code.
Though I have used OpenFOAM for several years,
I know how basic codes work such as pimpleFOAM, pisoFOAM and interFOAM.
However, I am really de-facto new to modify the code myself.

When I find articles, I can get time discretized equations or space discretized equations.
What should I do if I wanna use the formulations in discretized equations?
As far as I know, discretization can be controlled at fvScheme but some expressions seem not to be achieved through fvScheme.
For example, if I have time discretized equation as below, how can I formulate a system of equations?
\frac{C_{n+\frac{1}{2}}-C_{n-\frac{1}{2}}}{\Delta t}+ \nabla \cdot \left( C_n \underline{u}_n\right) =0

I know this is second-order time discretized equation.
However, I do know how to exactly construct the system of equations as given.

I really appreciate it if you give me any advice or any guide to solving this issue.

Best regards,
Jun
mykkujinu2201 is offline   Reply With Quote

Old   June 16, 2021, 06:29
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Have a look at the programmer guide. Equations look like this

Code:
fvm::ddt(C) + fvm::div(phi,C)
Over the fvschemes dictionary you specify the type of discretication
mAlletto is offline   Reply With Quote

Old   June 16, 2021, 20:50
Default Thank you
  #3
Member
 
Jun
Join Date: Nov 2015
Posts: 57
Rep Power: 10
mykkujinu2201 is on a distinguished road
Dear Alleto,

First of all, thank you so much for your reply.

Well, I already know how to construct matrix with fvm, fvc, and fvScheme.

My problem is that whenever I encounter equations in analytic form with information about their discretization scheme, I can handle it.
However, I do not know how to construct matrix from "discretized equation".
Do you know how to handle for this purpose?

Best regards,
Jun
mykkujinu2201 is offline   Reply With Quote

Old   June 17, 2021, 01:31
Default
  #4
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
When you encounter a dircetized equation you have to choose the corresponding scheme in the fvschemes. There is no other easy way. You can program you scheme by your self of course.
mAlletto is offline   Reply With Quote

Old   June 18, 2021, 16:14
Default
  #5
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Maybe like so:

int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"

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

//Construct linear solver and preconditioner only once, for re-use later
fvScalarMatrix TEqn
(
fvm::laplacian(k, T)
);
autoPtr<fvScalarMatrix::fvSolver> solver(TEqn.solver());
solverPerformance solverPerf;

for (int i=0; i<10; i++)
{
TEqn.source() = mesh.V() * (- su - fvc::Sp(sp, T));
solverPerf = solver->solve();

runTime++;
runTime.write();
}

Info<< nl;
runTime.printExecutionTime(Info);

Info<< "End\n" << endl;

return 0;
}
dlahaye is offline   Reply With Quote

Old   March 28, 2024, 01:52
Default Share a very good presentation
  #6
New Member
 
Yanjun Tong
Join Date: Jul 2020
Posts: 13
Rep Power: 5
Hughtong is on a distinguished road
https://www.tfd.chalmers.se/~hani/ku...s/fvMatrix.pdf
AtoHM likes this.
Hughtong is offline   Reply With Quote

Old   April 23, 2024, 02:26
Default
  #7
New Member
 
Lavinia Cummerata
Join Date: Feb 2024
Posts: 3
Rep Power: 2
Kaley2 is on a distinguished road
When faced with a discretized equation, you must select the appropriate scheme in the fvschemes. There's no simpler alternative. Of course, you always have the option to program your own scheme if needed.
Kaley2 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
Guide: Writing Equations in LaTeX on the CFD Online Forums pete Site Help, Feedback & Discussions 27 May 19, 2022 03:19
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
System of Equations Nora Main CFD Forum 3 June 4, 2007 01:27
? fluctuating equations for homogenous shear turb. ff_fan Main CFD Forum 1 September 20, 2002 07:39
CONSERVATION EQUATIONS IN NONINERTIAL SYSTEM!!! zhang zhanwang Main CFD Forum 0 August 17, 1998 07:38


All times are GMT -4. The time now is 01:57.