DFT-EFE
 
Loading...
Searching...
No Matches
dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim > Class Template Reference

A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete Kohn-Sham operator on vectors. More...

#include <KohnShamOperatorContextFE.h>

Inheritance diagram for dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >:
Collaboration diagram for dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >:

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
 

Detailed Description

template<typename ValueTypeOperator, typename ValueTypeOperand, typename ValueTypeBasisData, utils::MemorySpace memorySpace, size_type dim>
class dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >

A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete Kohn-Sham operator on vectors.

Template Parameters
ValueTypeOperatorThe datatype (float, double, complex<double>, etc.) for the underlying operator
ValueTypeOperandThe datatype (float, double, complex<double>, etc.) of the vector, matrices, etc. on which the operator will act
memorySpaceThe meory sapce (HOST, DEVICE, HOST_PINNED, etc.) in which the data of the operator and its operands reside

Member Typedef Documentation

◆ HamiltonianPtrVariant

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
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> *>

◆ Storage

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
using dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::Storage = utils::MemoryStorage<ValueTypeOperator, memorySpace>

◆ ValueType

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
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)

Constructor & Destructor Documentation

◆ KohnShamOperatorContextFE()

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
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.

Here is the call graph for this function:

◆ ~KohnShamOperatorContextFE()

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::~KohnShamOperatorContextFE ( )
default

Member Function Documentation

◆ apply()

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
void dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::apply ( linearAlgebra::MultiVector< ValueTypeOperand, memorySpace > &  X,
linearAlgebra::MultiVector< ValueType, memorySpace > &  Y 
) const
override
Here is the call graph for this function:

◆ reinit()

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
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

  • j) << "\t"; } rootCout << "]" <<std::endl; }

---------------------— 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();

Here is the caller graph for this function:

Member Data Documentation

◆ d_feBasisManager

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
const basis:: FEBasisManager<ValueTypeOperand, ValueTypeBasisData, memorySpace, dim>* dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::d_feBasisManager
private

◆ d_hamiltonianInAllCells

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
Storage dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::d_hamiltonianInAllCells
private

◆ d_linAlgOpContext

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
linearAlgebra::LinAlgOpContext<memorySpace> dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::d_linAlgOpContext
private

◆ d_maxCellTimesNumVecs

template<typename ValueTypeOperator , typename ValueTypeOperand , typename ValueTypeBasisData , utils::MemorySpace memorySpace, size_type dim>
const size_type dftefe::ksdft::KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeBasisData, memorySpace, dim >::d_maxCellTimesNumVecs
private

The documentation for this class was generated from the following files: