| 101 | } |
| 102 | |
| 103 | void Run(M& m, Vars& var) { |
| 104 | auto sem = m.GetSem(); |
| 105 | struct { |
| 106 | FieldNode<Scal> fnl; |
| 107 | FieldCell<Scal> fcu; |
| 108 | MapEmbed<BCond<Scal>> mebc; |
| 109 | Scal t = 0; |
| 110 | Scal diff; |
| 111 | Scal dt; |
| 112 | std::unique_ptr<Embed<M>> eb_; |
| 113 | } * ctx(sem); |
| 114 | auto& fnl = ctx->fnl; |
| 115 | auto& fcu = ctx->fcu; |
| 116 | auto& mebc = ctx->mebc; |
| 117 | auto& t = ctx->t; |
| 118 | auto& dt = ctx->dt; |
| 119 | auto& diff = ctx->diff; |
| 120 | |
| 121 | if (sem("init")) { |
| 122 | diff = var.Double["diff"]; |
| 123 | dt = var.Double["cfl"] * sqr(m.GetCellSize()[0]) * diff; |
| 124 | // initial field |
| 125 | fcu.Reinit(m, 0); |
| 126 | for (auto c : m.AllCells()) { |
| 127 | auto x = m.GetCenter(c); |
| 128 | fcu[c] = ((Vect(0.5, 0.5, 0) - x).norminf() < 0.1); |
| 129 | } |
| 130 | // level-set for embedded boundaries |
| 131 | fnl.Reinit(m, 0); |
| 132 | for (auto n : m.AllNodes()) { |
| 133 | auto x = m.GetNode(n); |
| 134 | fnl[n] = (0.4 - (Vect(0.5, 0.5, 0) - Vect(x[0], x[1], 0.)).norm()); |
| 135 | } |
| 136 | ctx->eb_.reset(new Embed<M>(m, var.Double["gradlim"])); |
| 137 | m.Dump(&fcu, "u"); |
| 138 | } |
| 139 | if (sem.Nested("eb-init")) { |
| 140 | ctx->eb_->Init(fnl); |
| 141 | } |
| 142 | if (sem.Nested("eb-dump")) { |
| 143 | ctx->eb_->DumpPlaneSection(Vect(0., 0., 1e-3), Vect(0., 0., 1.)); |
| 144 | } |
| 145 | if (sem("init2")) { |
| 146 | auto& eb = *ctx->eb_; |
| 147 | // boundary conditions |
| 148 | for (auto c : eb.SuCFaces()) { |
| 149 | auto& bc = mebc[c]; |
| 150 | bc.type = BCondType::dirichlet; |
| 151 | bc.val = 1; |
| 152 | } |
| 153 | } |
| 154 | sem.LoopBegin(); |
| 155 | if (sem("step")) { |
| 156 | if (m.IsRoot()) { |
| 157 | std::cout << "t=" << t << std::endl; |
| 158 | } |
| 159 | switch (var.Int["case"]) { |
| 160 | case 0: |
nothing calls this directly
no test coverage detected