Peano
Loading...
Searching...
No Matches
parseTest4.py
Go to the documentation of this file.
1import numpy as np
2from postProcess import parse_patch_file, reorder_array
3
4if __name__ == "__main__":
5 v_cg_random = parse_patch_file("Test4CG.value-0.peano-patch-file", "CG") # CG random distribution
6 vector2 = parse_patch_file("Test4CG.vector2-1.peano-patch-file", "CG") # vector2 = R * v_dg_random
7
8 v_dg_random = parse_patch_file("Test4DG.solution-0.peano-patch-file", "DG") # v_dg_random
9 vector1 = parse_patch_file("Test4DG.vector1-1.peano-patch-file", "DG") # vector1 = P * v_cg_random
10
11 # Reorder vector2 in accordance with v_cg_random
12 vector2 = reorder_array(v_cg_random, vector2)
13
14 # Compute v_cg_random * R * v_dg_random = v_cg_random * vector2
15 dot_prod_cg = np.dot(v_cg_random[:,2], vector2[:,2])
16
17 # Compute dot product v_dg_random * P * v_cg_random = v_dg_random * vector1
18 # Iterate over all cell keys in the dictionary
19 # keys are coordinates of the left-bottom vertex of each cell
20 dot_prod_dg = 0.0
21 for key in v_dg_random.keys():
22 cell_values_random = np.asarray(v_dg_random[key])
23 # Access the same key in vector1
24 cell_values_vector1 = np.asarray(vector1[key])
25
26 dot_prod_dg += np.dot(cell_values_random, cell_values_vector1)
27
28 # Check | v_cg_random * R * v_dg_random - v_dg_random * P * v_cg_random | < eps
29 diff = abs(dot_prod_cg - dot_prod_dg)
30 print(f'{diff}')