Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ OBJS_BASE=assoc_laguerre.o\
orb_io.o\

OBJS_CELL=atom_pseudo.o\
base_cell.o\
basecell.o\
qlist.o\
atom_spec.o\
pseudo.o\
Expand Down Expand Up @@ -225,8 +225,8 @@ OBJS_CELL=atom_pseudo.o\
read_pp_ucell.o\
cal_wfc.o\
cal_ux.o\
distributed_mdcell_reader.o\
md_cell.o\
mdcell_reader.o\
mdcell.o\
cif_io.o\
ucell_io.o\

Expand Down
8 changes: 4 additions & 4 deletions source/source_base/parallel_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ int CommunicationDomain::rank() const
return rank_;
}

CommunicationDomain world_communication_domain()
CommunicationDomain world_comm_domain()
{
CommunicationDomain communication_domain;
CommunicationDomain comm_domain;
#ifdef __MPI
communication_domain.initialize(MPI_COMM_WORLD);
comm_domain.initialize(MPI_COMM_WORLD);
#endif
return communication_domain;
return comm_domain;
}
} // namespace ModuleBase
2 changes: 1 addition & 1 deletion source/source_base/parallel_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CommunicationDomain
int rank_ = 0;
};

CommunicationDomain world_communication_domain();
CommunicationDomain world_comm_domain();
} // namespace ModuleBase

#endif
6 changes: 3 additions & 3 deletions source/source_cell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_subdirectory(module_neighlist)
add_library(
cell
OBJECT
base_cell.cpp
basecell.cpp
atom_pseudo.cpp
atom_spec.cpp
pseudo.cpp
Expand All @@ -15,8 +15,8 @@ add_library(
read_pp_upf201.cpp
read_pp_blps.cpp
read_pp_vwr.cpp
distributed_mdcell_reader.cpp
md_cell.cpp
mdcell_reader.cpp
mdcell.cpp
unitcell.cpp
read_atoms.cpp
read_atoms_helper.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "source_cell/base_cell.h"
#include "source_cell/basecell.h"

#include "source_base/tool_quit.h"

void BaseCell::require_kind(const Kind& expected, const char* caller) const
{
if (this->kind() != expected)
{
const char* required_cell = expected == Kind::unit_cell ? "UnitCell" : "MDCell";
const char* required_cell = expected == Kind::unitcell ? "UnitCell" : "MDCell";
ModuleBase::WARNING_QUIT(caller, std::string("This operation only supports ") + required_cell + ".");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef BASE_CELL_H
#define BASE_CELL_H
#ifndef BASECELL_H
#define BASECELL_H

#include "source_base/matrix3.h"

Expand All @@ -10,8 +10,8 @@ class BaseCell
public:
enum class Kind
{
unit_cell,
md_cell
unitcell,
mdcell
};

virtual ~BaseCell() = default;
Expand Down
16 changes: 8 additions & 8 deletions source/source_cell/md_cell.cpp → source/source_cell/mdcell.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "source_cell/md_cell.h"
#include "source_cell/mdcell.h"

#include "source_base/parallel_cell.h"
#include "source_cell/unitcell.h"
Expand Down Expand Up @@ -180,12 +180,12 @@ void MDCell::initialize_from_owned_atoms_(double cutoff, double skin)
void MDCell::initialize_from_unitcell(UnitCell& ucell,
double cutoff,
double skin,
const ModuleBase::CommunicationDomain& communication_domain)
const ModuleBase::CommunicationDomain& comm_domain)
{
#ifdef __MPI
initialize_from_ucell_(ucell, communication_domain.communicator(), cutoff, skin);
initialize_from_ucell_(ucell, comm_domain.communicator(), cutoff, skin);
#else
static_cast<void>(communication_domain);
static_cast<void>(comm_domain);
initialize_from_ucell_(ucell, cutoff, skin);
#endif
}
Expand All @@ -201,7 +201,7 @@ void MDCell::initialize_from_owned_atoms(const ModuleBase::Matrix3& latvec,
const std::vector<std::int64_t>& type_atom_counts,
double cutoff,
double skin,
const ModuleBase::CommunicationDomain& communication_domain)
const ModuleBase::CommunicationDomain& comm_domain)
{
latvec_ = latvec;
gt_ = gt;
Expand All @@ -213,9 +213,9 @@ void MDCell::initialize_from_owned_atoms(const ModuleBase::Matrix3& latvec,
type_masses_ = type_masses;
type_atom_counts_ = type_atom_counts;
#ifdef __MPI
initialize_from_owned_atoms_(communication_domain.communicator(), cutoff, skin);
initialize_from_owned_atoms_(comm_domain.communicator(), cutoff, skin);
#else
static_cast<void>(communication_domain);
static_cast<void>(comm_domain);
initialize_from_owned_atoms_(cutoff, skin);
#endif
}
Expand Down Expand Up @@ -556,7 +556,7 @@ void MDCell::sync_backing_unitcell()

BaseCell::Kind MDCell::get_kind() const
{
return Kind::md_cell;
return Kind::mdcell;
}

std::int64_t MDCell::get_nat() const
Expand Down
14 changes: 9 additions & 5 deletions source/source_cell/md_cell.h → source/source_cell/mdcell.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef MD_CELL_H
#define MD_CELL_H
#ifndef MDCELL_H
#define MDCELL_H

#include "source_cell/base_cell.h"
#include "source_cell/basecell.h"
#include "source_cell/strumeta.h"
#include "source_cell/module_neighlist/local_atom.h"

#ifdef __MPI
Expand Down Expand Up @@ -33,7 +34,7 @@ class MDCell : public BaseCell
void initialize_from_unitcell(UnitCell& ucell,
double cutoff,
double skin,
const ModuleBase::CommunicationDomain& communication_domain);
const ModuleBase::CommunicationDomain& comm_domain);
void initialize_from_owned_atoms(const ModuleBase::Matrix3& latvec,
const ModuleBase::Matrix3& gt,
double lat0,
Expand All @@ -45,7 +46,7 @@ class MDCell : public BaseCell
const std::vector<std::int64_t>& type_atom_counts,
double cutoff,
double skin,
const ModuleBase::CommunicationDomain& communication_domain);
const ModuleBase::CommunicationDomain& comm_domain);

#ifdef __MPI
int mpi_rank() const;
Expand All @@ -68,6 +69,8 @@ class MDCell : public BaseCell
const std::vector<std::string>& type_labels() const { return type_labels_; }
const std::vector<double>& type_masses() const { return type_masses_; }
const std::vector<std::int64_t>& type_atom_counts() const { return type_atom_counts_; }
StruMeta& mutable_stru_meta() { return stru_meta_; }
const StruMeta& stru_meta() const { return stru_meta_; }
std::vector<LocalAtom>& mutable_owned_atoms();
std::vector<LocalAtom>& mutable_ghost_atoms();

Expand Down Expand Up @@ -110,6 +113,7 @@ class MDCell : public BaseCell
std::vector<std::string> type_labels_;
std::vector<double> type_masses_;
std::vector<std::int64_t> type_atom_counts_;
StruMeta stru_meta_;
double cutoff_ = 0.0;
double skin_ = 0.0;
std::unique_ptr<NeighborSearch> neighbor_search_;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "source_cell/distributed_mdcell_reader.h"
#include "source_cell/mdcell_reader.h"

#include "source_base/constants.h"
#include "source_base/parallel_cell.h"
#include "source_base/vector3.h"
#include "source_cell/md_cell.h"
#include "source_cell/mdcell.h"

#ifdef __MPI
#include "source_cell/module_neighlist/domain_decomposition.h"
Expand All @@ -30,7 +30,7 @@ struct StruMetadata
std::vector<std::string> labels;
std::vector<double> masses;
std::vector<std::int64_t> type_atom_counts;
MdStruFileMetadata stru_file_metadata;
StruMeta stru_meta;
};

