PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
testFe.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#include "testFeLib.h"
12#include <PeriDEMConfig.h>
13#include <iostream>
14#include "util/io.h" // InputParser class
15#include "util/parallelUtil.h" // MPI-related functions
16#include <format>
17
18int main(int argc, char *argv[]) {
19
20 // init parallel
21 util::parallel::initMpi(argc, argv);
22 int mpiSize = util::parallel::mpiSize(), mpiRank = util::parallel::mpiRank();
23 util::io::print(std::format("Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
25
26 util::io::InputParser input(argc, argv);
27
28 if (input.cmdOptionExists("-h") or !input.cmdOptionExists("-i")) {
29 // print help
30 std::cout << argv[0] << " (Version " << MAJOR_VERSION << "."
31 << MINOR_VERSION << "." << UPDATE_VERSION
32 << ") -i <data-filepath>" << std::endl;
33 exit(EXIT_FAILURE);
34 }
35
36 // read input file
37 std::string filepath = input.getCmdOption("-i");
38
43
44 //
45 // test quadrature method for triangle
46 //
47 {
48 // test quad data for line element
49 for (size_t i = 1; i < 6; i++)
50 test::testLineElem(i, filepath);
51
52 // test quad data for triangle element
53 for (size_t i = 1; i < 6; i++)
54 test::testTriElem(i, filepath);
55
56 // test quad data for quadrangle element
57 for (size_t i = 1; i < 6; i++)
58 test::testQuadElem(i, filepath);
59
60 // test quad data for triangle element
61 for (size_t i = 1; i < 4; i++)
62 test::testTetElem(i, filepath);
63
64 // test additional time in computing quad points instead of storing it
65 if (false) {
66 for (size_t i = 1; i < 6; i++) {
67 test::testTriElemTime(i, 1000);
68
69 test::testTriElemTime(i, 10000);
70
71 test::testTriElemTime(i, 100000);
72
73 test::testTriElemTime(i, 1000000);
74 }
75 }
76 }
77
78 return EXIT_SUCCESS;
79}
int main(int argc, char *argv[])
Definition main.cpp:29
Input command line argument parser.
Definition inputParser.h:28
bool cmdOptionExists(const std::string &option) const
Check if argument exists.
Definition inputParser.h:60
const std::string & getCmdOption(const std::string &option) const
Get value of argument specified by key.
Definition inputParser.h:45
void testPatchTriDistorted()
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
void testTriElemTime(size_t n, size_t N)
Computes the time needed when quad data for elements are stored and when they are computed as and whe...
void testLineElem(size_t n, std::string filepath)
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
void testTetElem(size_t n, std::string filepath)
Perform test on quadrature points on tetrahedral elements.
void testQuadElem(size_t n, std::string filepath)
Perform test on quadrature points on quadrangle elements.
void testPatchTet()
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
void testPatchQuad()
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
void testPatchTri()
Perform test on quadrature points on line elements (NOT IMPLEMENTED)
void testTriElem(size_t n, std::string filepath)
Perform test on quadrature points on triangle elements.
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
Definition io.h:171
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor