36int main (
int argc,
char *argv[])
39 const char *mesh_file_1 =
"triple-pt-1.mesh";
40 const char *mesh_file_2 =
"triple-pt-2.mesh";
41 const char *sltn_file_1 =
"triple-pt-1.gf";
42 const char *sltn_file_2 =
"triple-pt-2.gf";
43 bool visualization =
true;
49 args.
AddOption(&mesh_file_1,
"-m1",
"--mesh1",
50 "Mesh file for solution 1.");
51 args.
AddOption(&mesh_file_2,
"-m2",
"--mesh2",
52 "Mesh file for solution 2.");
53 args.
AddOption(&sltn_file_1,
"-s1",
"--solution1",
54 "Grid function for solution 1.");
55 args.
AddOption(&sltn_file_2,
"-s2",
"--solution2",
56 "Grid function for solution 2.");
57 args.
AddOption(&pts_cnt_1D,
"-p",
"--points1D",
58 "Number of comparison points in one direction");
59 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
61 "Enable or disable GLVis visualization.");
62 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
72 Mesh mesh_1(mesh_file_1, 1, 1,
false);
73 Mesh mesh_2(mesh_file_2, 1, 1,
false);
75 MFEM_VERIFY(
dim > 1,
"GSLIB requires a 2D or a 3D mesh" );
80 const int mesh_poly_deg = mesh_1.
GetNodes()->FESpace()->GetElementOrder(0);
81 cout <<
"Mesh curvature: "
82 << mesh_1.
GetNodes()->OwnFEC()->Name() <<
" " << mesh_poly_deg << endl;
92 MFEM_VERIFY(mesh_poly_deg > 0,
"The order of the mesh must be positive.");
94 cout <<
"Generating equidistant points for:\n"
95 <<
" x in [" << pos_min(0) <<
", " << pos_max(0) <<
"]\n"
96 <<
" y in [" << pos_min(1) <<
", " << pos_max(1) <<
"]\n";
99 cout <<
"z in [" << pos_min(2) <<
", " << pos_max(2) <<
"]\n";
102 ifstream mat_stream_1(sltn_file_1), mat_stream_2(sltn_file_2);
115 cout <<
"Unable to connect to GLVis server at "
116 <<
vishost <<
':' << visport << endl;
121 sout1 <<
"solution\n" << mesh_1 << func_1
122 <<
"window_title 'Solution 1'"
123 <<
"window_geometry 0 0 600 600";
124 if (
dim == 2) { sout1 <<
"keys RmjAc"; }
125 if (
dim == 3) { sout1 <<
"keys mA\n"; }
129 sout2 <<
"solution\n" << mesh_2 << func_2
130 <<
"window_title 'Solution 2'"
131 <<
"window_geometry 600 0 600 600";
132 if (
dim == 2) { sout2 <<
"keys RmjAc"; }
133 if (
dim == 3) { sout2 <<
"keys mA\n"; }
141 const int pts_cnt = pow(pts_cnt_1D,
dim);
150 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
151 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
161 vxyz(i) = pos_min(0) + ip.
x * (pos_max(0)-pos_min(0));
162 vxyz(pts_cnt + i) = pos_min(1) + ip.
y * (pos_max(1)-pos_min(1));
163 vxyz(2*pts_cnt + i) = pos_min(2) + ip.
z * (pos_max(2)-pos_min(2));
168 Vector interp_vals_1(pts_cnt), interp_vals_2(pts_cnt);
171 finder1.Interpolate(vxyz, func_1, interp_vals_1);
177 double avg_diff = 0.0, max_diff = 0.0, diff_p;
178 for (
int p = 0;
p < pts_cnt;
p++)
180 diff_p = fabs(interp_vals_1(
p) - interp_vals_2(
p));
182 if (diff_p > max_diff) { max_diff = diff_p; }
187 double *nd1 = n1->
GetData(), *nd2 = n2->GetData();
188 double avg_dist = 0.0;
189 const int node_cnt = n1->
Size() /
dim;
190 if (n1->
Size() == n2->Size())
192 for (
int i = 0; i < node_cnt; i++)
195 for (
int d = 0; d <
dim; d++)
197 const int j = i + d * node_cnt;
198 diff_i += (nd1[j] - nd2[j]) * (nd1[j] - nd2[j]);
200 avg_dist += sqrt(diff_i);
202 avg_dist /= node_cnt;
204 else { avg_dist = -1.0; }
206 std::cout <<
"Avg position difference: " << avg_dist << std::endl
207 <<
"Searched " << pts_cnt <<
" points.\n"
208 <<
"Max diff: " << max_diff << std::endl
209 <<
"Avg diff: " << avg_diff << std::endl;
217 const int nodes_cnt = vxyz.
Size() /
dim;
218 interp_vals_2.
SetSize(nodes_cnt);
221 for (
int n = 0; n < nodes_cnt; n++)
223 diff(n) = fabs(diff(n) - interp_vals_2(n));
232 sout3 <<
"solution\n" << mesh_1 << diff
233 <<
"window_title 'Difference'"
234 <<
"window_geometry 1200 0 600 600";
235 if (
dim == 2) { sout3 <<
"keys RmjAcpppppppppppppppppppppp"; }
236 if (
dim == 3) { sout3 <<
"keys mA\n"; }
245 const double vol_diff = diff * lf;
246 std::cout <<
"Vol diff: " << vol_diff << std::endl;
@ ClosedUniform
Nodes: x_i = i/(n-1), i=0,...,n-1.
A coefficient that is constant across space and time.
Class for domain integration .
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points....
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
Interpolation of field values at prescribed reference space positions.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
virtual void ProjectDiscCoefficient(std::variant< Coefficient *, VectorCoefficient * > coeff, Array< int > &dof_attr)
Project a discontinuous (vector) coefficient as a grid function on a continuous finite element space....
FiniteElementSpace * FESpace()
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Arbitrary order L2 elements in 3D on a cube.
Arbitrary order L2 elements in 2D on a square.
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
int Dimension() const
Dimension of the reference space used within the elements.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1, int pyr_type=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void GetNodes(Vector &node_coord) const
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
real_t p(const Vector &x, real_t t)