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;
A general function coefficient.
Class for grid function - Vector with associated FE space.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
This class implements the serial variational transfer between finite element spaces....
void SetVerbose(const bool verbose)
Expose process details with verbose output.
void AddMortarIntegrator(const std::shared_ptr< MortarIntegrator > &integrator)
This method must be called before Assemble or Transfer. It will assemble the operator in all intersec...
bool Transfer(const GridFunction &src_fun, GridFunction &dest_fun)
transfer a function from source to destination. if the transfer is to be performed multiple times use...
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
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...
A general vector function coefficient.
void plot(mfem::Mesh &mesh, mfem::GridFunction &x, std::string title)
void vector_fun(const mfem::Vector &x, mfem::Vector &f)
double example_fun(const mfem::Vector &x)
void check_options(mfem::OptionsParser &args)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void InitTransfer(int argc, char *argv[])
Initializes the par_moonolith library. It also calls MPI_Init.
int FinalizeTransfer()
Finalize the par_moonolith library.