Dear All,
[...]
> The fix should be easy -- my proposal is to explicitly tell
> vtk_export::write_vec what is the dimension of the vector field
> When exporting point data this dimension will be deduced from 
> mesh_fem. When exporting cell data or sliced point data this dimension
> must be specified explicitly or will be set by default to 1.
> This way we can export cell data which is a vector field (is this
> supported by VTK?).
[...]
As shown in the attached example the fix proposed in the previous mail
works also for cell centered vector fields and VTK supports it.

Regards,

Roman

Attachment: cell_vectors.pdf
Description: Adobe PDF document

/*
 * Author: Roman Putanowicz <[email protected]>
 * Created: Thu May 06 10:22:55 2010
 * Modified by:
 */

#include <stdlib.h> // for EXIT_SUCCESS
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <string>

#include "getfem/getfem_model_solvers.h"
#include "getfem/getfem_models.h"
#include "getfem/getfem_export.h"
#include "getfem/getfem_regular_meshes.h"
#include "getfem/getfem_mesh_slice.h"
#include "getfem/bgeot_comma_init.h"
#include "getfem/getfem_mesh_fem_global_function.h"
#include "getfem/bgeot_geometric_trans.h"
#include "gmm/gmm.h"
#include <string>

int main_body(int argc, char** argv);

/** main function
 * 
 * This function should contain command line parsing and initialization
 * code. The real work should be done by calling main_body().
 */
int main(int argc, char **argv) {
  int result =  EXIT_SUCCESS;
  result = main_body(argc, argv);

  return result;
}

/** The function where the main work is done after configuration
 * and command line parsing.
 */
int main_body(int argc, char** argv) {
  try {  

    getfem::mesh mesh;
    std::vector<getfem::size_type> nsubdiv(1, 4);

    getfem::regular_unit_mesh(mesh, nsubdiv, 
                              bgeot::geometric_trans_descriptor("GT_PK(1,1)"));

    getfem::size_type Ncells = mesh.nb_convex();
    
    std::vector<double> V(Ncells*3);
    for (getfem::size_type i=2; i<Ncells*3; i+=3) {
      V[i] = 10*i+1;
    }

    getfem::vtk_export out("cell_vectors.vtk", true);
    out.set_header("ala");
    out.exporting(mesh);
    out.write_cell_data(V, "dummy", 3);

    return EXIT_SUCCESS;
  } GMM_STANDARD_CATCH_ERROR;
 
  return EXIT_FAILURE;
}
_______________________________________________
Getfem-users mailing list
[email protected]
https://mail.gna.org/listinfo/getfem-users

Reply via email to