https://gitlab.opengeosys.org/ogs/ogs.git
Revision e35ef356ff378abbfa5b767dcfd2db4afc529405 authored by Dmitri Naumov on 09 December 2015, 16:37:53 UTC, committed by Thomas Fischer on 14 December 2015, 09:50:03 UTC
Use reserve and push_back for copy instead of resize
saving initialization of the data.
1 parent b2f4478
Raw File
Tip revision: e35ef356ff378abbfa5b767dcfd2db4afc529405 authored by Dmitri Naumov on 09 December 2015, 16:37:53 UTC
[MeL] Assert materials PropVector. Speedup copy.
Tip revision: e35ef35
readMeshFromFile.cpp
/**
 * \file
 * \author Karsten Rink
 * \date   2012-09-27
 * \brief  Implementation of readMeshFromFile function.
 *
 * \copyright
 * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 * @file readMeshFromFile.cpp
 * @date 2012-09-27
 * @author Karsten Rink
 */

#include "readMeshFromFile.h"

#ifdef USE_PETSC
#include <petsc.h>
#endif

#include <boost/algorithm/string/erase.hpp>

#include <logog/include/logog.hpp>

#include "BaseLib/FileTools.h"
#include "BaseLib/StringTools.h"

#include "MeshLib/Mesh.h"

#include "FileIO/Legacy/MeshIO.h"
#include "FileIO/VtkIO/VtuInterface.h"

#ifdef USE_PETSC
#include "FileIO/MPI_IO/NodePartitionedMeshReader.h"
#include "MeshLib/NodePartitionedMesh.h"
#endif

namespace FileIO
{
MeshLib::Mesh* readMeshFromFile(const std::string &file_name)
{
#ifdef USE_PETSC
	NodePartitionedMeshReader read_pmesh(PETSC_COMM_WORLD);
	const std::string file_name_base = BaseLib::dropFileExtension(file_name);
	return read_pmesh.read(file_name_base);
#else
	if (BaseLib::hasFileExtension("msh", file_name))
	{
		Legacy::MeshIO meshIO;
		return meshIO.loadMeshFromFile(file_name);
	}

	if (BaseLib::hasFileExtension("vtu", file_name))
		return VtuInterface::readVTUFile(file_name);

	ERR("readMeshFromFile(): Unknown mesh file format in file %s.", file_name.c_str());
	return nullptr;
#endif
}
} // end namespace FileIO
back to top