39void check(
bool ok,
const std::string &what) {
43 std::cerr <<
" FAIL: " << what <<
"\n";
47void checkClose(
double got,
double want,
const std::string &what,
48 double tol = 1.0e-12) {
49 check(std::abs(got - want) <= tol * std::max(1.0, std::abs(want)),
50 what +
" (got " + std::to_string(got) +
", want " +
51 std::to_string(want) +
")");
56 check(j.contains(key), key +
" present");
58 check(j.at(key).is_object(), key +
" is an object, not an array");
62 std::cout <<
"ModelDeck\n";
64 json{{
"Dimension", 3},
67 {
"Discretization_Type",
json{{
"Spatial",
"finite_difference"}, {
"Time",
"central_difference"}}},
68 {
"Populate_ElementNodeConnectivity",
false},
69 {
"Quad_Approximation_Order", 3},
70 {
"Particle_Sim_Type",
"Single_Particle"},
74 check(d.d_dim == 3,
"Dimension round-trips");
75 checkClose(d.d_tFinal, 0.25,
"Final_Time round-trips");
76 check(d.d_Nt == 500,
"Time_Steps round-trips");
77 check(!d.d_populateElementNodeConnectivity,
78 "Populate_ElementNodeConnectivity round-trips");
79 check(d.d_quadOrder == 3,
"Quad_Approximation_Order round-trips");
80 check(d.d_particleSimType ==
"Single_Particle",
81 "Particle_Sim_Type round-trips");
82 check(d.d_seed == 7,
"Seed round-trips");
83 checkClose(d.d_dt, 0.25 / 500.,
"dt derived from Final_Time / Time_Steps");
87 std::cout <<
"OutputDeck\n";
89 json{{
"File_Format",
"vtu"},
91 {
"Tags", std::vector<std::string>({
"Displacement",
"Damage_Z"})},
92 {
"Output_Interval", 25},
94 {
"Perform_FE_Out",
false},
95 {
"Compress_Type",
"zlib"},
96 {
"Perform_Out",
true},
97 {
"Test_Output_Interval", 5},
99 {
"PVD_Collection",
true}});
102 check(d.d_path ==
"out/",
"Path round-trips");
103 check(d.d_dtOut == 25,
"Output_Interval round-trips");
104 check(d.d_debug == 1,
"Debug round-trips");
105 check(!d.d_performFEOut,
"Perform_FE_Out round-trips");
106 check(d.d_dtTestOut == 5,
"Test_Output_Interval round-trips");
107 check(d.d_tagPPFile ==
"3",
"Tag_PP round-trips");
108 check(d.d_pvdCollection,
"PVD_Collection round-trips");
109 check(d.d_outTags.size() == 2,
"Tags round-trip");
113 std::cout <<
"MaterialDeck\n";
116 json{{
"Type",
"PMBBond"},
117 {
"Is_Plane_Strain",
true},
124 {
"Compute_From_Classical",
true},
125 {
"Influence_Function",
json{{
"Type", 1}}}});
128 check(d.d_materialType ==
"PMBBond",
"Type round-trips");
129 check(d.d_isPlaneStrain,
"Is_Plane_Strain round-trips (writer/reader key)");
130 checkClose(d.d_horizon, 6.0e-4,
"Horizon round-trips");
131 checkClose(d.d_density, 1200.,
"Density round-trips");
132 check(d.d_influenceFnType == 1,
"Influence_Function.Type round-trips");
136 json{{
"Type",
"PDState"},
137 {
"Is_Plane_Strain",
false},
143 {
"Compute_From_Classical",
true},
144 {
"Influence_Function",
json{{
"Type", 0}}}});
147 check(!d2.d_isPlaneStrain,
"Is_Plane_Strain false round-trips");
151 std::cout <<
"MeshDeck\n";
156 check(d.d_createMesh,
"bare Mesh_Size still means CreateMesh");
157 checkClose(d.d_hMeshing, 1.0e-4,
"Mesh_Size round-trips");
163 check(d2.d_filename ==
"mesh.msh",
"File round-trips");
164 check(!d2.d_createMesh,
"a plain File does not request mesh creation");
168 json{{
"File",
"mesh.msh"},
169 {
"Mesh_Size", 2.0e-4},
170 {
"Create_Mesh",
true},
172 {
"Write_Mesh_File",
false},
173 {
"Void_Regions", {{0., 0., 0., 1., 1., 1.}}}});
176 check(d3.d_filename ==
"mesh.msh",
"File round-trips with CreateMesh");
177 check(d3.d_createMesh,
"CreateMesh.Flag round-trips");
178 check(d3.d_createMeshInfo ==
"uniform",
"CreateMesh.Info round-trips");
179 check(!d3.d_writeMeshFile,
"Write_Mesh_File round-trips");
180 checkClose(d3.d_hMeshing, 2.0e-4,
"CreateMesh.Mesh_Size round-trips");
181 check(d3.d_voidRegions.size() == 1,
"Void_Regions round-trip");
185 std::cout <<
"ContactPairDeck\n";
187 json{{
"Contact_Radius_Factor", 0.95},
189 {
"Damping_On",
true},
191 {
"Friction_On",
true},
192 {
"Friction_Coeff", 0.5},
194 {
"Beta_n_Factor", 100.},
198 check(d.d_computeContactR,
"Contact_Radius_Factor round-trips");
199 checkClose(d.d_contactR, 0.95,
"contact radius factor value");
201 checkClose(d.d_eps, 0.9,
"Epsilon round-trips");
202 check(d.d_frictionOn,
"Friction_On round-trips");
203 checkClose(d.d_mu, 0.5,
"Friction_Coeff round-trips");
204 checkClose(d.d_KnFactor, 2.0,
"Kn_Factor round-trips");
205 checkClose(d.d_betanFactor, 100.,
"Beta_n_Factor round-trips");
209 json{{
"Contact_Radius_Factor", 0.95},
211 {
"Damping_On",
false},
213 {
"Friction_On",
false},
214 {
"Friction_Coeff", 0.},
216 {
"Beta_n_Factor", 100.},
220 check(!d2.d_dampingOn,
"Damping_On false round-trips");
221 checkClose(d2.d_betanFactor, 0.,
"Beta_n_Factor zeroed when damping is off");
225 std::cout <<
"ContactDeck\n";
227 check(j.at(
"Sets") == 2,
"Sets count");
228 for (
const auto &key : {
"Set_1_1",
"Set_1_2",
"Set_2_2"})
229 check(j.contains(key), std::string(
"pair ") + key +
" present");
230 check(j.contains(
"Damping_Law"),
"Damping_Law present");
231 check(j.contains(
"Correct_Volume"),
"Correct_Volume present");
235 std::cout <<
"PNeighborDeck / PGenDeck\n";
237 json{{
"Update_Criteria",
"simple_all"},
238 {
"Search_Factor", 8.},
239 {
"Search_Interval", 5},
240 {
"Near_Bd_Nodes_Tol", 0.25}});
243 check(d.d_updateCriteria ==
"simple_all",
"Update_Criteria round-trips");
244 checkClose(d.d_sFactor, 8.,
"Search_Factor round-trips");
245 check(d.d_neighUpdateInterval == 5,
"Search_Interval round-trips");
246 checkClose(d.d_nearBdNodesTol, 0.25,
"Near_Bd_Nodes_Tol round-trips");
249 check(jg.at(
"Method") ==
"From_File",
"Method present");
253 std::cout <<
"TestDeck\n";
256 check(empty.empty(),
"an unnamed test yields an empty block");
260 check(j.is_object(),
"Test block is an object, not an array");
266 for (
const std::string name : {
"Compressive_Test",
"compressive_test"}) {
268 json{{
"Test_Name", name},
270 json{{
"Wall_Id", 13}, {
"Wall_Force_Direction", 2}}}});
277 name +
": Wall_Force_Direction round-trips");
282 std::cout <<
"BCBaseDeck\n";
290 json{{
"Type",
"Displacement_BC"},
291 {
"Particle_List", {0, 1}},
292 {
"Particle_Exclude_List", {2}},
293 {
"Direction", {1, 2}},
294 {
"Zero_Displacement",
true},
296 json{{
"Type",
"linear"},
297 {
"Parameters", std::vector<double>{0.5}}}},
299 json{{
"Type",
"constant"},
300 {
"Parameters", std::vector<double>{}}}}},
303 if (j.contains(
"Region"))
307 check(j.at(
"Time_Function").contains(
"Type"),
308 "Time_Function.Type survives alongside Parameters");
309 check(j.at(
"Time_Function").contains(
"Parameters"),
310 "Time_Function.Parameters present");
316 "Region geometry round-trips");
320 check(d.
d_pList.size() == 2,
"Particle_List round-trips");
328 {
"Particle_List", {1}},
329 {
"IC_Type",
"Constant_Velocity"},
330 {
"IC_Vector", {0., -2.5, 0.}}});
334 check(dic.
d_icType ==
"Constant_Velocity",
"IC type round-trips");
339 std::cout <<
"BCDeck\n";
341 json{{
"Displacement_BC_Sets", 1},
345 check(j.at(
"Force_BC").contains(
"Gravity"),
"Gravity present");
357void run(
void (*fn)(),
const std::string &name) {
360 }
catch (
const std::exception &e) {
363 std::cerr <<
" FAIL: " << name <<
" threw: " << e.what() <<
"\n";
370 std::cout <<
"Deck factory round-trip\n"
371 <<
"-----------------------\n";
383 std::cout <<
"-----------------------\n"
386 std::cerr <<
g_failures <<
" check(s) failed\n";
nlohmann::ordered_json json
void checkIsObject(const json &j, const std::string &key)
void testNeighborAndGenDecks()
void check(bool ok, const std::string &what)
void testContactPairDeck()
void checkClose(double got, double want, const std::string &what, double tol=1.0e-12)
void createGeomObject(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< std::string > &vec_type, const std::vector< std::string > &vec_flag, std::shared_ptr< geom::GeomObject > &obj, bool perform_check)
Input data for geometrical objects.
std::vector< double > d_geomParams
Zone parameters.
std::string d_geomName
Zone type.
User-input data for particle neighbor search.
std::vector< size_t > d_pList
List of particles (if any)
std::vector< size_t > d_pNotList
List of particles to not include (if any)
geom::GeomData d_regionGeomData
Region geometry (if any)
void readFromJson(const json &j, std::string type)
Reads from json object.
std::vector< double > d_timeFnParams
List of parameters for function wrt time.
static json getExampleJson(const json &given=json::object(), const geom::GeomData *region=nullptr)
Returns example JSON object for ModelDeck configuration.
std::vector< size_t > d_direction
List of dofs on which this bc will be applied.
std::string d_icType
Type.
bool d_isDisplacementZero
Specify if this bc corresponds to zero displacement condition.
bool d_isRegionActive
Flag that indicates if region-based application of boundary condition is active. So cases of 'region'...
util::Point d_icVec
Initial velocity vector.
std::string d_timeFnType
Name of the formula with respect to time.
std::string d_spatialFnType
Name of the formula of with respect to spatial coordinate.
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
Structure to read and store material related data.
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
void readFromJson(const json &j)
Reads from json object.
Structure to read and store mesh related input data.
void readFromJson(const json &j)
static json getExampleJson(const json &given=json::object())
Returns example JSON object for ModelDeck configuration.
Structure to read and store model related input data.
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
Structure to read input data for performing simulation output.
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const std::string &)=delete
Returns example JSON object for ModelDeck configuration.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
User-input data for particle neighbor search.
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
Structure to read and store test-related input data.
size_t d_particleForceDirectionCompressiveTest
if it is a compressive test, specify force direction on wall
void readFromJson(const json &j)
Reads from json object.
static json getExampleJson(const json &given=json::object())
Returns the block with the given fields set.
std::string d_testName
Specify test name (if any)
size_t d_particleIdCompressiveTest
if it is a compressive test, specify wall id and direction
A structure to represent 3d vectors.
double d_y
the y coordinate
std::vector< double > toVec() const
Returns coordinate in stl form.