MCPcopy Create free account
hub / github.com/cselab/aphros / Diffusion2

Function Diffusion2

examples/104_embed_diffusion/main.cpp:77–101  ·  view source on GitHub ↗

Diffusion solver with redistribution to neighbor cells and LoopFaces() to avoid code duplicatoin.

Source from the content-addressed store, hash-verified

75// Diffusion solver with redistribution to neighbor cells
76// and LoopFaces() to avoid code duplicatoin.
77void Diffusion2(
78 FieldCell<Scal>& fcu, const MapEmbed<BCond<Scal>>& mebc, Scal diff, Scal dt,
79 const Embed<M>& eb) {
80 const auto feg = UEmbed<M>::Gradient(fcu, mebc, eb);
81 // Compute flux.
82 FieldEmbed<Scal> fed(eb, 0);
83 eb.LoopFaces([&](auto cf) { // lambda-function applied to faces and
84 // embedded faces
85 fed[cf] = feg[cf] * diff * eb.GetArea(cf);
86 });
87 // Compute the change at one time step.
88 FieldCell<Scal> fct(eb, 0);
89 for (auto c : eb.Cells()) {
90 Scal sum = fed[c];
91 for (auto q : eb.Nci(c)) {
92 sum += fed[eb.GetFace(c, q)] * eb.GetOutwardFactor(c, q);
93 }
94 fct[c] = sum * dt;
95 }
96 fct = UEmbed<M>::RedistributeCutCells(fct, eb);
97 // Advance in time.
98 for (auto c : eb.Cells()) {
99 fcu[c] += fct[c] / eb.GetVolume(c);
100 }
101}
102
103void Run(M& m, Vars& var) {
104 auto sem = m.GetSem();

Callers 1

RunFunction · 0.85

Calls 8

GradientFunction · 0.50
LoopFacesMethod · 0.45
GetAreaMethod · 0.45
CellsMethod · 0.45
NciMethod · 0.45
GetFaceMethod · 0.45
GetOutwardFactorMethod · 0.45
GetVolumeMethod · 0.45

Tested by

no test coverage detected