//! \brief Setup up for our basis. //! \details Bases with the same size is collapsed to one, while different sized bases are appended //! \param plist The process list with bases and fields //! \param level The file level to load bases from //! \param hdf The HDF5 file reader to use //! \param dims The dimensionality of the basis //! \param n The number of points in each direction per knot span in the tesselation //! \param vtf The VTF/VTU file to write to //! \param block Running VTF block counter //! \param vtflevel The time level / load case in the VTF file PatchMap setupPatchMap(const ProcessList& plist, int level, HDF5Writer& hdf, int dims, int* n, VTF& vtf, int& block, int vtflevel) { vtf.clearGeometryBlocks(); int start=1; std::map<int, BasisInfo> created; PatchMap result; for (ProcessList::const_iterator it = plist.begin(); it != plist.end(); ++it) { if (it->first == "nodalforces") continue; readBasis(result[it->first].Patch, it->second[0].basis, it->second[0].patches, hdf, dims, level); std::map<int, BasisInfo>::iterator loc = created.find(it->second[0].patches); // tesselate some more patches if (loc == created.end()) { generateFEModel(created[it->second[0].patches].FakeModel, result[it->first].Patch, dims, n); loc = created.find(it->second[0].patches); loc->second.StartPart = start; for (size_t l=0;l<result[it->first].Patch.size();++l) writePatchGeometry(result[it->first].Patch[l], start+l, vtf, n, ++block); start += it->second[0].patches; } result[it->first].StartPart = loc->second.StartPart; result[it->first].FakeModel = loc->second.FakeModel; } return result; }
bool SPxSolver::readBasisFile( const char* filename, const NameSet* rowNames, const NameSet* colNames) { METHOD( "SPxSolver::readBasisFile()" ); spxifstream file(filename); if (!file) return false; return readBasis(file, rowNames, colNames); }
void TangentSpace::read(const H5::CommonFG &loc, const string &entry, const shared_ptr<Project> &project) { this->project = project; auto group = loc.openGroup(entry); assert(H5::readAttribute<string>(group, "type", project->enumtype) == "TangentSpace"); H5::readAttribute(group, "name", name); assert(H5::readGroupAttribute<string>(group, "project", "name") == project->name); configuration = project->configurations.at( H5::readGroupAttribute<string>(group, "configuration", "name")); assert(H5::readGroupAttribute<string>( group, string("configuration/tangentspaces/") + name, "name") == name); H5::readAttribute(group, "dimension", dimension); H5::readGroup(group, "bases", [&](const H5::Group &group, const string &name) { readBasis(group, name); }); // Cannot check "fields" since fields have not been read yet // assert(H5::checkGroupNames(group, "fields", fields)); configuration->insert(name, shared_from_this()); }
int main(int argc, char* argv[]) { int program = 0; // Get input file from first command line argument if(argc < 3){ // No input file given std::cerr << "Usage: ./drudeh [input_file] [basis_file]\n"; program = -1; } else { std::string ifname = argv[1]; // Input filename std::string bfname = argv[2]; // Basis filename std::string ofname = ifname; // Output file prefix std::size_t pos = ofname.find('.'); if (pos != std::string::npos) { // Cut off extension ofname.erase(pos, ofname.length()); } ofname += ".output"; // Open the input file std::ifstream input(ifname); // Check it opened successfully if (!input.is_open()){ std::cerr << "Failed to open input file.\n"; program = -1; } else { // Declare and read parameters int N; std::vector<double> mu, omega, q; N = readParams(input, mu, omega, q); // Make the zeta vector std::vector<double> zeta(N); for (int i = 0; i < N; i++) zeta[i] = 0.5*mu[i]*omega[i]; // Geometry Eigen::MatrixXd R(N-1, 3); // Rewind input file input.clear(); input.seekg(0, std::ios::beg); // Read in geometry readGeom(input, R, N); // Open basis file std::ifstream basis(bfname); // Check if opened successfully if (!basis.is_open()){ std::cerr << "Failed to open basis file.\n"; program = -1; } else { // Initialise array of basis functions std::vector<BasisFunction> bfs; // Read in the basis functions int nbfs = readBasis(basis, bfs, N, zeta, R); // Form and diagonalise hamiltonian matrix Eigen::MatrixXd D = hamiltonian(N, nbfs, bfs, R, mu, omega, q); // Find lowest non-zero eigenvalue //int i = 0; double lowest_eig = D(0); // while ( D(i) < 0.1 ) i++; // if ( i < nbfs ) //lowest_eig = D(i); // Open output file std::ofstream output(ofname); if (!output.is_open()){ std::cout << "Couldn't open output file.\n"; std::cout << "Total number of basis functions = " << nbfs << "\n"; std::cout << "Lowest eigenvalue = " << std::setprecision(15) << lowest_eig << "\n"; } else { output << "Total number of basis functions = " << nbfs << "\n"; output << "Lowest eigenvalue = "<< std::setprecision(15) << lowest_eig << "\n"; } } } } return program; }