A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete Kohn-Sham operator on vectors. More...
#include <KohnShamOperatorContextFE.h>
Public Types | |
using | ValueType = linearAlgebra::blasLapack::scalar_type< ValueTypeOperator, ValueTypeOperand > |
define ValueType as the superior (bigger set) of the ValueTypeOperator and ValueTypeOperand (e.g., between double and complex<double>, complex<double> is the bigger set) More... | |
using | Storage = utils::MemoryStorage< ValueTypeOperator, memorySpace > |
using | HamiltonianPtrVariant = std::variant< Hamiltonian< float, memorySpace > *, Hamiltonian< double, memorySpace > *, Hamiltonian< std::complex< float >, memorySpace > *, Hamiltonian< std::complex< double >, memorySpace > * > |
Public Member Functions | |
KohnShamOperatorContextFE (const basis::FEBasisManager< ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > &feBasisManager, std::vector< HamiltonianPtrVariant > hamiltonianComponentsVec, linearAlgebra::LinAlgOpContext< memorySpace > &linAlgOpContext, const size_type maxCellTimesNumVecs) | |
Constructor. More... | |
~KohnShamOperatorContextFE ()=default | |
void | reinit (const basis::FEBasisManager< ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > &feBasisManager, std::vector< HamiltonianPtrVariant > hamiltonianVec) |
void | apply (linearAlgebra::MultiVector< ValueTypeOperand, memorySpace > &X, linearAlgebra::MultiVector< ValueType, memorySpace > &Y) const override |
Private Attributes | |
const basis::FEBasisManager< ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > * | d_feBasisManager |
Storage | d_hamiltonianInAllCells |
const size_type | d_maxCellTimesNumVecs |
linearAlgebra::LinAlgOpContext< memorySpace > | d_linAlgOpContext |
A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete Kohn-Sham operator on vectors.
ValueTypeOperator | The datatype (float, double, complex<double>, etc.) for the underlying operator |
ValueTypeOperand | The datatype (float, double, complex<double>, etc.) of the vector, matrices, etc. on which the operator will act |
memorySpace | The meory sapce (HOST, DEVICE, HOST_PINNED, etc.) in which the data of the operator and its operands reside |
using dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::HamiltonianPtrVariant = std::variant<Hamiltonian<float, memorySpace> *, Hamiltonian<double, memorySpace> *, Hamiltonian<std::complex<float>, memorySpace> *, Hamiltonian<std::complex<double>, memorySpace> *> |
using dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::Storage = utils::MemoryStorage<ValueTypeOperator, memorySpace> |
using dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::ValueType = linearAlgebra::blasLapack::scalar_type<ValueTypeOperator, ValueTypeOperand> |
define ValueType as the superior (bigger set) of the ValueTypeOperator and ValueTypeOperand (e.g., between double and complex<double>, complex<double> is the bigger set)
dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::KohnShamOperatorContextFE | ( | const basis::FEBasisManager< ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > & | feBasisManager, |
std::vector< HamiltonianPtrVariant > | hamiltonianComponentsVec, | ||
linearAlgebra::LinAlgOpContext< memorySpace > & | linAlgOpContext, | ||
const size_type | maxCellTimesNumVecs | ||
) |
Constructor.
|
default |
|
override |
void dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::reinit | ( | const basis::FEBasisManager< ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > & | feBasisManager, |
std::vector< HamiltonianPtrVariant > | hamiltonianVec | ||
) |
---------------------— print EE block------------------------— const basis::BasisDofHandler &basisDofHandler = feBasisManager.getBasisDofHandler();
const basis::EFEBasisDofHandler<ValueTypeOperand, ValueTypeOperator, memorySpace, dim> &efebasisDofHandler = dynamic_cast<const basis::EFEBasisDofHandler<ValueTypeOperand, ValueTypeOperator, memorySpace, dim> &>(basisDofHandler);
const size_type numCellClassicalDofs = utils::mathFunctions::sizeTypePow( (efebasisDofHandler.getFEOrder(0) + 1), dim); const size_type nglobalEnrichmentIds = efebasisDofHandler.nGlobalEnrichmentNodes(); const size_type nglobalClassicalIds = (efebasisDofHandler.getGlobalRanges())[0].second;
std::vector<ValueTypeOperator> hamEnrichmentBlockSTL( nglobalEnrichmentIds * nglobalEnrichmentIds, 0), hamEnrichmentBlockSTLTmp(nglobalEnrichmentIds * nglobalEnrichmentIds, 0);
size_type cellId = 0; size_type cumulativeBasisDataInCells = 0; for (auto enrichmentVecInCell : efebasisDofHandler.getEnrichmentIdsPartition() ->overlappingEnrichmentIdsInCells()) { size_type nCellEnrichmentDofs = enrichmentVecInCell.size(); for (unsigned int j = 0; j < nCellEnrichmentDofs; j++) { for (unsigned int k = 0; k < nCellEnrichmentDofs; k++) { (hamEnrichmentBlockSTLTmp.data() + enrichmentVecInCell[j] * nglobalEnrichmentIds + enrichmentVecInCell[k]) += (d_hamiltonianInAllCells.data() + cumulativeBasisDataInCells + (numCellClassicalDofs + nCellEnrichmentDofs) (numCellClassicalDofs + j) + numCellClassicalDofs + k); } } cumulativeBasisDataInCells += utils::mathFunctions::sizeTypePow( (nCellEnrichmentDofs + numCellClassicalDofs), 2); cellId += 1; }
int err = utils::mpi::MPIAllreduce<utils::MemorySpace::HOST>( hamEnrichmentBlockSTLTmp.data(), hamEnrichmentBlockSTL.data(), hamEnrichmentBlockSTLTmp.size(), utils::mpi::MPIDouble, utils::mpi::MPISum, d_feBasisManager->getMPIPatternP2P()->mpiCommunicator()); std::pair<bool, std::string> mpiIsSuccessAndMsg = utils::mpi::MPIErrIsSuccessAndMsg(err); utils::throwException(mpiIsSuccessAndMsg.first, "MPI Error:" + mpiIsSuccessAndMsg.second);
int rank; utils::mpi::MPICommRank(d_feBasisManager->getMPIPatternP2P()->mpiCommunicator(), &rank);
utils::ConditionalOStream rootCout(std::cout); rootCout.setCondition(rank == 0);
rootCout << "Hamiltonian Enrichment Block Matrix: "<<std::endl; for(size_type i = 0 ; i < nglobalEnrichmentIds ; i++) { rootCout << "["; for(size_type j = 0 ; j < nglobalEnrichmentIds ; j++) { rootCout << *(hamEnrichmentBlockSTL.data() + i*nglobalEnrichmentIds
---------------------— print EC block to file------------------------— std::vector<ValueTypeOperator> hamECBlockSTL( (nglobalClassicalIds + nglobalEnrichmentIds) * nglobalEnrichmentIds, 0), hamECBlockSTLTmp((nglobalClassicalIds + nglobalEnrichmentIds) * nglobalEnrichmentIds, 0);
cumulativeBasisDataInCells = 0; for (size_type iCell = 0; iCell < efebasisDofHandler.nLocallyOwnedCells() ; iCell++) {
get cell dof global ids std::vector<global_size_type> cellGlobalNodeIds(0); efebasisDofHandler.getCellDofsGlobalIds(iCell, cellGlobalNodeIds);
std::vector<global_size_type> enrichmentVecInCell = efebasisDofHandler.getEnrichmentIdsPartition() ->overlappingEnrichmentIdsInCells()[iCell];
size_type nCellEnrichmentDofs = enrichmentVecInCell.size();
loop over nodes of a cell for ( size_type iNode = 0 ; iNode < numCellClassicalDofs + nCellEnrichmentDofs; iNode++) { for ( size_type jNode = 0 ; jNode < nCellEnrichmentDofs ; jNode++) { (hamECBlockSTLTmp.data() + cellGlobalNodeIds[iNode] * nglobalEnrichmentIds + enrichmentVecInCell[jNode]) += (d_hamiltonianInAllCells.data() + cumulativeBasisDataInCells + (numCellClassicalDofs + nCellEnrichmentDofs) * iNode + jNode + numCellClassicalDofs); } } cumulativeBasisDataInCells += utils::mathFunctions::sizeTypePow((cellGlobalNodeIds.size()),2); }
err = utils::mpi::MPIAllreduce<utils::MemorySpace::HOST>( hamECBlockSTLTmp.data(), hamECBlockSTL.data(), hamECBlockSTLTmp.size(), utils::mpi::MPIDouble, utils::mpi::MPISum, d_feBasisManager->getMPIPatternP2P()->mpiCommunicator()); mpiIsSuccessAndMsg = utils::mpi::MPIErrIsSuccessAndMsg(err); utils::throwException(mpiIsSuccessAndMsg.first, "MPI Error:" + mpiIsSuccessAndMsg.second);
std::ofstream myfile; myfile.open("wings"); utils::ConditionalOStream rootCout1(myfile); rootCout1.setCondition(rank == 0);
for(size_type i = 0 ; i < nglobalClassicalIds + nglobalEnrichmentIds ; i++) { rootCout1 << i <<": ["; for(size_type j = 0 ; j < nglobalEnrichmentIds ; j++) { rootCout1 << *(hamECBlockSTL.data() + i*nglobalEnrichmentIds + j) << "\t"; } rootCout1 << "]" <<std::endl; } myfile.close();
|
private |
|
private |
|
private |
|
private |