Skip to content

Commit

Permalink
Merge pull request #173 from PDoakORNL/clang-format-proposed
Browse files Browse the repository at this point in the history
Clang format proposed
  • Loading branch information
ye-luo authored Aug 7, 2018
2 parents 0d57c07 + 0ccf312 commit 7672fdd
Show file tree
Hide file tree
Showing 109 changed files with 4,174 additions and 3,831 deletions.
114 changes: 114 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
# @future IndentPPDirectives: BeforeHash
IndentWidth: 2
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 100000
PenaltyBreakComment: 20
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 9
PenaltyReturnTypeOnItsOwnLine: 8
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...

108 changes: 55 additions & 53 deletions src/Drivers/Mover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

namespace qmcplusplus
{

/**
/**
* @brief Container class includes all the classes required to operate walker moves
*
* Movers are distinct from walkers. Walkers are lightweight in memory, while
Expand All @@ -44,67 +43,70 @@ namespace qmcplusplus
*
* This class is used only by QMC drivers.
*/
struct Mover
{
using RealType = QMCTraits::RealType;

/// random number generator
RandomGenerator<RealType> rng;
/// electrons
ParticleSet els;
/// single particle orbitals
SPOSet *spo;
/// wavefunction container
WaveFunction wavefunction;
/// non-local pseudo-potentials
NonLocalPP<RealType> nlpp;

/// constructor
Mover(const uint32_t myPrime,
const ParticleSet &ions)
: spo(nullptr), rng(myPrime), nlpp(rng)
{
build_els(els, ions, rng);
}

/// destructor
~Mover() { if (spo!=nullptr) delete spo; }
struct Mover
{
using RealType = QMCTraits::RealType;

};
/// random number generator
RandomGenerator<RealType> rng;
/// electrons
ParticleSet els;
/// single particle orbitals
SPOSet* spo;
/// wavefunction container
WaveFunction wavefunction;
/// non-local pseudo-potentials
NonLocalPP<RealType> nlpp;

template <class T, typename TBOOL>
const std::vector<T *> filtered_list(const std::vector<T *> &input_list, const std::vector<TBOOL> &chosen)
/// constructor
Mover(const uint32_t myPrime, const ParticleSet& ions) : spo(nullptr), rng(myPrime), nlpp(rng)
{
std::vector<T *> final_list;
for(int iw=0; iw<input_list.size(); iw++)
if(chosen[iw]) final_list.push_back(input_list[iw]);
return final_list;
build_els(els, ions, rng);
}

const std::vector<ParticleSet *> extract_els_list(const std::vector<Mover *> &mover_list)
/// destructor
~Mover()
{
std::vector<ParticleSet *> els_list;
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
els_list.push_back(&(*it)->els);
return els_list;
if (spo != nullptr)
delete spo;
}
};

const std::vector<SPOSet *> extract_spo_list(const std::vector<Mover *> &mover_list)
{
std::vector<SPOSet *> spo_list;
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
spo_list.push_back((*it)->spo);
return spo_list;
}
template<class T, typename TBOOL>
const std::vector<T*>
filtered_list(const std::vector<T*>& input_list, const std::vector<TBOOL>& chosen)
{
std::vector<T*> final_list;
for (int iw = 0; iw < input_list.size(); iw++)
if (chosen[iw])
final_list.push_back(input_list[iw]);
return final_list;
}

const std::vector<WaveFunction *> extract_wf_list(const std::vector<Mover *> &mover_list)
{
std::vector<WaveFunction *> wf_list;
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
wf_list.push_back(&(*it)->wavefunction);
return wf_list;
}
const std::vector<ParticleSet*> extract_els_list(const std::vector<Mover*>& mover_list)
{
std::vector<ParticleSet*> els_list;
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
els_list.push_back(&(*it)->els);
return els_list;
}

const std::vector<SPOSet*> extract_spo_list(const std::vector<Mover*>& mover_list)
{
std::vector<SPOSet*> spo_list;
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
spo_list.push_back((*it)->spo);
return spo_list;
}

const std::vector<WaveFunction*> extract_wf_list(const std::vector<Mover*>& mover_list)
{
std::vector<WaveFunction*> wf_list;
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
wf_list.push_back(&(*it)->wavefunction);
return wf_list;
}

} // namespace qmcplusplus

#endif
30 changes: 16 additions & 14 deletions src/Drivers/check_determinant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace qmcplusplus;

void print_help()
{
//clang-format off
// clang-format off
cout << "usage:" << '\n';
cout << " check_determinant [-hvV] [-g \"n0 n1 n2\"] [-n steps]" << '\n';
cout << " [-N substeps] [-s seed]" << '\n';
Expand All @@ -48,14 +48,12 @@ void print_help()
cout << " -s set the random seed. default: 11" << '\n';
cout << " -v verbose output" << '\n';
cout << " -V print version information and exit" << '\n';
//clang-format on
// clang-format on

exit(1); // print help and exit
}
int main(int argc, char **argv)
int main(int argc, char** argv)
{


// clang-format off
typedef QMCTraits::RealType RealType;
typedef ParticleSet::ParticlePos_t ParticlePos_t;
Expand All @@ -75,7 +73,7 @@ int main(int argc, char **argv)
bool verbose = false;

int opt;
while(optind < argc)
while (optind < argc)
{
if ((opt = getopt(argc, argv, "hvVg:n:N:r:s:")) != -1)
{
Expand All @@ -84,7 +82,9 @@ int main(int argc, char **argv)
case 'g': // tiling1 tiling2 tiling3
sscanf(optarg, "%d %d %d", &na, &nb, &nc);
break;
case 'h': print_help(); break;
case 'h':
print_help();
break;
case 'n':
nsteps = atoi(optarg);
break;
Expand All @@ -94,7 +94,9 @@ int main(int argc, char **argv)
case 's':
iseed = atoi(optarg);
break;
case 'v': verbose = true; break;
case 'v':
verbose = true;
break;
case 'V':
print_version(true);
return 1;
Expand Down Expand Up @@ -126,7 +128,7 @@ int main(int argc, char **argv)

double accumulated_error = 0.0;

#pragma omp parallel reduction(+:accumulated_error)
#pragma omp parallel reduction(+ : accumulated_error)
{
int ip = omp_get_thread_num();

Expand Down Expand Up @@ -178,7 +180,8 @@ int main(int argc, char **argv)
PosType dr = sqrttau * delta[iel];
bool isValid = els.makeMoveAndCheck(iel, dr);

if (!isValid) continue;
if (!isValid)
continue;

// Compute gradient at the trial position

Expand Down Expand Up @@ -213,13 +216,12 @@ int main(int argc, char **argv)

constexpr double small_err = std::numeric_limits<double>::epsilon() * 6e8;

cout << "total accumulated error of " << accumulated_error << " for " << np
<< " procs" << '\n';
cout << "total accumulated error of " << accumulated_error << " for " << np << " procs" << '\n';

if (accumulated_error / np > small_err)
{
cout << "Checking failed with accumulated error: " << accumulated_error / np
<< " > " << small_err << '\n';
cout << "Checking failed with accumulated error: " << accumulated_error / np << " > "
<< small_err << '\n';
return 1;
}
else
Expand Down
Loading

0 comments on commit 7672fdd

Please sign in to comment.