std::string next_data_line(std::ifstream& ifs, const char* context)
Expand Down Expand Up @@ -130,15 +130,15 @@ StruMetadata parse_stru_metadata(std::ifstream& ifs)
}
if (line == "NUMERICAL_ORBITAL")
{
for (std::size_t it = 0; it < metadata.stru_file_metadata.species.size(); ++it)
for (std::size_t it = 0; it < metadata.stru_meta.species.size(); ++it)
{
metadata.stru_file_metadata.species[it].orbital_file = next_data_line(ifs, "NUMERICAL_ORBITAL body");
metadata.stru_meta.species[it].orbital_file = next_data_line(ifs, "NUMERICAL_ORBITAL body");
}
continue;
}
if (line == "NUMERICAL_DESCRIPTOR")
{
metadata.stru_file_metadata.descriptor_file = next_data_line(ifs, "NUMERICAL_DESCRIPTOR body");
metadata.stru_meta.descriptor_file = next_data_line(ifs, "NUMERICAL_DESCRIPTOR body");
continue;
}

Expand All @@ -153,9 +153,9 @@ StruMetadata parse_stru_metadata(std::ifstream& ifs)

metadata.labels.push_back(label);
metadata.masses.push_back(parse_double(mass_token, "atomic mass"));
MdStruFileSpecies species;
StruSpecies species;
iss >> species.pseudo_file >> species.pseudo_type;
metadata.stru_file_metadata.species.push_back(species);
metadata.stru_meta.species.push_back(species);
}

