Skip to content
Snippets Groups Projects
Commit 75aa426b authored by Abelin Kameni's avatar Abelin Kameni
Browse files

Transformation of nodal value in RK44

parent 5907890e
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ set(SRC ...@@ -23,6 +23,7 @@ set(SRC
dgConservationLawMaxwell.cpp dgConservationLawMaxwell.cpp
dgConservationLawPerfectGas.cpp dgConservationLawPerfectGas.cpp
dgLimiter.cpp dgLimiter.cpp
dgTransformNodalValue.cpp
dgResidual.cpp dgResidual.cpp
dgDofContainer.cpp dgDofContainer.cpp
function.cpp function.cpp
......
...@@ -2,14 +2,14 @@ model = GModel () ...@@ -2,14 +2,14 @@ model = GModel ()
model:load ('square.geo') model:load ('square.geo')
model:load ('square.msh') model:load ('square.msh')
dg = dgSystemOfEquations (model) dg = dgSystemOfEquations (model)
dg:setOrder(3) dg:setOrder(1)
-- conservation law -- conservation law
-- advection speed -- advection speed
nu=fullMatrix(1,1); nu=fullMatrix(1,1);
nu:set(0,0,0.01) nu:set(0,0,0.01)
law = dgConservationLawAdvection('',functionConstant(nu):getName()) law = dgConservationLawAdvectionDiffusion('',functionConstant(nu):getName())
dg:setConservationLaw(law) dg:setConservationLaw(law)
-- boundary condition -- boundary condition
...@@ -34,7 +34,8 @@ dg:exportSolution('output/Diffusion_00000') ...@@ -34,7 +34,8 @@ dg:exportSolution('output/Diffusion_00000')
-- main loop -- main loop
for i=1,10000 do for i=1,10000 do
norm = dg:RK44(0.001) --norm = dg:RK44(0.001)
norm = dg:RK44_TransformNodalValue(0.00001)
if (i % 50 == 0) then if (i % 50 == 0) then
print('iter',i,norm) print('iter',i,norm)
dg:exportSolution(string.format("output/Diffusion-%05d", i)) dg:exportSolution(string.format("output/Diffusion-%05d", i))
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "MEdge.h" #include "MEdge.h"
#include "function.h" #include "function.h"
#include "dgLimiter.h" #include "dgLimiter.h"
#include "dgTransformNodalValue.h"
#include "meshPartition.h" #include "meshPartition.h"
/* /*
......
...@@ -11,6 +11,7 @@ class dgConservationLaw; ...@@ -11,6 +11,7 @@ class dgConservationLaw;
class dgDofContainer; class dgDofContainer;
class dgTerm; class dgTerm;
class dgLimiter; class dgLimiter;
class dgTransformNodalValue;
class dgSystemOfEquations; class dgSystemOfEquations;
class dgAlgorithm { class dgAlgorithm {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "dgConservationLaw.h" #include "dgConservationLaw.h"
#include "dgDofContainer.h" #include "dgDofContainer.h"
#include "dgLimiter.h" #include "dgLimiter.h"
#include "dgTransformNodalvalue.h"
#include "dgResidual.h" #include "dgResidual.h"
#include "dgGroupOfElements.h" #include "dgGroupOfElements.h"
...@@ -108,10 +109,14 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw, ...@@ -108,10 +109,14 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw,
dgDofContainer K (groups, nbFields); dgDofContainer K (groups, nbFields);
dgDofContainer Unp (groups, nbFields); dgDofContainer Unp (groups, nbFields);
dgDofContainer resd(groups, nbFields); dgDofContainer resd(groups, nbFields);
K.scale(0.);
K.axpy(*sol);
Unp.scale(0.); Unp.scale(0.);
Unp.axpy(*sol); Unp.axpy(*sol);
if (_TransformNodalValue) _TransformNodalValue->apply(&Unp);
K.scale(0.);
K.axpy(Unp);
dgResidual residual(claw); dgResidual residual(claw);
for(int j=0; j<nStages;j++){ for(int j=0; j<nStages;j++){
...@@ -119,7 +124,7 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw, ...@@ -119,7 +124,7 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw,
K.scale(A[j]*dt); K.scale(A[j]*dt);
K.axpy(*sol); K.axpy(*sol);
} }
if (_TransformNodalValue) _TransformNodalValue->apply_Inverse(&K);
if (_limiter) _limiter->apply(&K); if (_limiter) _limiter->apply(&K);
residual.compute(*groups,K,resd); residual.compute(*groups,K,resd);
K.scale(0.); K.scale(0.);
...@@ -136,6 +141,7 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw, ...@@ -136,6 +141,7 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw,
Unp.axpy(K,b[j]*dt); Unp.axpy(K,b[j]*dt);
} }
if (_limiter) _limiter->apply(&Unp); if (_limiter) _limiter->apply(&Unp);
if (_TransformNodalValue) _TransformNodalValue->apply_Inverse(&Unp);
sol->scale(0.); sol->scale(0.);
sol->axpy(Unp); sol->axpy(Unp);
return sol->norm(); return sol->norm();
...@@ -241,5 +247,10 @@ void dgRungeKutta::registerBindings(binding *b) { ...@@ -241,5 +247,10 @@ void dgRungeKutta::registerBindings(binding *b) {
cm = cb->addMethod("setLimiter",&dgRungeKutta::setLimiter); cm = cb->addMethod("setLimiter",&dgRungeKutta::setLimiter);
cm->setArgNames("limiter",NULL); cm->setArgNames("limiter",NULL);
cm->setDescription("if a limiter is set, it is applied after each RK stage"); cm->setDescription("if a limiter is set, it is applied after each RK stage");
cm = cb->addMethod("setTransformNodalValue",&dgRungeKutta::setTransformNodalValue);
cm->setArgNames("TransformNodalValue",NULL);
cm->setDescription("if the Nodal values is transformed in first step of RK");
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
class dgConservationLaw; class dgConservationLaw;
class dgDofContainer; class dgDofContainer;
class dgLimiter; class dgLimiter;
class dgTransformNodalValue;
class dgGroupCollection; class dgGroupCollection;
class dgGroupOfElements; class dgGroupOfElements;
class dgGroupOfFaces; class dgGroupOfFaces;
...@@ -17,8 +18,11 @@ class dgRungeKutta { ...@@ -17,8 +18,11 @@ class dgRungeKutta {
double diagonalRK(const dgConservationLaw *claw, double dt, dgDofContainer *solution, int nStages, double *A, double *b); // c == A double diagonalRK(const dgConservationLaw *claw, double dt, dgDofContainer *solution, int nStages, double *A, double *b); // c == A
double nonDiagonalRK(const dgConservationLaw *claw, double dt, dgDofContainer *solution, int nStages, fullMatrix<double>&A, double *b, double *c); double nonDiagonalRK(const dgConservationLaw *claw, double dt, dgDofContainer *solution, int nStages, fullMatrix<double>&A, double *b, double *c);
dgLimiter *_limiter; dgLimiter *_limiter;
dgTransformNodalValue *_TransformNodalValue;
public: public:
void setLimiter(dgLimiter *limiter) { _limiter = limiter; } void setLimiter(dgLimiter *limiter) { _limiter = limiter; }
void setTransformNodalValue(dgTransformNodalValue *TransformNodalValue) { _TransformNodalValue = TransformNodalValue; }
double iterateEuler(const dgConservationLaw *claw, double dt, dgDofContainer *solution); double iterateEuler(const dgConservationLaw *claw, double dt, dgDofContainer *solution);
double iterate22(const dgConservationLaw *claw, double dt, dgDofContainer *solution); double iterate22(const dgConservationLaw *claw, double dt, dgDofContainer *solution);
double iterate33(const dgConservationLaw *claw, double dt, dgDofContainer *solution); double iterate33(const dgConservationLaw *claw, double dt, dgDofContainer *solution);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "PView.h" #include "PView.h"
#include "PViewData.h" #include "PViewData.h"
#include "dgLimiter.h" #include "dgLimiter.h"
#include "dgTransformNodalValue.h"
#include "dgRungeKutta.h" #include "dgRungeKutta.h"
#ifdef HAVE_MPI #ifdef HAVE_MPI
#include "mpi.h" #include "mpi.h"
...@@ -69,6 +70,16 @@ void dgSystemOfEquations::registerBindings(binding *b) { ...@@ -69,6 +70,16 @@ void dgSystemOfEquations::registerBindings(binding *b) {
cm = cb->addMethod("RK44_limiter",&dgSystemOfEquations::RK44_limiter); cm = cb->addMethod("RK44_limiter",&dgSystemOfEquations::RK44_limiter);
cm->setArgNames("dt",NULL); cm->setArgNames("dt",NULL);
cm->setDescription("do one RK44 time step with the slope limiter (only for p=1)"); cm->setDescription("do one RK44 time step with the slope limiter (only for p=1)");
cm = cb->addMethod("RK44_TransformNodalValue",&dgSystemOfEquations::RK44_TransformNodalValue);
cm->setArgNames("dt",NULL);
cm->setDescription("do one RK44 time step with a transformation of nodal value");
cm = cb->addMethod("RK44_TransformNodalValue_limiter",&dgSystemOfEquations::RK44_TransformNodalValue_limiter);
cm->setArgNames("dt",NULL);
cm->setDescription("do one RK44 time step with a limiter and a transformation of nodal value");
////cm = cb->addMethod("multirateRK43",&dgSystemOfEquations::multirateRK43); ////cm = cb->addMethod("multirateRK43",&dgSystemOfEquations::multirateRK43);
//cm->setArgNames("dt",NULL); //cm->setArgNames("dt",NULL);
//cm->setDescription("Do a runge-kuta temporal iteration with 4 sub-steps and a precision order of 3 using different time-step depending on the element size. This function returns the sum of the nodal residuals."); //cm->setDescription("Do a runge-kuta temporal iteration with 4 sub-steps and a precision order of 3 using different time-step depending on the element size. This function returns the sum of the nodal residuals.");
...@@ -126,6 +137,31 @@ double dgSystemOfEquations::RK44_limiter(double dt){ ...@@ -126,6 +137,31 @@ double dgSystemOfEquations::RK44_limiter(double dt){
return _solution->norm(); return _solution->norm();
} }
double dgSystemOfEquations::RK44_TransformNodalValue(double dt){
dgTransformNodalValue *tnv = new dgSupraTransformNodalValue(_claw);
dgRungeKutta rk;
rk.setTransformNodalValue(tnv);
rk.iterate44(_claw, dt, _solution);
delete tnv;
return _solution->norm();
}
double dgSystemOfEquations::RK44_TransformNodalValue_limiter(double dt){
dgLimiter *sl = new dgSlopeLimiter(_claw);
dgTransformNodalValue *tnv = new dgSupraTransformNodalValue(_claw);
dgRungeKutta rk;
rk.setTransformNodalValue(tnv);
rk.setLimiter(sl);
rk.iterate44(_claw, dt, _solution);
delete sl;
delete tnv;
return _solution->norm();
}
double dgSystemOfEquations::ForwardEuler(double dt){ double dgSystemOfEquations::ForwardEuler(double dt){
dgRungeKutta rk; dgRungeKutta rk;
rk.iterateEuler(_claw, dt, _solution); rk.iterateEuler(_claw, dt, _solution);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "dgConservationLaw.h" #include "dgConservationLaw.h"
#include "Gmsh.h" #include "Gmsh.h"
#include "dgLimiter.h" #include "dgLimiter.h"
#include "dgTransformNodalValue.h"
#include "dgDofContainer.h" #include "dgDofContainer.h"
...@@ -43,6 +44,9 @@ public: ...@@ -43,6 +44,9 @@ public:
void L2Projection (std::string functionName); // assign the solution to a given function void L2Projection (std::string functionName); // assign the solution to a given function
double RK44(double dt); double RK44(double dt);
double RK44_limiter(double dt); double RK44_limiter(double dt);
double RK44_TransformNodalValue(double dt);
double RK44_TransformNodalValue_limiter(double dt);
double ForwardEuler(double dt); double ForwardEuler(double dt);
double computeInvSpectralRadius(); double computeInvSpectralRadius();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment