bp1.cpp (e9e07e3c173f1020aad3c9d07d1bbff6c36fa923) bp1.cpp (9647a07ed4cccf5520ee61cfc49faed91542e405)
1// libCEED + MFEM Example: BP1
2//
3// This example illustrates a simple usage of libCEED with the MFEM (mfem.org)
4// finite element library.
5//
6// The example reads a mesh from a file and solves a simple linear system with a
7// mass matrix (L2-projection of a given analytic function provided by
8// 'solution'). The mass matrix required for performing the projection is

--- 127 unchanged lines hidden (view full) ---

136 }
137 cg.SetOperator(mass);
138
139 mfem::GridFunction sol(fespace);
140 sol = 0.0;
141 cg.Mult(b, sol);
142
143 // 9. Compute and print the L2 projection error.
1// libCEED + MFEM Example: BP1
2//
3// This example illustrates a simple usage of libCEED with the MFEM (mfem.org)
4// finite element library.
5//
6// The example reads a mesh from a file and solves a simple linear system with a
7// mass matrix (L2-projection of a given analytic function provided by
8// 'solution'). The mass matrix required for performing the projection is

--- 127 unchanged lines hidden (view full) ---

136 }
137 cg.SetOperator(mass);
138
139 mfem::GridFunction sol(fespace);
140 sol = 0.0;
141 cg.Mult(b, sol);
142
143 // 9. Compute and print the L2 projection error.
144 double err_l2 = sol.ComputeL2Error(sol_coeff);
144 if (!test) {
145 if (!test) {
145 std::cout << "L2 projection error: " << sol.ComputeL2Error(sol_coeff)
146 std::cout << "L2 projection error: " << err_l2
146 << std::endl;
147 } else {
148 if (fabs(sol.ComputeL2Error(sol_coeff))>2e-4) {
147 << std::endl;
148 } else {
149 if (fabs(sol.ComputeL2Error(sol_coeff))>2e-4) {
149 std::cout << "Error too large" << std::endl;
150 std::cout << "Error too large: " << err_l2 << std::endl;
150 }
151 }
152
153 // 10. Open a socket connection to GLVis and send the mesh and solution for
154 // visualization.
155 if (visualization) {
156 char vishost[] = "localhost";
157 int visport = 19916;

--- 12 unchanged lines hidden ---
151 }
152 }
153
154 // 10. Open a socket connection to GLVis and send the mesh and solution for
155 // visualization.
156 if (visualization) {
157 char vishost[] = "localhost";
158 int visport = 19916;

--- 12 unchanged lines hidden ---