Skip to content

Commit 0afa102

Browse files
committed
fix UT errors
1 parent 146daae commit 0afa102

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

source/module_hsolver/test/test_hsolver_pw.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,68 @@
1414
#include "module_hsolver/hsolver_pw.h"
1515
#undef private
1616
#undef protected
17+
18+
// Mock implementations for the template functions causing linking errors
19+
namespace ModulePW {
20+
// Mock implementation for recip_to_real
21+
template<typename FPTYPE, typename Device>
22+
void PW_Basis_K::recip_to_real(const Device* ctx,
23+
const std::complex<FPTYPE>* in,
24+
std::complex<FPTYPE>* out,
25+
const int ik,
26+
const bool add,
27+
const FPTYPE factor) const
28+
{
29+
// Simple mock implementation that does nothing
30+
// In a real test, you might want to implement behavior that simulates the actual function
31+
}
32+
33+
// Mock implementation for real_to_recip
34+
template<typename FPTYPE, typename Device>
35+
void PW_Basis_K::real_to_recip(const Device* ctx,
36+
const std::complex<FPTYPE>* in,
37+
std::complex<FPTYPE>* out,
38+
const int ik,
39+
const bool add,
40+
const FPTYPE factor) const
41+
{
42+
// Simple mock implementation that does nothing
43+
}
44+
45+
// Explicit template instantiations
46+
template void PW_Basis_K::recip_to_real<float, base_device::DEVICE_CPU>(
47+
const base_device::DEVICE_CPU* ctx,
48+
const std::complex<float>* in,
49+
std::complex<float>* out,
50+
const int ik,
51+
const bool add,
52+
const float factor) const;
53+
54+
template void PW_Basis_K::recip_to_real<double, base_device::DEVICE_CPU>(
55+
const base_device::DEVICE_CPU* ctx,
56+
const std::complex<double>* in,
57+
std::complex<double>* out,
58+
const int ik,
59+
const bool add,
60+
const double factor) const;
61+
62+
template void PW_Basis_K::real_to_recip<float, base_device::DEVICE_CPU>(
63+
const base_device::DEVICE_CPU* ctx,
64+
const std::complex<float>* in,
65+
std::complex<float>* out,
66+
const int ik,
67+
const bool add,
68+
const float factor) const;
69+
70+
template void PW_Basis_K::real_to_recip<double, base_device::DEVICE_CPU>(
71+
const base_device::DEVICE_CPU* ctx,
72+
const std::complex<double>* in,
73+
std::complex<double>* out,
74+
const int ik,
75+
const bool add,
76+
const double factor) const;
77+
}
78+
1779
/************************************************
1880
* unit test of HSolverPW class
1981
***********************************************/

source/module_hsolver/test/test_hsolver_sdft.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,66 @@ void Stochastic_Iter<T, Device>::cal_storho(const UnitCell& ucell,
133133
Charge::Charge(){};
134134
Charge::~Charge(){};
135135

136+
// Mock implementations for the template functions causing linking errors
137+
namespace ModulePW {
138+
// Mock implementation for recip_to_real
139+
template<typename FPTYPE, typename Device>
140+
void PW_Basis_K::recip_to_real(const Device* ctx,
141+
const std::complex<FPTYPE>* in,
142+
std::complex<FPTYPE>* out,
143+
const int ik,
144+
const bool add,
145+
const FPTYPE factor) const
146+
{
147+
// Simple mock implementation that does nothing
148+
// In a real test, you might want to implement behavior that simulates the actual function
149+
}
150+
151+
// Mock implementation for real_to_recip
152+
template<typename FPTYPE, typename Device>
153+
void PW_Basis_K::real_to_recip(const Device* ctx,
154+
const std::complex<FPTYPE>* in,
155+
std::complex<FPTYPE>* out,
156+
const int ik,
157+
const bool add,
158+
const FPTYPE factor) const
159+
{
160+
// Simple mock implementation that does nothing
161+
}
162+
163+
// Explicit template instantiations
164+
template void PW_Basis_K::recip_to_real<float, base_device::DEVICE_CPU>(
165+
const base_device::DEVICE_CPU* ctx,
166+
const std::complex<float>* in,
167+
std::complex<float>* out,
168+
const int ik,
169+
const bool add,
170+
const float factor) const;
171+
172+
template void PW_Basis_K::recip_to_real<double, base_device::DEVICE_CPU>(
173+
const base_device::DEVICE_CPU* ctx,
174+
const std::complex<double>* in,
175+
std::complex<double>* out,
176+
const int ik,
177+
const bool add,
178+
const double factor) const;
179+
180+
template void PW_Basis_K::real_to_recip<float, base_device::DEVICE_CPU>(
181+
const base_device::DEVICE_CPU* ctx,
182+
const std::complex<float>* in,
183+
std::complex<float>* out,
184+
const int ik,
185+
const bool add,
186+
const float factor) const;
187+
188+
template void PW_Basis_K::real_to_recip<double, base_device::DEVICE_CPU>(
189+
const base_device::DEVICE_CPU* ctx,
190+
const std::complex<double>* in,
191+
std::complex<double>* out,
192+
const int ik,
193+
const bool add,
194+
const double factor) const;
195+
}
136196
/************************************************
137197
* unit test of HSolverPW_SDFT class
138198
***********************************************/

0 commit comments

Comments
 (0)