32int main(
int argc,
char *argv[])
34 MPI_Init(&argc, &argv);
38 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
39 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
44 const char *source_mesh_file =
"../../data/inline-tri.mesh";
45 const char *destination_mesh_file =
"../../data/inline-quad.mesh";
47 int src_n_refinements = 0;
48 int dest_n_refinements = 0;
49 int source_fe_order = 1;
50 int dest_fe_order = 1;
51 bool visualization =
true;
52 bool use_vector_fe =
false;
54 bool assemble_mass_and_coupling_together =
true;
57 args.
AddOption(&source_mesh_file,
"-s",
"--source_mesh",
58 "Mesh file to use for src.");
59 args.
AddOption(&destination_mesh_file,
"-d",
"--destination_mesh",
60 "Mesh file to use for dest.");
61 args.
AddOption(&src_n_refinements,
"-sr",
"--source_refinements",
62 "Number of src refinements");
63 args.
AddOption(&dest_n_refinements,
"-dr",
"--dest_refinements",
64 "Number of dest refinements");
65 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
67 "Enable or disable GLVis visualization.");
68 args.
AddOption(&source_fe_order,
"-so",
"--source_fe_order",
69 "Order of the src finite elements");
70 args.
AddOption(&dest_fe_order,
"-do",
"--dest_fe_order",
71 "Order of the dest finite elements");
72 args.
AddOption(&verbose,
"-verb",
"--verbose",
"--no-verb",
"--no-verbose",
73 "Enable/Disable verbose output");
74 args.
AddOption(&use_vector_fe,
"-vfe",
"--use_vector_fe",
"-no-vfe",
75 "--no-vector_fe",
"Use vector finite elements (Experimental)");
76 args.
AddOption(&assemble_mass_and_coupling_together,
"-act",
77 "--assemble_mass_and_coupling_together",
"-no-act",
78 "--no-assemble_mass_and_coupling_together",
79 "Assemble mass and coupling operators together (better for non-affine elements)");
83 shared_ptr<Mesh> src_mesh, dest_mesh;
87 imesh.open(destination_mesh_file);
90 dest_mesh = make_shared<Mesh>(imesh, 1, 1);
96 mfem::err <<
"WARNING: Destination mesh file not found: "
97 << destination_mesh_file <<
"\n"
98 <<
"Using default 2D quad mesh.";
103 const int dim = dest_mesh->Dimension();
108 dest_mesh->GetBoundingBox(box_min, box_max);
112 imesh.open(source_mesh_file);
116 src_mesh = make_shared<Mesh>(imesh, 1, 1);
122 mfem::err <<
"WARNING: Source mesh file not found: " << source_mesh_file
124 <<
"Using default box mesh.\n";
137 for (
int i = 0; i < src_mesh->GetNV(); ++i)
139 double *v = src_mesh->GetVertex(i);
141 for (
int d = 0; d <
dim; ++d)
148 for (
int i = 0; i < src_n_refinements; ++i)
150 src_mesh->UniformRefinement();
153 for (
int i = 0; i < dest_n_refinements; ++i)
155 dest_mesh->UniformRefinement();
158 auto p_src_mesh = make_shared<ParMesh>(MPI_COMM_WORLD, *src_mesh);
159 auto p_dest_mesh = make_shared<ParMesh>(MPI_COMM_WORLD, *dest_mesh);
161 shared_ptr<FiniteElementCollection> src_fe_coll, dest_fe_coll;
166 make_shared<RT_FECollection>(source_fe_order, src_mesh->Dimension());
168 make_shared<RT_FECollection>(dest_fe_order, dest_mesh->Dimension());
173 make_shared<L2_FECollection>(source_fe_order, src_mesh->Dimension());
175 make_shared<L2_FECollection>(dest_fe_order, dest_mesh->Dimension());
179 make_shared<ParFiniteElementSpace>(p_src_mesh.get(), src_fe_coll.get());
182 make_shared<ParFiniteElementSpace>(p_dest_mesh.get(), dest_fe_coll.get());
209 assemble_mass_and_coupling_together);
221 if (assembler.
Transfer(src_fun, dest_fun))
242 mfem::out <<
"l2 error: src: " << src_err <<
", dest: " << dest_err
246 plot(*p_src_mesh, src_fun,
"source");
247 plot(*p_dest_mesh, dest_fun,
"destination");
252 mfem::out <<
"No intersection no transfer!" << std::endl;
257 return MPI_Finalize();
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...