<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>as the error message already indicates, the writer expects a
      vector of scalars of size num_cell * n_comp and then assumes that
      n_comp consecutive vector elements belong to one cell.  I think
      you first need to produce a "flat" vector of your data, like this:</p>
    <p>n_comp = <span
        class="gmail-m_1992109487122447782gmail-short_text" lang="en"><span
          class="gmail-m_1992109487122447782gmail-"><span
            class="gmail-m_1992109487122447782gmail-short_text"
            lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                style="font-size:12.8px">GridType::dimensionworld; <br>
              </span></span></span></span></span></p>
    <p><span class="gmail-m_1992109487122447782gmail-short_text"
        lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
            class="gmail-m_1992109487122447782gmail-short_text"
            lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                style="font-size:12.8px">N = num_cell *ncomp ; <br>
              </span></span></span></span></span></p>
    <p>std::vector<double> velocity_flat(N);</p>
    <p>for (size_t idx = 0; idx < num_cell; ++idx)</p>
    <p>    for (size_t k = 0; k < n_comp; ++k)</p>
    <p>        velocity_flat[idx*n_comp+k] = velocity[idx][k]; <br>
    </p>
    <p><br>
    </p>
    <p>Then pass this to your VTK writer like this:</p>
    <p>vtkwriter.addCellData(velocity_flat,"velocity",n_comp); <br>
    </p>
    <p>Not the most elegant version, but it works. <br>
    </p>
    <p>As an alternative, if you have PDELab, you could make a
      GridFunction from your data and pass a pointer to the gridfunction
      too addCellData.For this, you need to derive your function from
      GridFunctionBase<...> and implement the memeber function <br>
    </p>
    <p>void evaluate(const Cell& c, const
      Dune::FieldVector<RF,dimension>& xlocal,
      Dune::FieldVector<RF,n_comp>& y) <br>
    </p>
    <p>that evaluates your function at cell c, local coordinate xlocal
      and puts the result into y. <br>
    </p>
    <br>
    Disclaimer: I am not a Dune developer, merely a user. So take
    everything I say here with a grain of salt.<br>
    <br>
    Regards,<br>
    <br>
    Gregor Corbin<br>
    <br>
    <div class="moz-cite-prefix">Am 12.02.2018 um 14:15 schrieb
      Ponomarev, Ilya:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+xTMOOZPv4+3YKa6CZhwfrptKne--JO7+WxLT3P4cj=LYEVkw@mail.gmail.com">
      <div dir="ltr">
        <div
style="text-align:start;text-indent:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">
          <div>
            <div>
              <div>
                <div><span style="font-size:12.8px">Good afternoon</span><span
                    style="font-size:12.8px">.</span><br>
                  <br>
                </div>
              </div>
            </div>
            <span id="gmail-m_1992109487122447782gmail-result_box"
              class="gmail-m_1992109487122447782gmail-short_text"
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  id="gmail-m_1992109487122447782gmail-result_box"
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-">I have
                    structure</span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">std::vector<Dune::FieldVector<double
                      ,GridType::dimensionworld>>
                      velocity(num_cell);;</span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">num_cell is number of
                      cells in my grid from the size of
Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType,Dune::MCMGElementLayout>
                      object.</span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">I store 3 components of
                      speed in my structure.</span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px"><br>
                    </span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">But I didn't catch, how I
                      can visualize my speed with addCellData in object
                      of Dune::VTKSequenceWriter class. Simple
                      structure, like temperature or concentration, are
                      visualized correctly, but structure with several
                      components - not.</span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">I got an error:</span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px"><br>
                    </span></span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-">
                    <div><span style="font-size:12.8px">dune-grid/dune/grid/io/file/vtk/function.hh:123:47:
                        error: cannot convert ‘const value_type {aka
                        const Dune::FieldVector<double, 3>}’ to
                        ‘double’ in return</span></div>
                    <div><span style="font-size:12.8px">       return
                        v[mapper.index(e)*ncomps_+mycomp_];</span></div>
                    <div><span style="font-size:12.8px"><br>
                      </span></div>
                  </span></span></span></span></div>
          <div><span class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                  class="gmail-m_1992109487122447782gmail-short_text"
                  lang="en"><span
                    class="gmail-m_1992109487122447782gmail-"><span
                      style="font-size:12.8px">Could you explain me,
                      please, how that problem can be solved? </span><br>
                    <br>
                  </span></span></span></span></div>
          <span id="gmail-m_1992109487122447782gmail-result_box"
            class="gmail-m_1992109487122447782gmail-short_text"
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px"
            lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
                id="gmail-m_1992109487122447782gmail-result_box"
                class="gmail-m_1992109487122447782gmail-short_text"
                lang="en"><span
                  class="gmail-m_1992109487122447782gmail-">Best
                  regards,<br>
                </span></span></span></span></div>
        <span id="gmail-m_1992109487122447782gmail-result_box"
          class="gmail-m_1992109487122447782gmail-short_text"
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"
          lang="en"><span class="gmail-m_1992109487122447782gmail-"><span
              id="gmail-m_1992109487122447782gmail-result_box"
              class="gmail-m_1992109487122447782gmail-short_text"
              lang="en"><span class="gmail-m_1992109487122447782gmail-">Ilya
                Ponomarev.</span></span></span></span><br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Dune mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune@lists.dune-project.org">Dune@lists.dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune">http://lists.dune-project.org/mailman/listinfo/dune</a></pre>
    </blockquote>
    <br>
  </body>
</html>