59 lines
2.3 KiB
C++
59 lines
2.3 KiB
C++
#ifndef FESA_TESTS_SOLID_OUTPUT_FIXTURE_H_
|
|
#define FESA_TESTS_SOLID_OUTPUT_FIXTURE_H_
|
|
#include <atomic>
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <string>
|
|
namespace solid_output_test {
|
|
inline std::string Deck(unsigned procedure) {
|
|
std::string s =
|
|
"*Part,name=P\n*Node\n10,0,0,0\n20,1,0,0\n30,1,1,0\n40,0,1,0\n"
|
|
"50,0,0,1\n60,1,0,1\n70,1,1,1\n80,0,1,1\n"
|
|
"*Element,type=C3D8,elset=Solid\n99,10,20,30,40,50,60,70,80\n"
|
|
"*Solid Section,elset=Solid,material=M\n,\n*End Part\n"
|
|
"*Assembly,name=A\n*Instance,name=I,part=P\n*End Instance\n"
|
|
"*Nset,nset=Fixed,instance=I\n10,20,30,40,50,60,70\n"
|
|
"*Nset,nset=Tip,instance=I\n80\n*End Assembly\n"
|
|
"*Material,name=M\n*Elastic\n100,.25\n*Density\n2\n"
|
|
"*Boundary\nFixed,1,6\nTip,2,3\n";
|
|
s += "*Step,name=RawSolid,inc=2,nlgeom=";
|
|
s += (procedure == 1 || procedure == 4) ? "YES\n" : "NO\n";
|
|
if (procedure == 0) s += "*Static\n1,1,1,1\n";
|
|
if (procedure == 1) s += "*Static,Direct\n.5,1\n";
|
|
if (procedure == 2)
|
|
s += "*Frequency,eigensolver=Lanczos,normalization=mass\n1\n";
|
|
if (procedure >= 3) s += "*Dynamic,Direct\n.1,.2\n";
|
|
if (procedure != 2) s += "*Cload\nTip,1,.001\n";
|
|
return s + "*End Step\n";
|
|
}
|
|
struct Files {
|
|
std::filesystem::path folder, input, output, log;
|
|
explicit Files(unsigned procedure) {
|
|
static std::atomic<unsigned long long> sequence{0};
|
|
folder = std::filesystem::temp_directory_path() /
|
|
("fesa-solid-output-" +
|
|
std::to_string(
|
|
std::chrono::steady_clock::now().time_since_epoch().count()) +
|
|
"-" + std::to_string(sequence.fetch_add(1)));
|
|
std::filesystem::create_directory(folder);
|
|
input = folder / "Solid.inp";
|
|
output = folder / "Solid_results.h5";
|
|
log = folder / "Solid_log.txt";
|
|
std::ofstream out(input);
|
|
out << Deck(procedure);
|
|
}
|
|
~Files() {
|
|
std::error_code ignored;
|
|
std::filesystem::remove_all(folder, ignored);
|
|
}
|
|
};
|
|
inline const char* Procedure(unsigned p) {
|
|
static const char* names[] = {"linear-static", "nonlinear-static-full-newton",
|
|
"linear-frequency", "hht-linear-dynamics",
|
|
"hht-nonlinear-dynamics"};
|
|
return names[p];
|
|
}
|
|
} // namespace solid_output_test
|
|
#endif
|