Skip to content
Snippets Groups Projects
Commit 5d185799 authored by Richard Comblen's avatar Richard Comblen
Browse files

New bindings for RK, see RayleighTaylor.lua for examples

parent 36efc4ab
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ set(SRC
dgConservationLawShallowWater2d.cpp
dgConservationLawWaveEquation.cpp
dgConservationLawPerfectGas.cpp
dgSlopeLimiter.cpp
dgLimiter.cpp
dgDofContainer.cpp
function.cpp
functionDerivator.cpp
......
......@@ -72,29 +72,30 @@ law:addBoundaryCondition('Top',law:newOutsideValueBoundary(FS))
GC=dgGroupCollection(myModel,2,order)
solution=dgDofContainer(GC,4)
solution:L2Projection(FS)
DG:limitSolution()
GC:splitGroupsForMultirate(0.0003,law)
-- limiter=dgSlopeLimiter()
-- limiter:apply(solution)
GC:buildGroupsOfInterfaces(myModel,2,order)
print'*** setting the initial solution ***'
--print'*** export ***'
DG:exportSolution('output/rt_0')
solution:exportMsh(string.format("output/rt-%06d", 0))
print'*** solve ***'
LC = 0.1*.1
dt = .0003;
print('DT=',dt)
RK=dgRungeKutta()
-- RK:setLimiter(limiter)
for i=1,10000 do
-- norm = DG:RK44_limiter(dt)
norm = DG:RK44(dt)
norm = RK:iterate44(law,dt,solution)
if (i % 10 == 0) then
print('*** ITER ***',i,norm)
end
if (i % 100 == 0) then
DG:exportSolution(string.format("output/rt-%06d", i))
solution:exportMsh(string.format("output/rt-%06d", i))
end
end
......
......@@ -4,8 +4,9 @@
#include "function.h"
//----------------------------------------------------------------------------------
bool dgSlopeLimiter::apply ( dgDofContainer &solution, dgGroupCollection &groups)
bool dgSlopeLimiter::apply ( dgDofContainer &solution)
{
dgGroupCollection &groups=*solution.getGroups();
solution.scatter();
int nbFields =_claw->getNbFields();
......@@ -120,3 +121,19 @@ bool dgSlopeLimiter::apply ( dgDofContainer &solution, dgGroupCollection &groups
return true;
}
/*
#include "Bindings.h"
void dgSlopeLimiter::registerBindings(binding *b) {
classBinding *cb = b->addClass<dgSlopeLimiter>("dgSlopeLimiter");
cb->setDescription("The usual DG slope limiter: keep the mean, reduces uniformly the slope until it does not overshoot the neighbors' mean");
methodBinding *cm;
cm = cb->setConstructor<dgSlopeLimiter,dgConservationLaw *>();
cm->setDescription("A new explicit slope limiter");
cm->setArgNames("law",NULL);
// cm = cb->addMethod("apply",&dgLimiter::apply);
// cm->setArgNames("solution",NULL);
// cm->setDescription("apply the limiter on the solution");
}
*/
......@@ -6,19 +6,21 @@
struct dgDofContainer;
class dgGroupCollection;
class dgConservationLaw;
class binding;
class dgLimiter{
protected:
dgConservationLaw *_claw;
public:
dgLimiter (dgConservationLaw *claw) : _claw(claw) {}
virtual bool apply ( dgDofContainer &sol, dgGroupCollection &groups)=0;
virtual bool apply ( dgDofContainer &sol)=0;
};
class dgSlopeLimiter : public dgLimiter{
public :
dgSlopeLimiter (dgConservationLaw *claw) : dgLimiter (claw) {}
virtual bool apply ( dgDofContainer &solution, dgGroupCollection &groups);
virtual bool apply ( dgDofContainer &solution);
//static void registerBindings(binding *b);
};
#endif
......@@ -49,7 +49,7 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw,
K.axpy(*sol);
}
if (_limiter) _limiter->apply(K, *groups);
if (_limiter) _limiter->apply(K);
dgAlgorithm::residual(*claw,*groups,K,resd);
K.scale(0.);
for(int k=0; k < groups->getNbElementGroups(); k++) {
......@@ -64,9 +64,10 @@ double dgRungeKutta::diagonalRK (const dgConservationLaw *claw,
}
Unp.axpy(K,b[j]*dt);
}
if (_limiter) _limiter->apply(Unp, *groups);
if (_limiter) _limiter->apply(Unp);
sol->scale(0.);
sol->axpy(Unp);
return sol->norm();
}
dgRungeKutta::dgRungeKutta():_limiter(NULL) {}
......@@ -89,4 +90,7 @@ void dgRungeKutta::registerBindings(binding *b) {
cm = cb->addMethod("iterate44",&dgRungeKutta::iterate44);
cm->setArgNames("law","dt","solution",NULL);
cm->setDescription("update solution by doing classical fourth order runge-kutta step of time step dt for the conservation law");
// cm = cb->addMethod("setLimiter",&dgRungeKutta::setLimiter);
// cm->setArgNames("limiter",NULL);
// cm->setDescription("if a limiter is set, it is applied after each RK stage");
}
......@@ -142,7 +142,7 @@ void dgSystemOfEquations::exportSolution(std::string outputFile){
void dgSystemOfEquations::limitSolution(){
dgLimiter *sl = new dgSlopeLimiter(_claw);
sl->apply(*_solution,_groups);
sl->apply(*_solution);
delete sl;
}
......
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