26int main(
int argc,
char *argv[])
31 const char *source_mesh_file =
"../../data/inline-tri.mesh";
32 const char *destination_mesh_file =
"../../data/inline-quad.mesh";
34 int src_n_refinements = 0;
35 int dest_n_refinements = 0;
36 int source_fe_order = 1;
37 int dest_fe_order = 1;
38 bool visualization =
true;
39 bool use_vector_fe =
false;
43 args.
AddOption(&source_mesh_file,
"-s",
"--source_mesh",
44 "Mesh file to use for src.");
45 args.
AddOption(&destination_mesh_file,
"-d",
"--destination_mesh",
46 "Mesh file to use for dest.");
47 args.
AddOption(&src_n_refinements,
"-sr",
"--source_refinements",
48 "Number of src refinements");
49 args.
AddOption(&dest_n_refinements,
"-dr",
"--dest_refinements",
50 "Number of dest refinements");
51 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
53 "Enable or disable GLVis visualization.");
54 args.
AddOption(&source_fe_order,
"-so",
"--source_fe_order",
55 "Order of the src finite elements");
56 args.
AddOption(&dest_fe_order,
"-do",
"--dest_fe_order",
57 "Order of the dest finite elements");
58 args.
AddOption(&verbose,
"-verb",
"--verbose",
"--no-verb",
"--no-verbose",
59 "Enable/Disable verbose output");
60 args.
AddOption(&use_vector_fe,
"-vfe",
"--use_vector_fe",
"-no-vfe",
61 "--no-vector_fe",
"Use vector finite elements");
65 shared_ptr<Mesh> src_mesh, dest_mesh;
69 imesh.open(destination_mesh_file);
72 dest_mesh = make_shared<Mesh>(imesh, 1, 1);
77 mfem::err <<
"WARNING: Destination mesh file not found: "
78 << destination_mesh_file <<
"\n"
79 <<
"Using default 2D quad mesh.";
84 const int dim = dest_mesh->Dimension();
87 dest_mesh->GetBoundingBox(box_min, box_max);
91 imesh.open(source_mesh_file);
95 src_mesh = make_shared<Mesh>(imesh, 1, 1);
100 mfem::err <<
"WARNING: Source mesh file not found: " << source_mesh_file
102 <<
"Using default box mesh.\n";
115 for (
int i = 0; i < src_mesh->GetNV(); ++i)
117 double *v = src_mesh->GetVertex(i);
119 for (
int d = 0; d <
dim; ++d)
126 for (
int i = 0; i < src_n_refinements; ++i)
128 src_mesh->UniformRefinement();
131 for (
int i = 0; i < dest_n_refinements; ++i)
133 dest_mesh->UniformRefinement();
136 shared_ptr<FiniteElementCollection> src_fe_coll, dest_fe_coll;
141 make_shared<RT_FECollection>(source_fe_order, src_mesh->Dimension());
143 make_shared<RT_FECollection>(dest_fe_order, dest_mesh->Dimension());
148 make_shared<L2_FECollection>(source_fe_order, src_mesh->Dimension());
150 make_shared<L2_FECollection>(dest_fe_order, dest_mesh->Dimension());
154 make_shared<FiniteElementSpace>(src_mesh.get(), src_fe_coll.get());
157 make_shared<FiniteElementSpace>(dest_mesh.get(), dest_fe_coll.get());
195 if (assembler.
Transfer(src_fun, dest_fun))
215 mfem::out <<
"l2 error: src: " << src_err <<
", dest: " << dest_err
218 plot(*src_mesh, src_fun,
"source");
219 plot(*dest_mesh, dest_fun,
"destination");
224 mfem::out <<
"No intersection -> no transfer!" << std::endl;
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...