DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_basic_cfv.py
Go to the documentation of this file.
1from DNDSR import DNDS, Geom, CFV
2from DNDSR.Geom.utils import *
3import numpy as np
4import json
5
6
8 print(CFV.tUDof_1)
9 # CFV.VariationalReconstruction_2()
10
11 mpi = DNDS.MPIInfo()
12 mpi.setWorld()
13
14 meshFile = os.path.join(
15 os.path.dirname(__file__), "..", "..", "data", "mesh", "NACA0012_H2.cgns"
16 )
17
18 meshFile = os.path.join(
19 os.path.dirname(__file__), "..", "..", "data", "mesh", "Uniform_3x3.cgns"
20 )
21
22 mesh, reader, name2Id = create_mesh_from_CGNS(
23 meshFile,
24 mpi,
25 2,
26 periodic_geometry={
27 "translation1": [3, 0, 0],
28 "translation2": [0, 3, 0],
29 },
30 )
31
32 meshBnd, readerBnd = create_bnd_mesh(mesh)
33
34 vfvSettings = json.loads(
35 "".join(
36 [
37 line if not line.strip().startswith("//") else ""
38 for line in """{
39 "maxOrder": 3,
40 "intOrder": 5,
41 "intOrderVR": 5,
42 "cacheDiffBase": true,
43 "jacobiRelax": 1.0,
44 "SORInstead": false,
45 "smoothThreshold": 1e-3,
46 "WBAP_nStd": 10.0,
47 "normWBAP": false,
48 "subs2ndOrder": 1,
49 "subs2ndOrderGGScheme": 0,
50 "baseSettings": {
51 "localOrientation": false,
52 "anisotropicLengths": false
53 },
54 "functionalSettings": {
55 // "scaleType": "MeanAACBB",
56 "dirWeightScheme": "HQM_OPT",
57 // "dirWeightScheme": "ManualDirWeight",
58 // "manualDirWeights": [
59 // 1.0,
60 // 1,
61 // 0,
62 // 0
63 // ],
64 "geomWeightScheme": "HQM_SD",
65 "geomWeightPower": 0.5,
66 "geomWeightBias": 1,
67 // "geomWeightScheme": "SD_Power",
68 // "geomWeightPower1": -0.5,
69 // "geomWeightPower2": 0.5,
70 // "useAnisotropicFunctional": true,
71 // // "anisotropicType": "InertiaCoordBB",
72 // "inertiaWeightPower": 0,
73 // "scaleMultiplier": 1,
74 "_tail": 0
75 }
76 }
77 """.splitlines()
78 ]
79 )
80 )
81 print(vfvSettings)
82
83 vfv = CFV.VariationalReconstruction_2(mpi, mesh)
84 vfv.ParseSettings(vfvSettings)
85 vfv.SetPeriodicTransformationsNoOp()
86
87 bcid_2_bcweight_map = {}
88 for name, id in name2Id.n2id_map.items():
89 # if name == "WALL":
90 bcid_2_bcweight_map[(id, 0)] = 1.0
91 if name.startswith("PERIODIC"):
92 bcid_2_bcweight_map[(id, 0)] = 1.0
93 bcid_2_bcweight_map[(id, 1)] = 1.0
94 bcid_2_bcweight_map[(id, 2)] = 1.0
95 bcid_2_bcweight_map[(id, 3)] = 1.0
96 vfv.ConstructMetrics()
97 vfv.ConstructBaseAndWeight_map(bcid_2_bcweight_map)
98 vfv.ConstructRecCoeff()
99
100 u = CFV.tUDof_D()
101 rhs = CFV.tUDof_D()
102 uRec, uRecNew = [CFV.tURec_D() for _ in range(2)]
103 for u_ in [u, rhs]:
104 vfv.BuildUDof_D(u_, 1)
105 for uRec_ in [uRec, uRecNew]:
106 vfv.BuildURec_D(uRec_, 1)
107 for i in range(mesh.NumCell()):
108 u_i = np.array(u[i], copy=False)
109 u_i[0] = vfv.GetCellBary(i)[0]
110 print(vfv.GetCellBary(i))
111 print(np.array(u[i], copy=False))
112
113 print(
114 f"rank [{mpi.rank}], u.Size() = {u.Size()}, u.father.Size() = {u.father.Size()}"
115 + "\n"
116 + f"{u.trans.mpi}"
117 )
118 eval = CFV.ModelEvaluator(mesh, vfv, {}, 1)
119 eval.EvaluateRHS(rhs, u, uRec, 0.0)
120 for i in range(mesh.NumCell()):
121 print(np.array(rhs[i], copy=False))
122 FBoundary = eval.get_FBoundary(0.5)
123 eval.DoReconstructionIter(uRec, uRecNew, u, 0.0, False)
124 for i in range(mesh.NumCell()):
125 print(np.array(uRec[i], copy=False))
126
127
128if __name__ == "__main__":
129 test_basic()
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Definition MPI.hpp:215