expect_keyword(ifs, "LATTICE_CONSTANT");
Expand Down Expand Up @@ -190,13 +190,13 @@ std::vector<LocalAtom> read_owned_atoms(std::ifstream& ifs,
double cutoff,
double skin,
std::int64_t& nat,
const ModuleBase::CommunicationDomain& communication_domain)
const ModuleBase::CommunicationDomain& comm_domain)
{
int rank = 0;
#ifdef __MPI
DomainDecomposition decomposition;
decomposition.init(communication_domain.communicator(), metadata.latvec, metadata.lat0, cutoff, skin);
rank = communication_domain.rank();
decomposition.init(comm_domain.communicator(), metadata.latvec, metadata.lat0, cutoff, skin);
rank = comm_domain.rank();
#endif

int begin[3] = {0, 0, 0};
Expand Down Expand Up @@ -232,7 +232,7 @@ std::vector<LocalAtom> read_owned_atoms(std::ifstream& ifs,
throw std::runtime_error("ATOMIC_POSITIONS label order does not match ATOMIC_SPECIES.");
}
std::istringstream magnetism(next_data_line(ifs, "magnetism"));
magnetism >> metadata.stru_file_metadata.species[it].start_mag;
magnetism >> metadata.stru_meta.species[it].start_mag;
const std::int64_t nat_type = parse_int64(next_data_line(ifs, "atom count"), "atom count");

for (std::int64_t ia = 0; ia < nat_type; ++ia)
Expand Down Expand Up @@ -323,12 +323,11 @@ std::vector<LocalAtom> read_owned_atoms(std::ifstream& ifs,
}
} // namespace

MDCell DistributedMDCellReader::read_stru(const std::string& stru_file,
MDCell MDCellReader::read_stru(const std::string& stru_file,
const std::vector<int>& cell_replica,
double cutoff,
double skin,
MdStruFileMetadata& stru_metadata,
const ModuleBase::CommunicationDomain& communication_domain)
const ModuleBase::CommunicationDomain& comm_domain)
{
if (cutoff <= 0.0)
{
Expand All @@ -355,7 +354,7 @@ MDCell DistributedMDCellReader::read_stru(const std::string& stru_file,
metadata.omega = std::abs(metadata.latvec.Det()) * metadata.lat0 * metadata.lat0 * metadata.lat0;
std::int64_t nat = 0;
const std::vector<LocalAtom> owned_atoms = read_owned_atoms(ifs, metadata, primitive_latvec, primitive_gt,
cell_replica, cutoff, skin, nat, communication_domain);
cell_replica, cutoff, skin, nat, comm_domain);
MDCell mdcell;
mdcell.initialize_from_owned_atoms(metadata.latvec,
metadata.gt,
Expand All @@ -368,7 +367,7 @@ MDCell DistributedMDCellReader::read_stru(const std::string& stru_file,
metadata.type_atom_counts,
cutoff,
skin,
communication_domain);
stru_metadata = metadata.stru_file_metadata;
comm_domain);
mdcell.mutable_stru_meta() = metadata.stru_meta;
return mdcell;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef DISTRIBUTED_MDCELL_READER_H
#define DISTRIBUTED_MDCELL_READER_H

#include "source_cell/md_stru_file_metadata.h"
#ifndef MDCELL_READER_H
#define MDCELL_READER_H

#include <string>
#include <vector>
Expand All @@ -12,15 +10,14 @@ namespace ModuleBase
class CommunicationDomain;
}

class DistributedMDCellReader
class MDCellReader
{
public:
static MDCell read_stru(const std::string& stru_file,
const std::vector<int>& cell_replica,
double cutoff,
double skin,
MdStruFileMetadata& stru_metadata,
const ModuleBase::CommunicationDomain& communication_domain);
const ModuleBase::CommunicationDomain& comm_domain);
};

#endif
10 changes: 5 additions & 5 deletions source/source_cell/module_neighlist/neighbor_search.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "source_cell/module_neighlist/neighbor_search.h"
#include "source_cell/md_cell.h"
#include "source_cell/mdcell.h"
#include "source_cell/unitcell.h"

#include <cmath>
Expand Down Expand Up @@ -146,14 +146,14 @@ void NeighborSearch::init_from_unitcell_(const UnitCell& ucell, double sr)

void NeighborSearch::init(BaseCell& cell, double sr)
{
if (cell.kind() == BaseCell::Kind::md_cell)
if (cell.kind() == BaseCell::Kind::mdcell)
{
MDCell& md_cell = static_cast<MDCell&>(cell);
init_from_mdcell_(md_cell, sr);
MDCell& mdcell = static_cast<MDCell&>(cell);
init_from_mdcell_(mdcell, sr);
return;
}

assert(cell.kind() == BaseCell::Kind::unit_cell);
assert(cell.kind() == BaseCell::Kind::unitcell);
UnitCell& ucell = static_cast<UnitCell&>(cell);
init_from_unitcell_(ucell, sr);
}
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/module_neighlist/neighbor_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "source_cell/module_neighlist/bin_manager.h"
#include "source_cell/module_neighlist/neighbor_list.h"
#include "source_cell/module_neighlist/local_atom.h"
#include "source_cell/base_cell.h"
#include "source_cell/basecell.h"

class MDCell;
class UnitCell;
Expand Down
Loading
Loading