diff --git a/lib/atc/ATC_Coupling.cpp b/lib/atc/ATC_Coupling.cpp index d9ca2be8780b552c1b6aafdd5ca1d2f5901db1be..e9c98612fd33383f7bcfadbadbc7d0cb55189030 100644 --- a/lib/atc/ATC_Coupling.cpp +++ b/lib/atc/ATC_Coupling.cpp @@ -10,6 +10,12 @@ #include "PhysicsModel.h" #include "AtomToMoleculeTransfer.h" #include "MoleculeSet.h" +#include "FieldManager.h" + +using std::string; +using std::map; +using std::pair; +using std::set; namespace ATC { //-------------------------------------------------- @@ -26,6 +32,8 @@ namespace ATC { atomicRegulator_(NULL), atomQuadForInternal_(true), elementMask_(NULL), + elementMaskMass_(NULL), + elementMaskMassMd_(NULL), internalToMask_(NULL), internalElement_(NULL), ghostElement_(NULL), @@ -46,6 +54,8 @@ namespace ATC { mdMassNormalization_ = true; // check to see if lammps has any charges if (lammpsInterface_->atom_charge()) trackCharge_ = true; + // default: perform velocity verlet + integrateInternalAtoms_ = true; } //-------------------------------------------------- ATC_Coupling::~ATC_Coupling() @@ -93,7 +103,7 @@ namespace ATC { \section syntax fix_modify AtC initial <field> <nodeset> <constant | function> - <field> = field name valid for type of physics, temperature | electron_temperature - - <nodeset> = name of set of nodes to apply boundary condition + - <nodeset> = name of set of nodes to apply initial condition - <constant | function> = value or name of function followed by its parameters \section examples @@ -102,8 +112,6 @@ namespace ATC { Sets the initial values for the specified field at the specified nodes. \section restrictions keyword 'all' reserved in nodeset name - \section related - see \ref man_internal \section default none */ @@ -150,15 +158,29 @@ namespace ATC { parse_field(arg,argIdx,thisField,thisIndex); string nsetName(arg[argIdx++]); XT_Function * f = NULL; + // fix current value + if (narg == argIdx) { + set<int> nodeSet = (feEngine_->fe_mesh())->nodeset(nsetName); + set<int>::const_iterator iset; + const DENS_MAT & field =(fields_.find(thisField)->second).quantity(); + for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { + int inode = *iset; + double v = field(inode,thisIndex); + f = XT_Function_Mgr::instance()->constant_function(v); + set<int> one; one.insert(inode); + prescribedDataMgr_->fix_field(one,thisField,thisIndex,f); + } + } // parse constant - if (narg == argIdx+1) { + else if (narg == argIdx+1) { f = XT_Function_Mgr::instance()->constant_function(atof(arg[argIdx])); + prescribedDataMgr_->fix_field(nsetName,thisField,thisIndex,f); } // parse function else { f = XT_Function_Mgr::instance()->function(&(arg[argIdx]),narg-argIdx); + prescribedDataMgr_->fix_field(nsetName,thisField,thisIndex,f); } - prescribedDataMgr_->fix_field(nsetName,thisField,thisIndex,f); match = true; } @@ -314,9 +336,13 @@ namespace ATC { \section examples <TT> fix_modify atc fe_md_boundary interpolate </TT> \n \section description + Specifies different methods for computing fluxes between between the MD and FE integration regions. Faceset defines a faceset separating the MD and FE regions and uses finite element face quadrature to compute the flux. Interpolate uses a reconstruction scheme to approximate the flux, which is more robust but less accurate if the MD/FE boundary does correspond to a faceset. No boundary results in no fluxes between the systems being computed. \section restrictions + If faceset is used, all the AtC non-boundary atoms must lie within and completely fill the domain enclosed by the faceset. \section related + see \man_boundary_faceset for how to specify the faceset name. \section default + Interpolate. */ else if (strcmp(arg[argIdx],"fe_md_boundary")==0) { bndyIntType_ = FE_INTERPOLATION;// default @@ -346,8 +372,11 @@ namespace ATC { \section examples fix_modify AtC boundary_faceset is obndy \section description - \section restrictions + This command species the faceset name when using a faceset to compute the MD/FE boundary fluxes. The faceset must already exist. + \section restrictions + This is only valid when fe_md_boundary is set to faceset. \section related + \man_fe_md_boundary \section default */ else if (strcmp(arg[argIdx],"boundary_faceset")==0) { @@ -373,7 +402,7 @@ namespace ATC { \section examples <TT> fix_modify atc internal_quadrature off </TT> \section description - Command use or not use atomic quadrature on internal elements + Command to use or not use atomic quadrature on internal elements fully filled with atoms. By turning the internal quadrature off these elements do not contribute to the governing PDE and the fields at the internal nodes follow the weighted averages of the atomic data. @@ -446,7 +475,9 @@ namespace ATC { match = true; } - /*! \page man_atomic_charge fix_modify AtC <include | omit> atomic_charge + /*! \page man_atomic_charge fix_modify AtC atomic_charge + \section syntax + fix_modify AtC <include | omit> atomic_charge - <include | omit> = switch to activiate/deactiviate inclusion of intrinsic atomic charge in ATC \section examples <TT> fix_modify atc compute include atomic_charge </TT> @@ -475,7 +506,9 @@ namespace ATC { } } - /*! \page man_source_integration fix_modify AtC source_integration < fe | atom> + /*! \page man_source_integration fix_modify AtC source_integration + \section syntax + fix_modify AtC source_integration < fe | atom> \section examples <TT> fix_modify atc source_integration atom </TT> \section description @@ -495,16 +528,17 @@ namespace ATC { match = true; } - /*! \page man_consistent_fe_initialization fix_modify AtC consistent_fe_initialization <on | off> - - <include | omit> = switch to activiate/deactiviate the intial setting of FE intrinsic field to match the projected MD field + /*! \page man_consistent_fe_initialization fix_modify AtC consistent_fe_initialization + \section syntax + fix_modify AtC consistent_fe_initialization <on | off> + - <on|off> = switch to activiate/deactiviate the intial setting of FE intrinsic field to match the projected MD field \section examples - <TT> fix_modify atc compute include atomic_charge </TT> + <TT> fix_modify atc consistent_fe_initialization on </TT> \section description Determines whether AtC initializes FE intrinsic fields (e.g., temperature) to match the projected MD values. This is particularly useful for fully overlapping simulations. \section restrictions - Can be used with: thermal, two_temperature - Cannot be used with time filtering on - Does not include boundary nodes + Can be used with: thermal, two_temperature. + Cannot be used with time filtering on. Does not include boundary nodes. \section related \section default Default is off @@ -555,15 +589,16 @@ namespace ATC { } } - /*! \page man_mass_matrix fix_modify AtC mass_matrix <fe | md_fe> + /*! \page man_mass_matrix fix_modify AtC mass_matrix + \section syntax + fix_modify AtC mass_matrix <fe | md_fe> - <fe | md_fe> = activiate/deactiviate using the FE mass matrix in the MD region \section examples <TT> fix_modify atc mass_matrix fe </TT> \section description Determines whether AtC uses the FE mass matrix based on Gaussian quadrature or based on atomic quadrature in the MD region. This is useful for fully overlapping simulations to improve efficiency. \section restrictions - Should not be used unless the FE region is contained within the MD region, - otherwise the method will be unstable and inaccurate + Should not be used unless the FE region is contained within the MD region, otherwise the method will be unstable and inaccurate \section related \section default Default is off @@ -590,9 +625,12 @@ namespace ATC { \section examples <TT> fix_modify AtC material gap_region 2</TT> \section description + Sets the material model in elementset_name to be of type material_id. \section restrictions + The element set must already be created and the material must be specified in the material file given the the atc fix on construction \section related \section default + All elements default to the first material in the material file. */ else if (strcmp(arg[argIdx],"material")==0) { argIdx++; @@ -693,43 +731,12 @@ namespace ATC { throw ATC_Error("Unknown physics type in ATC_Coupling::create_physics_model"); } } - //-------------------------------------------------------- - void ATC_Coupling::init_integrate_velocity() - { - const DENS_MAT & m(atomMasses_->quantity()); - double dt = 0.5 * lammpsInterface_->dt(); - - _deltaQuantity_ = atomForces_->quantity(); - for (int i = 0; i < nLocal_; i++) - for (int j = 0; j < nsd_; j ++) - _deltaQuantity_(i,j) *= dt/m(i,0); - - (*atomVelocities_) += _deltaQuantity_; - } - //-------------------------------------------------------- - void ATC_Coupling::init_integrate_position() - { - double dt = lammpsInterface_->dt(); - _deltaQuantity_ = atomVelocities_->quantity(); - _deltaQuantity_ *= dt; - (*atomPositions_) += _deltaQuantity_; - } - //-------------------------------------------------------- - void ATC_Coupling::final_integrate() - { - const DENS_MAT & m(atomMasses_->quantity()); - double dt = 0.5 * lammpsInterface_->dt(); - _deltaQuantity_ = atomForces_->quantity(); - for (int i = 0; i < nLocal_; i++) - for (int j = 0; j < nsd_; j ++) - _deltaQuantity_(i,j) *= dt/m(i,0); - - (*atomVelocities_) += _deltaQuantity_; - } //-------------------------------------------------------- void ATC_Coupling::construct_methods() { + ATC_Method::construct_methods(); + // construct needed time filters for mass matrices if (timeFilterManager_.need_reset()) { init_filter(); @@ -807,10 +814,11 @@ namespace ATC { //----------------------------------------------------------------- // this is w_a source_a void ATC_Coupling::compute_sources_at_atoms(const RHS_MASK & rhsMask, - const FIELDS & fields, - const PhysicsModel * physicsModel, - FIELD_MATS & atomicSources) + const FIELDS & fields, + const PhysicsModel * physicsModel, + FIELD_MATS & atomicSources) { + if (shpFcnMask_) { feEngine_->compute_source(rhsMask, fields, physicsModel, @@ -819,7 +827,16 @@ namespace ATC { shpFcnMask_->quantity(), shpFcnDerivsMask_->quantity(), atomicSources); - + } + else { + for (FIELDS::const_iterator field = fields.begin(); + field != fields.end(); field++) { + FieldName thisFieldName = field->first; + FIELDS::const_iterator fieldItr = fields.find(thisFieldName); + const DENS_MAT & field = (fieldItr->second).quantity(); + atomicSources[thisFieldName].reset(field.nRows(),field.nCols()); + } + } } //----------------------------------------------------------------- @@ -849,6 +866,24 @@ namespace ATC { } } //----------------------------------------------------------------- + void ATC_Coupling::masked_atom_domain_rhs_tangent( + const pair<FieldName,FieldName> row_col, + const RHS_MASK & rhsMask, + const FIELDS & fields, + SPAR_MAT & stiffness, + const PhysicsModel * physicsModel) + { + if (shpFcnMask_) { + feEngine_->compute_tangent_matrix(rhsMask, row_col, + fields, physicsModel, atomMaterialGroupsMask_, + atomicWeightsMask_->quantity(), shpFcnMask_->quantity(), + shpFcnDerivsMask_->quantity(),stiffness); + } + else { + stiffness.reset(nNodes_,nNodes_); + } + } + //----------------------------------------------------------------- void ATC_Coupling::compute_rhs_tangent( const pair<FieldName,FieldName> row_col, const RHS_MASK & rhsMask, @@ -871,10 +906,11 @@ namespace ATC { } feEngine_->compute_tangent_matrix(rhsMaskFE, row_col, fields , physicsModel, elementToMaterialMap_, stiffness); - feEngine_->compute_tangent_matrix(rhsMaskMD, row_col, - fields, physicsModel, atomMaterialGroupsMask_, - atomicWeightsMask_->quantity(), shpFcnMask_->quantity(), - shpFcnDerivsMask_->quantity(),stiffnessAtomDomain_); + masked_atom_domain_rhs_tangent(row_col, + rhsMaskMD, + fields, + stiffnessAtomDomain_, + physicsModel); stiffness += stiffnessAtomDomain_; } @@ -925,6 +961,32 @@ namespace ATC { feEngine_->add_robin_fluxes(rhsMask, fields, time(), robinFcn, rhs); } //----------------------------------------------------------------- + void ATC_Coupling::masked_atom_domain_rhs_integral( + const Array2D<bool> & rhsMask, + const FIELDS & fields, FIELDS & rhs, + const PhysicsModel * physicsModel) + { + if (shpFcnMask_) { + feEngine_->compute_rhs_vector(rhsMask, + fields, + physicsModel, + atomMaterialGroupsMask_, + atomicWeightsMask_->quantity(), + shpFcnMask_->quantity(), + shpFcnDerivsMask_->quantity(), + rhs); + } + else { + for (FIELDS::const_iterator field = fields.begin(); + field != fields.end(); field++) { + FieldName thisFieldName = field->first; + FIELDS::const_iterator fieldItr = fields.find(thisFieldName); + const DENS_MAT & field = (fieldItr->second).quantity(); + (rhs[thisFieldName].set_quantity()).reset(field.nRows(),field.nCols()); + } + } + } + //----------------------------------------------------------------- void ATC_Coupling::evaluate_rhs_integral( const Array2D<bool> & rhsMask, const FIELDS & fields, FIELDS & rhs, @@ -942,14 +1004,10 @@ namespace ATC { elementToMaterialMap_, rhs, &(elementMask_->quantity())); - feEngine_->compute_rhs_vector(rhsMask, - fields, - physicsModel, - atomMaterialGroupsMask_, - atomicWeightsMask_->quantity(), - shpFcnMask_->quantity(), - shpFcnDerivsMask_->quantity(), - rhsAtomDomain_); + masked_atom_domain_rhs_integral(rhsMask, + fields, + rhsAtomDomain_, + physicsModel); for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; @@ -958,14 +1016,10 @@ namespace ATC { } else if (integrationType == ATOM_DOMAIN) { - feEngine_->compute_rhs_vector(rhsMask, - fields, - physicsModel, - atomMaterialGroupsMask_, - atomicWeightsMask_->quantity(), - shpFcnMask_->quantity(), - shpFcnDerivsMask_->quantity(), - rhs); + masked_atom_domain_rhs_integral(rhsMask, + fields, + rhs, + physicsModel); } else if (integrationType == FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE) { RHS_MASK rhsMaskFE = rhsMask; @@ -983,14 +1037,10 @@ namespace ATC { physicsModel, elementToMaterialMap_, rhs); - feEngine_->compute_rhs_vector(rhsMaskMD, - fields, - physicsModel, - atomMaterialGroupsMask_, - atomicWeightsMask_->quantity(), - shpFcnMask_->quantity(), - shpFcnDerivsMask_->quantity(), - rhsAtomDomain_); + masked_atom_domain_rhs_integral(rhsMaskMD, + fields, + rhsAtomDomain_, + physicsModel); for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; @@ -1123,6 +1173,52 @@ namespace ATC { } } //-------------------------------------------------------- + // create_full_element_mask + // constructs element mask which only masks out + // null elements + //-------------------------------------------------------- + MatrixDependencyManager<DenseMatrix, bool> * ATC_Coupling::create_full_element_mask() + { + MatrixDependencyManager<DenseMatrix, bool> * elementMaskMan = new MatrixDependencyManager<DenseMatrix, bool>(feEngine_->num_elements(),1); + DenseMatrix<bool> & elementMask(elementMaskMan->set_quantity()); + elementMask = true; + + const set<int> & nullElements = feEngine_->null_elements(); + set<int>::const_iterator iset; + for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { + int ielem = *iset; + elementMask(ielem,0) = false; + } + + return elementMaskMan; + } + //-------------------------------------------------------- + // create_element_set_mask + // constructs element mask based on an element set, + // uses ints for MPI communication later + //-------------------------------------------------------- + MatrixDependencyManager<DenseMatrix, int> * ATC_Coupling::create_element_set_mask(const string & elementSetName) + { + MatrixDependencyManager<DenseMatrix, int> * elementMaskMan = new MatrixDependencyManager<DenseMatrix, int>(feEngine_->num_elements(),1); + DenseMatrix<int> & elementMask(elementMaskMan->set_quantity()); + elementMask = false; + + const set<int> & elementSet((feEngine_->fe_mesh())->elementset(elementSetName)); + set<int>::const_iterator iset; + for (iset = elementSet.begin(); iset != elementSet.end(); ++iset) { + int ielem = *iset; + elementMask(ielem,0) = true; + } + + const set<int> & nullElements = feEngine_->null_elements(); + for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { + int ielem = *iset; + elementMask(ielem,0) = false; + } + + return elementMaskMan; + } + //-------------------------------------------------------- // set_computational_geometry // constructs needed transfer operators which define // hybrid atom/FE computational geometry @@ -1131,70 +1227,85 @@ namespace ATC { { ATC_Method::set_computational_geometry(); + // does element contain internal atoms + if (internalElementSet_.size()) { + // set up elements and maps based on prescribed element sets + internalElement_ = create_element_set_mask(internalElementSet_); + } + else { + internalElement_ = new AtomTypeElement(this,atomElement_); + } + interscaleManager_.add_dense_matrix_int(internalElement_, + "ElementHasInternal"); + if (groupbitGhost_) { atomGhostElement_ = new AtomToElementMap(this, atomGhostCoarseGrainingPositions_, GHOST); interscaleManager_.add_per_atom_int_quantity(atomGhostElement_, "AtomGhostElement"); - } - - // does element contain internal atoms - internalElement_ = new AtomTypeElement(this,atomElement_); - interscaleManager_.add_dense_matrix_int(internalElement_, - "ElementHasInternal"); - // does element contain ghost atoms - if (atomGhostElement_) { + + // does element contain ghost atoms ghostElement_ = new AtomTypeElement(this,atomGhostElement_); interscaleManager_.add_dense_matrix_int(ghostElement_, "ElementHasGhost"); } - // element masking for FE quadrature + + // element masking for approximate right-hand side FE atomic quadrature if (atomQuadForInternal_) { - elementMask_ = new MatrixDependencyManager<DenseMatrix, bool>(feEngine_->num_elements(),1); - DenseMatrix<bool> & elementMask(elementMask_->set_quantity()); - elementMask = true; - - const set<int> & nullElements = feEngine_->null_elements(); - set<int>::const_iterator iset; - for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { - int ielem = *iset; - elementMask(ielem,0) = false; - } + elementMask_ = create_full_element_mask(); } else { - elementMask_ = new ElementMask(this); + if (internalElementSet_.size()) { + // when geometry is based on elements, there are no mixed elements + elementMask_ = new MatrixDependencyManager<DenseMatrix, bool>; + (elementMask_->set_quantity()).reset(feEngine_->num_elements(),1,false); + } + else { + elementMask_ = new ElementMask(this); + } internalToMask_ = new AtomToElementset(this,elementMask_); interscaleManager_.add_per_atom_int_quantity(internalToMask_, "InternalToMaskMap"); } interscaleManager_.add_dense_matrix_bool(elementMask_, - "ElementMask"); - // node type - nodalGeometryType_ = new NodalGeometryType(this); + "ElementMask"); + + if (useFeMdMassMatrix_) { + if (atomQuadForInternal_) { + elementMaskMass_ = elementMask_; + } + else { + elementMaskMass_ = create_full_element_mask(); + interscaleManager_.add_dense_matrix_bool(elementMaskMass_, + "NonNullElementMask"); + } + + elementMaskMassMd_ = new AtomElementMask(this); + interscaleManager_.add_dense_matrix_bool(elementMaskMassMd_, + "InternalElementMask"); + } + + // assign element and node types for computational geometry + if (internalElementSet_.size()) { + nodalGeometryType_ = new NodalGeometryTypeElementSet(this); + } + else { + nodalGeometryType_ = new NodalGeometryType(this); + } interscaleManager_.add_dense_matrix_int(nodalGeometryType_, - "NodalGeometryType"); + "NodalGeometryType"); } //-------------------------------------------------------- - // construct_transfers - // constructs needed transfer operators + // construct_interpolant + // constructs: interpolatn, accumulant, weights, and spatial derivatives //-------------------------------------------------------- - void ATC_Coupling::construct_transfers() + void ATC_Coupling::construct_interpolant() { - ATC_Method::construct_transfers(); - // finite element shape functions for interpolants PerAtomShapeFunction * atomShapeFunctions = new PerAtomShapeFunction(this); interscaleManager_.add_per_atom_sparse_matrix(atomShapeFunctions,"Interpolant"); shpFcn_ = atomShapeFunctions; - if (groupbitGhost_) { - atomShapeFunctions = new PerAtomShapeFunction(this, - atomGhostCoarseGrainingPositions_, - atomGhostElement_, - GHOST); - interscaleManager_.add_per_atom_sparse_matrix(atomShapeFunctions,"InterpolantGhost"); - shpFcnGhost_ = atomShapeFunctions; - } // use shape functions for accumulants if no kernel function is provided if (!kernelFunction_) { @@ -1209,30 +1320,64 @@ namespace ATC { accumulantWeights_ = new AccumulantWeights(accumulant_); mdMassNormalization_ = false; } - - // add species transfer operators - map<string,pair<IdType,int> >::const_iterator specid; - for (specid = speciesIds_.begin(); specid != speciesIds_.end(); specid++) { - const string specie = specid->first; - LargeToSmallAtomMap * specieMap; - if ((specid->second).first == ATOM_TYPE) { - specieMap = new AtomToType(this,(specid->second).second); - interscaleManager_.add_per_atom_int_quantity(specieMap, - "AtomMap"+specie); + this->create_atom_volume(); + + // masked atom weights + if (atomQuadForInternal_) { + atomicWeightsMask_ = atomVolume_; + } + else { + atomicWeightsMask_ = new MappedDiagonalMatrix(this, + atomVolume_, + internalToMask_); + interscaleManager_.add_diagonal_matrix(atomicWeightsMask_, + "AtomWeightsMask"); + } + // nodal volumes for mass matrix, relies on atomVolumes constructed in base class construct_transfers + nodalAtomicVolume_ = new AdmtfShapeFunctionRestriction(this,atomVolume_,shpFcn_); + interscaleManager_.add_dense_matrix(nodalAtomicVolume_,"NodalAtomicVolume"); + + // shape function derivatives, masked shape function and derivatives if needed for FE quadrature in atomic domain + if (atomQuadForInternal_) { + shpFcnDerivs_ = new PerAtomShapeFunctionGradient(this); + interscaleManager_.add_vector_sparse_matrix(shpFcnDerivs_, + "InterpolantGradient"); + + shpFcnMask_ = shpFcn_; + shpFcnDerivsMask_ = shpFcnDerivs_; + } + else { + bool hasMaskedElt = false; + const DenseMatrix<bool> & elementMask(elementMask_->quantity()); + for (int i = 0; i < elementMask.size(); ++i) { + if (elementMask(i,0)) { + hasMaskedElt = true; + break; + } } - else { // if ((specie->second).first == ATOM_GROUP) - specieMap = new AtomToGroup(this,(specid->second).second); - interscaleManager_.add_per_atom_int_quantity(specieMap, - "AtomMap"+specie); + if (hasMaskedElt) { + shpFcnDerivs_ = new PerAtomShapeFunctionGradient(this); + interscaleManager_.add_vector_sparse_matrix(shpFcnDerivs_, + "InterpolantGradient"); + + shpFcnMask_ = new RowMappedSparseMatrix(this, + shpFcn_, + internalToMask_); + interscaleManager_.add_sparse_matrix(shpFcnMask_, + "ShapeFunctionMask"); + shpFcnDerivsMask_ = new RowMappedSparseMatrixVector(this, + shpFcnDerivs_, + internalToMask_); + interscaleManager_.add_vector_sparse_matrix(shpFcnDerivsMask_,"ShapeFunctionGradientMask"); } - ReducedSparseMatrix * accumulantSpecie = new ReducedSparseMatrix(this, - accumulant_, - specieMap); - interscaleManager_.add_sparse_matrix(accumulantSpecie,"Accumulant"+specie); } - - // add molecule transfer operators + } + //-------------------------------------------------------- + // construct_molecule_transfers + //-------------------------------------------------------- + void ATC_Coupling::construct_molecule_transfers() + { map<string,pair<MolSize,int> >::const_iterator molecule; PerAtomQuantity<double> * atomProcGhostCoarseGrainingPositions = interscaleManager_.per_atom_quantity("AtomicProcGhostCoarseGrainingPositions"); @@ -1258,58 +1403,16 @@ namespace ATC { interscaleManager_.add_sparse_matrix(shpFcnMol, "ShapeFunction"+moleculeName); } - - - this->create_atom_volume(); - - // masked atom weights - if (atomQuadForInternal_) { - atomicWeightsMask_ = atomVolume_; - } - else { - atomicWeightsMask_ = new MappedDiagonalMatrix(this, - atomVolume_, - internalToMask_); - interscaleManager_.add_diagonal_matrix(atomicWeightsMask_, - "AtomWeightsMask"); - } + } + //-------------------------------------------------------- + // construct_transfers + // constructs needed transfer operators + //-------------------------------------------------------- + void ATC_Coupling::construct_transfers() + { + ATC_Method::construct_transfers(); - // shape function derivatives - PerAtomShapeFunctionGradient * atomShapeFunctionGradients = new PerAtomShapeFunctionGradient(this); - interscaleManager_.add_vector_sparse_matrix(atomShapeFunctionGradients, - "InterpolantGradient"); - shpFcnDerivs_ = atomShapeFunctionGradients; - if (groupbitGhost_) { - atomShapeFunctionGradients = new PerAtomShapeFunctionGradient(this, - atomGhostElement_, - atomGhostCoarseGrainingPositions_, - "InterpolantGradientGhost", - GHOST); - interscaleManager_.add_vector_sparse_matrix(atomShapeFunctionGradients, - "InterpolantGradientGhost"); - shpFcnDerivsGhost_ = atomShapeFunctionGradients; - } - // masked shape function and derivatives - if (atomQuadForInternal_) { - shpFcnMask_ = shpFcn_; - shpFcnDerivsMask_ = shpFcnDerivs_; - } - else { - shpFcnMask_ = new RowMappedSparseMatrix(this, - shpFcn_, - internalToMask_); - interscaleManager_.add_sparse_matrix(shpFcnMask_, - "ShapeFunctionMask"); - shpFcnDerivsMask_ = new RowMappedSparseMatrixVector(this, - shpFcnDerivs_, - internalToMask_); - interscaleManager_.add_vector_sparse_matrix(shpFcnDerivsMask_,"ShapeFunctionGradientMask"); - } - - // nodal volumes for mass matrix, relies on atomVolumes constructed in base class construct_transfers - nodalAtomicVolume_ = new AdmtfShapeFunctionRestriction(this,atomVolume_,shpFcn_); - interscaleManager_.add_dense_matrix(nodalAtomicVolume_,"NodalAtomicVolume"); extrinsicModelManager_.construct_transfers(); } @@ -1387,11 +1490,15 @@ namespace ATC { if (useFeMdMassMatrix_) { feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel, elementToMaterialMap_,massMats_, - &(elementMask_->quantity())); + &(elementMaskMass_->quantity())); const DIAG_MAT & myMassMat(massMats_[thisField].quantity()); DIAG_MAT & myMassMatInv(massMatsInv_[thisField].set_quantity()); - DIAG_MAT & myMassMatMDInv(massMatsMdInv_[thisField].set_quantity()); - (massMatsMd_[thisField].set_quantity()) = myMassMat; + DIAG_MAT & myMassMatMdInv(massMatsMdInv_[thisField].set_quantity()); + + feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel, + elementToMaterialMap_,massMatsMd_, + &(elementMaskMassMd_->quantity())); + const DIAG_MAT & myMassMatMd(massMatsMd_[thisField].quantity()); // compute inverse mass matrices since we're using lumped masses for (int iNode = 0; iNode < nNodes_; iNode++) { @@ -1399,7 +1506,11 @@ namespace ATC { myMassMatInv(iNode,iNode) = 1./myMassMat(iNode,iNode); else myMassMatInv(iNode,iNode) = 0.; - myMassMatMDInv = myMassMatInv; + + if (fabs(myMassMatMd(iNode,iNode))>0) + myMassMatMdInv(iNode,iNode) = 1./myMassMatMd(iNode,iNode); + else + myMassMatMdInv(iNode,iNode) = 0.; } } else { @@ -1418,10 +1529,14 @@ namespace ATC { } // atomic quadrature for FE mass matrix in atomic domain - - feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel,atomMaterialGroupsMask_, - atomicWeightsMask_->quantity(),shpFcnMask_->quantity(), - massMatsAqInstantaneous_); + if (shpFcnMask_) { + feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel,atomMaterialGroupsMask_, + atomicWeightsMask_->quantity(),shpFcnMask_->quantity(), + massMatsAqInstantaneous_); + } + else { + (massMatsAqInstantaneous_[thisField].set_quantity()).reset(nNodes_,nNodes_); + } // set up mass MD matrices compute_md_mass_matrix(thisField,massMatsMdInstantaneous_[thisField].set_quantity()); @@ -1489,12 +1604,81 @@ namespace ATC { } } } -//-------------------------------------------------------- + + //-------------------------------------------------------- + // pre_init_integrate + // time integration before the lammps atomic + // integration of the Verlet step 1 + //-------------------------------------------------------- + void ATC_Coupling::pre_init_integrate() + { + ATC_Method::pre_init_integrate(); + double dt = lammpsInterface_->dt(); + + // Perform any initialization, no actual integration + for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { + (_tiIt_->second)->pre_initial_integrate1(dt); + } + + // Apply controllers to atom velocities, if needed + atomicRegulator_->apply_pre_predictor(dt,lammpsInterface_->ntimestep()); + + // predict nodal fields and time derivatives + for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { + (_tiIt_->second)->pre_initial_integrate2(dt); + } + extrinsicModelManager_.pre_init_integrate(); + } + + //-------------------------------------------------------- + // mid_init_integrate + // time integration between the velocity update and + // the position lammps update of Verlet step 1 + //-------------------------------------------------------- + void ATC_Coupling::mid_init_integrate() + { + double dt = lammpsInterface_->dt(); + + // Compute nodal velocity at n+1/2, if needed + for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { + (_tiIt_->second)->mid_initial_integrate1(dt); + } + + atomicRegulator_->apply_mid_predictor(dt,lammpsInterface_->ntimestep()); + + extrinsicModelManager_.mid_init_integrate(); + } + + ///-------------------------------------------------------- + // post_init_integrate + // time integration after the lammps atomic updates of + // Verlet step 1 + //-------------------------------------------------------- void ATC_Coupling::post_init_integrate() { + double dt = lammpsInterface_->dt(); + + // Compute nodal velocity at n+1 + for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { + (_tiIt_->second)->post_initial_integrate1(dt); + } + + // Update kinetostat quantities if displacement is being regulated + atomicRegulator_->apply_post_predictor(dt,lammpsInterface_->ntimestep()); + + // Update extrisic model + extrinsicModelManager_.post_init_integrate(); + + // fixed values, non-group bcs handled through FE + set_fixed_nodes(); + + update_time(0.5); + + // ghost update, if needed + ATC_Method::post_init_integrate(); + // Apply time filtering to mass matrices, if needed if (timeFilterManager_.filter_dynamics() && !useFeMdMassMatrix_) { - double dt = lammpsInterface_->dt(); map<FieldName,int>::const_iterator field; for (field = fieldSizes_.begin(); field!=fieldSizes_.end(); field++) { FieldName thisField = field->first; diff --git a/lib/atc/ATC_Coupling.h b/lib/atc/ATC_Coupling.h index a890d9d838d50c34b650beeff069c07947bbb41d..464db33074beef6554ed2f4dbd453399440723c3 100644 --- a/lib/atc/ATC_Coupling.h +++ b/lib/atc/ATC_Coupling.h @@ -1,12 +1,15 @@ #ifndef ATC_COUPLING_H #define ATC_COUPLING_H +#include <set> +#include <map> +#include <string> +#include <utility> + // ATC headers #include "ATC_Method.h" #include "ExtrinsicModel.h" -using namespace std; - namespace ATC { // Forward declarations @@ -34,7 +37,7 @@ namespace ATC { friend class SliceSchrodingerPoissonSolver; /** constructor */ - ATC_Coupling(string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix); + ATC_Coupling(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix); /** destructor */ virtual ~ATC_Coupling(); @@ -61,14 +64,11 @@ namespace ATC { /** post integration run : called at end of run or simulation */ virtual void finish(); - /** Predictor phase, Verlet first step for velocity */ - virtual void init_integrate_velocity(); + /** first time, before atomic integration */ + virtual void pre_init_integrate(); /** Predictor phase, executed between velocity and position Verlet */ - virtual void mid_init_integrate(){}; - - /** Predictor phase, Verlet first step for position */ - virtual void init_integrate_position(); + virtual void mid_init_integrate(); /** Predictor phase, executed after Verlet */ virtual void post_init_integrate(); @@ -76,9 +76,6 @@ namespace ATC { /** Corrector phase, executed before Verlet */ virtual void pre_final_integrate(){}; - /** Corrector phase, Verlet second step for velocity */ - virtual void final_integrate(); - /** Corrector phase, executed after Verlet*/ virtual void post_final_integrate() {lammpsInterface_->computes_addstep(lammpsInterface_->ntimestep()+1);}; @@ -94,15 +91,15 @@ namespace ATC { SPAR_MAN &atom_to_overlap_mat() {return atomToOverlapMat_;}; /** check if atomic quadrature is being used for MD_ONLY nodes */ bool atom_quadrature_on(){return atomQuadForInternal_;}; - const set<string> & boundary_face_names() {return boundaryFaceNames_;}; + const std::set<std::string> & boundary_face_names() {return boundaryFaceNames_;}; /** access to boundary integration method */ int boundary_integration_type() {return bndyIntType_;}; void set_boundary_integration_type(int boundaryIntegrationType) {bndyIntType_ = boundaryIntegrationType;}; - void set_boundary_face_set(const set< pair<int,int> > * boundaryFaceSet) + void set_boundary_face_set(const std::set< std::pair<int,int> > * boundaryFaceSet) {bndyFaceSet_ = boundaryFaceSet;}; BoundaryIntegrationType parse_boundary_integration - (int narg, char **arg, const set< pair<int,int> > * boundaryFaceSet); + (int narg, char **arg, const std::set< std::pair<int,int> > * boundaryFaceSet); TemperatureDefType temperature_def() const {return temperatureDef_;}; void set_temperature_def(TemperatureDefType tdef) {temperatureDef_ = tdef;}; @@ -114,7 +111,7 @@ namespace ATC { void compute_boundary_flux(const Array2D<bool> & rhs_mask, const FIELDS &fields, FIELDS &rhs, - const Array< set <int> > atomMaterialGroups, + const Array< std::set <int> > atomMaterialGroups, const VectorDependencyManager<SPAR_MAT * > * shpFcnDerivs, const SPAR_MAN * shpFcn = NULL, const DIAG_MAN * atomicWeights = NULL, @@ -135,10 +132,15 @@ namespace ATC { /** wrapper for FE_Engine's compute_sources */ void compute_sources_at_atoms(const RHS_MASK & rhsMask, - const FIELDS & fields, - const PhysicsModel * physicsModel, - FIELD_MATS & atomicSources); - + const FIELDS & fields, + const PhysicsModel * physicsModel, + FIELD_MATS & atomicSources); + /** computes tangent matrix using atomic quadrature near FE region */ + void masked_atom_domain_rhs_tangent(const std::pair<FieldName,FieldName> row_col, + const RHS_MASK & rhsMask, + const FIELDS & fields, + SPAR_MAT & stiffness, + const PhysicsModel * physicsModel); /** wrapper for FE_Engine's compute_rhs_vector functions */ void compute_rhs_vector(const RHS_MASK & rhs_mask, const FIELDS &fields, @@ -146,7 +148,7 @@ namespace ATC { const IntegrationDomainType domain, // = FULL_DOMAIN const PhysicsModel * physicsModel=NULL); /** wrapper for FE_Engine's compute_tangent_matrix */ - void compute_rhs_tangent(const pair<FieldName,FieldName> row_col, + void compute_rhs_tangent(const std::pair<FieldName,FieldName> row_col, const RHS_MASK & rhsMask, const FIELDS & fields, SPAR_MAT & stiffness, @@ -200,7 +202,7 @@ namespace ATC { void construct_prescribed_data_manager (void); /** method to create physics model */ void create_physics_model(const PhysicsType & physicsType, - string matFileName); + std::string matFileName); /** access to physics model */ PhysicsModel * physics_model() {return physicsModel_; }; /*@}*/ @@ -274,6 +276,11 @@ namespace ATC { const FIELDS &fields, GRAD_FIELD_MATS &flux, const PhysicsModel * physicsModel=NULL); + /** evaluate rhs on the atomic domain which is near the FE region */ + void masked_atom_domain_rhs_integral(const Array2D<bool> & rhs_mask, + const FIELDS &fields, + FIELDS &rhs, + const PhysicsModel * physicsModel); /** evaluate rhs on a specified domain defined by mask and physics model */ void evaluate_rhs_integral(const Array2D<bool> & rhs_mask, const FIELDS &fields, @@ -317,6 +324,10 @@ namespace ATC { virtual void construct_methods(); /** set up data which is dependency managed */ virtual void construct_transfers(); + /** sets up mol transfers */ + virtual void construct_molecule_transfers(); + /** sets up accumulant & interpolant */ + virtual void construct_interpolant(); //--------------------------------------------------------------- /** status */ @@ -345,11 +356,11 @@ namespace ATC { /** manager for regulator */ AtomicRegulator * atomicRegulator_; /** managers for time integrators per field */ - map<FieldName,TimeIntegrator * > timeIntegrators_; + std::map<FieldName,TimeIntegrator * > timeIntegrators_; /** time integrator iterator */ - mutable map<FieldName,TimeIntegrator * >::iterator _tiIt_; + mutable std::map<FieldName,TimeIntegrator * >::iterator _tiIt_; /** time integrator const iterator */ - mutable map<FieldName,TimeIntegrator * >::const_iterator _ctiIt_; + mutable std::map<FieldName,TimeIntegrator * >::const_iterator _ctiIt_; /*@}*/ //--------------------------------------------------------------- @@ -360,8 +371,8 @@ namespace ATC { /** atomic ATC material tag */ - Array< set <int> > atomMaterialGroups_; // ATOMIC_TAG*atomMaterialGroups_; - Array< set <int> > atomMaterialGroupsMask_; // ATOMIC_TAG*atomMaterialGroupsMask_; + Array< std::set <int> > atomMaterialGroups_; // ATOMIC_TAG*atomMaterialGroups_; + Array< std::set <int> > atomMaterialGroupsMask_; // ATOMIC_TAG*atomMaterialGroupsMask_; /*@}*/ //--------------------------------------------------------------- @@ -370,18 +381,22 @@ namespace ATC { /*@{*/ bool atomQuadForInternal_; MatrixDependencyManager<DenseMatrix, bool> * elementMask_; + MatrixDependencyManager<DenseMatrix, bool> * elementMaskMass_; + MatrixDependencyManager<DenseMatrix, bool> * elementMaskMassMd_; + MatrixDependencyManager<DenseMatrix, bool> * create_full_element_mask(); + MatrixDependencyManager<DenseMatrix, int> * create_element_set_mask(const std::string & elementSetName); LargeToSmallAtomMap * internalToMask_; - AtomTypeElement * internalElement_; - AtomTypeElement * ghostElement_; - NodalGeometryType * nodalGeometryType_; + MatrixDependencyManager<DenseMatrix, int> * internalElement_; + MatrixDependencyManager<DenseMatrix, int> * ghostElement_; + DenseMatrixTransfer<int> * nodalGeometryType_; /*@}*/ /** \name boundary integration */ /*@{*/ /** boundary flux quadrature */ int bndyIntType_; - const set< pair<int,int> > * bndyFaceSet_; - set<string> boundaryFaceNames_; + const std::set< std::pair<int,int> > * bndyFaceSet_; + std::set<std::string> boundaryFaceNames_; /*@}*/ //---------------------------------------------------------------- diff --git a/lib/atc/ATC_CouplingEnergy.cpp b/lib/atc/ATC_CouplingEnergy.cpp index 5a80620b0fb27a194f009b999119980faa3044e0..066bf0b43ec3b4e4bb85054438375dec55def3da 100644 --- a/lib/atc/ATC_CouplingEnergy.cpp +++ b/lib/atc/ATC_CouplingEnergy.cpp @@ -11,6 +11,8 @@ #include <utility> #include <typeinfo> +using std::string; + namespace ATC { //-------------------------------------------------------- @@ -93,15 +95,6 @@ namespace ATC { // init_filter uses fieldRateNdFiltered which comes from the time integrator, // which is why the time integrator is initialized first - // set the reference potential, if necessary, because the nodal energy is needed to initialize the time integrator - if (!initialized_) { - if (temperatureDef_==TOTAL) { - PerAtomQuantity<double> * atomicReferencePotential = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); - PerAtomQuantity<double> * atomicPotentialEnergy = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - atomicReferencePotential->set_quantity() = atomicPotentialEnergy->quantity(); - } - } - // other initializations if (reset_methods()) { for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { @@ -114,7 +107,9 @@ namespace ATC { if (timeFilterManager_.need_reset()) { init_filter(); } - timeFilterManager_.initialize(); // clears need for reset + // clears need for reset + timeFilterManager_.initialize(); + ghostManager_.initialize(); if (!initialized_) { // initialize sources based on initial FE temperature @@ -196,21 +191,34 @@ namespace ATC { "AtomicTwiceKineticEnergy"); // atomic potential energy - //ComputedAtomQuantity * atomicPotentialEnergy = new ComputedAtomQuantity(this,lammpsInterface_->compute_pe_name(), 1./(lammpsInterface_->mvv2e())); - //interscaleManager_.add_per_atom_quantity(atomicPotentialEnergy, - // "AtomicPotentialEnergy"); - PerAtomQuantity<double> * atomicPotentialEnergy = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - -///////////////////////////////////// - FieldManager fmgr(this); - fmgr.nodal_atomic_field(REFERENCE_POTENTIAL_ENERGY); - PerAtomQuantity<double> * atomicReferencePotential = - interscaleManager_.per_atom_quantity("AtomicReferencePotential"); -///////////////////////////////////// + ComputedAtomQuantity * atomicPotentialEnergy = new ComputedAtomQuantity(this, + lammpsInterface_->compute_pe_name(), + 1./(lammpsInterface_->mvv2e())); + interscaleManager_.add_per_atom_quantity(atomicPotentialEnergy, + "AtomicPotentialEnergy"); + + // reference potential energy + AtcAtomQuantity<double> * atomicReferencePotential; + if (!initialized_) { + atomicReferencePotential = new AtcAtomQuantity<double>(this); + interscaleManager_.add_per_atom_quantity(atomicReferencePotential, + "AtomicReferencePotential"); + atomicReferencePotential->set_memory_type(PERSISTENT); + } + else { + atomicReferencePotential = static_cast<AtcAtomQuantity<double> * >(interscaleManager_.per_atom_quantity("AtomicReferencePotential")); + } + nodalRefPotentialEnergy_ = new AtfShapeFunctionRestriction(this, + atomicReferencePotential, + shpFcn_); + interscaleManager_.add_dense_matrix(nodalRefPotentialEnergy_, + "NodalAtomicReferencePotential"); + // fluctuating potential energy - AtomicEnergyForTemperature * atomicFluctuatingPotentialEnergy = new FluctuatingPotentialEnergy(this, - atomicPotentialEnergy, - atomicReferencePotential); + AtomicEnergyForTemperature * atomicFluctuatingPotentialEnergy = + new FluctuatingPotentialEnergy(this, + atomicPotentialEnergy, + atomicReferencePotential); interscaleManager_.add_per_atom_quantity(atomicFluctuatingPotentialEnergy, "AtomicFluctuatingPotentialEnergy"); @@ -388,6 +396,9 @@ namespace ATC { else if (strcmp(arg[argIndx],"temperature_definition")==0) { argIndx++; string_to_temperature_def(arg[argIndx],temperatureDef_); + if (temperatureDef_ == TOTAL) { + setRefPE_ = true; + } foundMatch = true; needReset_ = true; } @@ -451,31 +462,7 @@ namespace ATC { atomElement_); } - //-------------------------------------------------- - // pre_init_integrate - // time integration before the lammps atomic - // integration of the Verlet step 1 - //-------------------------------------------------- - void ATC_CouplingEnergy::pre_init_integrate() - { - ATC_Coupling::pre_init_integrate(); - double dt = lammpsInterface_->dt(); - - // Perform any initialization, no actual integration - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate1(dt); - } - - // Apply thermostat force to atom velocities - atomicRegulator_->apply_pre_predictor(dt,lammpsInterface_->ntimestep()); - - // Predict nodal temperatures and time derivatives based on FE data - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate2(dt); - } - extrinsicModelManager_.pre_init_integrate(); - } - +#ifdef OBSOLETE //-------------------------------------------------------- // mid_init_integrate // time integration between the velocity update and @@ -525,7 +512,7 @@ namespace ATC { ATC_Coupling::post_init_integrate(); } - +#endif //-------------------------------------------------------- // post_final_integrate // integration after the second stage lammps atomic diff --git a/lib/atc/ATC_CouplingEnergy.h b/lib/atc/ATC_CouplingEnergy.h index 6866cd0510b7c4102a45e1041bccaba1bccba4d5..ba26961187585d545405cd8599424e923347200e 100644 --- a/lib/atc/ATC_CouplingEnergy.h +++ b/lib/atc/ATC_CouplingEnergy.h @@ -9,6 +9,7 @@ // Other headers #include <map> +#include <string> namespace ATC { @@ -52,14 +53,13 @@ namespace ATC { /** post time integration */ virtual void finish(); +#ifdef OBSOLETE - /** first time substep routines */ - virtual void pre_init_integrate(); /** first time, after atomic velocity but before position integration */ virtual void mid_init_integrate(); /** first time, after atomic integration */ virtual void post_init_integrate(); - +#endif /** second time substep routine */ virtual void post_final_integrate(); @@ -117,8 +117,8 @@ namespace ATC { DENS_MAT _keTemp_, _peTemp_; // Add in fields for restarting - virtual void read_restart_data(string fileName_, RESTART_LIST & data); - virtual void write_restart_data(string fileName_, RESTART_LIST & data); + virtual void read_restart_data(std::string fileName_, RESTART_LIST & data); + virtual void write_restart_data(std::string fileName_, RESTART_LIST & data); void pack_thermal_fields(RESTART_LIST & data); }; diff --git a/lib/atc/ATC_CouplingMass.cpp b/lib/atc/ATC_CouplingMass.cpp index dd586d59c413483db0a6d66a81c33c250b40eacd..54fb065413c32bfeca6b0b4bc91b4e105a369732 100644 --- a/lib/atc/ATC_CouplingMass.cpp +++ b/lib/atc/ATC_CouplingMass.cpp @@ -16,10 +16,14 @@ // Other Headers #include <vector> -#include <map> #include <set> #include <utility> +using ATC_Utility::to_string; +using std::map; +using std::string; +using std::pair; + namespace ATC { //-------------------------------------------------------- @@ -114,7 +118,7 @@ namespace ATC { void ATC_CouplingMass::initialize() { - fieldSizes_[SPECIES_CONCENTRATION] = speciesIds_.size(); + fieldSizes_[SPECIES_CONCENTRATION] = ntracked(); // Base class initalizations ATC_Coupling::initialize(); @@ -128,10 +132,9 @@ namespace ATC { if (consistentInitialization_) { DENS_MAT & massDensity(fields_[MASS_DENSITY].set_quantity()); - const DENS_MAT & atomicMassDensity(nodalAtomicFields_[MASS_DENSITY].quantity()); + const DENS_MAT & atomicMassDensity(atomicFields_[MASS_DENSITY]->quantity()); DENS_MAT & speciesConcentration(fields_[SPECIES_CONCENTRATION].set_quantity()); - //const DENS_MAT & atomicSpeciesConcentration(nodalAtomicFields_[SPECIES_CONCENTRATION].quantity()); const DENS_MAT & atomicSpeciesConcentration(atomicFields_[SPECIES_CONCENTRATION]->quantity()); const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); @@ -146,6 +149,8 @@ namespace ATC { } } } + + // other initializatifields_[SPECIES_CONCENTRATION].quantity()ons if (reset_methods()) { for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { @@ -153,9 +158,13 @@ namespace ATC { } } extrinsicModelManager_.initialize(); // always needed to construct new Poisson solver - if (timeFilterManager_.need_reset()) { init_filter(); } - timeFilterManager_.initialize(); // clears need for reset + if (timeFilterManager_.need_reset()) { + init_filter(); + } + // clears need for reset + timeFilterManager_.initialize(); atomicRegulator_->initialize(); + ghostManager_.initialize(); if (!initialized_) { // initialize sources based on initial FE temperature @@ -261,16 +270,6 @@ namespace ATC { } } - //-------------------------------------------------- - // pack_fields - // bundle all allocated field matrices into a list - // for output needs - //-------------------------------------------------- - - void ATC_CouplingMass::pack_species_fields(RESTART_LIST & data) - { - } - //-------------------------------------------------- // write_restart_file // bundle matrices that need to be saved and call @@ -278,7 +277,6 @@ namespace ATC { //-------------------------------------------------- void ATC_CouplingMass::write_restart_data(string fileName, RESTART_LIST & data) { - pack_species_fields(data); ATC_Method::write_restart_data(fileName,data); } @@ -289,8 +287,6 @@ namespace ATC { //-------------------------------------------------- void ATC_CouplingMass::read_restart_data(string fileName, RESTART_LIST & data) { - - pack_species_fields(data); ATC_Method::read_restart_data(fileName,data); } @@ -322,29 +318,7 @@ namespace ATC { } } - //-------------------------------------------------------- - // pre_init_integrate - // time integration before the lammps atomic - // integration of the Verlet step 1 - //-------------------------------------------------------- - void ATC_CouplingMass::pre_init_integrate() - { - ATC_Coupling::pre_init_integrate(); - double dt = lammpsInterface_->dt(); - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate1(dt); - } - - // Apply thermostat force to atom velocities - atomicRegulator_->apply_pre_predictor(dt,lammpsInterface_->ntimestep()); - - // Predict nodal temperatures and time derivatives based on FE data - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate2(dt); - } - extrinsicModelManager_.pre_init_integrate(); - } - +#ifdef OBSOLETE //-------------------------------------------------------- // mid_init_integrate // time integration between the velocity update and @@ -385,7 +359,7 @@ namespace ATC { update_time(0.5); // half step ATC_Coupling::post_init_integrate(); } - +#endif //-------------------------------------------------------- // post_final_integrate // integration after the second stage lammps atomic @@ -516,8 +490,7 @@ namespace ATC { } } if (lammpsInterface_->rank_zero()) { - // tagged data - + // tagged data --only for molecule map<string,DENS_MAN>::iterator densMan; for (densMan = taggedDensMan_.begin(); densMan != taggedDensMan_.end(); densMan++) { outputData[densMan->first] = & (densMan->second).set_quantity(); diff --git a/lib/atc/ATC_CouplingMass.h b/lib/atc/ATC_CouplingMass.h index aa22cc512c509dc1baba2441c123de8394c2ab9c..38535b14791442f3a974eca609f5d63347b1ce11 100644 --- a/lib/atc/ATC_CouplingMass.h +++ b/lib/atc/ATC_CouplingMass.h @@ -8,6 +8,7 @@ // Other headers #include <map> +#include <string> namespace ATC { @@ -53,12 +54,13 @@ namespace ATC { /** prior to exchange */ virtual void pre_exchange(); virtual void reset_atoms() { resetNlocal_=true;} - /** first time, before atomic integration */ - virtual void pre_init_integrate(); +#ifdef OBSOLETE + /** first time, after atomic velocity but before position integration */ virtual void mid_init_integrate(); /** first time, after atomic integration */ virtual void post_init_integrate(); +#endif /** second time, after atomic integration */ virtual void post_final_integrate(); @@ -95,9 +97,8 @@ namespace ATC { Array2D<bool> speciesMask_; // Add in fields for restarting - virtual void read_restart_data(string fileName_, RESTART_LIST & data); - virtual void write_restart_data(string fileName_, RESTART_LIST & data); - void pack_species_fields(RESTART_LIST & data); + virtual void read_restart_data(std::string fileName_, RESTART_LIST & data); + virtual void write_restart_data(std::string fileName_, RESTART_LIST & data); // DATA structures for tracking individual species and molecules FIELD_POINTERS atomicFields_; diff --git a/lib/atc/ATC_CouplingMomentum.cpp b/lib/atc/ATC_CouplingMomentum.cpp index 53819529d1cac8e57608bf1f8369679896c7a9ab..f81c6ec62e701e67a33eed9934727d722bc128b9 100644 --- a/lib/atc/ATC_CouplingMomentum.cpp +++ b/lib/atc/ATC_CouplingMomentum.cpp @@ -11,6 +11,9 @@ #include <map> #include <set> #include <utility> +#include <iostream> + +using std::string; namespace ATC { @@ -32,8 +35,6 @@ namespace ATC { : ATC_Coupling(groupName,perAtomArray,thisFix), nodalAtomicMass_(NULL), nodalAtomicCount_(NULL), - boundaryDynamics_(PRESCRIBED), - gamma_(0),mu_(1),kappa_(1), refPE_(0) { // Allocate PhysicsModel @@ -60,11 +61,13 @@ namespace ATC { trackDisplacement_ = true; fieldSizes_[DISPLACEMENT] = fieldSizes_[VELOCITY]; timeIntegrators_[VELOCITY] = new MomentumTimeIntegrator(this,TimeIntegrator::VERLET); + ghostManager_.set_boundary_dynamics(GhostManager::PRESCRIBED); } else if (intrinsicModel == SHEAR) { atomToElementMapType_ = EULERIAN; atomToElementMapFrequency_ = 1; timeIntegrators_[VELOCITY] = new MomentumTimeIntegrator(this,TimeIntegrator::GEAR); + ghostManager_.set_boundary_dynamics(GhostManager::NO_BOUNDARY_DYNAMICS); } // output variable vector info: @@ -119,7 +122,9 @@ namespace ATC { if (timeFilterManager_.need_reset()) { // reset kinetostat power init_filter(); } - timeFilterManager_.initialize(); // clears need for reset + // clears need for reset + timeFilterManager_.initialize(); + ghostManager_.initialize(); if (!initialized_) { // initialize sources based on initial FE temperature @@ -356,9 +361,11 @@ namespace ATC { } // switch for if displacement is tracked or not - /*! \page man_disp_control fix_modify AtC transfer track_displacement + /*! \page man_track_displacement fix_modify AtC track_displacement \section syntax - fix_modify AtC transfer track_displacement <on/off> \n + fix_modify AtC track_displacement <on/off> \n + \section examples + <TT> fix_modify atc track_displacement on </TT> \n \section description Determines whether displacement is tracked or not. For solids problems this is a useful quantity, but for fluids it is not relevant. \section restrictions @@ -380,39 +387,10 @@ namespace ATC { needReset_ = true; } } - /*! \page man_boundary_dynamics fix_modify AtC transfer boundary_dynamics - \section syntax - fix_modify AtC transfer boundary_dynamics <type> \n - \section description - \section restrictions - \section default - on - */ + else if (strcmp(arg[argIndex],"boundary_dynamics")==0) { argIndex++; - gamma_ = 0; - kappa_ = 0; - mu_ = 0; - if (strcmp(arg[argIndex],"damped_harmonic")==0) { - argIndex++; - gamma_ = atof(arg[argIndex++]); - kappa_ = atof(arg[argIndex++]); - mu_ = atof(arg[argIndex++]); - boundaryDynamics_ = DAMPED_HARMONIC; - foundMatch = true; - } - else if (strcmp(arg[argIndex],"prescribed")==0) { - boundaryDynamics_ = PRESCRIBED; - foundMatch = true; - } - else if (strcmp(arg[argIndex],"coupled")==0) { - boundaryDynamics_ = COUPLED; - foundMatch = true; - } - else if (strcmp(arg[argIndex],"none")==0) { - boundaryDynamics_ = NO_BOUNDARY_DYNAMICS; - foundMatch = true; - } + foundMatch = ghostManager_.modify(narg-argIndex,&arg[argIndex]); } // no match, call base class parser @@ -474,31 +452,7 @@ namespace ATC { atomElement_); } - //-------------------------------------------------------- - // pre_init_integrate - // time integration before the lammps atomic - // integration of the Verlet step 1 - //-------------------------------------------------------- - void ATC_CouplingMomentum::pre_init_integrate() - { - ATC_Coupling::pre_init_integrate(); - double dt = lammpsInterface_->dt(); - - // get any initial data before its modified - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate1(dt); - } - - // apply kinetostat force, if needed - atomicRegulator_->apply_pre_predictor(dt,lammpsInterface_->ntimestep()); - - // predict nodal velocities - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate2(dt); - } - extrinsicModelManager_.pre_init_integrate(); - } - +#ifdef OBSOLETE //-------------------------------------------------------- // mid_init_integrate // time integration between the velocity update and @@ -545,19 +499,13 @@ namespace ATC { // fixed values, non-group bcs handled through FE set_fixed_nodes(); - - - // enforce atomic boundary conditions - if (boundaryDynamics_==PRESCRIBED) set_ghost_atoms(); - else if (boundaryDynamics_==DAMPED_HARMONIC) initial_integrate_ghost(); - else if (boundaryDynamics_==COUPLED) initial_integrate_ghost(); // update time by a half dt update_time(0.5); ATC_Coupling::post_init_integrate(); } - +#endif //-------------------------------------------------------- // pre_final_integrate // integration before the second stage lammps atomic @@ -566,15 +514,6 @@ namespace ATC { void ATC_CouplingMomentum::pre_final_integrate() { ATC_Coupling::pre_final_integrate(); - - if (boundaryDynamics_==DAMPED_HARMONIC) { - apply_ghost_forces(); - final_integrate_ghost(); - } - else if (boundaryDynamics_==COUPLED) { - add_ghost_forces(); - final_integrate_ghost(); - } } //-------------------------------------------------------- @@ -750,134 +689,6 @@ namespace ATC { } } - //-------------------------------------------------------- - // set_ghost_atoms - // sets ghost atom positions to finite element - // displacements based on shape functions - //-------------------------------------------------------- - void ATC_CouplingMomentum::set_ghost_atoms() - { - // set atomic displacements based on FE displacements - double ** x = lammpsInterface_->xatom(); - // prolong - DenseMatrix<double> ghostAtomData(nLocalGhost_,nsd_); - if (nLocalGhost_>0) - ghostAtomData = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - - for (int i = 0; i < nLocalGhost_; ++i) - for (int j = 0; j < nsd_; ++j) - x[ghostToAtom_(i)][j] = ghostAtomData(i,j)+xref_[ghostToAtom_(i)][j]; - - - } - - //-------------------------------------------------------- - // add_ghost_forces - // add forces to dynamic ghosts - //-------------------------------------------------------- - void ATC_CouplingMomentum::add_ghost_forces() - { - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - - // add forces - DENS_MAT coarseDisp(nLocalGhost_,nsd_); - DENS_MAT coarseVel(nLocalGhost_,nsd_); - if (nLocalGhost_>0) { - coarseDisp = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - coarseVel = (shpFcnGhost_->quantity())*(fields_[VELOCITY].quantity()); - } - // dynamics one-way coupled to real atoms in a well tied to coarse scale - for (int i = 0; i < nLocalGhost_; ++i) { - for (int j = 0; j < nsd_; ++j) { - double du = coarseDisp(i,j)+xref_[ghostToAtom_(i)][j]-x[ghostToAtom_(i)][j]; - double dv = coarseVel(i,j)-v[ghostToAtom_(i)][j]; - f[ghostToAtom_(i)][j] += mu_*du + gamma_*dv; - - } - } - } - - void ATC_CouplingMomentum::apply_ghost_forces() - { - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - - // add forces - DENS_MAT coarseDisp(nLocalGhost_,nsd_); - DENS_MAT coarseVel(nLocalGhost_,nsd_); - if (nLocalGhost_>0) { - coarseDisp = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - coarseVel = (shpFcnGhost_->quantity())*(fields_[VELOCITY].quantity()); - } - // dynamics one-way coupled to real atoms in a well tied to coarse scale - for (int i = 0; i < nLocalGhost_; ++i) { - for (int j = 0; j < nsd_; ++j) { - double du = coarseDisp(i,j)+xref_[ghostToAtom_(i)][j]-x[ghostToAtom_(i)][j]; - double dv = coarseVel(i,j)-v[ghostToAtom_(i)][j]; - f[ghostToAtom_(i)][j] = mu_*du + gamma_*dv; - - } - } - } - - //-------------------------------------------------------- - // initial_integrate_ghost - // does the first step of the Verlet integration for - // ghost atoms, to be used with non-reflecting BCs - //-------------------------------------------------------- - void ATC_CouplingMomentum::initial_integrate_ghost() - { - double dtfm; - - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - const int *mask = lammpsInterface_->atom_mask(); - int nlocal = lammpsInterface_->nlocal(); - double dtv = lammpsInterface_->dt(); - double dtf = 0.5 * lammpsInterface_->dt() * lammpsInterface_->ftm2v(); - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / mu_; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - x[i][0] += dtv * v[i][0]; - x[i][1] += dtv * v[i][1]; - x[i][2] += dtv * v[i][2]; - } - } - } - - //-------------------------------------------------------- - // final_integrate_ghost - // does the second step of the Verlet integration for - // ghost atoms, to be used with non-reflecting BCs - //-------------------------------------------------------- - void ATC_CouplingMomentum::final_integrate_ghost() - { - double dtfm; - - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - const int *mask = lammpsInterface_->atom_mask(); - int nlocal = lammpsInterface_->nlocal(); - double dtf = 0.5 * lammpsInterface_->dt() * lammpsInterface_->ftm2v(); - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / mu_; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - } - } - } - //-------------------------------------------------------------------- // compute_scalar : added energy // this is used in the line search diff --git a/lib/atc/ATC_CouplingMomentum.h b/lib/atc/ATC_CouplingMomentum.h index 7ded389f21fab57ab619b4e601311cdd2dd8197c..8f83f527f1b71c8e1d55ce1151b60f8e433be555 100644 --- a/lib/atc/ATC_CouplingMomentum.h +++ b/lib/atc/ATC_CouplingMomentum.h @@ -9,7 +9,7 @@ #include "ElasticTimeIntegrator.h" // Other headers -#include <map> +#include <string> namespace ATC { @@ -54,14 +54,14 @@ namespace ATC { /** post time integration */ virtual void finish(); +#ifdef OBSOLETE + - /** first time, before atomic integration */ - virtual void pre_init_integrate(); /** first time, after atomic velocity but before position integration */ virtual void mid_init_integrate(); /** first time, after atomic integration */ virtual void post_init_integrate(); - +#endif /** second time, before atomic integration */ virtual void pre_final_integrate(); /** second time, after atomic integration */ @@ -98,17 +98,6 @@ namespace ATC { /** set up data which is dependency managed */ virtual void construct_transfers(); - // ghost atom routines - /** set ghost function positions based on FE state */ - virtual void set_ghost_atoms(); - /** analagous to FixATC initial_integrate applied to ghosts */ - void initial_integrate_ghost(); - /** analagous to FixATC final_integrate applied to ghosts */ - void final_integrate_ghost(); - /** forces on dynamic ghosts */ - void add_ghost_forces(); - void apply_ghost_forces(); - /** adds resetting of any kinetostat arrays associated with local atom count */ virtual void reset_nlocal(); @@ -129,14 +118,10 @@ namespace ATC { Array2D<bool> velocityMask_; // Add in fields for restarting - virtual void read_restart_data(string fileName_, RESTART_LIST & data); - virtual void write_restart_data(string fileName_, RESTART_LIST & data); + virtual void read_restart_data(std::string fileName_, RESTART_LIST & data); + virtual void write_restart_data(std::string fileName_, RESTART_LIST & data); void pack_elastic_fields(RESTART_LIST & data); - // boundary dynamics - BoundaryDynamicsType boundaryDynamics_; - double gamma_, mu_, kappa_; - // data double refPE_; diff --git a/lib/atc/ATC_CouplingMomentumEnergy.cpp b/lib/atc/ATC_CouplingMomentumEnergy.cpp index e7ed73d4b530e52cc33e6446d4d9c7437780f258..c82ecffb45254ed5ca871a3abbfc2d97aad85ae3 100644 --- a/lib/atc/ATC_CouplingMomentumEnergy.cpp +++ b/lib/atc/ATC_CouplingMomentumEnergy.cpp @@ -10,6 +10,9 @@ #include <set> #include <utility> #include <typeinfo> +#include <iostream> + +using std::string; namespace ATC { @@ -33,8 +36,6 @@ namespace ATC { nodalAtomicHeatCapacity_(NULL), nodalAtomicKineticTemperature_(NULL), nodalAtomicConfigurationalTemperature_(NULL), - boundaryDynamics_(PRESCRIBED), - gamma_(0),mu_(1),kappa_(1), refPE_(0) { // Allocate PhysicsModel @@ -45,24 +46,23 @@ namespace ATC { extrinsicModelManager_.create_model(extrinsicModel,matParamFile); } + // set up field data based on physicsModel + physicsModel_->num_fields(fieldSizes_,fieldMask_); + // Defaults set_time(); bndyIntType_ = FE_INTERPOLATION; - trackDisplacement_ = true; - - // set up field data based on physicsModel - physicsModel_->num_fields(fieldSizes_,fieldMask_); - fieldSizes_[DISPLACEMENT] = fieldSizes_[VELOCITY]; + trackCharge_ = false; // set up atomic regulator atomicRegulator_ = new KinetoThermostat(this); - // default to not track charge - trackCharge_ = false; - // set up physics specific time integrator and thermostat + trackDisplacement_ = true; + fieldSizes_[DISPLACEMENT] = fieldSizes_[VELOCITY]; timeIntegrators_[VELOCITY] = new MomentumTimeIntegrator(this,TimeIntegrator::FRACTIONAL_STEP); timeIntegrators_[TEMPERATURE] = new ThermalTimeIntegrator(this,TimeIntegrator::FRACTIONAL_STEP); + ghostManager_.set_boundary_dynamics(GhostManager::PRESCRIBED); // default physics temperatureDef_ = KINETIC; @@ -115,15 +115,6 @@ namespace ATC { // init_filter uses fieldRateNdFiltered which comes from the time integrator, // which is why the time integrator is initialized first - // set the reference potential, if necessary, because the nodal energy is needed to initialize the time integrator - if (!initialized_) { - if (temperatureDef_==TOTAL) { - PerAtomQuantity<double> * atomicReferencePotential = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); - PerAtomQuantity<double> * atomicPotentialEnergy = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - atomicReferencePotential->set_quantity() = atomicPotentialEnergy->quantity(); - } - } - // other initializations if (reset_methods()) { @@ -139,9 +130,12 @@ namespace ATC { atomicRegulator_->initialize(); extrinsicModelManager_.initialize(); } - if (timeFilterManager_.need_reset()) // reset thermostat power + if (timeFilterManager_.need_reset()) {// reset thermostat power init_filter(); - timeFilterManager_.initialize(); // clears need for reset + } + // clears need for reset + timeFilterManager_.initialize(); + ghostManager_.initialize(); if (!initialized_) { // initialize sources based on initial FE temperature @@ -326,11 +320,11 @@ namespace ATC { else { atomicReferencePotential = static_cast<AtcAtomQuantity<double> * >(interscaleManager_.per_atom_quantity("AtomicReferencePotential")); } - AtfShapeFunctionRestriction * nodalAtomicReferencePotential = new AtfShapeFunctionRestriction(this, - atomicReferencePotential, - shpFcn_); - interscaleManager_.add_dense_matrix(nodalAtomicReferencePotential, - "NodalAtomicReferencePotential"); + nodalRefPotentialEnergy_ = new AtfShapeFunctionRestriction(this, + atomicReferencePotential, + shpFcn_); + interscaleManager_.add_dense_matrix(nodalRefPotentialEnergy_, + "NodalAtomicReferencePotential"); // fluctuating potential energy AtomicEnergyForTemperature * atomicFluctuatingPotentialEnergy = new FluctuatingPotentialEnergy(this, @@ -545,28 +539,7 @@ namespace ATC { atomElement_); } - //-------------------------------------------------- - void ATC_CouplingMomentumEnergy::pre_init_integrate() - { - ATC_Coupling::pre_init_integrate(); - double dt = lammpsInterface_->dt(); - - // Perform any initialization, no actual integration - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate1(dt); - } - - // Apply controllers to atom velocities, if needed - atomicRegulator_->apply_pre_predictor(dt,lammpsInterface_->ntimestep()); - - // Predict nodal temperatures and time derivatives based on FE data - // predict nodal velocities - for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { - (_tiIt_->second)->pre_initial_integrate2(dt); - } - extrinsicModelManager_.pre_init_integrate(); - } - +#ifdef OBSOLETE //-------------------------------------------------------- // mid_init_integrate // time integration between the velocity update and @@ -612,19 +585,13 @@ namespace ATC { // fixed values, non-group bcs handled through FE set_fixed_nodes(); - - - // enforce atomic boundary conditions - if (boundaryDynamics_==PRESCRIBED) set_ghost_atoms(); - else if (boundaryDynamics_==DAMPED_HARMONIC) initial_integrate_ghost(); - else if (boundaryDynamics_==COUPLED) initial_integrate_ghost(); // update time by a half dt update_time(0.5); ATC_Coupling::post_init_integrate(); } - +#endif //-------------------------------------------------------- // pre_final_integrate // integration before the second stage lammps atomic @@ -633,15 +600,6 @@ namespace ATC { void ATC_CouplingMomentumEnergy::pre_final_integrate() { ATC_Coupling::pre_final_integrate(); - - if (boundaryDynamics_==DAMPED_HARMONIC) { - apply_ghost_forces(); - final_integrate_ghost(); - } - else if (boundaryDynamics_==COUPLED) { - add_ghost_forces(); - final_integrate_ghost(); - } } //-------------------------------------------------- @@ -896,166 +854,4 @@ namespace ATC { } } - //-------------------------------------------------------- - // set_ghost_atoms - // sets ghost atom positions to finite element - // displacements based on shape functions - //-------------------------------------------------------- - void ATC_CouplingMomentumEnergy::set_ghost_atoms() - { - // set atomic displacements based on FE displacements - double ** x = lammpsInterface_->xatom(); - // prolong - DenseMatrix<double> ghostAtomData(nLocalGhost_,nsd_); - if (nLocalGhost_>0) - ghostAtomData = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - - for (int i = 0; i < nLocalGhost_; ++i) - for (int j = 0; j < nsd_; ++j) - x[ghostToAtom_(i)][j] = ghostAtomData(i,j)+xref_[ghostToAtom_(i)][j]; - - - } - - //-------------------------------------------------------- - // add_ghost_forces - // add forces to dynamic ghosts - //-------------------------------------------------------- - void ATC_CouplingMomentumEnergy::add_ghost_forces() - { - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - - // add forces - DENS_MAT coarseDisp(nLocalGhost_,nsd_); - DENS_MAT coarseVel(nLocalGhost_,nsd_); - if (nLocalGhost_>0) { - coarseDisp = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - coarseVel = (shpFcnGhost_->quantity())*(fields_[VELOCITY].quantity()); - } - // dynamics one-way coupled to real atoms in a well tied to coarse scale - for (int i = 0; i < nLocalGhost_; ++i) { - for (int j = 0; j < nsd_; ++j) { - double du = coarseDisp(i,j)+xref_[ghostToAtom_(i)][j]-x[ghostToAtom_(i)][j]; - double dv = coarseVel(i,j)-v[ghostToAtom_(i)][j]; - f[ghostToAtom_(i)][j] += mu_*du + gamma_*dv; - - } - } - } - - void ATC_CouplingMomentumEnergy::apply_ghost_forces() - { - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - - // add forces - DENS_MAT coarseDisp(nLocalGhost_,nsd_); - DENS_MAT coarseVel(nLocalGhost_,nsd_); - if (nLocalGhost_>0) { - coarseDisp = (shpFcnGhost_->quantity())*(fields_[DISPLACEMENT].quantity()); - coarseVel = (shpFcnGhost_->quantity())*(fields_[VELOCITY].quantity()); - } - // dynamics one-way coupled to real atoms in a well tied to coarse scale - for (int i = 0; i < nLocalGhost_; ++i) { - for (int j = 0; j < nsd_; ++j) { - double du = coarseDisp(i,j)+xref_[ghostToAtom_(i)][j]-x[ghostToAtom_(i)][j]; - double dv = coarseVel(i,j)-v[ghostToAtom_(i)][j]; - f[ghostToAtom_(i)][j] = mu_*du + gamma_*dv; - - } - } - } - - //-------------------------------------------------------- - // initial_integrate_ghost - // does the first step of the Verlet integration for - // ghost atoms, to be used with non-reflecting BCs - //-------------------------------------------------------- - void ATC_CouplingMomentumEnergy::initial_integrate_ghost() - { - double dtfm; - - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - int *type = lammpsInterface_->atom_type(); - const int *mask = lammpsInterface_->atom_mask(); - int nlocal = lammpsInterface_->nlocal(); - double dtv = lammpsInterface_->dt(); - double dtf = 0.5 * lammpsInterface_->dt() * lammpsInterface_->ftm2v(); - double *mass = lammpsInterface_->atom_mass(); - - if (mass) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / mass[type[i]]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - x[i][0] += dtv * v[i][0]; - x[i][1] += dtv * v[i][1]; - x[i][2] += dtv * v[i][2]; - } - } - - } else { - double *rmass = lammpsInterface_->atom_rmass(); - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / rmass[i]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - x[i][0] += dtv * v[i][0]; - x[i][1] += dtv * v[i][1]; - x[i][2] += dtv * v[i][2]; - } - } - } - - } - - //-------------------------------------------------------- - // final_integrate_ghost - // does the second step of the Verlet integration for - // ghost atoms, to be used with non-reflecting BCs - //-------------------------------------------------------- - void ATC_CouplingMomentumEnergy::final_integrate_ghost() - { - double dtfm; - - double **v = lammpsInterface_->vatom(); - double **f = lammpsInterface_->fatom(); - int *type = lammpsInterface_->atom_type(); - const int *mask = lammpsInterface_->atom_mask(); - int nlocal = lammpsInterface_->nlocal(); - double dtf = 0.5 * lammpsInterface_->dt() * lammpsInterface_->ftm2v(); - - double *mass = lammpsInterface_->atom_mass(); - if (mass) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / mass[type[i]]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - } - } - - } else { - double *rmass = lammpsInterface_->atom_rmass(); - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbitGhost_) { - dtfm = dtf / rmass[i]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - } - } - } - - } }; diff --git a/lib/atc/ATC_CouplingMomentumEnergy.h b/lib/atc/ATC_CouplingMomentumEnergy.h index dd107295d31b547a602cb64ca652a0a7d8a886fb..60410e75dfff133c7b14cfb2ba78d83781c5b110 100644 --- a/lib/atc/ATC_CouplingMomentumEnergy.h +++ b/lib/atc/ATC_CouplingMomentumEnergy.h @@ -9,7 +9,7 @@ #include "ThermalTimeIntegrator.h" // Other headers -#include <map> +#include <string> namespace ATC { @@ -54,14 +54,14 @@ namespace ATC { /** post time integration */ virtual void finish(); +#ifdef OBSOLETE + - /** first time, before atomic integration */ - virtual void pre_init_integrate(); /** first time, after atomic velocity but before position integration */ virtual void mid_init_integrate(); /** first time, after atomic integration */ virtual void post_init_integrate(); - +#endif /** second time, before atomic integration */ virtual void pre_final_integrate(); /** second time, after atomic integration */ @@ -94,16 +94,6 @@ namespace ATC { /** set up data which is dependency managed */ virtual void construct_transfers(); - /** sets the position/velocity of the ghost atoms */ - virtual void set_ghost_atoms(); - /** analagous to FixATC initial_integrate applied to ghosts */ - void initial_integrate_ghost(); - /** analagous to FixATC final_integrate applied to ghosts */ - void final_integrate_ghost(); - /** forces on dynamic ghosts */ - void add_ghost_forces(); - void apply_ghost_forces(); - /** adds resetting of any kinetostat/thermostat arrays associated with local atom count */ virtual void reset_nlocal(); @@ -139,15 +129,11 @@ namespace ATC { DENS_MAT _keTemp_, _peTemp_; // Add in fields for restarting - virtual void read_restart_data(string fileName_, RESTART_LIST & data); - virtual void write_restart_data(string fileName_, RESTART_LIST & data); + virtual void read_restart_data(std::string fileName_, RESTART_LIST & data); + virtual void write_restart_data(std::string fileName_, RESTART_LIST & data); void pack_quantity_fields(RESTART_LIST & data); - // boundary dynamics - BoundaryDynamicsType boundaryDynamics_; - double gamma_, mu_, kappa_; - // data double refPE_; }; diff --git a/lib/atc/ATC_Error.h b/lib/atc/ATC_Error.h index 08a9bf0ec29fc4e2d1b450f2b79f02c0b6972b04..fc356dbec826c709327557aacb191c6fee2d00a8 100644 --- a/lib/atc/ATC_Error.h +++ b/lib/atc/ATC_Error.h @@ -17,10 +17,6 @@ #define HACK(l,m) - - - - namespace ATC { /** * @class ATC_Error diff --git a/lib/atc/ATC_Method.cpp b/lib/atc/ATC_Method.cpp index 7adc2ec7cd3cbf3eebb89ed0ac924d5eab9cab14..90d29f853edf923247588f7edd14faa78ed45ca9 100644 --- a/lib/atc/ATC_Method.cpp +++ b/lib/atc/ATC_Method.cpp @@ -13,11 +13,24 @@ #include "TransferLibrary.h" #include "KernelFunction.h" #include "Utility.h" +#include "FieldManager.h" #include <fstream> #include <sstream> +#include <iostream> using ATC_Utility::sgn; +using ATC_Utility::to_string; +using ATC_Utility::is_dbl; + +using std::stringstream; +using std::ifstream; +using std::ofstream; +using std::string; +using std::map; +using std::set; +using std::vector; +using std::pair; namespace ATC { @@ -27,6 +40,9 @@ namespace ATC { lammpsInterface_(LammpsInterface::instance()), interscaleManager_(this), timeFilterManager_(this), + integrateInternalAtoms_(false), + atomTimeIntegrator_(NULL), + ghostManager_(this), feEngine_(NULL), initialized_(false), meshDataInitialized_(false), @@ -37,9 +53,6 @@ namespace ATC { atomProcGhostCoarseGrainingPositions_(NULL), atomReferencePositions_(NULL), nsd_(lammpsInterface_->dimension()), -#ifdef EXTENDED_ERROR_CHECKING - atomSwitch_(false), -#endif xref_(NULL), readXref_(false), needXrefProcessorGhosts_(false), @@ -47,6 +60,7 @@ namespace ATC { needsAtomToElementMap_(true), atomElement_(NULL), atomGhostElement_(NULL), + internalElementSet_(""), atomMasses_(NULL), atomPositions_(NULL), atomVelocities_(NULL), @@ -82,8 +96,6 @@ namespace ATC { nLocal_(0), nLocalTotal_(0), nLocalGhost_(0), - nInternal_(0), - nGhost_(0), atomToElementMapType_(LAGRANGIAN), atomToElementMapFrequency_(0), regionID_(-1), @@ -97,15 +109,18 @@ namespace ATC { accumulantMolGrad_(NULL), accumulantWeights_(NULL), accumulantInverseVolumes_(&invNodeVolumes_), + accumulantBandwidth_(0), useRestart_(false), hasRefPE_(false), setRefPE_(false), setRefPEvalue_(false), refPEvalue_(0.), readRefPE_(false), + nodalRefPotentialEnergy_(NULL), simTime_(0.0), stepCounter_(0) { + lammpsInterface_->print_msg_once("version "+version()); lammpsInterface_->set_fix_pointer(thisFix); interscaleManager_.set_lammps_data_prefix(); grow_arrays(lammpsInterface_->nmax()); @@ -119,6 +134,7 @@ namespace ATC { { lammpsInterface_->destroy_2d_double_array(xref_); lammpsInterface_->destroy_2d_double_array(perAtomOutput_); + if (atomTimeIntegrator_) delete atomTimeIntegrator_; if (feEngine_) delete feEngine_; } @@ -214,6 +230,11 @@ namespace ATC { accumulantMol_=&kernelAccumulantMol_; // KKM add accumulantMolGrad_=&kernelAccumulantMolGrad_; // KKM add } + // pass off to ghost manager + else if (strcmp(arg[argIdx],"boundary_dynamics")==0) { + argIdx++; + match = ghostManager_.modify(narg-argIdx,&arg[argIdx]); + } // parsing handled here else { @@ -246,10 +267,7 @@ pecified ( see \ref man_fix_atc ) \section related \section default - By default, on-the-fly calculation is not active (i.e. off). However, co -de does a memory allocation - check to determine if it can store all needed bond and kernel matrix ele -ments. If this allocation fails, on-the-fly is activated. \n + By default, on-the-fly calculation is not active (i.e. off). However, code does a memory allocation check to determine if it can store all needed bond and kernel matrix ele ments. If this allocation fails, on-the-fly is activated. \n */ else if (strcmp(arg[argIdx],"on_the_fly")==0) { @@ -296,11 +314,12 @@ ments. If this allocation fails, on-the-fly is activated. \n \section related see \ref man_fix_atc \section default + no default format output indexed by time */ else if (strcmp(arg[argIdx],"output")==0) { argIdx++; - /*! \page man_output_nodeset fix_modify AtC output + /*! \page man_output_nodeset fix_modify AtC output nodeset \section syntax fix_modify AtC output nodeset <nodeset_name> <operation> - nodeset_name (string) = name of nodeset to be operated on @@ -337,13 +356,13 @@ ments. If this allocation fails, on-the-fly is activated. \n } - /*! \page man_boundary_integral fix_modify AtC boundary_integral + /*! \page man_boundary_integral fix_modify AtC output boundary_integral \section syntax - fix_modify AtC boundary_integral [field] faceset [name] + fix_modify AtC output boundary_integral [field] faceset [name] - field (string) : name of hardy field - name (string) : name of faceset \section examples - <TT> fix_modify AtC boundary_integral stress faceset loop1 </TT> \n + <TT> fix_modify AtC output boundary_integral stress faceset loop1 </TT> \n \section description Calculates a surface integral of the given field dotted with the outward normal of the faces and puts output in the "GLOBALS" file @@ -355,7 +374,7 @@ ments. If this allocation fails, on-the-fly is activated. \n none */ - /*! \page man_contour_integral fix_modify AtC contour_integral + /*! \page man_contour_integral fix_modify AtC output contour_integral \section syntax fix_modify AtC output contour_integral [field] faceset [name] <axis [x | y | z ]> @@ -363,7 +382,7 @@ ments. If this allocation fails, on-the-fly is activated. \n - name (string) : name of faceset - axis (string) : x or y or z \section examples - <TT> fix_modify AtC contour_integral stress faceset loop1 </TT> \n + <TT> fix_modify AtC output contour_integral stress faceset loop1 </TT> \n \section description Calculates a surface integral of the given field dotted with the outward normal of the faces and puts output in the "GLOBALS" file @@ -391,7 +410,7 @@ ments. If this allocation fails, on-the-fly is activated. \n } } // end "boundary_integral" || "contour_integral" - /*! \page man_output_elementset fix_modify AtC output + /*! \page man_output_elementset fix_modify AtC output elementset \section syntax fix_modify AtC output volume_integral <eset_name> <field> {` - set_name (string) = name of elementset to be integrated over @@ -490,12 +509,12 @@ ments. If this allocation fails, on-the-fly is activated. \n } } // add a species for tracking - /*! \page man_mass_control fix_modify AtC add_species <TAG> group|type <ID> + /*! \page man_add_species fix_modify AtC add_species \section syntax - fix_modify_AtC add_species <TAG> group|type <ID> \n - + fix_modify_AtC add_species <TAG> <group|type> <ID> \n - <TAG> = tag for tracking a species \n - group|type = LAMMPS defined group or type of atoms \n + - <ID> = name of group or type number \n \section examples <TT> fix_modify AtC add_species gold type 1 </TT> \n <TT> group GOLDGROUP type 1 </TT> \n @@ -512,16 +531,12 @@ ments. If this allocation fails, on-the-fly is activated. \n string speciesTag = arg[argIdx]; string tag = arg[argIdx]; argIdx++; - IdType idType; if (strcmp(arg[argIdx],"group")==0) { - idType = ATOM_GROUP; if (narg-argIdx == 2) { string name = arg[++argIdx]; int id = lammpsInterface_->group_bit(name); groupList_.push_back(id); groupNames_.push_back(tag); - - speciesIds_[speciesTag] = pair<IdType,int>(idType,id); // OBSOLETE } else { while (++argIdx < narg) { @@ -530,17 +545,14 @@ ments. If this allocation fails, on-the-fly is activated. \n string tag = speciesTag+"-"+name; groupList_.push_back(id); groupNames_.push_back(tag); - speciesIds_[speciesTag] = pair<IdType,int>(idType,id); // OBSOLETE } } } else if (strcmp(arg[argIdx],"type")==0) { - idType = ATOM_TYPE; if (narg-argIdx == 2) { int id = atoi(arg[++argIdx]); typeList_.push_back(id); typeNames_.push_back(tag); - speciesIds_[speciesTag] = pair<IdType,int>(idType,id); // OBSOLETE } else { while (++argIdx < narg) { @@ -548,20 +560,19 @@ ments. If this allocation fails, on-the-fly is activated. \n string tag = speciesTag+"_"+to_string(id); typeList_.push_back(id); typeNames_.push_back(tag); - speciesIds_[speciesTag] = pair<IdType,int>(idType,id); // OBSOLETE } } } else { - throw ATC_Error("ATC_Method: only groups or types for add_species"); } + throw ATC_Error("ATC_Method: add_species only handles groups or types"); } match = true; } // remove species from tracking - /*! \page man_disp_control fix_modify AtC remove_species <TAG> + /*! \page man_remove_species fix_modify AtC remove_species \section syntax - fix_modify_AtC remove_species <TAG> \n + fix_modify_AtC delete_species <TAG> \n - <TAG> = tag for tracking a species \n \section examples @@ -573,22 +584,41 @@ ments. If this allocation fails, on-the-fly is activated. \n \section default No defaults for this command. */ - else if (strcmp(arg[argIdx],"remove_species")==0) { + else if (strcmp(arg[argIdx],"delete_species")==0) { argIdx++; - string speciesTag = arg[argIdx]; - speciesIds_.erase(speciesTag); - taggedDensMan_.erase(speciesTag); - + string tag = arg[argIdx++]; + if (strcmp(arg[argIdx],"group")==0) { + for (unsigned int j = 0; j < groupList_.size(); j++) { + if (tag == groupNames_[j]) { + groupList_.erase(groupList_.begin()+j); + groupNames_.erase(groupNames_.begin()+j); + break; + } + } + } + else if (strcmp(arg[argIdx],"type")==0) { + for (unsigned int j = 0; j < typeList_.size(); j++) { + if (tag == typeNames_[j]) { + typeList_.erase(typeList_.begin()+j); + typeNames_.erase(typeNames_.begin()+j); + break; + } + } + } + else { + throw ATC_Error("ATC_Method: delete_species only handles groups or types"); } + match = true; } // add a molecule for tracking - /*! \page man_mass_control fix_modify AtC add_molecule small|large <TAG> <GROUP_NAME> + /*! \page man_add_molecule fix_modify AtC add_molecule \section syntax - fix_modify_AtC add_molecule small|large <TAG> <GROUP_NAME> \n + fix_modify_AtC add_molecule <small|large> <TAG> <GROUP_NAME> \n - - <TAG> = tag for tracking a species \n - small|large = can be small if molecule size < cutoff radius, must be large otherwise \n + - <TAG> = tag for tracking a species \n + - <GROUP_NAME> = name of group that tracking will be applied to \n \section examples <TT> group WATERGROUP type 1 2 </TT> \n <TT> fix_modify AtC add_molecule small water WATERGROUP </TT> \n @@ -619,7 +649,7 @@ ments. If this allocation fails, on-the-fly is activated. \n } // remove molecule from tracking - /*! \page man_disp_control fix_modify AtC remove_molecule <TAG> + /*! \page man_remove_molecule fix_modify AtC remove_molecule \section syntax fix_modify_AtC remove_molecule <TAG> \n @@ -654,8 +684,6 @@ ments. If this allocation fails, on-the-fly is activated. \n domains with periodic boundary conditions no boundary atoms should be defined. \section restrictions - \section related - see \ref man_internal \section default none */ @@ -665,6 +693,64 @@ ments. If this allocation fails, on-the-fly is activated. \n match = true; } + /*! \page man_internal_atom_integrate fix_modify AtC internal_atom_integrate + \section syntax + fix_modify AtC internal_atom_integrate <on | off> + <TT> fix_modify AtC internal_atom_integrate on </TT> + \section description + Has AtC perform time integration for the atoms in the group on which it operates. This does not include boundary atoms. + \section default + on for coupling methods, off for post-processors + off + */ + else if (strcmp(arg[argIdx],"internal_atom_integrate")==0) { + argIdx++; + if (strcmp(arg[argIdx],"off")==0) { + integrateInternalAtoms_ = false; + match = true; + } + else { + integrateInternalAtoms_ = true; + match = true; + } + } + + /*! \page man_internal_element_set fix_modify AtC internal_element_set + \section syntax + fix_modify AtC internal_element_set <element-set-name> + - <element-set-name> = name of element set defining internal region, or off + \section examples + <TT> fix_modify AtC internal_element_set myElementSet </TT> + <TT> fix_modify AtC internal_element_set off </TT> + \section description + Enables AtC to base the region for internal atoms to be an element set. + If no ghost atoms are used, all the AtC atoms must be constrained to remain + in this element set by the user, e.g., with walls. If boundary atoms are + used in conjunction with Eulerian atom maps + AtC will partition all atoms of a boundary or internal type to be of type internal + if they are in the internal region or to be of type boundary otherwise. + \section restrictions + If boundary atoms are used in conjunction with Eulerian atom maps, the Eulerian + reset frequency must be an integer multiple of the Lammps reneighbor frequency + \section related + see \ref atom_element_map_type and \ref boundary + \section default + off + */ + else if (strcmp(arg[argIdx],"internal_element_set")==0) { + argIdx++; + if (strcmp(arg[argIdx],"off")==0) { + internalElementSet_ = ""; + match = true; + } + else { + internalElementSet_ = string(arg[argIdx]); + const set<int> & elementSet((feEngine_->fe_mesh())->elementset(internalElementSet_)); // check it exists and is not trivial + if (elementSet.size()==0) throw ATC_Error("internal_element_set - element set " + internalElementSet_ + " has no elements"); + match = true; + } + } + /*! \page man_atom_weight fix_modify AtC atom_weight \section syntax fix_modify AtC atom_weight <method> <arguments> @@ -672,8 +758,8 @@ ments. If this allocation fails, on-the-fly is activated. \n value: atoms in specified group assigned constant value given \n lattice: volume per atom for specified lattice type (e.g. fcc) and parameter \n element: element volume divided among atoms within element \n - region: \n - group: \n + region: volume per atom determined based on the atom count in the MD regions and their volumes. Note: meaningful only if atoms completely fill all the regions. \n + group: volume per atom determined based on the atom count in a group and its volume\n read_in: list of values for atoms are read-in from specified file \n \section examples <TT> fix_modify atc atom_weight constant myatoms 11.8 </TT> \n @@ -794,52 +880,6 @@ ments. If this allocation fails, on-the-fly is activated. \n } - /*! \page man_initial_atomic fix_modify AtC initial_atomic - \section syntax - \section examples - \section description - \section restrictions - \section related - \section default - */ - // set initial atomic displacements/velocities - /** Example commmand for initial atomic displacements/velocities - fix_modify atc initial_atomic displacement x all function gaussian */ - else if (strcmp(arg[argIdx],"initial_atomic")==0) { - XT_Function* function = NULL; - argIdx = 3; - if (strcmp(arg[argIdx],"all")==0) { - - if (strcmp(arg[argIdx+1],"function")==0) { - string fName = arg[argIdx+2]; - int nargs = narg - 3 - argIdx; - double argF[nargs]; - for (int i = 0; i < nargs; ++i) argF[i] = atof(arg[3+argIdx+i]); - function = XT_Function_Mgr::instance()->function(fName,nargs,argF); - } - } - if (function) { - argIdx--; - string sdim = arg[argIdx--]; - int idim = 0; - double **x = lammpsInterface_->xatom(); - double **v = lammpsInterface_->vatom(); - if (string_to_index(sdim,idim)) { - if (strcmp(arg[argIdx],"displacement")==0) { - for (int i = 0; i < lammpsInterface_->nlocal(); ++i) { - x[i][idim] += function->f(x[i],0); - } - } - else if (strcmp(arg[argIdx],"velocity")==0) { - for (int i = 0; i < lammpsInterface_->nlocal(); ++i) { - v[i][idim] = function->f(x[i],0); - } - } - } - match = true; - } - } - /*! \page man_reset_time fix_modify AtC reset_time \section syntax fix_modify AtC reset_time <value> @@ -861,6 +901,25 @@ ments. If this allocation fails, on-the-fly is activated. \n match = true; } + /*! \page man_reset_time fix_modify AtC kernel_bandwidth + \section syntax + fix_modify AtC kernel_bandwidth <value> + \section examples + <TT> fix_modify atc reset_time 8 </TT> \n + \section description + Sets a maximum parallel bandwidth for the kernel functions during parallel communication. If the command is not issued, the default will be to assume the bandwidth of the kernel matrix corresponds to the number of sampling locations. + \section restrictions + Only is used if kernel functions are being used. + \section related + \section default + Number of sample locations. + */ + else if (strcmp(arg[argIdx],"kernel_bandwidth")==0) { + argIdx++; + accumulantBandwidth_ = atoi(arg[argIdx]); + match = true; + } + /*! \page man_reset_atomic_reference_positions fix_modify AtC reset_atomic_reference_positions \section syntax fix_modify AtC reset_atomic_reference_positions @@ -884,17 +943,19 @@ ments. If this allocation fails, on-the-fly is activated. \n /*! \page man_set fix_modify AtC set \section syntax - fix_modify AtC set reference_potential_energy <value> - - value (double) : optional user specified zero point for PE in native LAMMPS energy units + fix_modify AtC set reference_potential_energy <value_or_filename(optional)> + - value (double) : optional user specified zero point for PE in native LAMMPS energy units \n + - filename (string) : optional user specified string for file of nodal PE values to be read-in \section examples <TT> fix_modify AtC set reference_potential_energy </TT> \n <TT> fix_modify AtC set reference_potential_energy -0.05 </TT> \n + <TT> fix_modify AtC set reference_potential_energy myPEvalues </TT> \n \section description Used to set various quantities for the post-processing algorithms. - Currently it only - sets the zero point for the potential energy density using + It sets the zero point for the potential energy density using the value provided for all nodes, or from the current - configuration of the lattice if no value is provided + configuration of the lattice if no value is provided, or + values provided within the specified filename. \section restrictions Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) @@ -1252,10 +1313,10 @@ ments. If this allocation fails, on-the-fly is activated. \n } atomVolume_->set_reset(); - // + // 6d) reference values this->set_reference_potential_energy(); - // 6d) atomic output for 0th step + // 6e) atomic output for 0th step update_peratom_output(); // clear need for resets @@ -1348,22 +1409,39 @@ ments. If this allocation fails, on-the-fly is activated. \n } //------------------------------------------------------------------- - void ATC_Method::construct_transfers() + void ATC_Method::construct_methods() { - // per-atom quantities from lammps - atomMasses_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS); - atomPositions_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION); - atomVelocities_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY); - atomForces_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE); - ComputedAtomQuantity * atomicPotentialEnergy = new ComputedAtomQuantity(this,lammpsInterface_->compute_pe_name(), peScale_); - interscaleManager_.add_per_atom_quantity(atomicPotentialEnergy, - "AtomicPotentialEnergy"); + if (this->reset_methods()) { + if (atomTimeIntegrator_) delete atomTimeIntegrator_; + if (integrateInternalAtoms_) { + atomTimeIntegrator_ = new AtomTimeIntegratorType(this,INTERNAL); + } + else { + atomTimeIntegrator_ = new AtomTimeIntegrator(); + } + + // set up integration schemes for ghosts + ghostManager_.construct_methods(); + } + } + + //------------------------------------------------------------------- + void ATC_Method::construct_transfers() + { + this->construct_interpolant(); + + this->construct_molecule_transfers(); + + atomTimeIntegrator_->construct_transfers(); + ghostManager_.construct_transfers(); + + + } //------------------------------------------------------------------- PerAtomDiagonalMatrix<double> * ATC_Method::create_atom_volume() { - // WIP_JAT have check for reset to see if we should freshen atomVolume_ if (atomVolume_) { return atomVolume_; } @@ -1424,12 +1502,34 @@ ments. If this allocation fails, on-the-fly is activated. \n return atomVolume_; } } + //-------------------------------------------------------- + void ATC_Method::init_integrate_velocity() + { + atomTimeIntegrator_->init_integrate_velocity(dt()); + ghostManager_.init_integrate_velocity(dt()); + } + //-------------------------------------------------------- + void ATC_Method::init_integrate_position() + { + atomTimeIntegrator_->init_integrate_position(dt()); + ghostManager_.init_integrate_position(dt()); + } + //------------------------------------------------------------------- + void ATC_Method::post_init_integrate() + { + ghostManager_.post_init_integrate(); + } //------------------------------------------------------------------- void ATC_Method::pre_exchange() { adjust_xref_pbc(); // call interscale manager to sync atc per-atom data with lammps array ahead of parallel communication interscaleManager_.prepare_exchange(); + + // change types based on moving from internal region to ghost region + if ((atomToElementMapType_ == EULERIAN) && (step() % atomToElementMapFrequency_ == 0)) { + ghostManager_.pre_exchange(); + } } //------------------------------------------------------------------- void ATC_Method::setup_pre_exchange() @@ -1441,12 +1541,6 @@ ments. If this allocation fails, on-the-fly is activated. \n //------------------------------------------------------------------- void ATC_Method::pre_neighbor() { -#ifdef EXTENDED_ERROR_CHECKING - if (atomSwitch_) { - lammpsInterface_->print_msg("Atoms left this processor"); - atomSwitch_ = false; - } -#endif // reset quantities arising from atom exchange reset_nlocal(); @@ -1464,9 +1558,12 @@ ments. If this allocation fails, on-the-fly is activated. \n { // this resets allow for the possibility of other fixes modifying positions and velocities, e.g. walls, but reduces efficiency interscaleManager_.lammps_force_reset(); - if ((atomToElementMapType_ == EULERIAN) && (step() % atomToElementMapFrequency_ == 0)) { - reset_coordinates(); - } + } + //-------------------------------------------------------- + void ATC_Method::final_integrate() + { + atomTimeIntegrator_->final_integrate(dt()); + ghostManager_.final_integrate(dt()); } //------------------------------------------------------------------- void ATC_Method::post_final_integrate() @@ -1507,10 +1604,9 @@ ments. If this allocation fails, on-the-fly is activated. \n //------------------------------------------------------------------- void ATC_Method::set_reference_potential_energy(void) { - // set the reference value for nodal PE if (setRefPE_) { if (setRefPEvalue_) { - nodalRefPotentialEnergy_ = refPEvalue_; + nodalRefPotentialEnergy_->set_quantity() = refPEvalue_; setRefPEvalue_ = false; } else if (readRefPE_) { @@ -1519,21 +1615,29 @@ ments. If this allocation fails, on-the-fly is activated. \n ss << "reading reference potential energy from " << nodalRefPEfile_; LammpsInterface::instance()->print_msg(ss.str()); } - nodalRefPotentialEnergy_.from_file(nodalRefPEfile_); + (nodalRefPotentialEnergy_->set_quantity()).from_file(nodalRefPEfile_); readRefPE_ = false; } else { - /* NOTE const */ PerAtomQuantity<double> * atomicPotentialEnergy - - - - - - =interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - AtfProjection * pe = new AtfProjection(this, atomicPotentialEnergy, - accumulant_, accumulantInverseVolumes_); - nodalRefPotentialEnergy_ = pe->quantity(); - delete pe; + hasRefPE_ = false; + SPAR_MAN * referenceAccumulant = interscaleManager_.sparse_matrix("ReferenceAccumulant"); + if (referenceAccumulant) { + referenceAccumulant->set_quantity() = accumulant_->quantity(); + } + DIAG_MAN * referenceAccumulantInverseVolumes = interscaleManager_.diagonal_matrix("ReferenceAccumulantInverseVolumes"); + if (referenceAccumulantInverseVolumes) { + referenceAccumulantInverseVolumes->set_quantity() = accumulantInverseVolumes_->quantity(); + } + PAQ * atomicRefPe = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); + if (!atomicRefPe) { + throw ATC_Error("ATC_Method::set_reference_potential_energy - atomic reference PE object was not created during construct_transfers"); + } + PAQ* pe = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); + if (!pe) { + throw ATC_Error("ATC_Method::set_reference_potential_energy - atomic PE object was not created during construct_transfers"); + } + atomicRefPe->set_quantity() = pe->quantity(); + atomicRefPe->fix_quantity(); } setRefPE_ = false; hasRefPE_ = true; @@ -1546,14 +1650,24 @@ ments. If this allocation fails, on-the-fly is activated. \n // memory management and processor information exchange //================================================================= + + //----------------------------------------------------------------- + // number of doubles + //----------------------------------------------------------------- + int ATC_Method::doubles_per_atom() const + { + + int doubles = 4; + doubles += interscaleManager_.memory_usage(); + return doubles; + } + //----------------------------------------------------------------- // memory usage of local atom-based arrays //----------------------------------------------------------------- int ATC_Method::memory_usage() { - - int bytes = 4; - bytes += interscaleManager_.memory_usage(); + int bytes = doubles_per_atom(); bytes *= lammpsInterface_->nmax() * sizeof(double); return bytes; } @@ -1591,9 +1705,6 @@ ments. If this allocation fails, on-the-fly is activated. \n //----------------------------------------------------------------- int ATC_Method::pack_exchange(int i, double *buf) { -#ifdef EXTENDED_ERROR_CHECKING - atomSwitch_ = true; -#endif buf[0] = xref_[i][0]; buf[1] = xref_[i][1]; buf[2] = xref_[i][2]; @@ -1719,28 +1830,29 @@ ments. If this allocation fails, on-the-fly is activated. \n nLocalTotal_ = lammpsInterface_->nlocal(); const int * mask = lammpsInterface_->atom_mask(); nLocal_ = 0; - nLocalGhost_ = 0; + nLocalGhost_ = 0; + for (int i = 0; i < nLocalTotal_; ++i) { if (mask[i] & groupbit_) nLocal_++; if (mask[i] & groupbitGhost_) nLocalGhost_++; } - int local_data[2] = {nLocal_, nLocalGhost_}; - int data[2] = {0, 0}; - lammpsInterface_->int_allsum(local_data,data,2); - nInternal_ = data[0]; - nGhost_ = data[1]; - // set up internal & ghost maps & coordinates + // set up internal & ghost maps if (nLocal_>0) { // set map - internalToAtom_.reset(nLocal_); + internalToAtom_.resize(nLocal_); int j = 0; // construct internalToAtom map // : internal index -> local lammps atom index for (int i = 0; i < nLocalTotal_; ++i) { if (mask[i] & groupbit_) internalToAtom_(j++) = i; } +#ifdef EXTENDED_ERROR_CHECKING + stringstream ss; + ss << "Nlocal = " << nLocal_ << " but only found " << j << "atoms"; + if (j!=nLocal_) throw ATC_Error(ss.str()); +#endif // construct reverse map atomToInternal_.clear(); for (int i = 0; i < nLocal_; ++i) { @@ -1749,7 +1861,7 @@ ments. If this allocation fails, on-the-fly is activated. \n } if (nLocalGhost_>0) { // set map - ghostToAtom_.reset(nLocalGhost_); + ghostToAtom_.resize(nLocalGhost_); int j = 0; for (int i = 0; i < nLocalTotal_; ++i) { if (mask[i] & groupbitGhost_) ghostToAtom_(j++) = i; @@ -1904,7 +2016,7 @@ ments. If this allocation fails, on-the-fly is activated. \n } // relies on shape functions if (ghost) { - restrict_volumetric_quantity(atomInfluence,influence,shpFcnGhost_->quantity()); + restrict_volumetric_quantity(atomInfluence,influence,(interscaleManager_.per_atom_sparse_matrix("InterpolantGhost"))->quantity()); } else { restrict_volumetric_quantity(atomInfluence,influence); diff --git a/lib/atc/ATC_Method.h b/lib/atc/ATC_Method.h index 79d00f54c3730f26ec4e9361eb357909bd1e27b8..17cd859dc1276990def9f9809c5d080f94c2e251 100644 --- a/lib/atc/ATC_Method.h +++ b/lib/atc/ATC_Method.h @@ -16,19 +16,22 @@ #include "ExtrinsicModel.h" #include "InterscaleOperators.h" #include "TransferLibrary.h" +#include "GhostManager.h" // Other headers #include <vector> #include <set> +#include <utility> +#include <string> +#include <map> -using namespace std; - -using LAMMPS_NS::Fix; - namespace ATC { + // forward declarations + class AtomTimeIntegrator; + /** * @class ATC_Method * @brief Base class for atom-continuum coupling or transfer operators @@ -39,12 +42,12 @@ namespace ATC { public: /** methods */ /** constructor */ - ATC_Method(string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix); + ATC_Method(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix); /** destructor */ virtual ~ATC_Method(); - string version() {return "2.0";} + std::string version() {return "2.0";} /** parser/modifier */ virtual bool modify(int narg, char **arg); @@ -66,22 +69,22 @@ namespace ATC { }; /** Predictor phase, Verlet first step for velocity */ - virtual void init_integrate_velocity(){}; + virtual void init_integrate_velocity(); /** Predictor phase, executed between velocity and position Verlet */ virtual void mid_init_integrate(){}; /** Predictor phase, Verlet first step for position */ - virtual void init_integrate_position(){}; + virtual void init_integrate_position(); /** Predictor phase, executed after Verlet */ - virtual void post_init_integrate(){}; + virtual void post_init_integrate(); /** Corrector phase, executed before Verlet */ virtual void pre_final_integrate(){}; /** Corrector phase, Verlet second step for velocity */ - virtual void final_integrate(){}; + virtual void final_integrate(); /** Corrector phase, executed after Verlet*/ virtual void post_final_integrate(); @@ -108,6 +111,7 @@ namespace ATC { void setup_pre_exchange(); virtual void pre_neighbor(); virtual void post_force(); + int doubles_per_atom() const; virtual int memory_usage(); virtual void grow_arrays(int); void copy_arrays(int, int); @@ -186,18 +190,18 @@ namespace ATC { /** print tracked types and groups */ int print_tracked() const { - string msg = "species:\n"; + std::string msg = "species:\n"; for(unsigned int i = 0; i < typeList_.size(); i++) { - msg+=" type:"+to_string(typeList_[i])+" name: "+ typeNames_[i]+"\n"; } + msg+=" type:"+ATC_Utility::to_string(typeList_[i])+" name: "+ typeNames_[i]+"\n"; } for(unsigned int i = 0; i < groupList_.size(); i++) { - msg+=" group (bit):"+to_string(groupList_[i])+" name: "+ groupNames_[i]+"\n"; + msg+=" group (bit):"+ATC_Utility::to_string(groupList_[i])+" name: "+ groupNames_[i]+"\n"; } ATC::LammpsInterface::instance()->print_msg_once(msg); return typeList_.size()+groupList_.size(); } - vector<string> tracked_names() const + std::vector<std::string> tracked_names() const { - vector<string> names(typeList_.size()+groupList_.size()); + std::vector<std::string> names(typeList_.size()+groupList_.size()); int j = 0; for(unsigned int i = 0; i < typeList_.size(); i++) { names[j++] = typeNames_[i]; @@ -207,7 +211,7 @@ namespace ATC { } return names; } - int tag_to_type(string tag) const { + int tag_to_type(std::string tag) const { for(unsigned int i = 0; i < typeList_.size(); i++) { if (tag == typeNames_[i]) return typeList_[i]; } @@ -237,10 +241,6 @@ namespace ATC { int nlocal_ghost() const {return nLocalGhost_;}; /** get the number of all LAMMPS real and parallel ghost atoms on this processor */ int nproc_ghost() const {return nLocalTotal_ + lammpsInterface_->nghost();}; - /** get number of ATC internal atoms */ - int ninternal() const {return nInternal_;} - /** get number of ATC ghost atoms */ - int nghost() const {return nGhost_;}; /** match group bits */ bool is_ghost_group(int grpbit) { return (grpbit == groupbitGhost_); } bool is_internal_group(int grpbit) { return (grpbit == groupbit_); } @@ -272,7 +272,7 @@ namespace ATC { /** access to all fields rates of change (roc) */ FIELDS &fields_roc() {return dot_fields_;}; /** add a new field */ - void add_fields(map<FieldName,int> & newFieldSizes); + void add_fields(std::map<FieldName,int> & newFieldSizes); /** access FE rate of change */ DENS_MAT &get_field_roc(FieldName thisField) { return dot_fields_[thisField].set_quantity(); }; @@ -303,14 +303,15 @@ namespace ATC { const Array<int> &internal_to_atom_map() {return internalToAtom_;}; /** ghost atom to global map */ const Array<int> &ghost_to_atom_map() {return ghostToAtom_;}; - const map<int,int> & atom_to_internal_map() {return atomToInternal_;}; + const std::map<int,int> & atom_to_internal_map() {return atomToInternal_;}; /** access to xref */ double ** xref() {return xref_;}; /** access to faceset names */ - const set<PAIR> &faceset(const string & name) const {return (feEngine_->fe_mesh())->faceset(name);}; + const std::set<PAIR> &faceset(const std::string & name) const {return (feEngine_->fe_mesh())->faceset(name);}; DENS_VEC copy_nodal_coordinates(int i) const { return feEngine_->fe_mesh()->nodal_coordinates(i); } /** access to set of DENS_MANs accessed by tagging */ - DENS_MAN & tagged_dens_man(const string & tag) {return taggedDensMan_[tag];}; + + DENS_MAN & tagged_dens_man(const std::string & tag) {return taggedDensMan_[tag];}; /** access to atom to element type map */ AtomToElementMapType atom_to_element_map_type() {return atomToElementMapType_;}; /** access to atom to element update frequency */ @@ -320,17 +321,18 @@ namespace ATC { /** step number within a run or minimize */ int local_step() const {return localStep_;}; /** flags whether a methods reset is required */ - virtual bool reset_methods() const {return (!initialized_) || timeFilterManager_.need_reset() || timeFilterManager_.end_equilibrate();}; + virtual bool reset_methods() const {return (!initialized_) || timeFilterManager_.need_reset() || timeFilterManager_.end_equilibrate() || ghostManager_.need_reset();}; /** sizes of each field being considered */ - const map<FieldName,int> & field_sizes() {return fieldSizes_;}; + const std::map<FieldName,int> & field_sizes() {return fieldSizes_;}; /*@}*/ /** compute the consistent MD mass matrix */ void compute_consistent_md_mass_matrix(const SPAR_MAT & shapeFunctionMatrix, SPAR_MAT & mdMassMatrix) const; - /** access to species ids */ - const map<string,pair<IdType,int> > & species_ids() const {return speciesIds_;}; /** access to molecule ids */ - const map<string,pair<MolSize,int> > & molecule_ids() const {return moleculeIds_;}; + const std::map<std::string,std::pair<MolSize,int> > & molecule_ids() const {return moleculeIds_;}; + /** access to internal element set */ + const std::string & internal_element_set() {return internalElementSet_;}; + //---------------------------------------------------------------- /** \name mass matrix operations */ @@ -408,7 +410,7 @@ namespace ATC { { MASS_MATS::const_iterator man = massMatsMd_.find(thisField); if (man == massMatsMd_.end() ) { - string msg = " MD mass for " + field_to_string(thisField) + " does not exist"; + std::string msg = " MD mass for " + field_to_string(thisField) + " does not exist"; throw ATC_Error(msg); } return man->second; @@ -423,12 +425,14 @@ namespace ATC { bool kernel_on_the_fly() const { return kernelOnTheFly_;} bool has_kernel_function() { return kernelFunction_ != NULL; } KernelFunction * kernel_function() { return kernelFunction_; } - vector<int> & type_list() { return typeList_; } - vector<int> & group_list() { return groupList_; } + std::vector<int> & type_list() { return typeList_; } + std::vector<int> & group_list() { return groupList_; } SPAR_MAN* interpolant() { return shpFcn_; } SPAR_MAN* accumulant() { return accumulant_; } DIAG_MAN* accumulant_weights() { return accumulantWeights_;} DIAG_MAN* accumulant_inverse_volumes() { return accumulantInverseVolumes_; } + int accumulant_bandwidth() const { if (accumulantBandwidth_) return accumulantBandwidth_; else return feEngine_->num_nodes(); }; + PerAtomQuantity<double> * atom_coarsegraining_positions() { return atomCoarseGrainingPositions_; } PerAtomQuantity<double> * atom_reference_positions() { return atomReferencePositions_; } PerAtomQuantity<int> * atom_to_element_map() { return atomElement_;} @@ -438,8 +442,8 @@ namespace ATC { /** from a atom group, find the nodes that have non-zero shape function contributions */ - bool nodal_influence(const int groupbit, set<int>& nset, set<int>& aset, double tol =1.e-8); - int nodal_influence(const int groupbit, set<int>& nset, set<int>& aset, + bool nodal_influence(const int groupbit, std::set<int>& nset, std::set<int>& aset, double tol =1.e-8); + int nodal_influence(const int groupbit, std::set<int>& nset, std::set<int>& aset, bool ghost, double tol =1.e-8); /*@{*/ @@ -465,8 +469,7 @@ namespace ATC { /** \name access to potential energy reference */ //--------------------------------------------------------------- /*@{*/ - bool has_ref_pe(void) const { return hasRefPE_; } - const DENS_MAT * nodal_ref_potential_energy(void) { return &nodalRefPotentialEnergy_; } + DENS_MAN * nodal_ref_potential_energy(void) { return nodalRefPotentialEnergy_; } protected: /** methods */ /** time functions */ @@ -490,15 +493,19 @@ namespace ATC { /** constructs all data which is updated with time integration, i.e. fields */ virtual void construct_time_integration_data() = 0; /** create methods, e.g. time integrators, filters */ - virtual void construct_methods() = 0; + virtual void construct_methods(); /** set up data which is dependency managed */ virtual void construct_transfers(); + /** sets up accumulant & interpolant */ + virtual void construct_interpolant()=0; + /** sets up mol transfers */ + virtual void construct_molecule_transfers()=0; /** update the peratom output pointers */ void update_peratom_output(void); - virtual void read_restart_data(string fileName_, RESTART_LIST & data); - virtual void write_restart_data(string fileName_, RESTART_LIST & data); + virtual void read_restart_data(std::string fileName_, RESTART_LIST & data); + virtual void write_restart_data(std::string fileName_, RESTART_LIST & data); void pack_fields(RESTART_LIST & data); /** mass matrices */ @@ -511,15 +518,15 @@ namespace ATC { MASS_MATS massMatsAq_; MASS_MATS massMatsAqInstantaneous_; Array<bool> useConsistentMassMatrix_; - map<FieldName,SPAR_MAN> consistentMassMats_; - map<FieldName,DENS_MAN> consistentMassMatsInv_; - map<FieldName,TimeFilter * > massMatTimeFilters_; + std::map<FieldName,SPAR_MAN> consistentMassMats_; + std::map<FieldName,DENS_MAN> consistentMassMatsInv_; + std::map<FieldName,TimeFilter * > massMatTimeFilters_; //--------------------------------------------------------------- /** \name quadrature weight function */ //--------------------------------------------------------------- /*@{*/ - void write_atomic_weights(const string filename,const DIAG_MAT & atomicVolumeMatrix); + void write_atomic_weights(const std::string filename,const DIAG_MAT & atomicVolumeMatrix); /** resets shape function matrices based on atoms on this processor */ virtual void reset_nlocal(); @@ -546,13 +553,12 @@ namespace ATC { //--------------------------------------------------------------- /*@{*/ /** map from species string tag to LAMMPS type id or group bit */ - map<string,pair<IdType,int> > speciesIds_; // OBSOLETE - map<string,pair<MolSize,int> > moleculeIds_; + std::map<std::string,std::pair<MolSize,int> > moleculeIds_; /** a list of lammps types & groups ATC tracks */ - vector<string> typeNames_; - vector<string> groupNames_; - vector<int> typeList_; - vector<int> groupList_; + std::vector<std::string> typeNames_; + std::vector<std::string> groupNames_; + std::vector<int> typeList_; + std::vector<int> groupList_; /*@}*/ void reset_fields(); @@ -574,6 +580,13 @@ namespace ATC { TimeFilterManager timeFilterManager_; + /** check to see if we are integrating the atoms */ + bool integrateInternalAtoms_; + /** object which integrates atoms */ + AtomTimeIntegrator * atomTimeIntegrator_; + /** objects which handles integration and modification of ghost atoms */ + GhostManager ghostManager_; + /** finite element handler */ FE_Engine * feEngine_; @@ -601,15 +614,17 @@ namespace ATC { /** Number of Spatial Dimensions */ int nsd_; + #ifdef EXTENDED_ERROR_CHECKING /** data for handling atoms crossing processors */ bool atomSwitch_; #endif + /** reference position of the atoms */ double ** xref_; bool readXref_; bool needXrefProcessorGhosts_; - string xRefFile_; + std::string xRefFile_; /** flag for tracking displacements or not, depending on physics */ bool trackDisplacement_; @@ -619,6 +634,9 @@ namespace ATC { bool needsAtomToElementMap_; PerAtomQuantity<int> * atomElement_; PerAtomQuantity<int> * atomGhostElement_; + + /* use element sets to define internal and/or ghost regions */ + std::string internalElementSet_; /** atomic ATC material tag */ @@ -650,7 +668,7 @@ namespace ATC { bool parallelConsistency_; /** base name for output files */ - string outputPrefix_; + std::string outputPrefix_; /** output flag */ @@ -696,7 +714,7 @@ namespace ATC { /** \name fields and necessary data for FEM */ //--------------------------------------------------------------- /*@{*/ - map<FieldName,int> fieldSizes_; + std::map<FieldName,int> fieldSizes_; FIELDS fields_; /*@}*/ @@ -726,11 +744,11 @@ namespace ATC { DIAG_MAN invNodeVolumes_; /** atomic quadrature integration weights (V_\alpha) */ ProtectedAtomDiagonalMatrix<double> * atomVolume_; - string atomicWeightsFile_; + std::string atomicWeightsFile_; bool atomicWeightsWriteFlag_; int atomicWeightsWriteFrequency_; double atomicVolume_; // global atomic volume for homogeneous set of atoms - map<int,double> Valpha_; + std::map<int,double> Valpha_; AtomicWeightType atomWeightType_; /*@}*/ @@ -749,8 +767,8 @@ namespace ATC { int groupbit_; int groupbitGhost_; bool needProcGhost_; - string groupTag_; - string groupTagGhost_; + std::string groupTag_; + std::string groupTagGhost_; /** number of atoms of correct type, ghosts are atoms outside our domain of interest @@ -760,8 +778,6 @@ namespace ATC { /** Number of atoms on this processor */ int nLocalTotal_; int nLocalGhost_; - int nInternal_; - int nGhost_; Array<int> internalToAtom_; std::map<int,int> atomToInternal_; Array<int> ghostToAtom_; @@ -783,10 +799,8 @@ namespace ATC { // sparse matrix where columns correspond to global node numbering SPAR_MAN * shpFcn_; VectorDependencyManager<SPAR_MAT * > * shpFcnDerivs_; - SPAR_MAN * shpFcnGhost_; - VectorDependencyManager<SPAR_MAT * > * shpFcnDerivsGhost_; - /** map from species string tag to the species density */ - map<string,DENS_MAN> taggedDensMan_; + /** map from species std::string tag to the species density */ + std::map<std::string,DENS_MAN> taggedDensMan_; /** weighted shape function matrices at overlap nodes for use with thermostats */ @@ -810,6 +824,7 @@ namespace ATC { SPAR_MAN kernelAccumulantMolGrad_; // KKM add DIAG_MAN* accumulantWeights_; DIAG_MAN* accumulantInverseVolumes_; + int accumulantBandwidth_; /*@}*/ @@ -817,15 +832,15 @@ namespace ATC { /** \name restart procedures */ //--------------------------------------------------------------- bool useRestart_; - string restartFileName_; + std::string restartFileName_; //--------------------------------------------------------------- /** \name data specific to node/faceset for global output */ //--------------------------------------------------------------- /** group computes : type, group_id -> value */ - map< pair < string, FieldName > , NodesetOperationType> nsetData_; - map < pair<string,string>, FacesetIntegralType > fsetData_; - map < pair<string, FieldName>,ElementsetOperationType > esetData_; + std::map< std::pair<std::string, FieldName > , NodesetOperationType> nsetData_; + std::map< std::pair<std::string,std::string>, FacesetIntegralType > fsetData_; + std::map< std::pair<std::string, FieldName>,ElementsetOperationType > esetData_; //--------------------------------------------------------------- @@ -836,8 +851,8 @@ namespace ATC { bool setRefPEvalue_; double refPEvalue_; bool readRefPE_; - string nodalRefPEfile_; - DENS_MAT nodalRefPotentialEnergy_; + std::string nodalRefPEfile_; + DENS_MAN* nodalRefPotentialEnergy_; void set_reference_potential_energy(void); private: /** data */ diff --git a/lib/atc/ATC_Transfer.cpp b/lib/atc/ATC_Transfer.cpp index 01e9f9066c8383427ffa8373d50d9484bed1e8e5..0e47d5fc1b9a3aacd5e6ec4198b38330698d26f9 100644 --- a/lib/atc/ATC_Transfer.cpp +++ b/lib/atc/ATC_Transfer.cpp @@ -37,15 +37,10 @@ using namespace std; using namespace ATC_Utility; using namespace voigt3; -//using ATC_Utility::to_string; -//using voigt3::vector_to_matrix; -//using voigt3::vector_to_symm_matrix; -//using voigt3::matrix_to_vector; -//using voigt3::symm_matrix_to_vector; namespace ATC { - const int numFields_ = 16; + const int numFields_ = 17; FieldName indices_[numFields_] = { CHARGE_DENSITY, MASS_DENSITY, @@ -61,7 +56,11 @@ namespace ATC { TEMPERATURE, CHARGE_FLUX, SPECIES_FLUX, - THERMAL_ENERGY}; + THERMAL_ENERGY, + ENERGY, + INTERNAL_ENERGY + }; + //KINETIC_STRESS; //ELECTRIC_POTENTIAL}; ATC_Transfer::ATC_Transfer(string groupName, @@ -133,6 +132,15 @@ namespace ATC { // called before the beginning of a "run" void ATC_Transfer::initialize() { + if (kernelOnTheFly_ && !readRefPE_ && !setRefPEvalue_) { + if (setRefPE_) { + stringstream ss; + ss << "WARNING: Reference PE requested from atoms, but not yet implemented for on-the-fly, ignoring"; + lammpsInterface_->print_msg_once(ss.str()); + setRefPE_ = false; + } + } + ATC_Method::initialize(); if (!initialized_) { @@ -152,6 +160,8 @@ namespace ATC { } resetKernelFunction_ = false; } + // clears need for reset + ghostManager_.initialize(); // initialize bond matrix B_Iab if ((! bondOnTheFly_) @@ -232,8 +242,6 @@ namespace ATC { void ATC_Transfer::construct_time_integration_data() { if (!initialized_) { - // ground state for PE - nodalRefPotentialEnergy_.reset(nNodes_,1); // size arrays for requested/required fields for(int index=0; index < NUM_TOTAL_FIELDS; ++index) { @@ -283,26 +291,21 @@ namespace ATC { } //------------------------------------------------------------------- - // constructs quantities - void ATC_Transfer::construct_transfers() + // construct_interpolant + // constructs: interpolatn, accumulant, weights, and spatial derivatives + //-------------------------------------------------------- + void ATC_Transfer::construct_interpolant() { - - // set pointer to positions - // REFACTOR use method's handling of xref/xpointer - set_xPointer(); - - ATC_Method::construct_transfers(); - + // interpolant if (!(kernelOnTheFly_)) { // finite element shape functions for interpolants PerAtomShapeFunction * atomShapeFunctions = new PerAtomShapeFunction(this); interscaleManager_.add_per_atom_sparse_matrix(atomShapeFunctions,"Interpolant"); shpFcn_ = atomShapeFunctions; } - + // accummulant and weights this->create_atom_volume(); - // accumulants if (kernelFunction_) { // kernel-based accumulants @@ -347,7 +350,68 @@ namespace ATC { "AccumulantWeights"); } } + // gradient matrix + if (gradFlags_.has_member(true)) { + NativeShapeFunctionGradient * gradientMatrix = new NativeShapeFunctionGradient(this); + interscaleManager_.add_vector_sparse_matrix(gradientMatrix,"GradientMatrix"); + gradientMatrix_ = gradientMatrix; + } + } + //------------------------------------------------------------------- + void ATC_Transfer::construct_molecule_transfers() + { + // molecule centroid, molecule charge, dipole moment and quadrupole moment calculations KKM add + if (!moleculeIds_.empty()) { + map<string,pair<MolSize,int> >::const_iterator molecule; + InterscaleManager & interscaleManager = this->interscale_manager(); // KKM add, may be we do not need this as interscaleManager_ already exists. + PerAtomQuantity<double> * atomProcGhostCoarseGrainingPositions_ = interscaleManager.per_atom_quantity("AtomicProcGhostCoarseGrainingPositions"); + FundamentalAtomQuantity * mass = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,PROC_GHOST); + molecule = moleculeIds_.begin(); + int groupbit = (molecule->second).second; + smallMoleculeSet_ = new SmallMoleculeSet(this,groupbit); + smallMoleculeSet_->initialize(); // KKM add, why should we? + interscaleManager_.add_small_molecule_set(smallMoleculeSet_,"MoleculeSet"); + moleculeCentroid_ = new SmallMoleculeCentroid(this,mass,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_); + interscaleManager_.add_dense_matrix(moleculeCentroid_,"MoleculeCentroid"); + AtomToSmallMoleculeTransfer<double> * moleculeMass = + new AtomToSmallMoleculeTransfer<double>(this,mass,smallMoleculeSet_); + interscaleManager_.add_dense_matrix(moleculeMass,"MoleculeMass"); + FundamentalAtomQuantity * atomicCharge = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE,PROC_GHOST); + AtomToSmallMoleculeTransfer<double> * moleculeCharge = + new AtomToSmallMoleculeTransfer<double>(this,atomicCharge,smallMoleculeSet_); + interscaleManager_.add_dense_matrix(moleculeCharge,"MoleculeCharge"); + dipoleMoment_ = new SmallMoleculeDipoleMoment(this,atomicCharge,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_,moleculeCentroid_); + interscaleManager_.add_dense_matrix(dipoleMoment_,"DipoleMoment"); + quadrupoleMoment_ = new SmallMoleculeQuadrupoleMoment(this,atomicCharge,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_,moleculeCentroid_); + interscaleManager_.add_dense_matrix(quadrupoleMoment_,"QuadrupoleMoment"); + } + } + //---------------------------------------------------------------------- + // constructs quantities + void ATC_Transfer::construct_transfers() + { + + // set pointer to positions + // REFACTOR use method's handling of xref/xpointer + set_xPointer(); + + ATC_Method::construct_transfers(); + + // reference potential energy + if (setRefPE_) { + if (!setRefPEvalue_ && !readRefPE_) { + FieldManager fmgr(this); + nodalRefPotentialEnergy_ = fmgr.nodal_atomic_field(REFERENCE_POTENTIAL_ENERGY); + } + else { + nodalRefPotentialEnergy_ = new DENS_MAN(nNodes_,1); + nodalRefPotentialEnergy_->set_memory_type(PERSISTENT); + interscaleManager_.add_dense_matrix(nodalRefPotentialEnergy_, + field_to_string(REFERENCE_POTENTIAL_ENERGY)); + } + } + // for hardy-based fluxes bool needsBondMatrix = (! bondOnTheFly_ ) && (fieldFlags_(STRESS) @@ -365,13 +429,7 @@ namespace ATC { } } if (pairMap_) interscaleManager_.add_pair_map(pairMap_,"PairMap"); - //if (pairMap_ && !initialized_) interscaleManager_.add_pair_map(pairMap_,"PairMap"); - - //const PerAtomQuantity<double> * x0= interscaleManager_.per_atom_quantity("AtomicReferencePositions"); - //const PerAtomQuantity<double> * x0= interscaleManager_.per_atom_quantity("AtomicCoarseGrainingPositions"); - //const PerAtomQuantity<double> * x0= interscaleManager_.per_atom_quantity("AtomicReferencePositions"); - if ( fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) || fieldFlags_(HEAT_FLUX) ) { const FE_Mesh * fe_mesh = feEngine_->fe_mesh(); @@ -386,7 +444,6 @@ namespace ATC { if ( fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) ) { if (atomToElementMapType_ == LAGRANGIAN) { -// pairVirial_ = new PairVirialLagrangian(lammpsInterface_,*pairMap_,x0); pairVirial_ = new PairVirialLagrangian(lammpsInterface_,*pairMap_,xref_); } else if (atomToElementMapType_ == EULERIAN) { @@ -411,39 +468,6 @@ namespace ATC { } if (pairHeatFlux_) interscaleManager_.add_dense_matrix(pairHeatFlux_,"PairHeatFlux"); - // gradient matrix - if (gradFlags_.has_member(true)) { - NativeShapeFunctionGradient * gradientMatrix = new NativeShapeFunctionGradient(this); - interscaleManager_.add_vector_sparse_matrix(gradientMatrix,"GradientMatrix"); - gradientMatrix_ = gradientMatrix; - } - - // molecule centroid, molecule charge, dipole moment and quadrupole moment calculations KKM add - if (!moleculeIds_.empty()) { - map<string,pair<MolSize,int> >::const_iterator molecule; - InterscaleManager & interscaleManager = this->interscale_manager(); // KKM add, may be we do not need this as interscaleManager_ already exists. - PerAtomQuantity<double> * atomProcGhostCoarseGrainingPositions_ = interscaleManager.per_atom_quantity("AtomicProcGhostCoarseGrainingPositions"); - FundamentalAtomQuantity * mass = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,PROC_GHOST); - molecule = moleculeIds_.begin(); - int groupbit = (molecule->second).second; - smallMoleculeSet_ = new SmallMoleculeSet(this,groupbit); - smallMoleculeSet_->initialize(); // KKM add, why should we? - interscaleManager_.add_small_molecule_set(smallMoleculeSet_,"MoleculeSet"); - moleculeCentroid_ = new SmallMoleculeCentroid(this,mass,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_); - interscaleManager_.add_dense_matrix(moleculeCentroid_,"MoleculeCentroid"); - AtomToSmallMoleculeTransfer<double> * moleculeMass = - new AtomToSmallMoleculeTransfer<double>(this,mass,smallMoleculeSet_); - interscaleManager_.add_dense_matrix(moleculeMass,"MoleculeMass"); - FundamentalAtomQuantity * atomicCharge = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE,PROC_GHOST); - AtomToSmallMoleculeTransfer<double> * moleculeCharge = - new AtomToSmallMoleculeTransfer<double>(this,atomicCharge,smallMoleculeSet_); - interscaleManager_.add_dense_matrix(moleculeCharge,"MoleculeCharge"); - dipoleMoment_ = new SmallMoleculeDipoleMoment(this,atomicCharge,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_,moleculeCentroid_); - interscaleManager_.add_dense_matrix(dipoleMoment_,"DipoleMoment"); - quadrupoleMoment_ = new SmallMoleculeQuadrupoleMoment(this,atomicCharge,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_,moleculeCentroid_); - interscaleManager_.add_dense_matrix(quadrupoleMoment_,"QuadrupoleMoment"); - } - FieldManager fmgr(this); // for(int index=0; index < NUM_TOTAL_FIELDS; ++index) @@ -454,9 +478,10 @@ namespace ATC { } } -// WIP REJ +// WIP REJ - move to fmgr if (fieldFlags_(ELECTRIC_POTENTIAL)) { - restrictedCharge_ = fmgr.restricted_atom_quantity(CHARGE_DENSITY); + PerAtomQuantity<double> * atomCharge = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE); + restrictedCharge_ = fmgr.restricted_atom_quantity(CHARGE_DENSITY,"default",atomCharge); } // computes @@ -489,6 +514,8 @@ namespace ATC { // sets initial values of filtered quantities void ATC_Transfer::construct_methods() { + ATC_Method::construct_methods(); + if ((!initialized_) || timeFilterManager_.need_reset()) { timeFilters_.reset(NUM_TOTAL_FIELDS+nComputes_); sampleCounter_ = 0; @@ -705,10 +732,10 @@ namespace ATC { } - /*! \page man_pair_interactions fix_modify AtC pair_interactions on|off + /*! \page man_pair_interactions fix_modify AtC pair_interactions/bond_interactions \section syntax - fix_modify AtC pair_interactions on|off \n - fix_modify AtC bond_interactions on|off \n + fix_modify AtC pair_interactions <on|off> \n + fix_modify AtC bond_interactions <on|off> \n \section examples <TT> fix_modify AtC bond_interactions on </TT> \n @@ -796,34 +823,6 @@ namespace ATC { } - /*! \page man_hardy_dxa_exact_mode fix_modify AtC dxa_exact_mode - \section syntax - fix_modify AtC dxa_exact_mode <optional on | off> \n - - on | off (keyword) = use "exact"/serial mode for DXA-based - calculation of dislocation density, or not \n - - \section examples - <TT> fix_modify AtC dxa_exact_mode </TT> \n - <TT> fix_modify AtC dxa_exact_mode on</TT> \n - <TT> fix_modify AtC dxa_exact_mode off</TT> \n - \section description - Overrides normal "exact"/serial mode for DXA code to extract dislocation segments, - as opposed to an "inexact" mode that's more efficient for parallel computation of - large systems. \n - \section restrictions - Must be used with the hardy/field type of AtC fix - ( see \ref man_fix_atc ) - \section related - \section default - By default, the DXA "exact"/serial mode is used (i.e. on). \n - */ - else if (strcmp(arg[argIdx],"dxa_exact_mode")==0) { - argIdx++; - dxaExactMode_ = true; - if (narg > argIdx && strcmp(arg[argIdx],"off")==0) dxaExactMode_ = false; - match = true; - } - /*! \page man_sample_frequency fix_modify AtC sample_frequency \section syntax fix_modify AtC sample_frequency [freq] @@ -831,8 +830,8 @@ namespace ATC { \section examples <TT> fix_modify AtC sample_frequency 10 \section description - Calculates a surface integral of the given field dotted with the - outward normal of the faces and puts output in the "GLOBALS" file + Specifies a frequency at which fields are computed for the case + where time filters are being applied. \section restrictions Must be used with the hardy/field AtC fix ( see \ref man_fix_atc ) and is only relevant when time filters are being used. @@ -931,14 +930,11 @@ namespace ATC { for(int i=0; i < numFields_; ++i) { FieldName index = indices_[i]; if (fieldFlags_(index)) { - hardyData_[field_to_string(index)].set_quantity() - = (outputFields_[index])->quantity(); + DENS_MAT & data(hardyData_[field_to_string(index)].set_quantity()); + data = (outputFields_[index])->quantity(); } } - if (fieldFlags_(INTERNAL_ENERGY)) - compute_internal_energy(hardyData_["internal_energy"].set_quantity()); - if (fieldFlags_(ENERGY)) - compute_energy(hardyData_["energy"].set_quantity()); + if (fieldFlags_(STRESS)) compute_stress(hardyData_["stress"].set_quantity()); if (fieldFlags_(HEAT_FLUX)) @@ -982,7 +978,6 @@ namespace ATC { //DENS_MAT & T = hardyData_["temperature"]; //cauchy_born_entropic_energy(H,E,T); E += hardyData_["internal_energy"]; cauchy_born_energy(H, E, temp); - E -= nodalRefPotentialEnergy_; compute_eshelby_stress(hardyData_["cauchy_born_eshelby_stress"].set_quantity(), E,hardyData_["stress"].quantity(), @@ -1194,7 +1189,7 @@ namespace ATC { // data OUTPUT_LIST output_data; #ifdef REFERENCE_PE_OUTPUT - output_data["reference_potential_energy"] = & nodalRefPotentialEnergy_; + output_data["reference_potential_energy"] = nodalRefPotentialEnergy_->quantity(); #endif for(int index=0; index < NUM_TOTAL_FIELDS; ++index) { if (outputFlags_(index)) { @@ -1225,6 +1220,9 @@ namespace ATC { #endif } + DENS_MAT nodalInverseVolumes = CLON_VEC(accumulantInverseVolumes_->quantity()); + output_data["NodalInverseVolumes"] = &nodalInverseVolumes; + // output feEngine_->write_data(output_index(), & output_data); } @@ -1467,61 +1465,6 @@ namespace ATC { // HARDY COMPUTES // ***************UNCONVERTED************************** - //------------------------------------------------------------------- - // total energy - - void ATC_Transfer::compute_energy(DENS_MAT & energy) - { - PerAtomQuantity<double> * atomicPotentialEnergy = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - atomicScalar_=atomicPotentialEnergy->quantity(); - double mvv2e = lammpsInterface_->mvv2e(); - int * type = lammpsInterface_->atom_type(); - double * mass = lammpsInterface_->atom_mass(); - double * rmass = lammpsInterface_->atom_rmass(); - double ** vatom = lammpsInterface_->vatom(); - for (int i = 0; i < nLocal_; i++) { - int atomIdx = internalToAtom_(i); - double ma = mass ? mass[type[atomIdx]]: rmass[atomIdx]; - ma *= mvv2e; // convert mass to appropriate units - // compute kinetic energy per atom - double* v = vatom[atomIdx]; - double atomKE = 0.0; - for (int k = 0; k < nsd_; k++) { atomKE += v[k]*v[k]; } - atomKE *= 0.5*ma; - // add up total energy per atom - atomicScalar_(i,0) += atomKE; - } - project_volume_normalized(atomicScalar_, energy); - } - // internal energy - - void ATC_Transfer::compute_internal_energy(DENS_MAT & energy) - { - PerAtomQuantity<double> * atomicPotentialEnergy = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - PerAtomQuantity<double> * atomicProlongedVelocity = interscaleManager_.per_atom_quantity("ProlongedVelocity"); - atomicScalar_=atomicPotentialEnergy->quantity(); - atomicVector_=atomicProlongedVelocity->quantity(); - double mvv2e = lammpsInterface_->mvv2e(); - int * type = lammpsInterface_->atom_type(); - double * mass = lammpsInterface_->atom_mass(); - double * rmass = lammpsInterface_->atom_rmass(); - double ** vatom = lammpsInterface_->vatom(); - for (int i = 0; i < nLocal_; i++) { - int atomIdx = internalToAtom_(i); - double ma = mass ? mass[type[atomIdx]]: rmass[atomIdx]; - ma *= mvv2e; // convert mass to appropriate units - // compute kinetic energy per atom - double* v = vatom[atomIdx]; - double atomKE = 0.0; - for (int k = 0; k < nsd_; k++) { - atomKE += (v[k]-atomicVector_(i,k))*(v[k]-atomicVector_(i,k)); - } - atomKE *= 0.5*ma; - // add up total energy per atom - atomicScalar_(i,0) += atomKE; - } - project_volume_normalized(atomicScalar_, energy); - } //------------------------------------------------------------------- // MOLECULE //------------------------------------------------------------------- @@ -1749,6 +1692,8 @@ namespace ATC { F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; } double J = det(F); + double volume_per_atom = lammpsInterface_->volume_per_atom(); + J *= volume_per_atom; Cv(i,0) = 1.0 - J*new_rho(i,0); } } @@ -1904,9 +1849,9 @@ namespace ATC { E(i,0) *= 1/J; } } - // subtract zero point energy - E -= nodalRefPotentialEnergy_; + if (nodalRefPotentialEnergy_) + E -= nodalRefPotentialEnergy_->quantity(); } //--------------------------------------------------------------------------- // Computes the M/LH entropic energy density diff --git a/lib/atc/ATC_Transfer.h b/lib/atc/ATC_Transfer.h index 4b12c7354e35c52132e9e73a4093812092319250..8f4753bab72df9bfcc4ef37948f00fcfe7e267dd 100644 --- a/lib/atc/ATC_Transfer.h +++ b/lib/atc/ATC_Transfer.h @@ -9,8 +9,8 @@ // Other headers #include <map> -#include <list> -using std::list; +#include <string> +#include <vector> namespace ATC { @@ -56,7 +56,7 @@ class ATC_Transfer : public ATC_Method { virtual void output(); /** external access to hardy data and other information*/ - const DENS_MAT * hardy_data(string field) { return &hardyData_[field].quantity(); } + const DENS_MAT * hardy_data(std::string field) { return &hardyData_[field].quantity(); } protected: @@ -70,9 +70,9 @@ class ATC_Transfer : public ATC_Method { SmallMoleculeDipoleMoment * dipoleMoment_; // KKM add SmallMoleculeQuadrupoleMoment * quadrupoleMoment_; // KKM add /** container for dependency managed data */ - vector < DENS_MAN * > outputFields_; + std::vector < DENS_MAN * > outputFields_; - map < string, DENS_MAN * > outputFieldsTagged_; + std::map < std::string, DENS_MAN * > outputFieldsTagged_; DENS_MAN * restrictedCharge_; // WIP/TEMP @@ -86,7 +86,7 @@ class ATC_Transfer : public ATC_Method { Array<bool> outputFlags_; Array<bool> gradFlags_; Array<bool> rateFlags_; - map<string,int> computes_; + std::map<std::string,int> computes_; bool outputStepZero_; /** check whether atoms have shifted box or element or neighbors changed */ @@ -99,12 +99,16 @@ class ATC_Transfer : public ATC_Method { virtual void set_continuum_data(); /** sets up all data necessary to define the computational geometry */ virtual void set_computational_geometry(); + /** sets up accumulant & interpolant */ + virtual void construct_interpolant(); /** constructs all data which is updated with time integration, i.e. fields */ virtual void construct_time_integration_data(); /** create methods, e.g. time integrators, filters */ virtual void construct_methods(); /** set up data which is dependency managed */ virtual void construct_transfers(); + /** sets up mol transfers */ + virtual void construct_molecule_transfers(); /** compute atom to nodal quantities */ // OBSOLETE diff --git a/lib/atc/ATC_TransferKernel.cpp b/lib/atc/ATC_TransferKernel.cpp index c4e2a2928dfa2683dd301ecb8568b106f36532db..a4d592ba64fa3bf0929d0fd56d6e26b93e8f43e9 100644 --- a/lib/atc/ATC_TransferKernel.cpp +++ b/lib/atc/ATC_TransferKernel.cpp @@ -59,8 +59,8 @@ using ATC_Utility::to_string; quartic_cylinder = radius (double) \n quartic_sphere = radius (double) \n \section examples - fix_modify AtC kernel cell 1.0 1.0 1.0 - fix_modify AtC kernel quartic_sphere 10.0 + <TT> fix_modify AtC kernel cell 1.0 1.0 1.0 </TT> \n + <TT> fix_modify AtC kernel quartic_sphere 10.0 </TT> \section description \section restrictions @@ -140,6 +140,7 @@ using ATC_Utility::to_string; nodeData.zero(); if (nLocal_>0) { + set_xPointer(); DENS_VEC xI(nsd_),xa(nsd_),xaI(nsd_); double val; for (int i = 0; i < nNodes_; i++) { diff --git a/lib/atc/ATC_TypeDefs.h b/lib/atc/ATC_TypeDefs.h index e3e5f794cf967e9801357c92a58af67a2d355b42..ab24a8a22000568eaf6551228409e81e32151c85 100644 --- a/lib/atc/ATC_TypeDefs.h +++ b/lib/atc/ATC_TypeDefs.h @@ -2,8 +2,10 @@ #define ATC_TYPEDEFS_H #include <set> -using std::pair; -using std::set; +#include <vector> +#include <map> +#include <utility> +#include <string> #ifdef NEW_LAMMPS #include "lmptype.h" @@ -12,8 +14,6 @@ using std::set; #include "Array.h" #include "Array2D.h" -using namespace ATC_matrix; - #include "MatrixLibrary.h" #include "DependencyManager.h" @@ -122,6 +122,7 @@ namespace ATC THERMAL_ENERGY, KINETIC_ENERGY, STRESS, + KINETIC_STRESS, HEAT_FLUX, CHARGE_FLUX, SPECIES_FLUX, @@ -168,6 +169,7 @@ namespace ATC 1, // THERMAL_ENERGY 1, // KINETIC_ENERGY NDIM*NDIM, // STRESS + NDIM*NDIM, // KINETIC_STRESS NDIM, // HEAT_FLUX NDIM, // CHARGE_FLUX 0, // SPECIES_FLUX - VARIABLE @@ -190,17 +192,23 @@ namespace ATC NDIM*NDIM // DISLOCATION_DENSITY }; - enum hardyNormalization { + enum NodalAtomicFieldNormalization { NO_NORMALIZATION=0, - VOLUME_NORMALIZATION, NUMBER_NORMALIZATION, MASS_NORMALIZATION + VOLUME_NORMALIZATION, NUMBER_NORMALIZATION, MASS_NORMALIZATION, + MASS_MATRIX }; + inline FieldName use_mass_matrix(FieldName in) { + if (in == TEMPERATURE) return in; + else return MASS_DENSITY; + } + /** enums for FE Element and Interpolate classes */ enum FeEltGeometry {HEXA, TETRA}; enum FeIntQuadrature {NODAL, GAUSS1, GAUSS2, GAUSS3, FACE}; /** field name enum to string */ - inline FeIntQuadrature string_to_FIQ(const string &str) + inline FeIntQuadrature string_to_FIQ(const std::string &str) { if (str == "nodal") return NODAL; @@ -217,7 +225,7 @@ namespace ATC } /** field name enum to string */ - inline string field_to_string(const FieldName index) + inline std::string field_to_string(const FieldName index) { switch (index) { case TEMPERATURE: @@ -258,6 +266,8 @@ namespace ATC return "kinetic_energy"; case STRESS: return "stress"; + case KINETIC_STRESS: + return "kinetic_stress"; case ESHELBY_STRESS: return "eshelby_stress"; case CAUCHY_BORN_STRESS: @@ -302,7 +312,7 @@ namespace ATC }; /** string to field enum */ - inline FieldName string_to_field(const string & name) + inline FieldName string_to_field(const std::string & name) { if (name=="temperature") return TEMPERATURE; @@ -342,6 +352,8 @@ namespace ATC return KINETIC_ENERGY; else if (name=="stress") return STRESS; + else if (name=="kinetic_stress") + return KINETIC_STRESS; else if (name=="eshelby_stress") return ESHELBY_STRESS; else if (name=="cauchy_born_stress") @@ -399,7 +411,7 @@ namespace ATC else return false; }; - inline string field_to_intrinsic_name(const FieldName index) + inline std::string field_to_intrinsic_name(const FieldName index) { if (is_intrinsic(index)) { return "NodalAtomic"+ATC_Utility::to_cap(field_to_string(index)); @@ -408,7 +420,7 @@ namespace ATC throw ATC_Error("field "+field_to_string(index)+" is not an intrinsic field"); } } - inline string field_to_restriction_name(const FieldName index) + inline std::string field_to_restriction_name(const FieldName index) { if (is_intrinsic(index)) { return "Restricted"+ATC_Utility::to_cap(field_to_string(index)); @@ -417,7 +429,7 @@ namespace ATC throw ATC_Error("field "+field_to_string(index)+" is not an intrinsic field"); } } - inline string field_to_prolongation_name(const FieldName index) + inline std::string field_to_prolongation_name(const FieldName index) { return "Prolonged"+ATC_Utility::to_cap(field_to_string(index)); } @@ -430,16 +442,8 @@ namespace ATC TOTAL }; - /** types of ghost boundary conditions in momentum */ - enum BoundaryDynamicsType { - NO_BOUNDARY_DYNAMICS=0, - PRESCRIBED, - DAMPED_HARMONIC, - COUPLED - }; - /** string to temperature definition enum */ - inline bool string_to_temperature_def(const string & name, TemperatureDefType & index) { + inline bool string_to_temperature_def(const std::string & name, TemperatureDefType & index) { if (name=="none") index = NONE; else if (name=="kinetic") @@ -503,63 +507,63 @@ namespace ATC }; /** basic */ - typedef pair<int, int> PAIR; + typedef std::pair<int, int> PAIR; /** typedefs for compact set of bc values */ - typedef set < pair < int, double> > BC_SET; // node, value - typedef vector< BC_SET > BCS; // dof (node, value) - typedef set<int> NSET; // nodeset - typedef set<PAIR> FSET; // faceset - typedef set<int> ESET; // elementset + typedef std::set < std::pair < int, double> > BC_SET; // node, value + typedef std::vector< BC_SET > BCS; // dof (node, value) + typedef std::set<int> NSET; // nodeset + typedef std::set<PAIR> FSET; // faceset + typedef std::set<int> ESET; // elementset /** typedefs for N and B integrand functions */ - typedef set<FieldName> ARG_NAMES; - typedef map<FieldName, DenseMatrix<double> > ARGS; - typedef MatrixDependencyManager<DenseMatrix, double> FIELD; - typedef vector<MatrixDependencyManager<DenseMatrix, double> > GRAD_FIELD; - typedef map<FieldName, MatrixDependencyManager<DenseMatrix, double> > FIELDS; - typedef map<FieldName, MatrixDependencyManager<DenseMatrix, double> * > FIELD_POINTERS; - typedef map<FieldName, DenseMatrix<double> > FIELD_MATS; - typedef map<string, MatrixDependencyManager<DenseMatrix, double> > TAG_FIELDS; - typedef map<FieldName, vector<MatrixDependencyManager<DenseMatrix, double> > > GRAD_FIELDS; - typedef map<FieldName, vector<DenseMatrix<double> > > GRAD_FIELD_MATS; - typedef map<FieldName, MatrixDependencyManager<DiagonalMatrix, double> > MASS_MATS; - typedef map<FieldName, MatrixDependencyManager<SparseMatrix, double> > CON_MASS_MATS; - typedef MatrixDependencyManager<DenseMatrix, double> DENS_MAN; - typedef MatrixDependencyManager<SparseMatrix, double> SPAR_MAN; - typedef MatrixDependencyManager<ParSparseMatrix, double> PAR_SPAR_MAN; - typedef MatrixDependencyManager<DiagonalMatrix, double> DIAG_MAN; - typedef MatrixDependencyManager<ParDiagonalMatrix, double> PAR_DIAG_MAN; + typedef std::set<FieldName> ARG_NAMES; + typedef std::map<FieldName, ATC_matrix::DenseMatrix<double> > ARGS; + typedef ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> FIELD; + typedef std::vector<ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> > GRAD_FIELD; + typedef std::map<FieldName, ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> > FIELDS; + typedef std::map<FieldName, ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> * > FIELD_POINTERS; + typedef std::map<FieldName, ATC_matrix::DenseMatrix<double> > FIELD_MATS; + typedef std::map<std::string, ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> > TAG_FIELDS; + typedef std::map<FieldName, std::vector<ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> > > GRAD_FIELDS; + typedef std::map<FieldName, std::vector<ATC_matrix::DenseMatrix<double> > > GRAD_FIELD_MATS; + typedef std::map<FieldName, ATC::MatrixDependencyManager<DiagonalMatrix, double> > MASS_MATS; + typedef std::map<FieldName, ATC::MatrixDependencyManager<SparseMatrix, double> > CON_MASS_MATS; + typedef ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> DENS_MAN; + typedef ATC::MatrixDependencyManager<SparseMatrix, double> SPAR_MAN; + typedef ATC::MatrixDependencyManager<ParSparseMatrix, double> PAR_SPAR_MAN; + typedef ATC::MatrixDependencyManager<DiagonalMatrix, double> DIAG_MAN; + typedef ATC::MatrixDependencyManager<ParDiagonalMatrix, double> PAR_DIAG_MAN; /** typedefs for WeakEquation evaluation */ typedef Array2D<bool> RHS_MASK; /** typedefs for input/output */ - typedef map<string, const Matrix<double>*> OUTPUT_LIST; - typedef map<string, Matrix<double>*> RESTART_LIST; + typedef std::map<std::string, const ATC_matrix::Matrix<double>*> OUTPUT_LIST; + typedef std::map<std::string, ATC_matrix::Matrix<double>*> RESTART_LIST; - typedef pair<int, int> ID_PAIR; - typedef vector< pair<int, int> > ID_LIST; + typedef std::pair<int, int> ID_PAIR; + typedef std::vector< std::pair<int, int> > ID_LIST; /** misc typedefs */ class XT_Function; class UXT_Function; - typedef map<FieldName, map<PAIR, Array<XT_Function*> > > SURFACE_SOURCE; - typedef map<FieldName, map<PAIR, Array<UXT_Function*> > > ROBIN_SURFACE_SOURCE; - typedef map<FieldName, Array2D<XT_Function *> > VOLUME_SOURCE; - typedef map<string, MatrixDependencyManager<DenseMatrix, double> > ATOMIC_DATA; + typedef std::map<FieldName, std::map<PAIR, Array<XT_Function*> > > SURFACE_SOURCE; + typedef std::map<FieldName, std::map<PAIR, Array<UXT_Function*> > > ROBIN_SURFACE_SOURCE; + typedef std::map<FieldName, Array2D<XT_Function *> > VOLUME_SOURCE; + typedef std::map<std::string, ATC::MatrixDependencyManager<ATC_matrix::DenseMatrix, double> > ATOMIC_DATA; /** typedefs for FE_Mesh */ - typedef map<string, set<int > > NODE_SET_MAP; - typedef map<string, set<int > > ELEMENT_SET_MAP; - typedef map<string, set<PAIR> > FACE_SET_MAP; + typedef std::map<std::string, std::set<int > > NODE_SET_MAP; + typedef std::map<std::string, std::set<int > > ELEMENT_SET_MAP; + typedef std::map<std::string, std::set<PAIR> > FACE_SET_MAP; /** string to index */ // inline vs. static is used to avoid compiler warnings that the function isn't used // the compiler seems to just check if static functions are used in the file they're // declared in rather than all the files that include the header, // same for arrays (but not primitives, e.g. ints) hopefully this also speeds up the code - inline bool string_to_index(const string & dim, int & index, int & sgn) + inline bool string_to_index(const std::string & dim, int & index, int & sgn) { char dir; if (dim.empty()) return false; @@ -573,7 +577,7 @@ namespace ATC }; /** string to index */ - inline string index_to_string(const int &index) + inline std::string index_to_string(const int &index) { if (index==0) return "x"; else if (index==1) return "y"; @@ -582,7 +586,7 @@ namespace ATC }; /** string to index */ - inline bool string_to_index(const string &dim, int &index) + inline bool string_to_index(const std::string &dim, int &index) { if (dim=="x") index = 0; @@ -596,12 +600,12 @@ namespace ATC return true; }; - inline string print_mask(const Array2D<bool> & rhsMask) + inline std::string print_mask(const Array2D<bool> & rhsMask) { - string msg; + std::string msg; for (int i = 0; i < NUM_FIELDS; i++) { FieldName field = (FieldName) i; - string name = field_to_string(field); + std::string name = field_to_string(field); if (rhsMask(field,FLUX) || rhsMask(field,SOURCE) || rhsMask(field,PRESCRIBED_SOURCE) diff --git a/lib/atc/AtomToMoleculeTransfer.cpp b/lib/atc/AtomToMoleculeTransfer.cpp index 6cb139e2a9b556c2a4a6fe6ba0a3ac93bf85ef56..21293967bdb7851880c91b0ceb1900cfcae746a4 100644 --- a/lib/atc/AtomToMoleculeTransfer.cpp +++ b/lib/atc/AtomToMoleculeTransfer.cpp @@ -2,6 +2,8 @@ #include "AtomToMoleculeTransfer.h" #include "ATC_Method.h" +using std::set; + namespace ATC { //-------------------------------------------------------- diff --git a/lib/atc/AtomToMoleculeTransfer.h b/lib/atc/AtomToMoleculeTransfer.h index 95cf61fe998052cb36739ae5c8306cf4ebe47f66..c6523137a72a1780c2de04e6237d27bc79e90074 100644 --- a/lib/atc/AtomToMoleculeTransfer.h +++ b/lib/atc/AtomToMoleculeTransfer.h @@ -3,13 +3,13 @@ #ifndef ATOM_TO_MOLECULE_TRANSFER_H #define ATOM_TO_MOLECULE_TRANSFER_H +#include <set> + // ATC_Method headers #include "TransferOperator.h" #include "MoleculeSet.h" #include "PaqAtcUtility.h" -using namespace std; - namespace ATC { // forward declarations @@ -76,8 +76,8 @@ namespace ATC { int nLocalMol = smallMoleculeSet_->local_molecule_count(); (this->quantity_).reset(nLocalMol,sourceMatrix.nCols()); for (int i = 0; i < nLocalMol ; i++) { - const set<int> & atomsLocalMolArray = smallMoleculeSet_->atoms_by_local_molecule(i); - set<int>::const_iterator atomsLocalMolID; + const std::set<int> & atomsLocalMolArray = smallMoleculeSet_->atoms_by_local_molecule(i); + std::set<int>::const_iterator atomsLocalMolID; for (atomsLocalMolID = atomsLocalMolArray.begin(); atomsLocalMolID!= atomsLocalMolArray.end();atomsLocalMolID++) { for (int j = 0; j < sourceMatrix.nCols(); j++){ (this->quantity_)(i,j) += sourceMatrix(*atomsLocalMolID,j); diff --git a/lib/atc/AtomicRegulator.cpp b/lib/atc/AtomicRegulator.cpp index f353d0e4edaf82eb8671dcbfd5c05656358d7e39..ec04b8556b4a4e8dbd6493590d7091f832ac7b06 100644 --- a/lib/atc/AtomicRegulator.cpp +++ b/lib/atc/AtomicRegulator.cpp @@ -6,6 +6,11 @@ #include "TimeIntegrator.h" #include "LinearSolver.h" +using std::map; +using std::string; +using std::set; +using std::pair; + namespace ATC { @@ -158,7 +163,7 @@ namespace ATC { bool foundMatch = false; // set parameters for numerical matrix solutions - /*! \page man_control fix_modify AtC control <physics_type> + /*! \page man_control fix_modify AtC control \section syntax fix_modify AtC control <physics_type> <solution_parameter> <value>\n - physics_type (string) = thermal | momentum\n @@ -236,7 +241,7 @@ namespace ATC { \section examples <TT> fix_modify atc control lumped_lambda_solve on </TT> \n \section description - Command use or not use lumped matrix for lambda solve + Command to use or not use lumped matrix for lambda solve \section restrictions \section related \section default @@ -631,8 +636,14 @@ namespace ATC { regulatorPrefix_+"RegulatorShapeFunction"); // shape function derivatives + VectorDependencyManager<SPAR_MAT * > * interpolantGradient = interscaleManager.vector_sparse_matrix("InterpolantGradient"); + if (!interpolantGradient) { + interpolantGradient = new PerAtomShapeFunctionGradient(atc_); + interscaleManager.add_vector_sparse_matrix(interpolantGradient, + "InterpolantGradient"); + } shpFcnDerivs_ = new RowMappedSparseMatrixVector(atc_, - interscaleManager.vector_sparse_matrix("InterpolantGradient"), + interpolantGradient, lambdaAtomMap_); interscaleManager.add_vector_sparse_matrix(shpFcnDerivs_, regulatorPrefix_+"RegulatorShapeFunctionGradient"); diff --git a/lib/atc/AtomicRegulator.h b/lib/atc/AtomicRegulator.h index 74d719537609f0e0749a05d371c8cc275208493c..eadfce66dc3ad0e85125caf1a963dedab7afdaf4 100644 --- a/lib/atc/AtomicRegulator.h +++ b/lib/atc/AtomicRegulator.h @@ -3,13 +3,12 @@ #ifndef ATOMICREGULATOR_H #define ATOMICREGULATOR_H -// ATC headers #include "ATC_TypeDefs.h" - -// other headers #include <map> #include <set> #include <vector> +#include <utility> +#include <string> namespace ATC { @@ -72,7 +71,7 @@ namespace ATC { // constructor AtomicRegulator(ATC_Coupling * atc, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); // destructor virtual ~AtomicRegulator(); @@ -139,11 +138,11 @@ namespace ATC { // data access, intended for method objects /** returns a pointer to the DENS_MAN associated with the tag, creates a new data member if necessary */ - DENS_MAN * regulator_data(const string tag, int nCols); + DENS_MAN * regulator_data(const std::string tag, int nCols); /** can externally set regulator dynamic contributions */ virtual void reset_lambda_contribution(const DENS_MAT & target, const FieldName field=NUM_TOTAL_FIELDS) {}; /** returns a const pointer to the DENS_MAN associated with the tag, or NULL */ - const DENS_MAN * regulator_data(const string tag) const; + const DENS_MAN * regulator_data(const std::string tag) const; /** return the maximum number of iterations */ int max_iterations() {return maxIterations_;}; /** return the solver tolerance */ @@ -162,7 +161,7 @@ namespace ATC { BoundaryIntegrationType boundary_integration_type() {return boundaryIntegrationType_;}; /** access for boundary face sets */ - const set< pair<int,int> > * face_sets() + const std::set< std::pair<int,int> > * face_sets() { return boundaryFaceSet_;}; /** access for needing a reset */ bool need_reset() const {return needReset_;}; @@ -183,7 +182,7 @@ namespace ATC { bool md_flux_nodes(FieldName fieldName = NUM_TOTAL_FIELDS) const; /** returns prefix tag for regulator */ - const string & regulator_prefix() const {return regulatorPrefix_;}; + const std::string & regulator_prefix() const {return regulatorPrefix_;}; protected: @@ -215,7 +214,8 @@ namespace ATC { // regulator data /** container for all data, string is tag, bool is false if currently in use */ - map<string, pair<bool,DENS_MAN * > > regulatorData_; + std::map<std::string, std::pair<bool,DENS_MAN * > > regulatorData_; + /** maximum number of iterations used in solving for lambda */ int maxIterations_; /** tolerance used in solving for lambda */ @@ -238,7 +238,7 @@ namespace ATC { bool useLumpedLambda_; /** restrict application in certain directions */ - vector<bool> applyInDirection_; + std::vector<bool> applyInDirection_; // method pointers /** time filtering object */ @@ -248,10 +248,10 @@ namespace ATC { // boundary flux information BoundaryIntegrationType boundaryIntegrationType_; - const set< pair<int,int> > * boundaryFaceSet_; + const std::set< std::pair<int,int> > * boundaryFaceSet_; /** prefix string for registering data */ - const string regulatorPrefix_; + const std::string regulatorPrefix_; private: @@ -276,7 +276,7 @@ namespace ATC { public: RegulatorMethod(AtomicRegulator * atomicRegulator, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~RegulatorMethod(){}; @@ -358,10 +358,10 @@ namespace ATC { int nNodes_; /** prefix string for registering data */ - const string regulatorPrefix_; + const std::string regulatorPrefix_; /** mapping for atom materials for atomic FE quadrature */ - Array<set<int> > atomMaterialGroups_; + Array<std::set<int> > atomMaterialGroups_; /** shape function derivative matrices for boundary atoms */ VectorDependencyManager<SPAR_MAT * > * shpFcnDerivs_; @@ -393,7 +393,7 @@ namespace ATC { public: RegulatorShapeFunction(AtomicRegulator * atomicRegulator, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~RegulatorShapeFunction(); diff --git a/lib/atc/BodyForce.cpp b/lib/atc/BodyForce.cpp index 8bc76f2c5823b21faba5fed28970d778951e172b..ecef3749b74af0c0a0f9dc1634c812cdfdddfd09 100644 --- a/lib/atc/BodyForce.cpp +++ b/lib/atc/BodyForce.cpp @@ -3,19 +3,24 @@ #include <iostream> #include <fstream> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; using ATC_Utility::str2int; +using std::fstream; +using std::string; +using std::map; +using std::vector; namespace ATC { BodyForceViscous::BodyForceViscous( - fstream &fileId, map<string,double> & parameters) + fstream &fileId, std::map<std::string,double> & parameters) : BodyForce(), gamma_(0) { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); - vector<string> line; + std::vector<std::string> line; while(fileId.good()) { command_line(fileId, line); if (line.size() == 0) continue; diff --git a/lib/atc/BodyForce.h b/lib/atc/BodyForce.h index 4e312f17208143d4aa48d31174cb7adbc1bb751d..eef5df03bece9d6831739919a81f072565e06899 100644 --- a/lib/atc/BodyForce.h +++ b/lib/atc/BodyForce.h @@ -3,10 +3,6 @@ #include <map> #include <string> - -using std::map; -using std::string; - #include "ATC_TypeDefs.h" #include "Function.h" @@ -33,7 +29,7 @@ namespace ATC { class BodyForceViscous : public BodyForce { public: - BodyForceViscous(fstream &matfile,map<string,double> & parameters); + BodyForceViscous(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~BodyForceViscous() {}; virtual bool body_force(const FIELD_MATS &fields, DENS_MAT &flux) const @@ -53,7 +49,7 @@ namespace ATC { class BodyForceElectricField : public BodyForce { public: - BodyForceElectricField(fstream &matfile,map<string,double> & parameters) + BodyForceElectricField(std::fstream &matfile,std::map<std::string,double> & parameters) { throw ATC_Error("unimplemented due to issues with accessing electric field"); } virtual ~BodyForceElectricField() {}; virtual bool body_force(const FIELD_MATS &fields, diff --git a/lib/atc/CBLattice.cpp b/lib/atc/CBLattice.cpp index 67c2cf6be07687ba842f5407a11d55a74170c26a..c50b8eb3d582daf8eb82f9633a2ac5a7d852f0f1 100644 --- a/lib/atc/CBLattice.cpp +++ b/lib/atc/CBLattice.cpp @@ -1,6 +1,8 @@ #include "CBLattice.h" #include "CbPotential.h" +#include <fstream> + namespace ATC { // removes any overlapping atoms (avoid calling because it scales n^2.) INDEX AtomCluster::remove_overlap() @@ -29,7 +31,7 @@ namespace ATC { { const int npts = int(ref_coords_.size()); if (path.substr(path.size()-5,4) != ".dat") path += ".dat"; - fstream fid(path.c_str(), std::ios::out); + std::fstream fid(path.c_str(), std::ios::out); for (int i=0; i<npts; i++) { DENS_VEC x (current_config ? r(i):R(i)); @@ -44,7 +46,7 @@ namespace ATC { { const int npts = int(ref_coords_.size()); if (path.substr(path.size()-5,4) != ".vtk") path += ".vtk"; - fstream fid(path.c_str(), std::ios::out); + std::fstream fid(path.c_str(), std::ios::out); // write header fid << "# vtk DataFile Version 2.0\nWritten from FE-LAMMPS\n"; diff --git a/lib/atc/CBLattice.h b/lib/atc/CBLattice.h index eddb83515afea381421a827c7fd6f04787ef71e6..6082d80d6934813ef3845dff7237c4f949d1161a 100644 --- a/lib/atc/CBLattice.h +++ b/lib/atc/CBLattice.h @@ -7,7 +7,6 @@ #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" -using std::vector; namespace ATC { class CbPotential; // forward definition for potentials. diff --git a/lib/atc/CbEam.h b/lib/atc/CbEam.h index 2cf83ef0d754f5fcacaa6741cfd660071bd076d3..542aec9fa07d59386ad06290ddf93400dfda03ce 100644 --- a/lib/atc/CbEam.h +++ b/lib/atc/CbEam.h @@ -5,14 +5,14 @@ #include <cstdlib> #include "CbPotential.h" #include "LammpsInterface.h" -#include "pair_eam.h" - -//#define MIN(a,b) ((a) < (b) ? (a) : (b)) -//#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#include "MANYBODY/pair_eam.h" namespace ATC { + // forward declares + class LAMMPS_NS::PairEAM; + /** * @class CbEam * @brief Class for computing Cauchy-Born quantities for an Embeded-Atom Method material diff --git a/lib/atc/ChargeRegulator.cpp b/lib/atc/ChargeRegulator.cpp index dacafebc5028d99c89212166e41a7ed3e29406ec..c2f54b27b8cc1ac91c4f01f00c065b498a13cbbb 100644 --- a/lib/atc/ChargeRegulator.cpp +++ b/lib/atc/ChargeRegulator.cpp @@ -7,6 +7,19 @@ #include "Function.h" #include "PrescribedDataManager.h" +#include <sstream> +#include <string> +#include <vector> +#include <utility> +#include <set> + +using ATC_Utility::to_string; +using std::stringstream; +using std::map; +using std::vector; +using std::set; +using std::pair; +using std::string; namespace ATC { @@ -269,6 +282,23 @@ namespace ATC { initialized_ = true; } //-------------------------------------------------------- + // Initialize + //-------------------------------------------------------- + void ChargeRegulatorMethodFeedback::construct_transfers(void) + { + ChargeRegulatorMethod::construct_transfers(); + + InterscaleManager & interscaleManager((atomicRegulator_->atc_transfer())->interscale_manager()); + PerAtomSparseMatrix<double> * atomShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost"); + if (!atomShapeFunctions) { + atomShapeFunctions = new PerAtomShapeFunction(atomicRegulator_->atc_transfer(), + interscaleManager.per_atom_quantity("AtomicGhostCoarseGrainingPositions"), + interscaleManager.per_atom_int_quantity("AtomGhostElement"), + GHOST); + interscaleManager.add_per_atom_sparse_matrix(atomShapeFunctions,"InterpolantGhost"); + } + } + //-------------------------------------------------------- // find measurement atoms and nodes //-------------------------------------------------------- void ChargeRegulatorMethodFeedback::set_influence(void) diff --git a/lib/atc/ChargeRegulator.h b/lib/atc/ChargeRegulator.h index 515ffd450c249c8b07e1de57eebed14f7ca6158c..046a9f5157341cfa7d0a6f6932a650c84acbf68a 100644 --- a/lib/atc/ChargeRegulator.h +++ b/lib/atc/ChargeRegulator.h @@ -1,14 +1,12 @@ #ifndef CHARGE_REGULATOR_H #define CHARGE_REGULATOR_H -// ATC headers #include "AtomicRegulator.h" - -//class PoissonSolver; #include "PoissonSolver.h" - -// other headers #include <map> +#include <utility> +#include <string> +#include <vector> namespace ATC { @@ -47,7 +45,7 @@ namespace ATC { ChargeRegulatorType method; double value; int groupBit; - string groupTag; + std::string groupTag; double depth; double permittivity; ChargedSurfaceType surfaceType; @@ -79,8 +77,8 @@ namespace ATC { /** registry charge regulators */ - map<string,ChargeRegulatorMethod *> regulators_; - map<string,ChargeRegulatorParameters> parameters_; + std::map<std::string,ChargeRegulatorMethod *> regulators_; + std::map<std::string,ChargeRegulatorParameters> parameters_; private: ChargeRegulator(); // DO NOT define this @@ -116,7 +114,7 @@ namespace ATC { /** poisson solver */ PoissonSolver * poissonSolver_; /** (subset) of Green's functions */ - vector<SparseVector<double> > greensFunctions_; + std::vector<SparseVector<double> > greensFunctions_; /** cutoff radius */ double rC_,rCsq_; /** conversion constants */ @@ -159,6 +157,9 @@ namespace ATC { /** destructor */ ~ChargeRegulatorMethodFeedback(){}; + /** instantiate all needed data */ + virtual void construct_transfers(); + /** initialize */ virtual void initialize(void); @@ -242,7 +243,7 @@ namespace ATC { class ChargeRegulatorMethodEffectiveCharge : public ChargeRegulatorMethod { - typedef map<int,pair<DENS_VEC,double> > NODE_TO_XF_MAP; + typedef std::map<int,std::pair<DENS_VEC,double> > NODE_TO_XF_MAP; public: @@ -265,7 +266,7 @@ namespace ATC { // member data double chargeDensity_; - map<int,double> nodalChargePotential_; + std::map<int,double> nodalChargePotential_; NODE_TO_XF_MAP nodeXFMap_; diff --git a/lib/atc/CloneVector.h b/lib/atc/CloneVector.h index 5f747012fd59978c277df963abfa838cf94c00ab..0c3bef8c5931840f67cb80e29404137ab9bb91c8 100644 --- a/lib/atc/CloneVector.h +++ b/lib/atc/CloneVector.h @@ -2,6 +2,7 @@ #define CLONEVECTOR_H #include "Vector.h" +#include <algorithm> namespace ATC_matrix { @@ -121,11 +122,10 @@ T& CloneVector<T>::operator[](INDEX i) template<typename T> INDEX CloneVector<T>::nRows() const { - using std::min; if (_baseV) return _baseV->size(); if (_clone_type == CLONE_ROW) return _baseM->nCols(); if (_clone_type == CLONE_COL) return _baseM->nRows(); - if (_clone_type == CLONE_DIAG) return min(_baseM->nRows(), _baseM->nCols()); + if (_clone_type == CLONE_DIAG) return std::min(_baseM->nRows(), _baseM->nCols()); return 0; } //----------------------------------------------------------------------------- diff --git a/lib/atc/ConcentrationRegulator.cpp b/lib/atc/ConcentrationRegulator.cpp index 47f80cf92f0bf30ec7647e1886d909e706d6c8bd..86b5763fb44947b80a2d0506f8cf7a385fe5d0ba 100644 --- a/lib/atc/ConcentrationRegulator.cpp +++ b/lib/atc/ConcentrationRegulator.cpp @@ -3,6 +3,14 @@ #include "ATC_Coupling.h" #include "ATC_Error.h" +using ATC_Utility::to_string; +using ATC_Utility::rnd; +using std::map; +using std::string; +using std::pair; +using std::min; +using std::max; + namespace ATC { const double kMinScale_ = 10000.; diff --git a/lib/atc/ConcentrationRegulator.h b/lib/atc/ConcentrationRegulator.h index 147f85496a59fda422e2e106e24e8e762d5e93d4..f5acf46fb41cb294dd7d8e4ad23d9341e5f6b852 100644 --- a/lib/atc/ConcentrationRegulator.h +++ b/lib/atc/ConcentrationRegulator.h @@ -1,11 +1,12 @@ #ifndef CONCENTRATION_REGULATOR_H #define CONCENTRATION_REGULATOR_H -// ATC headers +#include <map> +#include <string> + #include "AtomicRegulator.h" #include "LammpsInterface.h" - namespace ATC { /** @@ -41,7 +42,7 @@ namespace ATC { double maxEnergy; int maxExchanges; int maxAttempts; - string transitionTag; + std::string transitionTag; ESET elemset; }; @@ -87,8 +88,8 @@ namespace ATC { protected: /** registry charge regulators */ - map<string,ConcentrationRegulatorMethod *> regulators_; - map<string,ConcentrationRegulatorParameters> parameters_; + std::map<std::string,ConcentrationRegulatorMethod *> regulators_; + std::map<std::string,ConcentrationRegulatorParameters> parameters_; private: ConcentrationRegulator(); // DO NOT define this diff --git a/lib/atc/DenseMatrix.h b/lib/atc/DenseMatrix.h index bbd6e04b5fc4e353788dd5b12441a1441091621c..39e2670814f17bff2b624341fd3bd4247a0c8233 100644 --- a/lib/atc/DenseMatrix.h +++ b/lib/atc/DenseMatrix.h @@ -44,7 +44,7 @@ public: INDEX nCols() const { return _nCols; } T * ptr() const { return _data; } void write_restart(FILE *f) const; - void from_file(string & name); + void from_file(std::string & name); void set_all_elements_to(const T &v); DiagonalMatrix<T> diag() const; @@ -156,7 +156,7 @@ DenseMatrix<T> DenseMatrix<T>::mult_by_element(const DenseMatrix<T>& B) const C(i,j) = (*this)(i,j)*B(i,j); } else if (B.nCols() == 1) { - cout << "MULTIPLYING\n"; + std::cout << "MULTIPLYING\n"; int szi = this->nRows(); int szj = this->nCols(); for (INDEX i = 0; i < szi; i++) @@ -210,7 +210,7 @@ void DenseMatrix<T>::write_restart(FILE *f) const // reads matrix from text file (matrix needs to be sized) //---------------------------------------------------------------------------- template <typename T> -void DenseMatrix<T>::from_file(string & name) +void DenseMatrix<T>::from_file(std::string & name) { GCHK(_nRows == 0,"from_file needs nRows > 0"); GCHK(_nCols == 0,"from_file needs nCols > 0"); @@ -328,7 +328,7 @@ DenseMatrix<T>& DenseMatrix<T>::operator=(const SparseMatrix<T> &c) for (INDEX i=0; i<c.size(); i++) { TRIPLET<T> x = c.triplet(i); - cout << "x.i: "<< x.i << "\nx.j: "<< x.j << "\nv.j: "<< x.v << std::endl << std::endl; + std::cout << "x.i: "<< x.i << "\nx.j: "<< x.j << "\nv.j: "<< x.v << std::endl << std::endl; (*this)(x.i, x.j) = x.v; } return *this; diff --git a/lib/atc/DependencyManager.h b/lib/atc/DependencyManager.h index 9cadf829b19402c99b56979ca9d94019a59359cf..13e33b55fb5563f5c1dbc87d29699aeeba425c49 100644 --- a/lib/atc/DependencyManager.h +++ b/lib/atc/DependencyManager.h @@ -8,8 +8,6 @@ #include "ATC_Error.h" #include "MPI_Wrappers.h" -using namespace MPI_Wrappers; - namespace ATC { class InterscaleManager; @@ -54,7 +52,7 @@ namespace ATC { void propagate_reset() { if (!isFixed_) { - set<DependencyManager *>::iterator it; + std::set<DependencyManager *>::iterator it; for (it = dependentQuantities_.begin(); it != dependentQuantities_.end(); it++) (*it)->force_reset(); } @@ -95,7 +93,7 @@ namespace ATC { protected: /** list of dependent atomic quantities */ - set<DependencyManager * > dependentQuantities_; + std::set<DependencyManager * > dependentQuantities_; /** flag for needing a recent */ // mutable is applied because there can be internal updates because we update when needed rather than when pushed @@ -187,7 +185,7 @@ namespace ATC { virtual void operator/=(const MatrixDependencyManager<T,U> & divisor) {get_quantity()/=divisor.quantity(); propagate_reset();}; /** execute the matrix print command */ - virtual void const print(const string &name) {get_quantity().print(name);}; + virtual void const print(const std::string &name) {get_quantity().print(name);}; protected: @@ -274,10 +272,10 @@ namespace ATC { virtual ~SetDependencyManager() {}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ - virtual set<T> & set_quantity() {propagate_reset(); return quantity_;}; + virtual std::set<T> & set_quantity() {propagate_reset(); return quantity_;}; /** access to a constant dense matrix of the quantity, indexed by AtC atom counts */ - virtual const set<T> & quantity() const {return quantity_;}; + virtual const std::set<T> & quantity() const {return quantity_;}; /** size of the set */ virtual int size() const {return (this->quantity()).size();}; @@ -286,7 +284,7 @@ namespace ATC { /** underlying set */ // mutable is applied because there can be internal updates because we update when needed rather than when pushed - mutable set<T> quantity_; + mutable std::set<T> quantity_; }; @@ -307,10 +305,10 @@ namespace ATC { virtual ~VectorDependencyManager() {}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ - virtual vector<T> & set_quantity() {propagate_reset(); return quantity_;}; + virtual std::vector<T> & set_quantity() {propagate_reset(); return quantity_;}; /** access to a constant dense matrix of the quantity, indexed by AtC atom counts */ - virtual const vector<T> & quantity() const {return quantity_;}; + virtual const std::vector<T> & quantity() const {return quantity_;}; /** size of the set */ virtual int size() const {return (this->quantity()).size();}; @@ -319,7 +317,7 @@ namespace ATC { /** underlying set */ // mutable is applied because there can be internal updates because we update when needed rather than when pushed - mutable vector<T> quantity_; + mutable std::vector<T> quantity_; }; diff --git a/lib/atc/DiagonalMatrix.h b/lib/atc/DiagonalMatrix.h index 90c4bf1934a9fbe3b7fa2ddc3e04554180957d3e..662941bac06b69ad205e806f8a9db65b9ce371eb 100644 --- a/lib/atc/DiagonalMatrix.h +++ b/lib/atc/DiagonalMatrix.h @@ -47,10 +47,10 @@ class DiagonalMatrix : public Matrix<T> void write_restart(FILE *f) const; // Dump matrix contents to screen (not defined for all datatypes) - string to_string() const { return _data->to_string(); } + std::string to_string() const { return _data->to_string(); } using Matrix<T>::matlab; - void matlab(ostream &o, const string &s="D") const; + void matlab(std::ostream &o, const std::string &s="D") const; // overloaded operators DiagonalMatrix<T>& operator=(const T s); @@ -399,7 +399,7 @@ DiagonalMatrix<T>& DiagonalMatrix<T>::operator=(const DiagonalMatrix<T>& C) // writes a matlab command to duplicate this sparse matrix //----------------------------------------------------------------------------- template<typename T> -void DiagonalMatrix<T>::matlab(ostream &o, const string &s) const +void DiagonalMatrix<T>::matlab(std::ostream &o, const std::string &s) const { _data->matlab(o, s); o << s <<"=diag("<<s<<",0);\n"; @@ -415,7 +415,7 @@ DiagonalMatrix<T>& DiagonalMatrix<T>::inv_this() if ((*this)[i]!=T(0)) (*this)[i] = 1.0/(*this)[i]; else { - cout<<"DiagonalMatrix::inv(): ("<<i<<","<<i<<")=0\n"; + std::cout<<"DiagonalMatrix::inv(): ("<<i<<","<<i<<")=0\n"; ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } @@ -423,8 +423,8 @@ DiagonalMatrix<T>& DiagonalMatrix<T>::inv_this() // Error check info const double min_max = _data->minabs() / _data->maxabs(); if (min_max > 1e-14) return *this; - cout << "DiagonalMatrix::inv_this(): Warning: Matrix is badly scaled."; - cout << " RCOND = "<<min_max<<"\n"; + std::cout << "DiagonalMatrix::inv_this(): Warning: Matrix is badly scaled."; + std::cout << " RCOND = "<<min_max<<"\n"; return *this; } //----------------------------------------------------------------------------- @@ -440,7 +440,7 @@ DiagonalMatrix<T> DiagonalMatrix<T>::inv() const if ((*this)[i]!=T(0)) invA[i]=1.0/(*this)[i]; else { - cout<<"DiagonalMatrix::inv(): ("<<i<<","<<i<<")=0\n"; + std::cout<<"DiagonalMatrix::inv(): ("<<i<<","<<i<<")=0\n"; ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } @@ -448,8 +448,8 @@ DiagonalMatrix<T> DiagonalMatrix<T>::inv() const // Error check info const double min_max = _data->minabs() / _data->maxabs(); if (min_max > 1e-14) return invA; - cout << "DiagonalMatrix::inv(): Warning: Matrix is badly scaled."; - cout << " RCOND = "<<min_max<<"\n"; + std::cout << "DiagonalMatrix::inv(): Warning: Matrix is badly scaled."; + std::cout << " RCOND = "<<min_max<<"\n"; return invA; } //----------------------------------------------------------------------------- @@ -477,7 +477,7 @@ void DiagonalMatrix<T>::_set_equal(const Matrix<T> &r) else if (pv) this->reset(*pv); else { - cout <<"Error in general sparse matrix assignment\n"; + std::cout <<"Error in general sparse matrix assignment\n"; exit(1); } } diff --git a/lib/atc/ElasticTimeIntegrator.cpp b/lib/atc/ElasticTimeIntegrator.cpp index 7748bff908c4a32fc98f3c91bc0e72d6af1befc9..b8058192efec719872b7335064ee46e09c69cda6 100644 --- a/lib/atc/ElasticTimeIntegrator.cpp +++ b/lib/atc/ElasticTimeIntegrator.cpp @@ -32,26 +32,24 @@ namespace ATC { bool foundMatch = false; int argIndex = 0; // time integration scheme - /*! \page man_time_integration fix_modify AtC time_integration + /*! \page man_momentum_time_integration fix_modify AtC time_integration (momentum) \section syntax fix_modify AtC time_integration <descriptor> \n - descriptor (string) = time integration type \n various time integration methods for the finite elements\n \section description - Verlet - atomic velocity update with 2nd order Verlet \n - nodal temperature update with 2nd order Verlet \n - kinetostats based on controlling force \n - FRACTIONAL_STEP - atomic velocity update with 2nd order Verlet \n - mixed nodal momentum update, 2nd order Verlet for continuum and exact 2nd order Verlet for atomic contributions\n - kinetostats based on controlling discrete momentum changes\n + verlet - atomic velocity update with 2nd order Verlet, nodal temperature update with 2nd order Verlet, kinetostats based on controlling force \n + fractional_step - atomic velocity update with 2nd order Verlet, mixed nodal momentum update, 2nd order Verlet for continuum and exact 2nd order Verlet for atomic contributions, kinetostats based on controlling discrete momentum changes\n + gear - atomic velocity update with 2nd order Verlet, nodal temperature update with 3rd or 4th order Gear, kinetostats based on controlling power \n \section examples <TT> fix_modify atc time_integration verlet </TT> \n <TT> fix_modify atc time_integration fractional_step </TT> \n \section description \section related + see \ref man_fix_atc \section default - Gear + none */ if (strcmp(arg[argIndex],"verlet")==0) { timeIntegrationType_ = VERLET; diff --git a/lib/atc/ElasticTimeIntegrator.h b/lib/atc/ElasticTimeIntegrator.h index 284d5d65feee57b7a2b440c84c38554def5a7428..f6d270f5fa19bc3f2e9852d56a3d1fb2df013b10 100644 --- a/lib/atc/ElasticTimeIntegrator.h +++ b/lib/atc/ElasticTimeIntegrator.h @@ -3,10 +3,8 @@ /** MomentumTimeIntegrator : a class to implement various elasticity integrators for FE quantities */ -// ATC headers #include "TimeIntegrator.h" -using namespace std; namespace ATC { // forward declarations diff --git a/lib/atc/ElectronChargeDensity.cpp b/lib/atc/ElectronChargeDensity.cpp index 7090d1e078f8ecbc53e1a7cf0da6d0d691a69436..69127a9335ce6e4c43a52677510d4922e3507328 100644 --- a/lib/atc/ElectronChargeDensity.cpp +++ b/lib/atc/ElectronChargeDensity.cpp @@ -2,11 +2,15 @@ #include "ATC_Error.h" #include <iostream> -#include <fstream> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; using ATC_Utility::str2int; +using std::fstream; +using std::map; +using std::string; +using std::vector; namespace ATC { ElectronChargeDensityInterpolation::ElectronChargeDensityInterpolation( diff --git a/lib/atc/ElectronChargeDensity.h b/lib/atc/ElectronChargeDensity.h index dd95e621cdf51c51eb5e85b8470f86476e7a4496..a5288c0b19086ec0f630e0a9093eb9456f63ec05 100644 --- a/lib/atc/ElectronChargeDensity.h +++ b/lib/atc/ElectronChargeDensity.h @@ -3,10 +3,7 @@ #include <map> #include <string> - -using std::map; -using std::string; - +#include <fstream> #include "ATC_TypeDefs.h" #include "Function.h" @@ -46,7 +43,7 @@ namespace ATC { class ElectronChargeDensityInterpolation : public ElectronChargeDensity { public: - ElectronChargeDensityInterpolation(fstream &matfile,map<string,double> & parameters); + ElectronChargeDensityInterpolation(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronChargeDensityInterpolation() {}; virtual bool electron_charge_density(const FIELD_MATS &fields, DENS_MAT &flux) const @@ -87,7 +84,7 @@ namespace ATC { class ElectronChargeDensityLinear : public ElectronChargeDensity { public: - ElectronChargeDensityLinear(fstream &matfile,map<string,double> & parameters); + ElectronChargeDensityLinear(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronChargeDensityLinear() {}; virtual bool electron_charge_density(const FIELD_MATS &fields, DENS_MAT &flux) const @@ -119,7 +116,7 @@ namespace ATC { class ElectronChargeDensityExponential : public ElectronChargeDensity { public: - ElectronChargeDensityExponential(fstream &matfile,map<string,double> & parameters); + ElectronChargeDensityExponential(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronChargeDensityExponential() {}; double n(const double phi, double T) const @@ -190,7 +187,7 @@ namespace ATC { class ElectronChargeDensityFermiDirac : public ElectronChargeDensity { public: - ElectronChargeDensityFermiDirac(fstream &matfile,map<string,double> & parameters); + ElectronChargeDensityFermiDirac(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronChargeDensityFermiDirac() {}; double fermi_dirac(const double E, const double T) const { diff --git a/lib/atc/ElectronDragPower.cpp b/lib/atc/ElectronDragPower.cpp index 8763aa45714ea0ee1fb9ef5880bc41fd0718f1e3..b6bb4522484d27c1cd4718a34554202cc411ab59 100644 --- a/lib/atc/ElectronDragPower.cpp +++ b/lib/atc/ElectronDragPower.cpp @@ -3,10 +3,14 @@ #include "ATC_Error.h" #include <iostream> -#include <fstream> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; +using std::map; +using std::string; +using std::fstream; +using std::vector; namespace ATC { diff --git a/lib/atc/ElectronDragPower.h b/lib/atc/ElectronDragPower.h index 3c19c7da4845eb78e92ed0739b03a1c5ebff72db..92103fe3e8993faf980bdbb826a6d4bcce8b6cd3 100644 --- a/lib/atc/ElectronDragPower.h +++ b/lib/atc/ElectronDragPower.h @@ -3,9 +3,7 @@ #include <map> #include <string> - -using std::map; -using std::string; +#include <fstream> #include "Material.h" #include "ATC_TypeDefs.h" @@ -46,8 +44,8 @@ namespace ATC { class ElectronDragPowerLinear : public ElectronDragPower { public: - ElectronDragPowerLinear(fstream &matfile, - map<string,double> & parameters, + ElectronDragPowerLinear(std::fstream &matfile, + std::map<std::string,double> & parameters, Material * material_); virtual ~ElectronDragPowerLinear() {}; virtual bool electron_drag_power(const FIELD_MATS &fields, diff --git a/lib/atc/ElectronFlux.cpp b/lib/atc/ElectronFlux.cpp index 06dae4c727d7475b485e17ab5b2f4b30958e19dc..8ae8503a311b53ab28b08f0580f40ecc24ae4e75 100644 --- a/lib/atc/ElectronFlux.cpp +++ b/lib/atc/ElectronFlux.cpp @@ -3,9 +3,16 @@ #include <iostream> #include <fstream> +#include <map> +#include <string> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; +using std::fstream; +using std::map; +using std::string; +using std::vector; namespace ATC { diff --git a/lib/atc/ElectronFlux.h b/lib/atc/ElectronFlux.h index 47595b7755a9053f9b39cd0a526f6df12c2f026e..c40ea475bccd98287058466737c68c8260ffc3a6 100644 --- a/lib/atc/ElectronFlux.h +++ b/lib/atc/ElectronFlux.h @@ -3,10 +3,6 @@ #include <map> #include <string> - -using std::map; -using std::string; - #include "ATC_TypeDefs.h" namespace ATC { @@ -88,7 +84,7 @@ namespace ATC { class ElectronFluxLinear : public ElectronFlux { public: - ElectronFluxLinear(fstream &matfile, map<string,double> & parameters); + ElectronFluxLinear(std::fstream &matfile, std::map<std::string,double> & parameters); virtual ~ElectronFluxLinear() {}; virtual void electron_flux(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, @@ -148,7 +144,7 @@ namespace ATC { class ElectronFluxThermopower : public ElectronFlux { public: - ElectronFluxThermopower(fstream &matfile,map<string,double> & parameters); + ElectronFluxThermopower(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronFluxThermopower() {}; virtual void electron_flux(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, @@ -211,7 +207,7 @@ namespace ATC { class ElectronFluxConvection : public ElectronFlux { public: - ElectronFluxConvection(fstream &matfile,map<string,double> & parameters); + ElectronFluxConvection(std::fstream &matfile,std::map<std::string,double> & parameters); virtual ~ElectronFluxConvection() {}; virtual void electron_flux(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, diff --git a/lib/atc/ElectronHeatCapacity.cpp b/lib/atc/ElectronHeatCapacity.cpp index b4b731ac37217bbef8855a185b96f8cd520817a2..aafaa3c37d575b286203991d3f833e8087f57110 100644 --- a/lib/atc/ElectronHeatCapacity.cpp +++ b/lib/atc/ElectronHeatCapacity.cpp @@ -3,9 +3,14 @@ #include <iostream> #include <fstream> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; +using std::fstream; +using std::map; +using std::string; +using std::vector; namespace ATC { diff --git a/lib/atc/ElectronHeatCapacity.h b/lib/atc/ElectronHeatCapacity.h index 9285f8c4fd450b57dbb00ca9213f4933abf34062..aefc3d681ce746a7f4282f198b6f752e3230ad3d 100644 --- a/lib/atc/ElectronHeatCapacity.h +++ b/lib/atc/ElectronHeatCapacity.h @@ -3,10 +3,6 @@ #include <map> #include <string> - -using std::map; -using std::string; - #include "ATC_TypeDefs.h" #include "Material.h" @@ -43,8 +39,8 @@ namespace ATC { class ElectronHeatCapacityConstant : public ElectronHeatCapacity { public: - ElectronHeatCapacityConstant(fstream &matfile, - map<string,double> & parameters); + ElectronHeatCapacityConstant(std::fstream &matfile, + std::map<std::string,double> & parameters); virtual ~ElectronHeatCapacityConstant() {}; virtual void electron_heat_capacity(const FIELD_MATS &fields, DENS_MAT &capacity) @@ -85,8 +81,8 @@ namespace ATC { class ElectronHeatCapacityLinear : public ElectronHeatCapacity { public: - ElectronHeatCapacityLinear(fstream &matfile, - map<string,double> & parameters); + ElectronHeatCapacityLinear(std::fstream &matfile, + std::map<std::string,double> & parameters); virtual ~ElectronHeatCapacityLinear() {}; virtual void electron_heat_capacity(const FIELD_MATS &fields, DENS_MAT &capacity) @@ -126,8 +122,8 @@ namespace ATC { class ElectronHeatCapacityConstantAddDensity : public ElectronHeatCapacityConstant { public: - ElectronHeatCapacityConstantAddDensity(fstream &matfile, - map<string,double> & parameters, + ElectronHeatCapacityConstantAddDensity(std::fstream &matfile, + std::map<std::string,double> & parameters, Material * material); virtual ~ElectronHeatCapacityConstantAddDensity() {}; virtual void electron_heat_capacity(const FIELD_MATS &fields, @@ -178,8 +174,8 @@ namespace ATC { class ElectronHeatCapacityLinearAddDensity : public ElectronHeatCapacityLinear { public: - ElectronHeatCapacityLinearAddDensity(fstream &matfile, - map<string,double> & parameters, + ElectronHeatCapacityLinearAddDensity(std::fstream &matfile, + std::map<std::string,double> & parameters, Material * material); virtual ~ElectronHeatCapacityLinearAddDensity() {}; virtual void electron_heat_capacity(const FIELD_MATS &fields, diff --git a/lib/atc/ElectronHeatFlux.cpp b/lib/atc/ElectronHeatFlux.cpp index fae193e3a83812df0239146ef163d0c4842768b1..fbe3d0d51246f98ac5b8de46b468ccb43ad5d1a1 100644 --- a/lib/atc/ElectronHeatFlux.cpp +++ b/lib/atc/ElectronHeatFlux.cpp @@ -3,9 +3,14 @@ #include <iostream> #include <fstream> +#include <vector> using ATC_Utility::command_line; using ATC_Utility::str2dbl; +using std::fstream; +using std::map; +using std::string; +using std::vector; namespace ATC { diff --git a/lib/atc/ElectronHeatFlux.h b/lib/atc/ElectronHeatFlux.h index deb26d31832d273181079c48011db1cc5fd897ac..12a68fed7090be6c976a1008bda0cde97ddc96d7 100644 --- a/lib/atc/ElectronHeatFlux.h +++ b/lib/atc/ElectronHeatFlux.h @@ -3,10 +3,6 @@ #include <map> #include <string> - -using std::map; -using std::string; - #include "ATC_TypeDefs.h" #include "ElectronFlux.h" #include "ElectronHeatCapacity.h" @@ -71,7 +67,7 @@ namespace ATC { class ElectronHeatFluxLinear : public ElectronHeatFlux { public: - ElectronHeatFluxLinear(fstream &matfile,map<string,double> & parameters, + ElectronHeatFluxLinear(std::fstream &matfile,std::map<std::string,double> & parameters, /*const*/ ElectronHeatCapacity * electronHeatCapacity = NULL); virtual ~ElectronHeatFluxLinear() {}; virtual void electron_heat_flux(const FIELD_MATS &fields, @@ -98,7 +94,7 @@ namespace ATC { class ElectronHeatFluxPowerLaw : public ElectronHeatFlux { public: - ElectronHeatFluxPowerLaw(fstream &matfile,map<string,double> ¶meters, + ElectronHeatFluxPowerLaw(std::fstream &matfile,std::map<std::string,double> ¶meters, /*const*/ ElectronHeatCapacity * electronHeatCapacity = NULL); virtual ~ElectronHeatFluxPowerLaw() {}; virtual void electron_heat_flux(const FIELD_MATS &fields, @@ -136,8 +132,8 @@ ctivity proportional to the ratio of the electron and phonon temperatures with t class ElectronHeatFluxThermopower : public ElectronHeatFlux { public: - ElectronHeatFluxThermopower(fstream &matfile, - map<string,double> & parameters, + ElectronHeatFluxThermopower(std::fstream &matfile, + std::map<std::string,double> & parameters, /*const*/ ElectronFlux * electronFlux = NULL, /*const*/ ElectronHeatCapacity * electronHeatCapacity = NULL); virtual ~ElectronHeatFluxThermopower() {}; diff --git a/lib/atc/ElectronPhononExchange.cpp b/lib/atc/ElectronPhononExchange.cpp index c040cdd3efac8761ee0359b78e676d1a4cad52da..2ed25fc557dd8494a9556a4fe86fa199fbc34d41 100644 --- a/lib/atc/ElectronPhononExchange.cpp +++ b/lib/atc/ElectronPhononExchange.cpp @@ -4,12 +4,16 @@ #include "LammpsInterface.h" #include <iostream> -#include <fstream> +#include <vector> #include <math.h> using ATC_Utility::command_line; using ATC_Utility::str2dbl; using ATC_Utility::str2int; +using std::fstream; +using std::map; +using std::string; +using std::vector; namespace ATC { diff --git a/lib/atc/ElectronPhononExchange.h b/lib/atc/ElectronPhononExchange.h index 1507495b9a839fb490cda5740da5a93f496196ee..59cc61b4d278366f8eea702a85757e04c8d89ad9 100644 --- a/lib/atc/ElectronPhononExchange.h +++ b/lib/atc/ElectronPhononExchange.h @@ -3,10 +3,7 @@ #include <map> #include <string> - -using std::map; -using std::string; - +#include <fstream> #include "ATC_TypeDefs.h" namespace ATC { @@ -37,8 +34,8 @@ namespace ATC { class ElectronPhononExchangeLinear : public ElectronPhononExchange { public: - ElectronPhononExchangeLinear(fstream &matfile, - map<string,double> & parameters); + ElectronPhononExchangeLinear(std::fstream &matfile, + std::map<std::string,double> & parameters); virtual ~ElectronPhononExchangeLinear() {}; virtual bool electron_phonon_exchange(const FIELD_MATS &fields, DENS_MAT &flux) @@ -66,8 +63,8 @@ namespace ATC { class ElectronPhononExchangePowerLaw : public ElectronPhononExchange { public: - ElectronPhononExchangePowerLaw(fstream &matfile, - map<string,double> & parameters); + ElectronPhononExchangePowerLaw(std::fstream &matfile, + std::map<std::string,double> & parameters); virtual ~ElectronPhononExchangePowerLaw() {}; virtual bool electron_phonon_exchange(const FIELD_MATS &fields, DENS_MAT &flux) @@ -96,8 +93,8 @@ namespace ATC { class ElectronPhononExchangeHertel : public ElectronPhononExchange { public: - ElectronPhononExchangeHertel(fstream &matfile, - map<string,double> & parameters, + ElectronPhononExchangeHertel(std::fstream &matfile, + std::map<std::string,double> & parameters, Material * material); virtual ~ElectronPhononExchangeHertel() {}; virtual bool electron_phonon_exchange(const FIELD_MATS &fields, diff --git a/lib/atc/ExtrinsicModel.cpp b/lib/atc/ExtrinsicModel.cpp index 3f9091c81418a1c709ebc7e69cd975c60557c819..0522f068193f6a7f198e331896c0d931019fce48 100644 --- a/lib/atc/ExtrinsicModel.cpp +++ b/lib/atc/ExtrinsicModel.cpp @@ -9,6 +9,12 @@ #include "LammpsInterface.h" #include "PrescribedDataManager.h" #include "PhysicsModel.h" +#include <sstream> + +using std::stringstream; +using std::vector; +using std::map; +using std::string; namespace ATC { diff --git a/lib/atc/ExtrinsicModel.h b/lib/atc/ExtrinsicModel.h index 468c3e115bd10a2d71905bcda147723c31634910..4d8fb95fd782485685476777790d5ff52e6e7de7 100644 --- a/lib/atc/ExtrinsicModel.h +++ b/lib/atc/ExtrinsicModel.h @@ -1,14 +1,14 @@ #ifndef EXTRINSIC_MODEL #define EXTRINSIC_MODEL -// ATC headers +#include <vector> +#include <map> +#include <string> + #include "ATC_TypeDefs.h" #include "MatrixLibrary.h" -using namespace std; namespace ATC { - - // forward declarations class ATC_Coupling; class ExtrinsicModel; class PhysicsModel; @@ -55,7 +55,7 @@ namespace ATC { bool modify(int narg, char **arg); /** create_model */ - void create_model(ExtrinsicModelType modelType, string matFileName); + void create_model(ExtrinsicModelType modelType, std::string matFileName); /** construct the transfers needed by the model */ void construct_transfers(); @@ -99,7 +99,7 @@ namespace ATC { /** model name enum to string */ - static bool model_to_string(const ExtrinsicModelType index, string & name) + static bool model_to_string(const ExtrinsicModelType index, std::string & name) { switch (index) { case NO_MODEL: @@ -146,7 +146,7 @@ namespace ATC { }; /** string to model enum */ - static bool string_to_model(const string & name, ExtrinsicModelType & index) + static bool string_to_model(const std::string & name, ExtrinsicModelType & index) { if (name=="no_model") index = NO_MODEL; @@ -191,7 +191,7 @@ namespace ATC { ATC_Coupling * atc_; /** equation handler */ - vector<ExtrinsicModel *> extrinsicModels_; + std::vector<ExtrinsicModel *> extrinsicModels_; private: ExtrinsicModelManager(); // DO NOT define this, only use constructor above @@ -216,7 +216,7 @@ namespace ATC { // constructor ExtrinsicModel(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModel(); @@ -269,7 +269,7 @@ namespace ATC { virtual void output(OUTPUT_LIST & outputData){}; /** get the fields and their sizes */ - void num_fields(map<FieldName,int> & fieldSizes); + void num_fields(std::map<FieldName,int> & fieldSizes); /** return the type of model being used */ ExtrinsicModelType model_type() const {return modelType_;}; diff --git a/lib/atc/ExtrinsicModelDriftDiffusion.cpp b/lib/atc/ExtrinsicModelDriftDiffusion.cpp index 5827a8a284e6f95bd1fad5d0a2e8139e97012c90..f98467703fbc76054c996089222ffcfbee995372 100644 --- a/lib/atc/ExtrinsicModelDriftDiffusion.cpp +++ b/lib/atc/ExtrinsicModelDriftDiffusion.cpp @@ -13,6 +13,14 @@ // timer #include "Utility.h" +#include <utility> + +using ATC_Utility::to_string; +using std::string; +using std::set; +using std::pair; +using std::vector; + const double tol = 1.e-8; const double zero_tol = 1.e-12; const double f_tol = 1.e-8; diff --git a/lib/atc/ExtrinsicModelDriftDiffusion.h b/lib/atc/ExtrinsicModelDriftDiffusion.h index 2761ae70d4d972f059fb326da2f8c02013fba418..92e2365dc1acefbefb901f9632a7cdbc23b0a019 100644 --- a/lib/atc/ExtrinsicModelDriftDiffusion.h +++ b/lib/atc/ExtrinsicModelDriftDiffusion.h @@ -1,16 +1,15 @@ #ifndef EXTRINSIC_MODEL_DRIFT_DIFFUSION #define EXTRINSIC_MODEL_DRIFT_DIFFUSION -/** owned fields: ELECTRON_DENSITY, ... */ +#include <set> +#include <string> +#include <vector> -// ATC headers #include "ExtrinsicModelTwoTemperature.h" #include "SchrodingerSolver.h" -using namespace std; namespace ATC { - // forward declarations class ATC_Coupling; class PrescribedDataManager; class ExtrinsicModel; @@ -23,6 +22,7 @@ namespace ATC { /** * @class ExtrinsicModelDriftDiffusion * @brief add electron temperature physics to phonon physics + * owned fields ELECTRON_DENSITY */ //-------------------------------------------------------- @@ -38,7 +38,7 @@ namespace ATC { // constructor ExtrinsicModelDriftDiffusion(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModelDriftDiffusion(); @@ -114,9 +114,9 @@ namespace ATC { bool oneD_; int oneDcoor_; int oneDstride_; - string oneDnodesetName_; - set<int> oneDnodeset_; - Array< set<int> > oneDslices_; + std::string oneDnodesetName_; + std::set<int> oneDnodeset_; + Array< std::set<int> > oneDslices_; int oneDconserve_; DENS_MAT JE_; @@ -141,7 +141,7 @@ namespace ATC { // constructor ExtrinsicModelDriftDiffusionConvection(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModelDriftDiffusionConvection(); @@ -170,7 +170,7 @@ namespace ATC { void compute_nodal_kinetic_energy(DENS_MAT & kineticEnergy); /** Linear solver for velocity */ - vector<LinearSolver * > velocitySolvers_; + std::vector<LinearSolver * > velocitySolvers_; /** Linear solver for solving the poisson equations */ diff --git a/lib/atc/ExtrinsicModelElectrostatic.cpp b/lib/atc/ExtrinsicModelElectrostatic.cpp index 515791227267bd13ed288521bd3236b9b96c9eb6..d07af21c0361d9c2805ae58e9ae88811c8e37953 100644 --- a/lib/atc/ExtrinsicModelElectrostatic.cpp +++ b/lib/atc/ExtrinsicModelElectrostatic.cpp @@ -11,6 +11,13 @@ #include "AtomToMoleculeTransfer.h" #include "MoleculeSet.h" #include "ChargeRegulator.h" +#include <set> + +using std::string; +using std::vector; +using std::map; +using std::pair; +using std::set; static const double kTol_ = 1.0e-8; static const double tol_sparse = 1.e-30;//tolerance for compaction from dense @@ -164,6 +171,15 @@ namespace ATC { // add charge density transfer operator if (atc_->track_charge()) { InterscaleManager & interscaleManager(atc_->interscale_manager()); + + // make sure we have gradients at atoms + VectorDependencyManager<SPAR_MAT * > * interpolantGradient = interscaleManager.vector_sparse_matrix("InterpolantGradient"); + if (!interpolantGradient) { + interpolantGradient = new PerAtomShapeFunctionGradient(atc_); + interscaleManager.add_vector_sparse_matrix(interpolantGradient, + "InterpolantGradient"); + } + FundamentalAtomQuantity * atomicCharge = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE); AtfShapeFunctionRestriction * nodalAtomicCharge = @@ -173,20 +189,6 @@ namespace ATC { new AtfShapeFunctionMdProjection(atc_,nodalAtomicCharge,MASS_DENSITY); interscaleManager.add_dense_matrix(nodalAtomicChargeDensity,"NodalAtomicChargeDensity"); - - // add species charge density transfer operators - const map<string,pair<IdType,int> > & speciesIds(atc_->species_ids()); - map<string,pair<IdType,int> >::const_iterator specid; - for (specid = speciesIds.begin(); specid != speciesIds.end(); specid++) { - const string specie = specid->first; - AtfShapeFunctionRestriction * nodalAtomicSpeciesCharge = - new AtfShapeFunctionRestriction(atc_,atomicCharge, - interscaleManager.sparse_matrix("Accumulant"+specie)); - interscaleManager.add_dense_matrix(nodalAtomicSpeciesCharge,"NodalAtomicSpeciesCharge"+specie); - AtfShapeFunctionMdProjection * nodalAtomicSpeciesChargeDensity = - new AtfShapeFunctionMdProjection(atc_,nodalAtomicSpeciesCharge,MASS_DENSITY); - interscaleManager.add_dense_matrix(nodalAtomicSpeciesChargeDensity,"NodalAtomicSpeciesChargeDensity"+specie); - } // get the total charge and dipole moment at the node per molecule // small molecules require per atom quantities with ghosts @@ -312,8 +314,18 @@ namespace ATC { nodalAtomicGhostCharge_ = interscaleManager.dense_matrix("NodalAtomicGhostCharge"); if (! nodalAtomicGhostCharge_) { FundamentalAtomQuantity * ghostCharge = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE, GHOST); + + PerAtomSparseMatrix<double> * ghostShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost"); + if (!ghostShapeFunctions) { + ghostShapeFunctions = new PerAtomShapeFunction(atc_, + interscaleManager.per_atom_quantity("AtomicGhostCoarseGrainingPositions"), + interscaleManager.per_atom_int_quantity("AtomGhostElement"), + GHOST); + interscaleManager.add_per_atom_sparse_matrix(ghostShapeFunctions,"InterpolantGhost"); + } + nodalAtomicGhostCharge_ = new AtfShapeFunctionRestriction(atc_,ghostCharge, - interscaleManager.per_atom_sparse_matrix("InterpolantGhost")); + ghostShapeFunctions); interscaleManager.add_dense_matrix(nodalAtomicGhostCharge_,"NodalAtomicGhostCharge"); } } @@ -446,14 +458,6 @@ namespace ATC { } } - const map<string,pair<IdType,int> > & speciesIds(atc_->species_ids()); - map<string,pair<IdType,int> >::const_iterator specie; - for (specie = speciesIds.begin(); specie != speciesIds.end(); specie++) { - DENS_MAN & nodalAtomicSpeciesChargeDensityOut(atc_->tagged_dens_man("NodalAtomicSpeciesChargeDensity"+specie->first)); - DENS_MAN * nodalAtomicSpeciesChargeDensity((atc_->interscale_manager()).dense_matrix("NodalAtomicSpeciesChargeDensity"+specie->first)); - nodalAtomicSpeciesChargeDensityOut = nodalAtomicSpeciesChargeDensity->quantity(); - } - const map<string,pair<MolSize,int> > & moleculeIds(atc_->molecule_ids()); map<string,pair<MolSize,int> >::const_iterator molecule; for (molecule = moleculeIds.begin(); molecule != moleculeIds.end(); molecule++) { @@ -540,10 +544,11 @@ namespace ATC { int nsd = atc_->nsd(); int nLocal = atc_->nlocal(); DENS_MAT E(nLocal,nsd); + const SPAR_MAT_VEC & shapeFucntionDerivatives(((atc_->interscale_manager()).vector_sparse_matrix("InterpolantGradient"))->quantity()); if (nLocal > 0) { for (int i=0; i < nsd; i++) { CLON_VEC Ei = column(E,i); - Ei = -1.*(*(((atc_->shpFcnDerivs_)->quantity())[i])*potential); + Ei = -1.*(*(shapeFucntionDerivatives[i])*potential); } } diff --git a/lib/atc/ExtrinsicModelElectrostatic.h b/lib/atc/ExtrinsicModelElectrostatic.h index b33cfed1845cd356f0d99eb4a00fd57c0f44dc57..c4a0af464d7b7f8d61a9a53e84ed01bc0b7256f6 100644 --- a/lib/atc/ExtrinsicModelElectrostatic.h +++ b/lib/atc/ExtrinsicModelElectrostatic.h @@ -1,13 +1,15 @@ #ifndef EXTRINSIC_MODEL_ELECTROSTATIC #define EXTRINSIC_MODEL_ELECTROSTATIC -/** owned fields: ELECTRIC_POTENTIAL */ +// WIP_REJ #define CHARGED_SURFACE -// ATC headers #include "ExtrinsicModel.h" +#include <utility> +#include <string> +#include <vector> +#include <map> -using namespace std; namespace ATC { // forward declarations @@ -23,6 +25,7 @@ namespace ATC { /** * @class ExtrinsicModelElectrostatic * @brief add self-consistent electrostatic forces + * owned field: ELECTRIC_POTENTIAL */ //-------------------------------------------------------- @@ -38,7 +41,7 @@ namespace ATC { // constructor ExtrinsicModelElectrostatic(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModelElectrostatic(); @@ -100,25 +103,25 @@ namespace ATC { void apply_charged_surfaces(MATRIX & nodalPotential); /** set charged surface data */ - void add_charged_surface(const string & facesetName, + void add_charged_surface(const std::string & facesetName, const double chargeDensity); #endif /** charge regulator */ ChargeRegulator * chargeRegulator_; /** local electric potential Green's function for each node */ - vector<SparseVector<double> > greensFunctions_; + std::vector<SparseVector<double> > greensFunctions_; #ifdef CHARGED_SURFACE /** stores surface charge data at fixed charge surfaces */ - map<string,double> surfaceCharges_; + std::map<std::string,double> surfaceCharges_; /** data structure to store information for applying charged surfaces */ - map<string,map<int,pair<DENS_VEC,double> > > chargedSurfaces_; + std::map<std::string,std::map<int,std::pair<DENS_VEC,double> > > chargedSurfaces_; #endif /** data structure storing potential induced only by charges under the nodal shape function support */ - map<string,map<int,double> > nodalChargePotential_; + std::map<std::string,std::map<int,double> > nodalChargePotential_; /** allows electric force only applied only in z direction to complement LAMMPS slab command */ @@ -161,7 +164,7 @@ namespace ATC { // constructor ExtrinsicModelElectrostaticMomentum(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModelElectrostaticMomentum(); diff --git a/lib/atc/ExtrinsicModelTwoTemperature.cpp b/lib/atc/ExtrinsicModelTwoTemperature.cpp index 864857ac246206a033680092b4342464e362d51a..ddacbf229407758e0de5e10212558e588a7c4755 100644 --- a/lib/atc/ExtrinsicModelTwoTemperature.cpp +++ b/lib/atc/ExtrinsicModelTwoTemperature.cpp @@ -7,6 +7,8 @@ #include "PrescribedDataManager.h" #include "PhysicsModel.h" +using std::string; + namespace ATC { //-------------------------------------------------------- diff --git a/lib/atc/ExtrinsicModelTwoTemperature.h b/lib/atc/ExtrinsicModelTwoTemperature.h index dd3a0af27549f32357972888a5d84a0db2029d09..4c3038bba18b3ecd0e421001860a2da588aede85 100644 --- a/lib/atc/ExtrinsicModelTwoTemperature.h +++ b/lib/atc/ExtrinsicModelTwoTemperature.h @@ -1,16 +1,12 @@ #ifndef EXTRINSIC_MODEL_TWO_TEMPERATURE #define EXTRINSIC_MODEL_TWO_TEMPERATURE -/** owned fields: ELECTRON_TEMPERATURE */ +#include <string> -// ATC headers #include "ExtrinsicModel.h" #include "FieldEulerIntegrator.h" -using namespace std; namespace ATC { - - // forward declarations class ATC_Coupling; class PrescribedDataManager; class ExtrinsicModel; @@ -19,6 +15,7 @@ namespace ATC { /** * @class ExtrinsicModelTwoTemperature * @brief add electron temperature physics to phonon physics + * owned field: ELECTRON_TEMPERATURE */ //-------------------------------------------------------- @@ -34,7 +31,7 @@ namespace ATC { // constructor ExtrinsicModelTwoTemperature(ExtrinsicModelManager * modelManager, ExtrinsicModelType modelType, - string matFileName); + std::string matFileName); // destructor virtual ~ExtrinsicModelTwoTemperature(); diff --git a/lib/atc/FE_Element.cpp b/lib/atc/FE_Element.cpp index 01c4b29b11a13f8dbc96a5f105102bd486816611..d7c57696722dbb97dbba4290c66be07237a60336 100644 --- a/lib/atc/FE_Element.cpp +++ b/lib/atc/FE_Element.cpp @@ -12,6 +12,7 @@ using ATC_Utility::dbl_geq; using ATC_Utility::det3; +using std::vector; namespace ATC { diff --git a/lib/atc/FE_Element.h b/lib/atc/FE_Element.h index ce0e6adda3fae4b945cc7e529d8859e453a95056..a29a654034bd194dc427be615cb1e0247c46cb06 100644 --- a/lib/atc/FE_Element.h +++ b/lib/atc/FE_Element.h @@ -1,13 +1,14 @@ #ifndef FE_ELEMENT_H #define FE_ELEMENT_H +#include <vector> +#include <string> + // ATC_Transfer headers #include "MatrixLibrary.h" #include "Array2D.h" #include "ATC_TypeDefs.h" -using namespace std; - namespace ATC { enum ProjectionGuessType { @@ -91,7 +92,7 @@ namespace ATC { virtual void set_quadrature(FeIntQuadrature type) = 0; /** return the set of 1d nodes that correspond to this node in 3d space */ - void mapping(const int inode, vector<int> &mapping) const; + void mapping(const int inode, std::vector<int> &mapping) const; /** extract face coordinates from element coordinates */ void face_coordinates(const DENS_MAT &eltCoords, @@ -140,7 +141,7 @@ namespace ATC { */ virtual void shape_function(const DENS_MAT eltCoords, DENS_MAT &N, - vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &dN, DIAG_MAT &weights); /** @@ -195,8 +196,8 @@ namespace ATC { virtual void face_shape_function(const DENS_MAT &eltCoords, const int faceID, DENS_MAT &N, - vector<DENS_MAT> &dN, - vector<DENS_MAT> &Nn, + std::vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &Nn, DIAG_MAT &weights); /** @@ -214,7 +215,7 @@ namespace ATC { */ virtual void tangents(const DENS_MAT &eltCoords, const DENS_VEC &x, - vector<DENS_VEC> & tangents, + std::vector<DENS_VEC> & tangents, const bool normalize=false) const; protected: @@ -226,7 +227,7 @@ namespace ATC { /** * generate the appropriate interpolation class */ - FE_Interpolate *interpolate_factory(string interpolateType); + FE_Interpolate *interpolate_factory(std::string interpolateType); /** initial guess for local coordinates */ virtual void initial_local_coordinates(const DENS_MAT &eltCoords, diff --git a/lib/atc/FE_Engine.cpp b/lib/atc/FE_Engine.cpp index 05f82c741ce9d4e15a9d0ccf2b2ab64389768c97..14bcb58c8b38e2276ee59cfd6651378648d0e5a5 100644 --- a/lib/atc/FE_Engine.cpp +++ b/lib/atc/FE_Engine.cpp @@ -6,6 +6,7 @@ #include "PhysicsModel.h" #include "KernelFunction.h" #include "Utility.h" +#include "MPI_Wrappers.h" #include <stdio.h> #include <stdlib.h> #include <map> @@ -16,6 +17,13 @@ using namespace std; +using ATC_Utility::is_numeric; +using ATC_Utility::to_string;; +using MPI_Wrappers::allsum; +using MPI_Wrappers::int_allsum; +using MPI_Wrappers::rank_zero; +using MPI_Wrappers::print_msg; +using MPI_Wrappers::print_msg_once; namespace ATC{ @@ -132,26 +140,24 @@ namespace ATC{ bool FE_Engine::modify(int narg, char **arg) { bool match = false; - /*! \page man_mesh fix_modify AtC mesh create + /*! \page man_mesh_create fix_modify AtC mesh create \section syntax fix_modify AtC mesh create <nx> <ny> <nz> <region-id> - <f|p> <f|p> <f|p> + <f|p> <f|p> <f|p> \n - nx ny nz = number of elements in x, y, z - region-id = id of region that is to be meshed - - f p p = perioidicity flags for x, y, z - fix_modify AtC mesh quadrature <quad> where - - quad = one of <nodal|gauss1|gauss2|gauss3|face> - - when a mesh is created it defaults to gauss2, use this call - to change it after the fact + - f p p = periodicity flags for x, y, z \section examples - <TT> fix_modify AtC create mesh 10 1 1 feRegion p p p </TT> + <TT> fix_modify AtC mesh create 10 1 1 feRegion p p p </TT> \n \section description Creates a uniform mesh in a rectangular region \section restrictions - creates only uniform rectangular grids in a rectangular region + Creates only uniform rectangular grids in a rectangular region \section related + \ref man_mesh_quadrature \section default - none + When created, mesh defaults to gauss2 (2-point Gaussian) quadrature. + Use "mesh quadrature" command to change quadrature style. */ int argIdx = 0; if (strcmp(arg[argIdx],"mesh")==0) { @@ -214,6 +220,20 @@ namespace ATC{ quadrature_ = GAUSS2; match = true; } + /*! \page man_mesh_quadrature fix_modify AtC mesh quadrature + \section syntax + fix_modify AtC mesh quadrature <quad> + - quad = one of <nodal|gauss1|gauss2|gauss3|face> --- when a mesh is created it defaults to gauss2, use this call to change it after the fact + \section examples + <TT> fix_modify AtC mesh quadrature face </TT> + \section description + (Re-)assigns the quadrature style for the existing mesh. + \section restrictions + \section related + \ref man_mesh_create + \section default + none + */ else if (strcmp(arg[argIdx],"quadrature")==0) { argIdx++; string quadStr = arg[argIdx]; @@ -221,9 +241,22 @@ namespace ATC{ set_quadrature(quadEnum); match = true; } - /** Example command for reading a mesh from a file: - fix_modify atc mesh read fileName */ - // read mesh + /*! \page man_mesh_read fix_modify AtC mesh read + \section syntax + fix_modify AtC mesh read <filename> <f|p> <f|p> <f|p> + - filename = name of file containing mesh to be read + - f p p = periodicity flags for x, y, z + \section examples + <TT> fix_modify AtC mesh read myComponent.mesh p p p </TT> \n + <TT> fix_modify AtC mesh read myOtherComponent.exo </TT> + \section description + Reads a mesh from a text or exodus file, and assigns periodic + boundary conditions if needed. + \section restrictions + \section related + \section default + periodicity flags are false by default + */ else if (strcmp(arg[argIdx],"read")==0) { argIdx++; string meshFile = arg[argIdx++]; @@ -247,9 +280,18 @@ namespace ATC{ } match = true; } - /** Example command for reading a mesh from a file: - fix_modify atc mesh write fileName */ - // write mesh + /*! \page man_mesh_write fix_modify AtC mesh write + \section syntax + fix_modify AtC mesh write <filename> + - filename = name of file to write mesh + \section examples + <TT> fix_modify AtC mesh write myMesh.mesh </TT> \n + \section description + Writes a mesh to a text file. + \section restrictions + \section related + \section default + */ else if (strcmp(arg[argIdx],"write")==0) { argIdx++; string meshFile = arg[argIdx]; @@ -936,6 +978,7 @@ namespace ATC{ DIAG_MAT & M = massMatrices[_fieldName_].set_quantity(); allsum(communicator_,MPI_IN_PLACE, M.ptr(), M.size()); } + // fix zero diagonal entries due to null material elements for (int inode = 0; inode < nNodesUnique_; ++inode) { for (int j = 0; j < nfields; ++j) { @@ -2534,8 +2577,10 @@ namespace ATC{ const MATRIX & ptCoords, SPAR_MAT & N ) const { +#ifdef EXTENDED_ERROR_CHECKING print_msg_once(communicator_,"kernel matrix bandwidth " +to_string(kernel_matrix_bandwidth(ptCoords))); +#endif if (! kernelFunction_) throw ATC_Error("no kernel function specified"); int npts = ptCoords.nRows(); diff --git a/lib/atc/FE_Engine.h b/lib/atc/FE_Engine.h index 8a2ffd405720e6f72540d6286609ccb8c82179b2..ab902fe6058ea3b0ac748b47e4fdd4fc0b591d67 100644 --- a/lib/atc/FE_Engine.h +++ b/lib/atc/FE_Engine.h @@ -1,10 +1,11 @@ #ifndef FE_ENGINE_H #define FE_ENGINE_H -// Other headers + #include <vector> #include <map> - -// ATC headers +#include <set> +#include <utility> +#include <string> #include "ATC_TypeDefs.h" #include "Array.h" #include "Array2D.h" @@ -14,12 +15,8 @@ #include "MeshReader.h" #include "mpi.h" -using namespace std; - namespace ATC { - // Forward declarations - class ATC_Method; class FE_Element; class XT_Function; @@ -86,7 +83,7 @@ namespace ATC { //---------------------------------------------------------------- /*@{*/ /** these assume the caller is handling the parallel collection */ - void initialize_output(int rank, string outputPrefix, set<int> otypes); + void initialize_output(int rank, std::string outputPrefix, std::set<int> otypes); /** write geometry */ void write_geometry(void); @@ -96,19 +93,19 @@ namespace ATC { void write_data(double time, FIELDS &soln, OUTPUT_LIST *data=NULL); void write_data(double time, OUTPUT_LIST *data); - void write_restart_file(string fileName, RESTART_LIST *data) + void write_restart_file(std::string fileName, RESTART_LIST *data) { outputManager_.write_restart_file(fileName,data); } - void read_restart_file(string fileName, RESTART_LIST *data) + void read_restart_file(std::string fileName, RESTART_LIST *data) { outputManager_.read_restart_file(fileName,data); } - void delete_elements(const set<int> &elementList); - void cut_mesh(const set<PAIR> &cutFaces, const set<int> &edgeNodes); + void delete_elements(const std::set<int> &elementList); + void cut_mesh(const std::set<PAIR> &cutFaces, const std::set<int> &edgeNodes); - void add_global(const string name, const double value) + void add_global(const std::string name, const double value) { outputManager_.add_global(name,value); } - void add_field_names(const string field, const vector<string> & names) + void add_field_names(const std::string field, const std::vector<std::string> & names) { outputManager_.add_field_names(field,names); } void reset_globals() { outputManager_.reset_globals(); } @@ -129,7 +126,7 @@ namespace ATC { AliasArray<int> &conn, DENS_MAT &N, DIAG_MAT &weights, - map<FieldName,DENS_MAT> &fieldsAtIPs) const; + std::map<FieldName,DENS_MAT> &fieldsAtIPs) const; /** interpolate fields & gradients */ void interpolate_fields(const int ielem, @@ -148,7 +145,7 @@ namespace ATC { /** compute tangent matrix for a pair of fields - native quadrature */ void compute_tangent_matrix( const RHS_MASK &rhsMask, - const pair<FieldName,FieldName> row_col, + const std::pair<FieldName,FieldName> row_col, const FIELDS &fields, const PhysicsModel *physicsModel, const Array<int> &elementMaterials, @@ -157,10 +154,10 @@ namespace ATC { /** compute tangent matrix for a pair of fields - given quadrature */ void compute_tangent_matrix(const RHS_MASK &rhsMask, - const pair<FieldName,FieldName> row_col, + const std::pair<FieldName,FieldName> row_col, const FIELDS &fields, const PhysicsModel *physicsModel, - const Array<set<int> > &pointMaterialGroups, + const Array<std::set<int> > &pointMaterialGroups, const DIAG_MAT &weights, const SPAR_MAT &N, const SPAR_MAT_VEC &dN, @@ -201,7 +198,7 @@ namespace ATC { const Array<FieldName> &mask, const FIELDS &fields, const PhysicsModel *physicsModel, - const Array<set<int> > &pointMaterialGroups, + const Array<std::set<int> > &pointMaterialGroups, const DIAG_MAT &weights, const SPAR_MAT &N, MASS_MATS &mass_matrix) const; @@ -231,7 +228,7 @@ namespace ATC { void compute_rhs_vector(const RHS_MASK &rhsMask, const FIELDS &fields, const PhysicsModel *physicsModel, - const Array<set<int> > &pointMaterialGroups, + const Array<std::set<int> > &pointMaterialGroups, const DIAG_MAT &weights, const SPAR_MAT &N, const SPAR_MAT_VEC &dN, @@ -241,7 +238,7 @@ namespace ATC { void compute_source(const Array2D<bool> &rhsMask, const FIELDS &fields, const PhysicsModel *physicsModel, - const Array<set<int> > &pointMaterialGroups, + const Array<std::set<int> > &pointMaterialGroups, const DIAG_MAT &weights, const SPAR_MAT &N, const SPAR_MAT_VEC &dN, @@ -260,7 +257,7 @@ namespace ATC { const FIELDS &fields, const PhysicsModel *physicsModel, const Array<int> &elementMaterials, - const set<PAIR> &faceSet, + const std::set<PAIR> &faceSet, FIELDS &rhs) const; /** compute the flux on using an L2 interpolation of the flux */ @@ -268,14 +265,14 @@ namespace ATC { const FIELDS &fields, const PhysicsModel *physicsModel, const Array<int> &elementMaterials, - const Array<set<int> > &pointMaterialGroups, + const Array<std::set<int> > &pointMaterialGroups, const DIAG_MAT &weights, const SPAR_MAT &N, const SPAR_MAT_VEC &dN, const DIAG_MAT &flux_mask, FIELDS &rhs, const DenseMatrix<bool> *elementMask=NULL, - const set<int> *nodeSet=NULL) const; + const std::set<int> *nodeSet=NULL) const; /** compute prescribed flux given an array of functions of x & t */ void add_fluxes(const Array<bool> &fieldMask, @@ -319,7 +316,7 @@ namespace ATC { /** compute surface flux of a nodal field */ void field_surface_flux(const DENS_MAT &field, - const set<PAIR> &faceSet, + const std::set<PAIR> &faceSet, DENS_MAT &values, const bool contour=false, const int axis=2) const; @@ -409,7 +406,7 @@ namespace ATC { /** \name nodeset */ //---------------------------------------------------------------- /** pass through */ - void create_nodeset(const string &name, const set<int> &nodeset) + void create_nodeset(const std::string &name, const std::set<int> &nodeset) { feMesh_->create_nodeset(name,nodeset); } //---------------------------------------------------------------- @@ -461,7 +458,7 @@ namespace ATC { { feMesh_->element_field(eltIdx, field, local_field); } /** access list of elements to be deleted */ - const set<int> &null_elements(void) const + const std::set<int> &null_elements(void) const { return nullElements_; } /** access to the amended nodal coordinate values */ @@ -511,15 +508,15 @@ namespace ATC { Array<bool> periodic); /** read an unstructured mesh from a file */ - void read_mesh(string meshFile, Array<bool> & periodicity); + void read_mesh(std::string meshFile, Array<bool> & periodicity); /*@}*/ /** data that can be used for a subset of original mesh */ - set<int> nullElements_; + std::set<int> nullElements_; /** faces upon which nodes are duplicated */ - set<PAIR> cutFaces_; - set<int> cutEdge_; + std::set<PAIR> cutFaces_; + std::set<int> cutEdge_; /** workspace */ int nNodesPerElement_; diff --git a/lib/atc/FE_Interpolate.cpp b/lib/atc/FE_Interpolate.cpp index 5f9bf02c208fc6e359f4adf42e64ce336224e26d..3f41e3002994db342561e2a5b8f2a6f5112ee9ec 100644 --- a/lib/atc/FE_Interpolate.cpp +++ b/lib/atc/FE_Interpolate.cpp @@ -7,6 +7,9 @@ // Other headers #include "math.h" +using std::map; +using std::vector; + namespace ATC { FE_Interpolate::FE_Interpolate(FE_Element *feElement) diff --git a/lib/atc/FE_Interpolate.h b/lib/atc/FE_Interpolate.h index b9f7adac5633b3510f2747d3c6786939485db546..9e0b1388c1b90dad2e1f738c23cc5c8fb9e09bd3 100644 --- a/lib/atc/FE_Interpolate.h +++ b/lib/atc/FE_Interpolate.h @@ -1,15 +1,14 @@ #ifndef FE_INTERPOLATE_H #define FE_INTERPOLATE_H -// ATC_Transfer headers #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" -using namespace std; +#include <vector> +#include <map> namespace ATC { - // Forward declarations struct FE_Quadrature; class FE_Element; @@ -73,7 +72,7 @@ namespace ATC { * weights(ip) */ virtual void shape_function(const DENS_MAT &eltCoords, DENS_MAT &N, - vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &dN, DIAG_MAT &weights); /** compute shape functions at all face ip's: @@ -92,8 +91,8 @@ namespace ATC { const DENS_MAT &faceCoords, const int faceID, DENS_MAT &N, - vector<DENS_MAT> &dN, - vector<DENS_MAT> &Nn, + std::vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &Nn, DIAG_MAT &weights); /** compute unit normal vector for a face: @@ -112,7 +111,7 @@ namespace ATC { DENS_MAT &dxdr) const; virtual void tangents(const DENS_MAT &eltCoords, const VECTOR &localCoords, - vector<DENS_VEC> &t, + std::vector<DENS_VEC> &t, const bool normalize = false) const; /** get number of ips in scheme */ int num_ips() const; @@ -127,23 +126,23 @@ namespace ATC { // Number of dimensions int nSD_; - map<FeIntQuadrature,FE_Quadrature *> feQuadList_; + std::map<FeIntQuadrature,FE_Quadrature *> feQuadList_; FE_Quadrature *feQuad_; // matrix of shape functions at ip's: N_(ip, node) DENS_MAT N_; - vector<DENS_MAT> dNdr_; + std::vector<DENS_MAT> dNdr_; // matrix of shape functions at ip's: N_(ip, node) - vector<DENS_MAT> NFace_; + std::vector<DENS_MAT> NFace_; // matrix of generic face shape function derivatives - vector<vector<DENS_MAT> > dNdrFace_; + std::vector<std::vector<DENS_MAT> > dNdrFace_; // matrix of generic face shape function derivatives - vector<DENS_MAT> dNdrFace2D_; + std::vector<DENS_MAT> dNdrFace2D_; }; diff --git a/lib/atc/FE_Mesh.cpp b/lib/atc/FE_Mesh.cpp index 6a5e811c7d9de1d7b8d67ac88500412912c53ec2..3dd00497d6f9e5c03695bf2c6b8f0b1a9eb4bbdd 100644 --- a/lib/atc/FE_Mesh.cpp +++ b/lib/atc/FE_Mesh.cpp @@ -207,7 +207,6 @@ namespace ATC { Command to assign an id to a set of FE nodes to be used subsequently in defining boundary conditions. \section restrictions - Only viable for rectangular grids. \section related \section default Coordinates are assumed to be in lattice units. @@ -235,7 +234,6 @@ namespace ATC { \section description Command to add nodes to an already existing FE nodeset. \section restrictions - Only viable for rectangular grids. \section related \section default Coordinates are assumed to be in lattice units. diff --git a/lib/atc/FE_Mesh.h b/lib/atc/FE_Mesh.h index ec984c32454cd9c375e8b549a3f48ef61f7185e5..b832a5b704928dfee474ba8ed6dcc79535f247af 100644 --- a/lib/atc/FE_Mesh.h +++ b/lib/atc/FE_Mesh.h @@ -1,14 +1,11 @@ #ifndef FE_MESH_H #define FE_MESH_H -// ATC_Transfer headers #include "Array.h" #include "Array2D.h" #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" #include "KD_Tree.h" - -// Other headers #include <vector> #include <deque> #include <list> @@ -16,12 +13,12 @@ #include <set> #include <utility> #include <float.h> +#include <string> +#include <vector> #include "mpi.h" -using namespace std; - namespace ATC { - // Forward declarations + class FE_Element; /** @@ -45,7 +42,7 @@ namespace ATC { void initialize(void); /** write an unstructured mesh */ - void write_mesh(string meshFile); + void write_mesh(std::string meshFile); @@ -117,7 +114,7 @@ namespace ATC { // N is numIPsInElement X numNodesInElement void shape_function(const int eltID, DENS_MAT &N, - vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &dN, DIAG_MAT &weights) const; /** evaluate shape functions for all ip's on a face */ @@ -129,8 +126,8 @@ namespace ATC { void face_shape_function(const PAIR &face, DENS_MAT &N, - vector<DENS_MAT> &dN, - vector<DENS_MAT> &Nn, + std::vector<DENS_MAT> &dN, + std::vector<DENS_MAT> &Nn, DIAG_MAT &weights) const; /** compute normal vector from the specified face */ @@ -222,92 +219,92 @@ namespace ATC { } /** query whether a nodeset with the given name exists */ - bool query_nodeset(const string & name) const; + bool query_nodeset(const std::string & name) const; /** get node set (unique ID's) from the string name assigned to the set */ - const set<int> & nodeset(const string & name) const; + const std::set<int> & nodeset(const std::string & name) const; /** create node set with tag "name" from nodes in given spatial range */ - void create_nodeset(const string & name, const set<int> & nodeset); - void create_nodeset(const string & name, + void create_nodeset(const std::string & name, const std::set<int> & nodeset); + void create_nodeset(const std::string & name, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); /** add to node set with tag "name" from nodes in given spatial range */ - void add_to_nodeset(const string & name, + void add_to_nodeset(const std::string & name, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); /** get element set from the string name assigned to the set */ - const set<int> & elementset(const string & name) const; + const std::set<int> & elementset(const std::string & name) const; /** create element set with tag "name" from nodes in given spatial range */ - void create_elementset(const string & name, + void create_elementset(const std::string & name, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); /** get the minimal element set from a nodeset by name */ - void nodeset_to_minimal_elementset(const string &name, - set<int> &elemSet) const; + void nodeset_to_minimal_elementset(const std::string &name, + std::set<int> &elemSet) const; /** get the minimal element set from a set of nodes */ - void nodeset_to_minimal_elementset(const set<int> &nodeSet, - set<int> &elemSet) const; + void nodeset_to_minimal_elementset(const std::set<int> &nodeSet, + std::set<int> &elemSet) const; /** get the maximal element set from a nodeset by name */ - void nodeset_to_maximal_elementset(const string &name, - set<int> &elemSet) const; + void nodeset_to_maximal_elementset(const std::string &name, + std::set<int> &elemSet) const; /** get the maximal element set from a set of nodes */ - void nodeset_to_maximal_elementset(const set<int> &nodeSet, - set<int> &elemSet) const; + void nodeset_to_maximal_elementset(const std::set<int> &nodeSet, + std::set<int> &elemSet) const; /** get complement of element set by name */ - void elementset_complement(const string &name, - set<int> &elemSet) const; - void elementset_complement(const set<int> &elemSet, - set<int> &elemSetComplement) const; + void elementset_complement(const std::string &name, + std::set<int> &elemSet) const; + void elementset_complement(const std::set<int> &elemSet, + std::set<int> &elemSetComplement) const; /** get the node set from an element set by name */ - void elementset_to_minimal_nodeset(const string &name, - set<int> &nodeSet) const; + void elementset_to_minimal_nodeset(const std::string &name, + std::set<int> &nodeSet) const; - void elementset_to_nodeset(const string &name, - set<int> &nodeSet) const; - void elementset_to_nodeset(const set<int> &elemSet, - set<int> &nodeSet) const; + void elementset_to_nodeset(const std::string &name, + std::set<int> &nodeSet) const; + void elementset_to_nodeset(const std::set<int> &elemSet, + std::set<int> &nodeSet) const; /** convert faceset to nodeset in _unique_ node numbering */ - void faceset_to_nodeset(const string &name, - set<int> &nodeSet) const; - void faceset_to_nodeset(const set<PAIR> &faceSet, - set<int> &nodeSet) const; + void faceset_to_nodeset(const std::string &name, + std::set<int> &nodeSet) const; + void faceset_to_nodeset(const std::set<PAIR> &faceSet, + std::set<int> &nodeSet) const; - void faceset_to_nodeset_global(const string &name, - set<int> &nodeSet) const; - void faceset_to_nodeset_global(const set<PAIR> &faceSet, - set<int> &nodeSet) const; + void faceset_to_nodeset_global(const std::string &name, + std::set<int> &nodeSet) const; + void faceset_to_nodeset_global(const std::set<PAIR> &faceSet, + std::set<int> &nodeSet) const; /** get face set from the string name assigned to the set */ - const set< pair<int,int> > & faceset(const string & name) const; + const std::set< std::pair<int,int> > & faceset(const std::string & name) const; /** create face set with tag "name" from faces aligned with box */ - void create_faceset(const string & name, + void create_faceset(const std::string & name, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, bool outward); /** create face set with tag "name" from faces aligned with plane */ - void create_faceset(const string & name, double x, int idir, int isgn, + void create_faceset(const std::string & name, double x, int idir, int isgn, int nIdx2=-1, double x2lo=0.0, double x2hi=0.0, int nIdx3=-1, double x3lo=0.0, double x3hi=0.0); /** cut mesh */ - virtual void cut_mesh(const set<PAIR> & faceSet, const set<int> & nodeSet) = 0; + virtual void cut_mesh(const std::set<PAIR> & faceSet, const std::set<int> & nodeSet) = 0; /** delete elements */ - virtual void delete_elements(const set<int> & elementList) = 0; + virtual void delete_elements(const std::set<int> & elementList) = 0; /** return number of spatial dimensions */ int num_spatial_dimensions() const { return nSD_; } @@ -389,16 +386,16 @@ namespace ATC { virtual double coordinate_tolerance(void) const {return 1.e-8;} /** element type */ - string element_type(void) const ; + std::string element_type(void) const ; /** output mesh subsets */ - void output(string prefix) const; + void output(std::string prefix) const; /* Parallelization data members */ /** return element vector for this processor */ - const vector<int> & owned_elts() const { return myElts_; } - const vector<int> & owned_and_ghost_elts() const { + const std::vector<int> & owned_elts() const { return myElts_; } + const std::vector<int> & owned_and_ghost_elts() const { return (decomposition_) ? myAndGhostElts_: myElts_; } bool is_owned_elt(int elt) const; @@ -442,7 +439,7 @@ namespace ATC { /** map from unique node id to associated elements for periodic meshes */ /** this data structure is only ever accessed from an unpartitioned context */ - Array<vector<int> > uniqueNodeToElementMap_; + Array<std::vector<int> > uniqueNodeToElementMap_; /** map of global to unique node ID's */ Array<int> globalToUniqueMap_; @@ -455,7 +452,7 @@ namespace ATC { NODE_SET_MAP nodeSetMap_; /** maximal nodeset */ - set<int> nodeSetAll_; + std::set<int> nodeSetAll_; /** map of string names to node sets */ FACE_SET_MAP faceSetMap_; @@ -464,32 +461,32 @@ namespace ATC { ELEMENT_SET_MAP elementSetMap_; /** maximal elementset */ - set<int> elementSetAll_; + std::set<int> elementSetAll_; /** length scaling used by lammps */ double xscale_, yscale_, zscale_; /** Processor demarcations */ - vector<double> procs_; + std::vector<double> procs_; /** Dimension (x=0, y=1, or z=2) */ int partitionAxis_; /** List of nodes for this processor */ - vector<int> myNodes_; + std::vector<int> myNodes_; /** List of elements for this processor */ - vector<int> myElts_; - vector<int> myAndGhostElts_; + std::vector<int> myElts_; + std::vector<int> myAndGhostElts_; /** maps between my IDs and the total IDs */ - map<int,int> elemToMyElemMap_; + std::map<int,int> elemToMyElemMap_; /** Lists of ghost nodes/neighbor ghost nodes */ - vector<int> ghostNodesL_; - vector<int> ghostNodesR_; - vector<int> shareNodesL_; - vector<int> shareNodesR_; + std::vector<int> ghostNodesL_; + std::vector<int> ghostNodesR_; + std::vector<int> shareNodesL_; + std::vector<int> shareNodesR_; /** extruded */ bool twoDimensional_; @@ -509,13 +506,13 @@ namespace ATC { /** constructor for read-in mesh **/ // can later be extended to take nodesets, elementsets, etc. - FE_3DMesh(const string elementType, + FE_3DMesh(const std::string elementType, const int nNodes, const int nElements, const Array2D<int> *connectivity, const DENS_MAT *nodalCoordinates, const Array<bool> periodicity, - const Array<pair<string,set<int> > > *nodeSets); + const Array<std::pair<std::string,std::set<int> > > *nodeSets); /** destructor */ virtual ~FE_3DMesh(); @@ -528,7 +525,7 @@ namespace ATC { /** Removes duplicate elements that appear in more than one vector within procEltLists. **/ - void prune_duplicate_elements(vector<vector<int> > &procEltLists, + void prune_duplicate_elements(std::vector<std::vector<int> > &procEltLists, int *eltToOwners); /** Takes procEltLists, and if there are more than nProcs of them @@ -538,7 +535,7 @@ namespace ATC { // processors if during pruning processors end up // elementless. This is slightly complicated because of // ghost nodes. - void redistribute_extra_proclists(vector<vector<int> > &procEltLists, + void redistribute_extra_proclists(std::vector<std::vector<int> > &procEltLists, int *eltToOwners, int nProcs); /** This takes in a dense matrix and a list of elements @@ -548,17 +545,17 @@ namespace ATC { // the set intersection, which does redundant computations // right now, and filling in the adjacencies for both elements // simultaneously when two elements share a face. - void compute_face_adjacencies(const list<int> &elts, + void compute_face_adjacencies(const std::list<int> &elts, DENS_MAT &faceAdjacencies); /** Counts the number of nonempty vectors in a vector of vectors. **/ - int numNonempty(vector<vector<int> > &v); + int numNonempty(std::vector<std::vector<int> > &v); /** In the partitioning, we want to sort vectors of integers by size, and furthermore we want empty vectors to count as the "largest" possible vector because they dont want to count in the minimum. **/ struct vectorComparer { - bool operator() (vector<int> l, vector<int> r) { + bool operator() (std::vector<int> l, std::vector<int> r) { if (l.empty()) return false; if (r.empty()) @@ -572,10 +569,10 @@ namespace ATC { return 0.25*(this->min_element_size()); // loose //return 0.5; } - virtual void cut_mesh(const set<PAIR> &faceSet, - const set<int> &nodeSet); + virtual void cut_mesh(const std::set<PAIR> &faceSet, + const std::set<int> &nodeSet); - virtual void delete_elements(const set<int> &elementSet); + virtual void delete_elements(const std::set<int> &elementSet); /** map spatial location to element */ virtual int map_to_element(const DENS_VEC &x) const; @@ -586,8 +583,8 @@ namespace ATC { /** create global-to-unique node mapping */ virtual void setup_periodicity(double tol = 1.e-8); void fix_periodicity (int idim); - int find_boundary_nodes(int idim, set<int> & nodes); - bool match_nodes(int idim, set<int> & top, set<int> & bot, + int find_boundary_nodes(int idim, std::set<int> & nodes); + bool match_nodes(int idim, std::set<int> & top, std::set<int> & bot, Array<int> & map); void set_unique_connectivity(void); bool orient(int idir); @@ -599,7 +596,7 @@ namespace ATC { bool contains_point(const int eltID, const DENS_VEC & x) const; private: - Array<vector<int> > nodeToParentElements_; + Array<std::vector<int> > nodeToParentElements_; }; @@ -655,7 +652,7 @@ namespace ATC { Array<double> hx_, hy_, hz_; /** nodal locations */ - vector< Array<double> > x_; + std::vector< Array<double> > x_; }; /** @@ -691,7 +688,7 @@ namespace ATC { { hx = L_[0]/n_[0]; hy = L_[1]/n_[1]; hz = L_[2]/n_[2]; } virtual double min_element_size(void) const - { return min(L_[0]/n_[0], min(L_[1]/n_[1], L_[2]/n_[2])); } + { return std::min(L_[0]/n_[0], std::min(L_[1]/n_[1], L_[2]/n_[2])); } /** map spatial location to element */ virtual int map_to_element(const DENS_VEC &x) const; diff --git a/lib/atc/FE_Quadrature.h b/lib/atc/FE_Quadrature.h index 953dce639f37d95fd93077a2fc5d0f3c0077b0d8..922ade05cba0a9c0f69bc29970849003d18af142 100644 --- a/lib/atc/FE_Quadrature.h +++ b/lib/atc/FE_Quadrature.h @@ -1,12 +1,11 @@ #ifndef FE_QUADRATURE_H #define FE_QUADRATURE_H -// ATC_Transfer headers +#include <vector> + #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" -using namespace std; - namespace ATC { /** @@ -17,7 +16,7 @@ namespace ATC { int numIPs; int numFaceIPs; DENS_MAT ipCoords; - vector<DENS_MAT> ipFaceCoords; + std::vector<DENS_MAT> ipFaceCoords; DENS_MAT ipFace2DCoords; DENS_VEC ipWeights; DENS_VEC ipFaceWeights; diff --git a/lib/atc/FieldManager.cpp b/lib/atc/FieldManager.cpp index c0c99c83dc218614e24b90d9606c5fc5cc1cad9c..9a74fc22cd224ab25771af824e8313e9ffe8eb42 100644 --- a/lib/atc/FieldManager.cpp +++ b/lib/atc/FieldManager.cpp @@ -4,6 +4,7 @@ #include "PerAtomQuantity.h" #include "TransferOperator.h" +using std::string; namespace ATC { @@ -48,14 +49,14 @@ typedef PerAtomQuantity<double> PAQ; //----------------------------------------------------------------------------- //* restricted_atom_quantity //----------------------------------------------------------------------------- - DENS_MAN * FieldManager::projected_atom_quantity(FieldName field,string name, PAQ * atomic, FieldName massMat, DIAG_MAN * normalization) + DENS_MAN * FieldManager::projected_atom_quantity(FieldName field,string name, PAQ * atomic, DIAG_MAN * normalization) { if (atc_->use_md_mass_normalization()) { if (name == "default") { name = field_to_intrinsic_name(field); } DENS_MAN * quantity = interscaleManager_.dense_matrix(name); if (!quantity) { DENS_MAN * restricted = restricted_atom_quantity(field,field_to_restriction_name(field),atomic); - quantity = new AtfShapeFunctionMdProjection(atc_,restricted,massMat); + quantity = new AtfShapeFunctionMdProjection(atc_,restricted,use_mass_matrix(field)); interscaleManager_.add_dense_matrix(quantity,name); } return quantity; @@ -68,13 +69,13 @@ typedef PerAtomQuantity<double> PAQ; if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { quantity = new OnTheFlyKernelAccumulationNormalized(atc_, atomic, - atc_->kernel_function(), - atc_->atom_coarsegraining_positions(), - normalization); + atc_->kernel_function(), + atc_->atom_coarsegraining_positions(), + normalization); } else { quantity = new OnTheFlyMeshAccumulationNormalized(atc_, atomic, - atc_->atom_coarsegraining_positions(), - normalization); + atc_->atom_coarsegraining_positions(), + normalization); } } else { quantity = new AtfProjection(atc_, atomic, @@ -89,7 +90,7 @@ typedef PerAtomQuantity<double> PAQ; //----------------------------------------------------------------------------- //* referenced_projected_atom_quantity //----------------------------------------------------------------------------- - DENS_MAN * FieldManager::referenced_projected_atom_quantity(FieldName field,string name, PAQ * atomic, const DENS_MAT * reference, FieldName massMat, DIAG_MAN * normalization) + DENS_MAN * FieldManager::referenced_projected_atom_quantity(FieldName field,string name, PAQ * atomic, DENS_MAN * reference, DIAG_MAN * normalization) { if (name == "default") { name = field_to_string(field); } DENS_MAN * quantity = interscaleManager_.dense_matrix(name); @@ -97,7 +98,7 @@ typedef PerAtomQuantity<double> PAQ; if (atc_->use_md_mass_normalization()) { DENS_MAN * restricted = restricted_atom_quantity(field,field_to_restriction_name(field),atomic); - quantity = new AtfShapeFunctionMdProjectionReferenced(atc_,restricted,reference,massMat); + quantity = new AtfShapeFunctionMdProjectionReferenced(atc_,restricted,reference,use_mass_matrix(field)); } else if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { @@ -128,7 +129,7 @@ typedef PerAtomQuantity<double> PAQ; //* scaled_projected_atom_quantity //----------------------------------------------------------------------------- - DENS_MAN * FieldManager::scaled_projected_atom_quantity(FieldName field,string name, PAQ * atomic, double scale, FieldName massMat, DIAG_MAN * normalization) + DENS_MAN * FieldManager::scaled_projected_atom_quantity(FieldName field,string name, PAQ * atomic, double scale, DIAG_MAN * normalization) { if (name == "default") { name = field_to_string(field); } DENS_MAN * quantity = interscaleManager_.dense_matrix(name); @@ -136,7 +137,7 @@ typedef PerAtomQuantity<double> PAQ; if (atc_->use_md_mass_normalization()) { DENS_MAN * restricted = restricted_atom_quantity(field,field_to_restriction_name(field),atomic); - quantity = new AtfShapeFunctionMdProjectionScaled(atc_,restricted,scale,massMat); + quantity = new AtfShapeFunctionMdProjectionScaled(atc_,restricted,scale,use_mass_matrix(field)); } else if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { @@ -167,7 +168,7 @@ typedef PerAtomQuantity<double> PAQ; DENS_MAN * FieldManager::charge_density(string name) { FundamentalAtomQuantity * atomic = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE); - return projected_atom_quantity(CHARGE_DENSITY,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(CHARGE_DENSITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* MASS_DENSITY @@ -175,38 +176,19 @@ typedef PerAtomQuantity<double> PAQ; DENS_MAN * FieldManager::mass_density(string name) { FundamentalAtomQuantity * atomic = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS); - return projected_atom_quantity(MASS_DENSITY,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(MASS_DENSITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* SPECIES_CONCENTRATION //----------------------------------------------------------------------------- DENS_MAN * FieldManager::species_concentration(string name) { - DENS_MAN * c = NULL; -#ifdef ATC_VERBOSE - atc_->print_tracked(); -#endif - PAQ * atomSpecies = atomic_species_vector(); - - if (atc_->kernel_on_the_fly()) { - if (atc_->kernel_based()) { - c = new OnTheFlyKernelAccumulationNormalized(atc_, atomSpecies, - atc_->kernel_function(), - atc_->atom_coarsegraining_positions(), - atc_->accumulant_inverse_volumes()); - } else { - c = new OnTheFlyMeshAccumulationNormalized(atc_, atomSpecies, - atc_->atom_coarsegraining_positions(), - atc_->accumulant_inverse_volumes()); - } - } else { - c = new AtfProjection(atc_, atomSpecies, - atc_->accumulant(), - atc_->accumulant_inverse_volumes()); + PerAtomQuantity<double> * atomTypeVector = interscaleManager_.per_atom_quantity("atom_species_vector"); + if (!atomTypeVector) { + atomTypeVector = new AtomTypeVector(atc_,atc_->type_list(),atc_->group_list()); + interscaleManager_.add_per_atom_quantity(atomTypeVector,"atom_species_vector"); } - if (name == "default") { name = field_to_string(SPECIES_CONCENTRATION); } - interscaleManager_.add_dense_matrix(c,name); - return c; + return projected_atom_quantity(SPECIES_CONCENTRATION,name,atomTypeVector,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* NUMBER_DENSITY @@ -218,7 +200,7 @@ typedef PerAtomQuantity<double> PAQ; atomic = new AtomNumber(atc_); interscaleManager_.add_per_atom_quantity(atomic, "atomNumber"); } - return projected_atom_quantity(NUMBER_DENSITY,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(NUMBER_DENSITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* MOMENTUM @@ -230,7 +212,7 @@ typedef PerAtomQuantity<double> PAQ; atomic = new AtomicMomentum(atc_); interscaleManager_.add_per_atom_quantity(atomic, "atomMomentum"); } - return projected_atom_quantity(MOMENTUM,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(MOMENTUM,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* VELOCITY @@ -266,7 +248,7 @@ typedef PerAtomQuantity<double> PAQ; DENS_MAN * FieldManager::projected_velocity(string name) { FundamentalAtomQuantity * atomic = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY); - return projected_atom_quantity(PROJECTED_VELOCITY,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(PROJECTED_VELOCITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* DISPLACEMENT @@ -318,13 +300,38 @@ typedef PerAtomQuantity<double> PAQ; //----------------------------------------------------------------------------- DENS_MAN * FieldManager::reference_potential_energy(string name) { - PAQ * atomic = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); - if (!atomic) { - atomic = new AtcAtomQuantity<double>(atc_); - interscaleManager_.add_per_atom_quantity(atomic, "AtomicReferencePotential"); - atomic->set_memory_type(PERSISTENT); + DENS_MAN * rpe = interscaleManager_.dense_matrix(field_to_string(REFERENCE_POTENTIAL_ENERGY)); + if (! rpe ) { + PAQ * atomic = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); + if (!atomic) { + atomic = new AtcAtomQuantity<double>(atc_); + interscaleManager_.add_per_atom_quantity(atomic, "AtomicReferencePotential"); + atomic->set_memory_type(PERSISTENT); + } + + SPAR_MAN * referenceAccumulant = interscaleManager_.sparse_matrix("ReferenceAccumulant"); + if (!referenceAccumulant) { + referenceAccumulant = new SPAR_MAN(); + referenceAccumulant->set_memory_type(PERSISTENT); + interscaleManager_.add_sparse_matrix(referenceAccumulant, + "ReferenceAccumulant"); + } + + DIAG_MAN * referenceAccumulantInverseVolumes = interscaleManager_.diagonal_matrix("ReferenceAccumulantInverseVolumes"); + if (!referenceAccumulantInverseVolumes) { + referenceAccumulantInverseVolumes = new DIAG_MAN(); + referenceAccumulantInverseVolumes->set_memory_type(PERSISTENT); + interscaleManager_.add_diagonal_matrix(referenceAccumulantInverseVolumes, + "ReferenceAccumulantInverseVolumes"); + } + + rpe = new AtfProjection(atc_, atomic, + referenceAccumulant, + referenceAccumulantInverseVolumes); + interscaleManager_.add_dense_matrix(rpe,field_to_string(REFERENCE_POTENTIAL_ENERGY)); + rpe->set_memory_type(PERSISTENT); } - return projected_atom_quantity(REFERENCE_POTENTIAL_ENERGY,"NodalAtomicReferencePotential",atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return rpe; } //----------------------------------------------------------------------------- //* POTENTIAL_ENERGY @@ -332,8 +339,17 @@ typedef PerAtomQuantity<double> PAQ; DENS_MAN * FieldManager::potential_energy(string name) { PerAtomQuantity<double> * atomic = interscaleManager_.per_atom_quantity("AtomicPotentialEnergy"); - const DENS_MAT * reference = atc_->nodal_ref_potential_energy(); - return referenced_projected_atom_quantity(POTENTIAL_ENERGY,name,atomic,reference,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + if (!atomic) { + atomic = new ComputedAtomQuantity(atc_,(atc_->lammps_interface())->compute_pe_name(), atc_->pe_scale()); + interscaleManager_.add_per_atom_quantity(atomic,"AtomicPotentialEnergy"); + } + DENS_MAN * reference = interscaleManager_.dense_matrix(field_to_string(REFERENCE_POTENTIAL_ENERGY)); + if (reference) { + return referenced_projected_atom_quantity(POTENTIAL_ENERGY,name,atomic,reference,atc_->accumulant_inverse_volumes()); + } + else { + return projected_atom_quantity(POTENTIAL_ENERGY,name,atomic,atc_->accumulant_inverse_volumes()); + } } //----------------------------------------------------------------------------- //* TEMPERATURE @@ -342,7 +358,7 @@ typedef PerAtomQuantity<double> PAQ; { double Tcoef = 1./((atc_->nsd())*(atc_->lammps_interface())->kBoltzmann()); PAQ * atomic = per_atom_quantity("AtomicTwiceFluctuatingKineticEnergy"); - return scaled_projected_atom_quantity(TEMPERATURE,name,atomic,Tcoef,TEMPERATURE,atc_->accumulant_weights()); + return scaled_projected_atom_quantity(TEMPERATURE,name,atomic,Tcoef,atc_->accumulant_weights()); } //----------------------------------------------------------------------------- //* KINETIC_TEMPERATURE @@ -351,7 +367,7 @@ typedef PerAtomQuantity<double> PAQ; { double Tcoef = 1./((atc_->nsd())*(atc_->lammps_interface())->kBoltzmann()); PAQ * atomic = per_atom_quantity("AtomicTwiceKineticEnergy"); - return scaled_projected_atom_quantity(KINETIC_TEMPERATURE,name,atomic,Tcoef,MASS_DENSITY,atc_->accumulant_weights()); + return scaled_projected_atom_quantity(KINETIC_TEMPERATURE,name,atomic,Tcoef,atc_->accumulant_weights()); } //----------------------------------------------------------------------------- //* THERMAL_ENERGY @@ -360,7 +376,7 @@ typedef PerAtomQuantity<double> PAQ; { double Ecoef = 0.5*atc_->ke_scale(); PAQ * atomic = per_atom_quantity("AtomicTwiceFluctuatingKineticEnergy"); - return scaled_projected_atom_quantity(THERMAL_ENERGY,name,atomic,Ecoef,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return scaled_projected_atom_quantity(THERMAL_ENERGY,name,atomic,Ecoef,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* KINETIC_ENERGY @@ -369,7 +385,7 @@ typedef PerAtomQuantity<double> PAQ; { double Ecoef = 0.5*atc_->ke_scale(); PAQ * atomic = per_atom_quantity("AtomicTwiceKineticEnergy"); - return scaled_projected_atom_quantity(KINETIC_ENERGY,name,atomic,Ecoef,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return scaled_projected_atom_quantity(KINETIC_ENERGY,name,atomic,Ecoef,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* CHARGE_FLUX @@ -378,7 +394,7 @@ typedef PerAtomQuantity<double> PAQ; { PAQ * atomic = per_atom_quantity("AtomicChargeVelocity"); - return projected_atom_quantity(CHARGE_FLUX,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(CHARGE_FLUX,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- //* SPECIES_FLUX @@ -386,8 +402,35 @@ typedef PerAtomQuantity<double> PAQ; DENS_MAN * FieldManager::species_flux(string name) { PAQ * atomic = per_atom_quantity("AtomicSpeciesVelocity"); - return projected_atom_quantity(SPECIES_FLUX,name,atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes()); + return projected_atom_quantity(SPECIES_FLUX,name,atomic,atc_->accumulant_inverse_volumes()); } +//----------------------------------------------------------------------------- +//* INTERNAL_ENERGY +//----------------------------------------------------------------------------- + DENS_MAN * FieldManager::internal_energy(string name) + { + if (name == "default") { name = field_to_string(INTERNAL_ENERGY); } + DENS_MAN * te = thermal_energy(field_to_string(THERMAL_ENERGY)); + DENS_MAN * pe = potential_energy(field_to_string(POTENTIAL_ENERGY)); + DenseMatrixSum * ie = new DenseMatrixSum(te,pe); + interscaleManager_.add_dense_matrix(ie,name); + return ie; + } +//----------------------------------------------------------------------------- +//* ENERGY +//----------------------------------------------------------------------------- + DENS_MAN * FieldManager::energy(string name) + { + if (name == "default") { name = field_to_string(ENERGY); } + DENS_MAN * ke = kinetic_energy(field_to_string(KINETIC_ENERGY)); + DENS_MAN * pe = potential_energy(field_to_string(POTENTIAL_ENERGY)); + DenseMatrixSum * e = new DenseMatrixSum(ke,pe); + interscaleManager_.add_dense_matrix(e,name); + + return e; + } + + @@ -479,26 +522,27 @@ typedef PerAtomQuantity<double> PAQ; } return atomic; } - - PAQ * FieldManager::prolonged_field(FieldName field) - { - PAQ * quantity = interscaleManager_.per_atom_quantity(field_to_prolongation_name(field)); - if (!quantity) { - + //----------------------------------------------------------------------------- + //* Prolonged coarse scale field + //----------------------------------------------------------------------------- + PAQ * FieldManager::prolonged_field(FieldName field) + { + PAQ * quantity = interscaleManager_.per_atom_quantity(field_to_prolongation_name(field)); + if (!quantity) { + DENS_MAN * coarseQuantity = interscaleManager_.dense_matrix(field_to_string(field)); - if (!coarseQuantity) coarseQuantity = nodal_atomic_field(field); - if (!coarseQuantity) throw ATC_Error("can not prolong quantity: " + field_to_string(field) + " no field registered"); - if (atc_->kernel_on_the_fly()) { - quantity = new OnTheFlyShapeFunctionProlongation(atc_, - coarseQuantity,atc_->atom_coarsegraining_positions()); - } else { - quantity = new FtaShapeFunctionProlongation(atc_, - coarseQuantity,atc_->interpolant()); - } - interscaleManager_.add_per_atom_quantity(quantity, - field_to_prolongation_name(field)); - } - return quantity; - } - + if (!coarseQuantity) coarseQuantity = nodal_atomic_field(field); + if (!coarseQuantity) throw ATC_Error("can not prolong quantity: " + field_to_string(field) + " no field registered"); + if (atc_->kernel_on_the_fly()) { + quantity = new OnTheFlyShapeFunctionProlongation(atc_, + coarseQuantity,atc_->atom_coarsegraining_positions()); + } else { + quantity = new FtaShapeFunctionProlongation(atc_, + coarseQuantity,atc_->interpolant()); + } + interscaleManager_.add_per_atom_quantity(quantity, + field_to_prolongation_name(field)); + } + return quantity; + } } diff --git a/lib/atc/FieldManager.h b/lib/atc/FieldManager.h index 903b57b8d247ce61124ee46f4a29f58d6fc8edd7..d3db3f268a65da6546c417245bd0fd500e40f610 100644 --- a/lib/atc/FieldManager.h +++ b/lib/atc/FieldManager.h @@ -1,6 +1,8 @@ #ifndef FIELD_MANAGER_H #define FIELD_MANAGER_H +#include <string> + #include "ATC_TypeDefs.h" #include "ATC_Error.h" #include "PerAtomQuantity.h" @@ -23,8 +25,9 @@ namespace ATC { public: FieldManager(ATC_Method * atc); virtual ~FieldManager(void){}; + /** this function returns a (density) field derived from atomic data */ DENS_MAN * nodal_atomic_field(FieldName fieldName, - string name = "default") { + std::string name = "default") { switch (fieldName) { case CHARGE_DENSITY: return charge_density(name); case MASS_DENSITY: return mass_density(name); @@ -42,10 +45,12 @@ namespace ATC { case KINETIC_TEMPERATURE: return kinetic_temperature(name); case CHARGE_FLUX: return charge_flux(name); case SPECIES_FLUX: return species_flux(name); + case INTERNAL_ENERGY: return internal_energy(name); + case ENERGY: return energy(name); default: throw ATC_Error("FieldManager:: unknown field"); return NULL; } } - CanonicalName string_to_canonical_name(string name){ + CanonicalName string_to_canonical_name(std::string name){ if (name == "AtomicTwiceFluctuatingKineticEnergy") return ATOMIC_TWICE_FLUCTUATING_KINETIC_ENERGY; else if (name == "AtomicTwiceKineticEnergy") @@ -63,7 +68,7 @@ namespace ATC { else throw ATC_Error("unknown canonical name "+name); } - PAQ * per_atom_quantity(string name) { + PAQ * per_atom_quantity(std::string name) { switch (string_to_canonical_name(name)) { case ATOMIC_TWICE_FLUCTUATING_KINETIC_ENERGY: return atomic_twice_fluctuating_kinetic_energy(); @@ -81,27 +86,30 @@ namespace ATC { throw ATC_Error("FieldManager:: unknown PAQ"); return NULL; } } - DENS_MAN * restricted_atom_quantity(FieldName field, string name = "default", PAQ * atomi = NULL); + /** this function returns a restriction of atomic data */ + DENS_MAN * restricted_atom_quantity(FieldName field, std::string name = "default", PAQ * atomi = NULL); protected: ATC_Method * atc_; InterscaleManager & interscaleManager_; // nodal atomic fields - DENS_MAN * charge_density(string name); - DENS_MAN * mass_density(string name); - DENS_MAN * species_concentration(string name); - DENS_MAN * number_density(string name); - DENS_MAN * momentum(string name); - DENS_MAN * velocity(string name); - DENS_MAN * projected_velocity(string name); - DENS_MAN * displacement(string name); - DENS_MAN * reference_potential_energy(string name); - DENS_MAN * potential_energy(string name); - DENS_MAN * thermal_energy(string name); - DENS_MAN * kinetic_energy(string name); - DENS_MAN * temperature(string name); - DENS_MAN * kinetic_temperature(string name); - DENS_MAN * charge_flux(string name); - DENS_MAN * species_flux(string name); + DENS_MAN * charge_density(std::string name); + DENS_MAN * mass_density(std::string name); + DENS_MAN * species_concentration(std::string name); + DENS_MAN * number_density(std::string name); + DENS_MAN * momentum(std::string name); + DENS_MAN * velocity(std::string name); + DENS_MAN * projected_velocity(std::string name); + DENS_MAN * displacement(std::string name); + DENS_MAN * reference_potential_energy(std::string name); + DENS_MAN * potential_energy(std::string name); + DENS_MAN * thermal_energy(std::string name); + DENS_MAN * kinetic_energy(std::string name); + DENS_MAN * temperature(std::string name); + DENS_MAN * kinetic_temperature(std::string name); + DENS_MAN * charge_flux(std::string name); + DENS_MAN * species_flux(std::string name); + DENS_MAN * internal_energy(std::string name); + DENS_MAN * energy(std::string name); // non intrinsic per atom quantities (intrinsic are handled elsewhere) PAQ * atomic_twice_kinetic_energy(); @@ -112,10 +120,10 @@ namespace ATC { PAQ * atomic_species_vector(); // internal functions - DENS_MAN * projected_atom_quantity(FieldName field,string name, PAQ * atomic, FieldName massMat, DIAG_MAN * normalization = NULL); - DENS_MAN * scaled_projected_atom_quantity(FieldName field,string name, PAQ * atomic, double scale, FieldName massMat, DIAG_MAN * normalization = NULL); - DENS_MAN * referenced_projected_atom_quantity(FieldName field, string name, PAQ * atomic, const DENS_MAT * reference, FieldName massMat, DIAG_MAN * normalization = NULL); - DENS_MAN * inferred_atom_quantity(FieldName field, string name, PAQ * atomic, FieldName massMat){return NULL;}; + DENS_MAN * projected_atom_quantity(FieldName field,std::string name, PAQ * atomic, DIAG_MAN * normalization = NULL); + DENS_MAN * scaled_projected_atom_quantity(FieldName field,std::string name, PAQ * atomic, double scale, DIAG_MAN * normalization = NULL); + DENS_MAN * referenced_projected_atom_quantity(FieldName field, std::string name, PAQ * atomic, DENS_MAN * reference, DIAG_MAN * normalization = NULL); + DENS_MAN * inferred_atom_quantity(FieldName field, std::string name, PAQ * atomic){return NULL;}; PAQ * prolonged_field(FieldName field); private: FieldManager(void); diff --git a/lib/atc/Function.cpp b/lib/atc/Function.cpp index beb3d2a3af768830727a0cab2d675d22cf678a72..36d3e9a090fa03f5fee24402e442afb9df1629fc 100644 --- a/lib/atc/Function.cpp +++ b/lib/atc/Function.cpp @@ -3,6 +3,11 @@ #include "LammpsInterface.h" #include <sstream> +using std::stringstream; +using std::string; +using std::set; +using std::fstream; + namespace ATC { //==================================================================== diff --git a/lib/atc/Function.h b/lib/atc/Function.h index 6c015f50713565745af8cb62c1d504689a582642..45d5d7220a3f0abe8e894207097bc5da42fa3dc8 100644 --- a/lib/atc/Function.h +++ b/lib/atc/Function.h @@ -10,9 +10,6 @@ #include "Array.h" #include "ATC_TypeDefs.h" -using namespace std; -using ATC_matrix::Array; - namespace ATC { /** @@ -20,14 +17,13 @@ namespace ATC { * @brief Base class for functions of fields, space and time */ - class Function { public: Function(int nargs, char** args); virtual ~Function(void) {}; /** name */ - const string & tag() { return tag_;} + const std::string & tag() { return tag_;} /** depdendencies */ virtual inline ARG_NAMES args(void) {ARG_NAMES names; return names;}; @@ -44,7 +40,7 @@ namespace ATC { protected: /** tag : name of function */ - string tag_; + std::string tag_; }; /** @@ -64,7 +60,7 @@ namespace ATC { private: static Function_Mgr * myInstance_; /** set to store all generated objects for later deletion */ - set<Function * > pointerSet_; + std::set<Function * > pointerSet_; }; @@ -95,7 +91,7 @@ namespace ATC { UXT_Function(int nargs, double* args); virtual ~UXT_Function(void) {}; - const string & tag() { return tag_;} + const std::string & tag() { return tag_;} /** function value */ virtual inline double f(double * u, double* x, double t) {return 0.0;}; @@ -104,7 +100,7 @@ namespace ATC { protected: /** tag : name of function */ - string tag_; + std::string tag_; }; /** @@ -118,7 +114,7 @@ namespace ATC { /** Static instance of this class */ static UXT_Function_Mgr * instance(); - UXT_Function* function(string & type, int nargs, double * arg); + UXT_Function* function(std::string & type, int nargs, double * arg); UXT_Function* function(char ** arg, int nargs); UXT_Function* linear_function(double c0, double c1); UXT_Function* copy_UXT_function(UXT_Function* other); @@ -128,7 +124,7 @@ namespace ATC { private: static UXT_Function_Mgr * myInstance_; /** set to store all generated objects for later deletion */ - set<UXT_Function * > pointerSet_; + std::set<UXT_Function * > pointerSet_; }; @@ -161,7 +157,7 @@ namespace ATC { XT_Function(int nargs, double* args); virtual ~XT_Function(void) {}; - const string & tag() { return tag_;} + const std::string & tag() { return tag_;} /** function value */ virtual inline double f(double* x, double t) {return 0.0;}; @@ -176,7 +172,7 @@ namespace ATC { /** mask : masks x,y,z dependence, x0 : origin */ double mask[3], x0[3]; /** tag : name of function */ - string tag_; + std::string tag_; }; /** @@ -189,7 +185,7 @@ namespace ATC { /** Static instance of this class */ static XT_Function_Mgr * instance(); - XT_Function* function(string & type, int nargs, double * arg); + XT_Function* function(std::string & type, int nargs, double * arg); XT_Function* function(char ** arg, int nargs); XT_Function* constant_function(double c); XT_Function* copy_XT_function(XT_Function* other); @@ -199,7 +195,7 @@ namespace ATC { private: static XT_Function_Mgr * myInstance_; /** set to store all generated objects for later deletion */ - set<XT_Function * > pointerSet_; + std::set<XT_Function * > pointerSet_; }; @@ -412,7 +408,7 @@ namespace ATC { virtual ~InterpolationFunction(void) {}; /** populate data */ - void initialize(int npts,fstream &fileId, double coef = 1.); + void initialize(int npts,std::fstream &fileId, double coef = 1.); /** function value */ double f(const double t) const; diff --git a/lib/atc/FundamentalAtomicQuantity.cpp b/lib/atc/FundamentalAtomicQuantity.cpp index 025e38f7d49e395f58da59499b3e194923aac3a5..0ebb54e16803803d4e2a4546f0b1dc74bbdc981d 100644 --- a/lib/atc/FundamentalAtomicQuantity.cpp +++ b/lib/atc/FundamentalAtomicQuantity.cpp @@ -1,5 +1,7 @@ #include "FundamentalAtomicQuantity.h" +using std::string; + namespace ATC { //-------------------------------------------------------- diff --git a/lib/atc/FundamentalAtomicQuantity.h b/lib/atc/FundamentalAtomicQuantity.h index 04f0e5b1501d5d31d3a7b399dc2fb3c83a56f829..46b3c4b00312db1bb108d3264c378591111aa3fd 100644 --- a/lib/atc/FundamentalAtomicQuantity.h +++ b/lib/atc/FundamentalAtomicQuantity.h @@ -3,10 +3,9 @@ #ifndef FUNDAMENTAL_ATOM_QUANTITY_H #define FUNDAMENTAL_ATOM_QUANTITY_H -// ATC_Method headers -#include "PerAtomQuantity.h" +#include <string> -using namespace std; +#include "PerAtomQuantity.h" namespace ATC { @@ -161,7 +160,7 @@ namespace ATC { // constructor ComputedAtomQuantity(ATC_Method * atc, - const string & tag, + const std::string & tag, double unitsConversion = 1., AtomType atomType=INTERNAL); @@ -224,7 +223,7 @@ namespace ATC { COMPUTE_POINTER computePointer_; /** tag for Lammps compute */ - string computeTag_; + std::string computeTag_; /** units conversion from LAMMPS to ATC units */ double unitsConversion_; diff --git a/lib/atc/GhostManager.cpp b/lib/atc/GhostManager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f722a2fa2781232c8037db71626c4eed0e1a2dfb --- /dev/null +++ b/lib/atc/GhostManager.cpp @@ -0,0 +1,499 @@ +// ATC transfer headers +#include "GhostManager.h" +#include "ATC_Method.h" +#include "LammpsInterface.h" +#include "ATC_Error.h" + +namespace ATC { + + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class GhostManager + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + GhostManager::GhostManager(ATC_Method * atc) : + ghostModifier_(NULL), + atc_(atc), + boundaryDynamics_(NO_BOUNDARY_DYNAMICS), + needReset_(true), + kappa_(0.), + gamma_(0.), + mu_(0.) + { + // do nothing + } + + //-------------------------------------------------------- + // Destructor + //-------------------------------------------------------- + GhostManager::~GhostManager() + { + if (ghostModifier_) delete ghostModifier_; + } + + //-------------------------------------------------------- + // modify + // parses inputs and modifies state of the integrator + //-------------------------------------------------------- + bool GhostManager::modify(int narg, char **arg) + { + int argIndex = 0; + + /*! \page man_boundary_dynamics fix_modify AtC boundary_dynamics + \section syntax + fix_modify AtC boundary_dynamics < on | damped_harmonic | prescribed | coupled | none > [args] \n + \section description + Sets different schemes for controlling boundary atoms. On will integrate the boundary atoms using the velocity-verlet algorithm. Damped harmonic uses a mass/spring/dashpot for the boundary atoms with added arguments of the damping and spring constants followed by the ratio of the boundary type mass to the desired mass. Prescribed forces the boundary atoms to follow the finite element displacement. Coupled does the same. + \section restrictions + Boundary atoms must be specified. When using swaps between internal and boundary atoms, the initial configuration must have already correctly partitioned the two. + \section related + \man_boundary + \section default + prescribed + on + */ + if (strcmp(arg[argIndex],"none")==0) { + boundaryDynamics_ = NO_BOUNDARY_DYNAMICS; + needReset_ = true; + return true; + } + else if (strcmp(arg[argIndex],"on")==0) { + boundaryDynamics_ = VERLET; + needReset_ = true; + return true; + } + else if (strcmp(arg[argIndex],"prescribed")==0) { + boundaryDynamics_ = PRESCRIBED; + needReset_ = true; + return true; + } + else if (strcmp(arg[argIndex],"damped_harmonic")==0) { + argIndex++; + kappa_ = atof(arg[argIndex++]); + gamma_ = atof(arg[argIndex++]); + mu_ = atof(arg[argIndex]); + boundaryDynamics_ = DAMPED_HARMONIC; + needReset_ = true; + return true; + } + else if (strcmp(arg[argIndex],"coupled")==0) { + boundaryDynamics_ = COUPLED; + kappa_ = 0.; + gamma_ = 0.; + mu_ = 0.; + needReset_ = true; + return true; + } + + return false; + } + + //-------------------------------------------------------- + // construct_methods + // constructs the specific method to modify the ghosts + //-------------------------------------------------------- + void GhostManager::construct_methods() + { + if (ghostModifier_) { + delete ghostModifier_; + ghostModifier_ = NULL; + } + + if (!atc_->groupbit_ghost()) { + ghostModifier_ = new GhostModifier(this); + return; + } + + switch (boundaryDynamics_) { + case VERLET: { + ghostModifier_ = new GhostModifier(this); + ghostModifier_->set_integrate_atoms(true); + break; + } + case PRESCRIBED: { + ghostModifier_ = new GhostModifierPrescribed(this); + break; + } + case COUPLED: + case DAMPED_HARMONIC: { + ghostModifier_ = new GhostModifierDampedHarmonic(this,kappa_,gamma_,mu_); + ghostModifier_->set_integrate_atoms(true); + break; + } + case SWAP: { + // if regions based on element sets, use verlet on ghosts and swap ghosts and internal when they move between regions + const std::string & internalElementSet(atc_->internal_element_set()); + if (internalElementSet.size() && (atc_->atom_to_element_map_type()==EULERIAN)) { + LammpsInterface * lammpsInterface = LammpsInterface::instance(); + if (atc_->atom_to_element_map_frequency() % lammpsInterface->reneighbor_frequency() != 0) { + throw ATC_Error("GhostManager::construct_methods - eulerian frequency and lammsp reneighbor frequency must be consistent to swap boundary and internal atoms"); + } + ghostModifier_ = new GhostIntegratorSwap(this); + } + break; + } + case SWAP_VERLET: { + // if regions based on element sets, use verlet on ghosts and swap ghosts and internal when they move between regions + const std::string & internalElementSet(atc_->internal_element_set()); + if (internalElementSet.size() && (atc_->atom_to_element_map_type()==EULERIAN)) { + LammpsInterface * lammpsInterface = LammpsInterface::instance(); + if (atc_->atom_to_element_map_frequency() % lammpsInterface->reneighbor_frequency() != 0) { + throw ATC_Error("GhostManager::construct_methods - eulerian frequency and lammsp reneighbor frequency must be consistent to swap boundary and internal atoms"); + } + ghostModifier_ = new GhostIntegratorSwap(this); + ghostModifier_->set_integrate_atoms(true); + } + break; + } + default: { + ghostModifier_ = new GhostModifier(this); + } + } + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void GhostManager::construct_transfers() + { + ghostModifier_->construct_transfers(); + } + + //-------------------------------------------------------- + // initialize + // initialize all data and variables before a run + //-------------------------------------------------------- + void GhostManager::initialize() + { + ghostModifier_->initialize(); + needReset_ = false; + } + + //-------------------------------------------------------- + // pre_exchange + // makes any updates required before lammps exchanges + // atoms + //-------------------------------------------------------- + void GhostManager::pre_exchange() + { + ghostModifier_->pre_exchange(); + } + + //-------------------------------------------------------- + // initial_integrate_velocity + // velocity update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostManager::init_integrate_velocity(double dt) + { + ghostModifier_->init_integrate_velocity(dt); + } + + //-------------------------------------------------------- + // initial_integrate_position + // position update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostManager::init_integrate_position(double dt) + { + ghostModifier_->init_integrate_position(dt); + } + + //-------------------------------------------------------- + // post_init_integrate + // makes any updates required after first integration + //-------------------------------------------------------- + void GhostManager::post_init_integrate() + { + ghostModifier_->post_init_integrate(); + } + + //-------------------------------------------------------- + // final_integrate + // velocity update in second part of velocity-verlet + //-------------------------------------------------------- + void GhostManager::final_integrate(double dt) + { + ghostModifier_->final_integrate(dt); + } + + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class GhostModifier + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + GhostModifier::GhostModifier(GhostManager * ghostManager) : + ghostManager_(ghostManager), + atomTimeIntegrator_(NULL), + integrateAtoms_(false) + { + // do nothing + } + + //-------------------------------------------------------- + // Destructor + //-------------------------------------------------------- + GhostModifier::~GhostModifier() + { + if (atomTimeIntegrator_) delete atomTimeIntegrator_; + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void GhostModifier::construct_transfers() + { + if (atomTimeIntegrator_) delete atomTimeIntegrator_; + if (integrateAtoms_) { + atomTimeIntegrator_ = new AtomTimeIntegratorType(ghostManager_->atc(),GHOST); + atomTimeIntegrator_->construct_transfers(); + } + else { + atomTimeIntegrator_ = new AtomTimeIntegrator(); + } + + } + + //-------------------------------------------------------- + // initial_integrate_velocity + // velocity update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostModifier::init_integrate_velocity(double dt) + { + atomTimeIntegrator_->init_integrate_velocity(dt); + } + + //-------------------------------------------------------- + // initial_integrate_position + // position update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostModifier::init_integrate_position(double dt) + { + atomTimeIntegrator_->init_integrate_position(dt); + } + + //-------------------------------------------------------- + // final_integrate + // velocity update in second part of velocity-verlet + //-------------------------------------------------------- + void GhostModifier::final_integrate(double dt) + { + atomTimeIntegrator_->final_integrate(dt); + } + + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class GhostModifierPrescribed + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + GhostModifierPrescribed::GhostModifierPrescribed(GhostManager * ghostManager) : + GhostModifier(ghostManager), + atomPositions_(NULL), + atomFeDisplacement_(NULL), + atomRefPositions_(NULL) + { + // do nothing + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void GhostModifierPrescribed::construct_transfers() + { + GhostModifier::construct_transfers(); + + InterscaleManager & interscaleManager((ghostManager_->atc())->interscale_manager()); + atomPositions_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION,GHOST); + + // prolongation from displacement field to atoms + PerAtomSparseMatrix<double> * atomShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost"); + if (!atomShapeFunctions) { + atomShapeFunctions = new PerAtomShapeFunction(ghostManager_->atc(), + interscaleManager.per_atom_quantity("AtomicGhostCoarseGrainingPositions"), + interscaleManager.per_atom_int_quantity("AtomGhostElement"), + GHOST); + interscaleManager.add_per_atom_sparse_matrix(atomShapeFunctions,"InterpolantGhost"); + } + atomFeDisplacement_ = new FtaShapeFunctionProlongation(ghostManager_->atc(), + &(ghostManager_->atc())->field(DISPLACEMENT), + atomShapeFunctions, + GHOST); + interscaleManager.add_per_atom_quantity(atomFeDisplacement_,field_to_prolongation_name(DISPLACEMENT)+"Ghost"); + + atomRefPositions_ = interscaleManager.per_atom_quantity("AtomicGhostCoarseGrainingPositions"); + } + + //-------------------------------------------------------- + // post_init_integrate + // after integration, fix ghost atoms' positions + //-------------------------------------------------------- + void GhostModifierPrescribed::post_init_integrate() + { + const DENS_MAT & atomFeDisplacement(atomFeDisplacement_->quantity()); + const DENS_MAT & atomRefPositions(atomRefPositions_->quantity()); + *atomPositions_ = atomFeDisplacement + atomRefPositions; + } + + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class GhostModifierDampedHarmonic + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + GhostModifierDampedHarmonic::GhostModifierDampedHarmonic(GhostManager * ghostManager, + double kappa, + double gamma, double mu) : + GhostModifierPrescribed(ghostManager), + atomVelocities_(NULL), + atomFeVelocity_(NULL), + atomForces_(NULL), + kappa_(kappa), + gamma_(gamma), + mu_(mu) + { + // do nothing + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void GhostModifierDampedHarmonic::construct_transfers() + { + GhostModifierPrescribed::construct_transfers(); + + InterscaleManager & interscaleManager((ghostManager_->atc())->interscale_manager()); + atomVelocities_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY,GHOST); + atomForces_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE,GHOST); + + // prolongation from displacement field to atoms + PerAtomSparseMatrix<double> * atomShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost"); + atomFeVelocity_ = new FtaShapeFunctionProlongation(ghostManager_->atc(), + &(ghostManager_->atc())->field(VELOCITY), + atomShapeFunctions, + GHOST); + interscaleManager.add_per_atom_quantity(atomFeVelocity_,field_to_prolongation_name(VELOCITY)+"Ghost"); + } + + //-------------------------------------------------------- + // initial_integrate_velocity + // velocity update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostModifierDampedHarmonic::init_integrate_velocity(double dt) + { + atomTimeIntegrator_->init_integrate_velocity(mu_*dt); + } + + //-------------------------------------------------------- + // initial_integrate_position + // position update in first part of velocity-verlet + //-------------------------------------------------------- + void GhostModifierDampedHarmonic::init_integrate_position(double dt) + { + atomTimeIntegrator_->init_integrate_position(dt); + } + + //-------------------------------------------------------- + // final_integrate + // velocity update in second part of velocity-verlet + //-------------------------------------------------------- + void GhostModifierDampedHarmonic::final_integrate(double dt) + { + + const DENS_MAT & atomPositions(atomPositions_->quantity()); + const DENS_MAT & atomVelocities(atomVelocities_->quantity()); + const DENS_MAT & atomFeDisplacement(atomFeDisplacement_->quantity()); + const DENS_MAT & atomFeVelocity(atomFeVelocity_->quantity()); + const DENS_MAT & atomRefPositions(atomRefPositions_->quantity()); + + _forces_ = atomFeDisplacement; + _forces_ += atomRefPositions; + _forces_ -= atomPositions; + _forces_ *= kappa_; + _forces_ += gamma_*(atomFeVelocity - atomVelocities); + *atomForces_ = _forces_; + + atomTimeIntegrator_->final_integrate(mu_*dt); + } + + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class GhostIntegratorVerletSwap + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + GhostIntegratorSwap::GhostIntegratorSwap(GhostManager * ghostManager) : + GhostModifier(ghostManager), + lammpsInterface_(LammpsInterface::instance()), + elementSet_((((ghostManager_->atc())->fe_engine())->fe_mesh())->elementset((ghostManager_->atc())->internal_element_set())), + atomElement_(NULL), + atomGhostElement_(NULL), + internalToAtom_((ghostManager_->atc())->internal_to_atom_map()), + ghostToAtom_((ghostManager_->atc())->ghost_to_atom_map()), + groupbit_((ghostManager_->atc())->groupbit()), + groupbitGhost_((ghostManager_->atc())->groupbit_ghost()) + { + // do nothing + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void GhostIntegratorSwap::construct_transfers() + { + GhostModifier::construct_transfers(); + + InterscaleManager & interscaleManager((ghostManager_->atc())->interscale_manager()); + atomElement_ = interscaleManager.per_atom_int_quantity("AtomElement"); + atomGhostElement_ = interscaleManager.per_atom_int_quantity("AtomGhostElement"); + } + + //-------------------------------------------------------- + // initialize + // initialize all data and variables before a run + //-------------------------------------------------------- + void GhostIntegratorSwap::initialize() + { + if ((ghostManager_->atc())->atom_to_element_map_frequency() % lammpsInterface_->reneighbor_frequency() != 0) { + throw ATC_Error("GhostIntegratorSwap::initialize - AtC Eulerian reset frequency must be a multiple of the Lammps reneighbor frequency when using internal/boundary atom swapping"); + } + } + + //-------------------------------------------------------- + // pre_exchange + // swaps atoms between types depending on region + //-------------------------------------------------------- + void GhostIntegratorSwap::pre_exchange() + { + // lammps mask to change type + int * mask = lammpsInterface_->atom_mask(); + + const DenseMatrix<int> & atomElement(atomElement_->quantity()); + for (int i = 0; i < atomElement.nRows(); ++i) { + if (elementSet_.find(atomElement(i,0)) == elementSet_.end()) { + mask[internalToAtom_(i)] |= groupbitGhost_; + // remove from internal + } + } + } +}; diff --git a/lib/atc/GhostManager.h b/lib/atc/GhostManager.h new file mode 100644 index 0000000000000000000000000000000000000000..dcacdbd3a0e00a49536838faa4ae276bc84a0bf5 --- /dev/null +++ b/lib/atc/GhostManager.h @@ -0,0 +1,327 @@ +#ifndef GHOST_MANAGER_H +#define GHOST_MANAGER_H + +// ATC headers +#include "MatrixLibrary.h" +#include "PerAtomQuantityLibrary.h" +#include "TimeIntegrator.h" +#include "ATC_TypeDefs.h" + +namespace ATC { + + // forward declarations + class ATC_Method; + class GhostModifier; + class LammpsInterface; + + /** + * @class GhostManager + * @brief Manages methods for modifying ghost atoms + */ + + class GhostManager { + + public: + + /** types of ghost boundary conditions in momentum */ + enum BoundaryDynamicsType { + NO_BOUNDARY_DYNAMICS=0, + VERLET, + PRESCRIBED, + DAMPED_HARMONIC, + COUPLED, + SWAP, + SWAP_VERLET + }; + + // constructor + GhostManager(ATC_Method * atc); + + // destructor + virtual ~GhostManager(); + + /** parser/modifier */ + virtual bool modify(int narg, char **arg); + + /** create objects to implement requested numerical method */ + virtual void construct_methods(); + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** pre time integration initialization of data */ + virtual void initialize(); + + /** prior to lammps exchange */ + virtual void pre_exchange(); + + /** Predictor phase, Verlet first step for velocity */ + virtual void init_integrate_velocity(double dt); + + /** Predictor phase, Verlet first step for position */ + virtual void init_integrate_position(double dt); + + /** set positions after integration */ + virtual void post_init_integrate(); + + /** Corrector phase, Verlet second step for velocity */ + virtual void final_integrate(double dt); + + /** sets the boundary dynamics flag as desired */ + void set_boundary_dynamics(BoundaryDynamicsType boundaryDynamics) {boundaryDynamics_ = boundaryDynamics;} + + /** flag for reset */ + bool need_reset() const {return needReset_;}; + + /** access to ATC method object */ + ATC_Method * atc() {return atc_;}; + + protected: + + /** pointer to routines that modify ghosts */ + GhostModifier* ghostModifier_; + + /** pointer to access ATC methods */ + ATC_Method * atc_; + + /** boundary dynamics method type */ + BoundaryDynamicsType boundaryDynamics_; + + /** flag for reset */ + bool needReset_; + + /** spring constant for some models */ + double kappa_; + + /** damping constant for some models */ + double gamma_; + + /** ratio between mass of ghost types and desired mass for some models */ + double mu_; + + private: + + // DO NOT define this + GhostManager(); + + }; + + /** + * @class GhostModifier + * @brief Base class for objects which modify the ghost atoms, integrates ghost atoms using velocity-verlet if requested + */ + + class GhostModifier { + + public: + + // constructor + GhostModifier(GhostManager * ghostManager); + + // destructor + virtual ~GhostModifier(); + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** pre time integration initialization of data */ + virtual void initialize(){}; + + /** Predictor phase, Verlet first step for velocity */ + virtual void init_integrate_velocity(double dt); + + /** Predictor phase, Verlet first step for position */ + virtual void init_integrate_position(double dt); + + /** set positions after integration */ + virtual void post_init_integrate(){}; + + /** prior to lammps exchange */ + virtual void pre_exchange(){}; + + /** Corrector phase, Verlet second step for velocity */ + virtual void final_integrate(double dt); + + /** sets the verlet integration flag as desired */ + void set_integrate_atoms(bool integrateAtoms) {integrateAtoms_ = integrateAtoms;} + + protected: + + /** owning ghost manager */ + GhostManager * ghostManager_; + + /** object which integrates atoms */ + AtomTimeIntegrator * atomTimeIntegrator_; + + /** flag to perform velocity-verlet integration of ghosts */ + bool integrateAtoms_; + + + private: + + // DO NOT define this + GhostModifier(); + + }; + + /** + * @class GhostModifierPrescribed + * @brief sets ghost atom positions based on FE displacement + */ + + class GhostModifierPrescribed : public GhostModifier { + + public: + + // constructor + GhostModifierPrescribed(GhostManager * ghostManager); + + // destructor + virtual ~GhostModifierPrescribed(){}; + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** set positions after integration */ + virtual void post_init_integrate(); + + protected: + + /** positions of atoms */ + PerAtomQuantity<double> * atomPositions_; + + /** FE displacement at ghost locations */ + PerAtomQuantity<double> * atomFeDisplacement_; + + /** atom reference positions */ + PerAtomQuantity<double> * atomRefPositions_; + + private: + + // DO NOT define this + GhostModifierPrescribed(); + + }; + + /** + * @class GhostModifierDampedHarmonic + * @brief Integrates ghost atoms using velocity-verlet with a damped harmonic force + */ + + class GhostModifierDampedHarmonic : public GhostModifierPrescribed { + + public: + + // constructor + GhostModifierDampedHarmonic(GhostManager * ghostManager, + double kappa_, double gamma, double mu); + + // destructor + virtual ~GhostModifierDampedHarmonic(){}; + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** Predictor phase, Verlet first step for velocity */ + virtual void init_integrate_velocity(double dt); + + /** Predictor phase, Verlet first step for position */ + virtual void init_integrate_position(double dt); + + /** set positions after integration */ + virtual void post_init_integrate(){}; + + /** Corrector phase, Verlet second step for velocity */ + virtual void final_integrate(double dt); + + protected: + + /** velocities of atoms */ + PerAtomQuantity<double> * atomVelocities_; + + /** FE velocity at ghost locations */ + PerAtomQuantity<double> * atomFeVelocity_; + + /** atom forces */ + PerAtomQuantity<double> * atomForces_; + + /** spring constant */ + double kappa_; + + /** damping constant */ + double gamma_; + + /** ratio between mass of ghost types and desired mass */ + double mu_; + + // workspace + DENS_MAT _forces_; + + private: + + // DO NOT define this + GhostModifierDampedHarmonic(); + + }; + + /** + * @class GhostIntegratorSwap + * @brief Integrates ghost atoms using velocity-verlet, and swaps atoms between ghost + * and internal depending on what element they are in + */ + + class GhostIntegratorSwap : public GhostModifier { + + public: + + // constructor + GhostIntegratorSwap(GhostManager * ghostManager); + + // destructor + virtual ~GhostIntegratorSwap(){}; + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** pre time integration initialization of data */ + virtual void initialize(); + + /** prior to lammps exchange */ + virtual void pre_exchange(); + + protected: + + /** pointer to lammps interface */ + LammpsInterface * lammpsInterface_; + + /** internal element set */ + const std::set<int> & elementSet_; + + /** internal to element map */ + PerAtomQuantity<int> * atomElement_; + + /** ghost to element map */ + PerAtomQuantity<int> * atomGhostElement_; + + /** internal to atom map */ + const Array<int> & internalToAtom_; + + /** ghost to atom map */ + const Array<int> & ghostToAtom_; + + /** group bit for internal */ + int groupbit_; + + /** group bit for ghost */ + int groupbitGhost_; + + private: + + // DO NOT define this + GhostIntegratorSwap(); + + }; + + +}; +#endif diff --git a/lib/atc/InterscaleOperators.cpp b/lib/atc/InterscaleOperators.cpp index 15facf9196a6d2eac30725ccc0d09b022570275b..28762b9772f648a4b995f641e9db48c23d9a4f2d 100644 --- a/lib/atc/InterscaleOperators.cpp +++ b/lib/atc/InterscaleOperators.cpp @@ -6,6 +6,10 @@ #include "ATC_Method.h" //#include <typeinfo> +using std::set; +using std::map; +using std::string; + namespace ATC{ //-------------------------------------------------------- @@ -550,6 +554,7 @@ namespace ATC{ post_exchange_loop(perAtomDiagonalMatrices_); post_exchange_loop(perAtomSparseMatrices_); post_exchange_loop(smallMoleculeSets_); + post_exchange_loop(pairMaps_); } //-------------------------------------------------------- diff --git a/lib/atc/InterscaleOperators.h b/lib/atc/InterscaleOperators.h index e4a4525a1b744007d38f3b3e58c8e21c407d84d1..20d16de9c502fe91f0bf8e9f693d888636cb76a5 100644 --- a/lib/atc/InterscaleOperators.h +++ b/lib/atc/InterscaleOperators.h @@ -4,7 +4,6 @@ #ifndef INTERSCALE_MANAGER_H #define INTERSCALE_MANAGER_H -// ATC_Transfer headers #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" #include "ATC_Error.h" @@ -14,8 +13,10 @@ #include "FundamentalAtomicQuantity.h" #include <vector> #include <map> +#include <set> +#include <string> +#include <utility> -using namespace std; namespace ATC { // forward declarations @@ -63,96 +64,96 @@ namespace ATC { FundamentalAtomQuantity * fundamental_atom_quantity(LammpsInterface::FundamentalAtomQuantity id, AtomType atomType = INTERNAL); /** access to double per atom quantities */ - PerAtomQuantity<double> * per_atom_quantity(const string & tag); + PerAtomQuantity<double> * per_atom_quantity(const std::string & tag); /** access to integer per atom quantities */ - PerAtomQuantity<int> * per_atom_int_quantity(const string & tag); + PerAtomQuantity<int> * per_atom_int_quantity(const std::string & tag); /** access to double per atom diagonal matrices */ - PerAtomDiagonalMatrix<double> * per_atom_diagonal_matrix(const string & tag); + PerAtomDiagonalMatrix<double> * per_atom_diagonal_matrix(const std::string & tag); /** access to double per atom sparse matrices */ - PerAtomSparseMatrix<double> * per_atom_sparse_matrix(const string & tag); + PerAtomSparseMatrix<double> * per_atom_sparse_matrix(const std::string & tag); /** access to pair maps */ - PairMap * pair_map(const string & tag); + PairMap * pair_map(const std::string & tag); // addition of new atom quantities, note provider must allocate but the manager will clean-up /** addition of a double atomic quantity */ void add_per_atom_quantity(PerAtomQuantity<double> * atomQuantity, - const string & tag); + const std::string & tag); /** addition of an integer atomic quantity */ void add_per_atom_int_quantity(PerAtomQuantity<int> * atomQuantity, - const string & tag); + const std::string & tag); /** addition of a double atomic diagonal matrix */ void add_per_atom_diagonal_matrix(PerAtomDiagonalMatrix<double> * atomQuantity, - const string & tag); + const std::string & tag); /** addition of a double atomic sparse matrix */ void add_per_atom_sparse_matrix(PerAtomSparseMatrix<double> * atomQuantity, - const string & tag); + const std::string & tag); /** addition of an pair map */ - void add_pair_map(PairMap * pairMap, const string & tag); + void add_pair_map(PairMap * pairMap, const std::string & tag); /** access to dense matrices */ - DENS_MAN * dense_matrix(const string & tag); + DENS_MAN * dense_matrix(const std::string & tag); /** addition of dense matrices */ void add_dense_matrix(DENS_MAN * denseMatrix, - const string & tag); + const std::string & tag); /** access integer dense matrices */ - MatrixDependencyManager<DenseMatrix, int> * dense_matrix_int(const string & tag); + MatrixDependencyManager<DenseMatrix, int> * dense_matrix_int(const std::string & tag); /** addition of integer dense matrices */ void add_dense_matrix_int(MatrixDependencyManager<DenseMatrix, int> * denseMatrix, - const string & tag); + const std::string & tag); /** access boolean dense matrices */ - MatrixDependencyManager<DenseMatrix, bool> * dense_matrix_bool(const string & tag); + MatrixDependencyManager<DenseMatrix, bool> * dense_matrix_bool(const std::string & tag); /** addition of boolean dense matrices */ void add_dense_matrix_bool(MatrixDependencyManager<DenseMatrix, bool> * denseMatrix, - const string & tag); + const std::string & tag); /** access to sparse matrices */ - SPAR_MAN * sparse_matrix(const string & tag); + SPAR_MAN * sparse_matrix(const std::string & tag); /** addition of a sparse matrix */ void add_sparse_matrix(SPAR_MAN * sparseMatrix, - const string & tag); + const std::string & tag); /** access to diagonal matrices */ - DIAG_MAN * diagonal_matrix(const string & tag); + DIAG_MAN * diagonal_matrix(const std::string & tag); /** addition of a diagonal matrix */ void add_diagonal_matrix(DIAG_MAN * diagonalMatrix, - const string & tag); + const std::string & tag); /** access to vectors of sparse matrices */ - VectorDependencyManager<SPAR_MAT * > * vector_sparse_matrix(const string & tag); + VectorDependencyManager<SPAR_MAT * > * vector_sparse_matrix(const std::string & tag); /** addition of a vector of sparse matrices */ void add_vector_sparse_matrix(VectorDependencyManager<SPAR_MAT * > * sparseMatrix, - const string & tag); + const std::string & tag); /** access to sets of ints */ - SetDependencyManager<int> * set_int(const string & tag); + SetDependencyManager<int> * set_int(const std::string & tag); /** addition of a set of ints */ void add_set_int(SetDependencyManager<int> * sparseMatrix, - const string & tag); + const std::string & tag); /** access to molecule sets */ - SmallMoleculeSet * small_molecule_set(const string & tag); + SmallMoleculeSet * small_molecule_set(const std::string & tag); /** addition of a transfer operator */ void add_small_molecule_set(SmallMoleculeSet * moleculeSet, - const string & tag); + const std::string & tag); /** addition of exchange list object */ - void add_to_exchange_list(const string & tag); + void add_to_exchange_list(const std::string & tag); /** searches through all lists to see if a tag is registered */ - DependencyManager * find(const string & tag); + DependencyManager * find(const std::string & tag); /** schedules a quantity for deletion, if it exists */ - void remove(const string & tag); + void remove(const std::string & tag); /** size communicated quantities initially */ void size_comm_quantities(); @@ -200,67 +201,67 @@ namespace ATC { bool initialized_; /** containers for fundamental atom quantities, set on request */ - vector<vector<FundamentalAtomQuantity* > > fundamentalAtomQuantities_; + std::vector<std::vector<FundamentalAtomQuantity* > > fundamentalAtomQuantities_; /** container for per-atom quantities using dense matrices of doubles */ - map<string, PerAtomQuantity<double> * > perAtomQuantities_; + std::map<std::string, PerAtomQuantity<double> * > perAtomQuantities_; /** container for integer atom quantities, set by AtC classes */ - map<string, PerAtomQuantity<int> * > perAtomIntQuantities_; + std::map<std::string, PerAtomQuantity<int> * > perAtomIntQuantities_; /** container for per-atom quantities using diagonal matrices of doubles */ - map<string, PerAtomDiagonalMatrix<double> * > perAtomDiagonalMatrices_; + std::map<std::string, PerAtomDiagonalMatrix<double> * > perAtomDiagonalMatrices_; /** container for per-atom quantities using sparse matrices of doubles */ - map<string, PerAtomSparseMatrix<double> * > perAtomSparseMatrices_; + std::map<std::string, PerAtomSparseMatrix<double> * > perAtomSparseMatrices_; /** container for pair maps */ - map<string, PairMap * > pairMaps_; + std::map<std::string, PairMap * > pairMaps_; /** container for dense matrices */ - map<string, DENS_MAN * > denseMatrices_; + std::map<std::string, DENS_MAN * > denseMatrices_; /** container for dense matrices for integer quantities */ - map<string, MatrixDependencyManager<DenseMatrix, int> * > denseMatricesInt_; + std::map<std::string, MatrixDependencyManager<DenseMatrix, int> * > denseMatricesInt_; /** container for dense matrces for boolean quantities */ - map<string, MatrixDependencyManager<DenseMatrix, bool> * > denseMatricesBool_; + std::map<std::string, MatrixDependencyManager<DenseMatrix, bool> * > denseMatricesBool_; /** container for sparse matrices */ - map<string, SPAR_MAN * > sparseMatrices_; + std::map<std::string, SPAR_MAN * > sparseMatrices_; /** container for diagonal matrices */ - map<string, DIAG_MAN * > diagonalMatrices_; + std::map<std::string, DIAG_MAN * > diagonalMatrices_; /** container for vectors of vectors of sparse matrices */ - map<string, VectorDependencyManager<SPAR_MAT * > * > vectorSparMat_; + std::map<std::string, VectorDependencyManager<SPAR_MAT * > * > vectorSparMat_; /** container for sets of integer quantities */ - map<string, SetDependencyManager<int> * > setInt_; + std::map<std::string, SetDependencyManager<int> * > setInt_; /** container for molecule sets */ - map<string, SmallMoleculeSet * > smallMoleculeSets_; + std::map<std::string, SmallMoleculeSet * > smallMoleculeSets_; /** container for atomic quantities which must be transfered when atoms cross processors */ - set<PerAtomQuantity<double> *> exchangeList_; + std::set<PerAtomQuantity<double> *> exchangeList_; /** container for atomic quantities which must be transfered to ghost atoms on other processors */ - vector<PerAtomQuantity<double> *> commList_; + std::vector<PerAtomQuantity<double> *> commList_; /** container for integer atomic quantities which must be transfered to ghost atoms on other processors */ - vector<PerAtomQuantity<int> *> commIntList_; + std::vector<PerAtomQuantity<int> *> commIntList_; /** container for atomic diagonal matrices which must be transfered to ghost atoms on other processors */ - vector<PerAtomDiagonalMatrix<double> *> commDmList_; + std::vector<PerAtomDiagonalMatrix<double> *> commDmList_; /** container for atomic sparse matrices which must be transfered to ghost atoms on other processors */ - vector<PerAtomSparseMatrix<double> *> commSmList_; + std::vector<PerAtomSparseMatrix<double> *> commSmList_; /** prefix for labeling associated lammps arrays */ - string prefix_; + std::string prefix_; /** order of deletion list of managed quantities */ - vector<DependencyManager * > deletionList_; + std::vector<DependencyManager * > deletionList_; /** creates a reverse sorted depth-first search list for deleting managed quantities */ void create_deletion_list(); @@ -270,27 +271,27 @@ namespace ATC { /** helper function to access a data entry in a list */ template <typename data> - data * return_quantity(map<string,data * > & list, const string & tag) + data * return_quantity(std::map<std::string,data * > & list, const std::string & tag) { - typename map<string,data * >::iterator it = list.find(tag); + typename std::map<std::string,data * >::iterator it = list.find(tag); if (it==list.end()) return NULL; return it->second; }; /** helper function to add a data entry to a list */ template <typename data> - void add_quantity(map<string,data * > & list, data * quantity, const string & tag) + void add_quantity(std::map<std::string,data * > & list, data * quantity, const std::string & tag) { - typename map<string,data * >::iterator it = list.find(tag); + typename std::map<std::string,data * >::iterator it = list.find(tag); if (it!=list.end()) throw ATC_Error("Tried to add another Quantity with tag "+tag+" in InterscaleManager::add_quantity"); - typename std::template pair<string,data * > myPair(tag,quantity); + typename std::template pair<std::string,data * > myPair(tag,quantity); list.insert(myPair); }; /** helper function to add a data entry to a list when it requires neighbor communication*/ template <typename data> - void add_comm_quantity(map<string,data * > & list, vector<data * > & commList, data * quantity, const string & tag) + void add_comm_quantity(std::map<std::string,data * > & list, std::vector<data * > & commList, data * quantity, const std::string & tag) { add_quantity(list,quantity,tag); // allocate data for parallel communication @@ -302,44 +303,44 @@ namespace ATC { /** helper function to fina a data entry in a list */ template <typename data> - data * find_in_list(map<string,data * > & list, const string & tag) + data * find_in_list(std::map<std::string,data * > & list, const std::string & tag) { - typename map<string,data * >::iterator it = list.find(tag); + typename std::map<std::string,data * >::iterator it = list.find(tag); if (it!=list.end()) return it->second; return NULL; }; /** helper function to force the reset of all data in a list */ template <typename data> - void force_reset_loop(map<string,data * > & list) + void force_reset_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) (it->second)->force_reset(); }; /** helper function to set the memory type to temporary of a list */ template <typename data> - void set_memory_temporary(map<string,data * > & list) + void set_memory_temporary(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) (it->second)->set_memory_type(TEMPORARY); }; /** helper function to perform intialization for dfs of a list */ template <typename data> - void dfs_prepare_loop(map<string,data * > & list) + void dfs_prepare_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) { + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) { (it->second)->dfsFound_ = false; } }; /** helper function to start the dfs visit for list */ template <typename data> - void dfs_visit_loop(map<string,data * > & list, + void dfs_visit_loop(std::map<std::string,data * > & list, int & index) { - typename map<string,data* >::iterator it = list.begin(); + typename std::map<std::string,data* >::iterator it = list.begin(); while (it != list.end()) { if (!((it->second)->dfsFound_)) index = dfs_visit(it->second,index); if ((it->second)->memory_type()==TEMPORARY) list.erase(it++); @@ -350,99 +351,102 @@ namespace ATC { // PAQ helper functions /** helper function to adjust local atom count for all data in a list before exchange, only valid with quantities that do that are aware of atom counts */ template <typename data> - void reset_nlocal_loop(map<string,data * > & list) + void reset_nlocal_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) { + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) { (it->second)->reset_nlocal(); } }; /** helper function to indicate lammps data is stale for all data in a list before exchange, only valid with PAQs */ template <typename data> - void lammps_reset_loop(map<string,data * > & list) + void lammps_reset_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) (it->second)->lammps_force_reset(); }; /** helper function to size all data in a list, only valid with comm lists */ template <typename data> - void size_comm_loop(vector<data * > & list) + void size_comm_loop(std::vector<data * > & list) { - for (typename vector<data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::vector<data* >::iterator it = list.begin(); it != list.end(); ++it) (*it)->quantity(); }; /** helper function to pack all data in a list before exchange, only valid with quantities that do work before parallel communication */ template <typename data> - void prepare_exchange_loop(map<string,data * > & list) + void prepare_exchange_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) { (it->second)->prepare_exchange(); + } }; /** helper function to extract all data in a list after exchange, only valid with quantities that do work after parallel communication */ template <typename data> - void post_exchange_loop(map<string,data * > & list) + void post_exchange_loop(std::map<std::string,data * > & list) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) { (it->second)->post_exchange(); + } }; /** helper function to determine memory usage of all data in a list, only valid with PAQs */ template <typename data> - void memory_usage_loop(const map<string,data * > & list, int & usage) const + void memory_usage_loop(const std::map<std::string,data * > & list, int & usage) const { - for (typename map<string,data* >::const_iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::const_iterator it = list.begin(); it != list.end(); ++it) usage += (it->second)->memory_usage(); }; /** helper function to pack arrays of all data before exchange in a list, only valid with PAQs */ template <typename data> - void pack_exchange_loop(map<string,data * > & list, int & index, int i, double *buffer) + void pack_exchange_loop(std::map<std::string,data * > & list, int & index, int i, double *buffer) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) { index += (it->second)->pack_exchange(i,&buffer[index]); + } }; /** helper function to unpack arrays of all data after exchange in a list, only valid with PAQs */ template <typename data> - void unpack_exchange_loop(map<string,data * > & list, int & index, int i, double *buffer) + void unpack_exchange_loop(std::map<std::string,data * > & list, int & index, int i, double *buffer) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) index += (it->second)->unpack_exchange(i,&buffer[index]); }; /** helper function to pack arrays of all data in a list, only valid with comm lists */ template <typename data> - void pack_comm_loop(vector<data * > & list, int & size, int index, double *buf, + void pack_comm_loop(std::vector<data * > & list, int & size, int index, double *buf, int pbc_flag, int *pbc) { - for (typename vector<data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::vector<data* >::iterator it = list.begin(); it != list.end(); ++it) size += (*it)->pack_comm(index,&buf[size],pbc_flag,pbc); }; /** helper function to unpack arrays of all data in a list, only valid with comm lists */ template <typename data> - void unpack_comm_loop(vector<data * > & list, int & size, int index, double *buf) + void unpack_comm_loop(std::vector<data * > & list, int & size, int index, double *buf) { - for (typename vector<data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::vector<data* >::iterator it = list.begin(); it != list.end(); ++it) size += (*it)->unpack_comm(index,&buf[size]); }; /** helper function to grow arrays of all data in a list, only valid with PAQs */ template <typename data> - void grow_arrays_loop(map<string,data * > & list, int nmax) + void grow_arrays_loop(std::map<std::string,data * > & list, int nmax) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) (it->second)->grow_lammps_array(nmax,prefix_+it->first); }; /** helper function to copy arrays of all data in a list, only valid with PAQs */ template <typename data> - void copy_arrays_loop(map<string,data * > & list, int i, int j) + void copy_arrays_loop(std::map<std::string,data * > & list, int i, int j) { - for (typename map<string,data* >::iterator it = list.begin(); it != list.end(); ++it) + for (typename std::map<std::string,data* >::iterator it = list.begin(); it != list.end(); ++it) (it->second)->copy_lammps_array(i,j); }; diff --git a/lib/atc/KD_Tree.cpp b/lib/atc/KD_Tree.cpp index 41e67c9f68e7d66823b7c6ea94518e79a9848b10..a28e54b7a4a114d2f793596d5df47b71c24cd2cc 100644 --- a/lib/atc/KD_Tree.cpp +++ b/lib/atc/KD_Tree.cpp @@ -1,6 +1,8 @@ #include "KD_Tree.h" #include <assert.h> +using std::vector; + KD_Tree *KD_Tree::create_KD_tree(const int nNodesPerElem, const int nNodes, const DENS_MAT *nodalCoords, const int nElems, const Array2D<int> &conn) { diff --git a/lib/atc/KD_Tree.h b/lib/atc/KD_Tree.h index 0bbcf25f2ae1c4c0e681bee1eff59d8a7978cc96..6c788c407112948bbcbbed4f3c8d2f612728fa69 100644 --- a/lib/atc/KD_Tree.h +++ b/lib/atc/KD_Tree.h @@ -5,8 +5,8 @@ #include "MatrixDef.h" #include "MatrixLibrary.h" #include <math.h> - -using namespace ATC_matrix; +#include <vector> +#include <utility> class Node { public: @@ -54,7 +54,7 @@ class Node { }; -typedef std::pair<int,vector<Node> > Elem; +typedef std::pair<int,std::vector<Node> > Elem; class KD_Tree { public: @@ -62,25 +62,25 @@ class KD_Tree { const DENS_MAT *points, const int nElems, const Array2D<int> &conn); - KD_Tree(vector<Node> *points, vector<Elem> *elems, + KD_Tree(std::vector<Node> *points, std::vector<Elem> *elems, int dimension=0); ~KD_Tree(); - vector<int> find_nearest(DENS_VEC query) { + std::vector<int> find_nearest(DENS_VEC query) { // Create a fake Node and find the nearest Node in the tree to it. return find_nearest_elements(Node(-1, query(0), query(1), query(2))); } - vector<int> find_nearest_elements(Node query, int dimension=0); + std::vector<int> find_nearest_elements(Node query, int dimension=0); - vector<vector<int> > getElemIDs(int depth); + std::vector<std::vector<int> > getElemIDs(int depth); private: Node value_; - vector<Node> *sortedPts_; - vector<Elem> *candElems_; + std::vector<Node> *sortedPts_; + std::vector<Elem> *candElems_; KD_Tree *leftChild_; KD_Tree *rightChild_; diff --git a/lib/atc/KernelFunction.h b/lib/atc/KernelFunction.h index f9ed3df68a137d1ad395e4e022a98f096c0df3f0..99668525374b7e5e1f4c4460667a130ef0cad684 100644 --- a/lib/atc/KernelFunction.h +++ b/lib/atc/KernelFunction.h @@ -1,4 +1,3 @@ -/** KernelFunction: Hardy smoothing */ #ifndef KERNEL_FUNCTION_H #define KERNEL_FUNCTION_H @@ -22,7 +21,7 @@ namespace ATC { ~KernelFunctionMgr(); private: static KernelFunctionMgr * myInstance_; - set<KernelFunction*> pointerSet_; + std::set<KernelFunction*> pointerSet_; }; /** diff --git a/lib/atc/KinetoThermostat.cpp b/lib/atc/KinetoThermostat.cpp index ccbbd12bc897ac4e69bca456c6158fb2b6c7671b..72afec7b3e750072eb595f4f3e58700fa0917b6a 100644 --- a/lib/atc/KinetoThermostat.cpp +++ b/lib/atc/KinetoThermostat.cpp @@ -36,20 +36,6 @@ namespace ATC { bool KinetoThermostat::modify(int narg, char **arg) { bool foundMatch = false; - - int argIndex = 0; - if (strcmp(arg[argIndex],"thermal")==0) { - foundMatch = thermostat_.modify(narg,arg); - } - - if (strcmp(arg[argIndex],"momentum")==0) { - foundMatch = kinetostat_.modify(narg,arg); - } - - if (!foundMatch) - foundMatch = AtomicRegulator::modify(narg,arg); - if (foundMatch) - needReset_ = true; return foundMatch; } diff --git a/lib/atc/KinetoThermostat.h b/lib/atc/KinetoThermostat.h index 2ad2294edd7432a4acbee52a0e63317abce818be..ee0883fb4fe663c82292ff4c8539bff96756ad02 100644 --- a/lib/atc/KinetoThermostat.h +++ b/lib/atc/KinetoThermostat.h @@ -1,16 +1,14 @@ #ifndef KINETOTHERMOSTAT_H #define KINETOTHERMOSTAT_H -// ATC headers #include "AtomicRegulator.h" #include "PerAtomQuantityLibrary.h" //TEMP_JAT - transitional headers until we have a new method #include "Kinetostat.h" #include "Thermostat.h" - -// other headers #include <map> #include <set> +#include <string> namespace ATC { /* #ifdef WIP_JAT */ @@ -33,7 +31,7 @@ namespace ATC { // constructor KinetoThermostat(ATC_Coupling * atc, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); // destructor virtual ~KinetoThermostat(){}; @@ -114,7 +112,7 @@ namespace ATC { /* public: */ /* ThermostatShapeFunction(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatShapeFunction() {}; */ @@ -250,7 +248,7 @@ namespace ATC { /* public: */ /* ThermostatGlcFs(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatGlcFs() {}; */ @@ -384,7 +382,7 @@ namespace ATC { /* public: */ /* ThermostatFlux(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatFlux() {}; */ @@ -429,7 +427,7 @@ namespace ATC { /* public: */ /* ThermostatFixed(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatFixed() {}; */ @@ -529,7 +527,7 @@ namespace ATC { /* public: */ /* ThermostatFluxFiltered(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatFluxFiltered() {}; */ @@ -577,7 +575,7 @@ namespace ATC { /* public: */ /* ThermostatFixedFiltered(Thermostat * thermostat, */ -/* const string & regulatorPrefix = ""); */ +/* const std::string & regulatorPrefix = ""); */ /* virtual ~ThermostatFixedFiltered() {}; */ diff --git a/lib/atc/Kinetostat.cpp b/lib/atc/Kinetostat.cpp index 74bb28817a9d9c2535d540f9d2ffa1a154f6c574..a76c678d220ac726e4162dc66a603995fe987e3f 100644 --- a/lib/atc/Kinetostat.cpp +++ b/lib/atc/Kinetostat.cpp @@ -7,6 +7,10 @@ #include "ElasticTimeIntegrator.h" #include "TransferOperator.h" +using std::set; +using std::pair; +using std::string; + namespace ATC { //-------------------------------------------------------- @@ -59,10 +63,10 @@ namespace ATC { evaulation\n \section examples fix_modify AtC control momentum glc_velocity \n - fix_modify AtC control momentum stress_flux faceset bndy_faces \n + fix_modify AtC control momentum flux faceset bndy_faces \n \section description \section restrictions - only for be used with specific transfers : + only to be used with specific transfers : elastic \n rescale not valid with time filtering activated \section related diff --git a/lib/atc/Kinetostat.h b/lib/atc/Kinetostat.h index 3023f7ddd314cf0ba7f01c74017a8207def1b7de..e85caa8860466121d1ffabdb82c1e757ea0f11a0 100644 --- a/lib/atc/Kinetostat.h +++ b/lib/atc/Kinetostat.h @@ -1,13 +1,12 @@ #ifndef KINETOSTAT_H #define KINETOSTAT_H -// ATC headers #include "AtomicRegulator.h" #include "PerAtomQuantityLibrary.h" - -// other headers #include <map> #include <set> +#include <utility> +#include <string> namespace ATC { @@ -28,7 +27,7 @@ namespace ATC { // constructor Kinetostat(ATC_Coupling *atc, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); // destructor virtual ~Kinetostat(){}; @@ -60,7 +59,7 @@ namespace ATC { public: KinetostatShapeFunction(Kinetostat *kinetostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~KinetostatShapeFunction(){}; @@ -140,7 +139,8 @@ namespace ATC { DIAG_MAN & mdMassMatrix_; /** nodeset corresponding to Hoover coupling */ - set<pair<int,int> > hooverNodes_; + std::set<std::pair<int,int> > hooverNodes_; + /** pointer to atom positions */ FundamentalAtomQuantity * atomPositions_; @@ -546,7 +546,7 @@ namespace ATC { public: KinetostatGlcFs(Kinetostat *kinetostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~KinetostatGlcFs(){}; @@ -629,7 +629,7 @@ namespace ATC { public: KinetostatFlux(Kinetostat *kinetostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~KinetostatFlux(){}; @@ -690,7 +690,7 @@ namespace ATC { public: KinetostatFluxGhost(Kinetostat *kinetostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~KinetostatFluxGhost(){}; @@ -729,7 +729,7 @@ namespace ATC { public: KinetostatFixed(Kinetostat *kinetostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~KinetostatFixed(){}; diff --git a/lib/atc/LammpsInterface.cpp b/lib/atc/LammpsInterface.cpp index c8a8692b16f8f27d895e0de3cbee28d6c3710c7e..b9b1aa8d31cc01761fca063353909cbdcd6205e7 100644 --- a/lib/atc/LammpsInterface.cpp +++ b/lib/atc/LammpsInterface.cpp @@ -21,8 +21,7 @@ #include "neigh_list.h" // neighbor list #include "update.h" // timestepping information #include "pair.h" // pair potentials - -#include "pair_eam.h" // pair potentials +#include "MANYBODY/pair_eam.h" // pair potentials #include "lattice.h" // lattice parameters #include "bond.h" // bond potentials #include "comm.h" // @@ -40,6 +39,15 @@ using ATC_Utility::to_string; #include <map> #include <typeinfo> +using std::max; +using std::stringstream; +using std::copy; +using std::map; +using std::pair; +using std::string; +using std::set; +using LAMMPS_NS::bigint; + namespace ATC { const static double PI = 3.141592653589793238; @@ -265,6 +273,8 @@ double ** LammpsInterface::fatom() const { return lammps_->atom->f; } const int * LammpsInterface::atom_mask() const { return (const int*)lammps_->atom->mask; } +int * LammpsInterface::atom_mask() { return lammps_->atom->mask; } + int * LammpsInterface::atom_type() const { return lammps_->atom->type; } int * LammpsInterface::atom_tag() const { return lammps_->atom->tag; } @@ -761,7 +771,7 @@ double LammpsInterface::pair_force(int n, double rsq, return lammps_->force->bond->single(type,rsq,i,j,fmag_over_rmag); } double LammpsInterface::pair_force( - map< pair< int,int >,int >::const_iterator itr, double rsq, + map< std::pair< int,int >,int >::const_iterator itr, double rsq, double & fmag_over_rmag, int nbonds) const { int n = itr->second; @@ -769,14 +779,14 @@ double LammpsInterface::pair_force( return pair_force(n, rsq,fmag_over_rmag); } else { - pair <int,int> ij = itr->first; + std::pair <int,int> ij = itr->first; int i = ij.first; int j = ij.second; return pair_force(i,j, rsq,fmag_over_rmag); } } double LammpsInterface::pair_force( - pair< pair< int,int >,int > apair, double rsq, + std::pair< std::pair< int,int >,int > apair, double rsq, double & fmag_over_rmag, int nbonds) const { int n = apair.second; @@ -784,7 +794,7 @@ double LammpsInterface::pair_force( return pair_force(n, rsq,fmag_over_rmag); } else { - pair <int,int> ij = apair.first; + std::pair <int,int> ij = apair.first; int i = ij.first; int j = ij.second; return pair_force(i,j, rsq,fmag_over_rmag); @@ -1258,6 +1268,8 @@ int ** LammpsInterface::neighbor_list_firstneigh() const { return list_->firstne int LammpsInterface::neighbor_ago() const { return lammps_->neighbor->ago; } +int LammpsInterface::reneighbor_frequency() const {return lammps_->neighbor->every; } + // ----------------------------------------------------------------- // bond list interface methods // ----------------------------------------------------------------- diff --git a/lib/atc/LammpsInterface.h b/lib/atc/LammpsInterface.h index 435290c0fc27b0d38d8056c3640016c553afc201..bb7c0f4825b4dfcf2afdc9bd1765d606f6df57e6 100644 --- a/lib/atc/LammpsInterface.h +++ b/lib/atc/LammpsInterface.h @@ -2,41 +2,26 @@ #define LAMMPS_INTERFACE_H #include <iostream> -using std::flush; #include <stdlib.h> -using std::copy; -using std::max; #include <map> -using std::map; #include <iostream> -using std::cout; #include <string> -using std::string; #include <sstream> -using std::stringstream; +#include <utility> #include "mpi.h" #include "lammps.h" #include "modify.h" #include "memory.h" - #include "random_park.h" typedef LAMMPS_NS::RanPark* RNG_POINTER; - #include "lmptype.h" -using LAMMPS_NS::bigint; -//using LAMMPS_NS::NEIGHMASK; - #include "compute.h" typedef const LAMMPS_NS::Compute* COMPUTE_POINTER; - #include "update.h" #include "min.h" - #include "ATC_Error.h" #include "ATC_TypeDefs.h" #include "MatrixDef.h" -using namespace ATC_matrix; -// must scope ATC_matrix #include "MPI_Wrappers.h" typedef LAMMPS_NS::Pair* POTENTIAL; @@ -60,7 +45,7 @@ namespace LAMMPS_NS { namespace ATC { -static const string atomPeNameBase_ = "atcPE"; +static const std::string atomPeNameBase_ = "atcPE"; static const double big_ = 1.e20; /** @@ -244,15 +229,15 @@ class LammpsInterface { { MPI_Wrappers::barrier(lammps_->world); } - void stop(string msg="") const + void stop(std::string msg="") const { MPI_Wrappers::stop(lammps_->world, msg); } // end MPI -------------------------------------------------------------------- - void print_debug(string msg="") const + void print_debug(std::string msg="") const { - cout << "rank " << comm_rank() << " " << msg << "\n" << std::flush; + std::cout << "rank " << comm_rank() << " " << msg << "\n" << std::flush; barrier(); } @@ -264,43 +249,43 @@ class LammpsInterface { return (size==1); } - void print_msg(string msg) const + void print_msg(std::string msg) const { int me; MPI_Comm_rank(lammps_->world,&me); - stringstream full_msg; + std::stringstream full_msg; if (serial()) { full_msg << " ATC: " << msg << "\n"; } else { full_msg << " ATC: P" << me << ", " << msg << "\n"; } - string mesg = full_msg.str(); + std::string mesg = full_msg.str(); if (lammps_->screen) fprintf(lammps_->screen, "%s",mesg.c_str()); if (lammps_->logfile) fprintf(lammps_->logfile,"%s",mesg.c_str()); } - void print_msg_once(string msg,bool prefix=true, bool endline=true) const + void print_msg_once(std::string msg,bool prefix=true, bool endline=true) const { int me; MPI_Comm_rank(lammps_->world,&me); if (me==0) { - stringstream full_msg; + std::stringstream full_msg; if (prefix) full_msg << " ATC: "; full_msg << msg; if (endline) full_msg << "\n"; - string mesg = full_msg.str(); + std::string mesg = full_msg.str(); if (lammps_->screen) fprintf(lammps_->screen, "%s",mesg.c_str()); if (lammps_->logfile) fprintf(lammps_->logfile,"%s",mesg.c_str()); } } - void all_print(double data, string tag ="") const + void all_print(double data, std::string tag ="") const { int me; MPI_Comm_rank(lammps_->world,&me); - stringstream full_msg; + std::stringstream full_msg; if (serial()) { full_msg << " ATC: " << tag << data << "\n"; } @@ -317,21 +302,21 @@ class LammpsInterface { } } if (rank_zero()) { - string mesg = full_msg.str(); + std::string mesg = full_msg.str(); if (lammps_->screen) fprintf(lammps_->screen, "%s",mesg.c_str()); if (lammps_->logfile) fprintf(lammps_->logfile,"%s",mesg.c_str()); } } - void stream_msg_once(string msg,bool prefix=true, bool endline=true) const + void stream_msg_once(std::string msg,bool prefix=true, bool endline=true) const { int me; MPI_Comm_rank(lammps_->world,&me); if (me==0) { - if (prefix) cout << " ATC: "; - cout << msg; - if (endline) cout << "\n"; - cout << flush; + if (prefix) std::cout << " ATC: "; + std::cout << msg; + if (endline) std::cout << "\n"; + std::cout << std::flush; } } @@ -343,9 +328,9 @@ class LammpsInterface { /** \name Methods that interface with Atom class */ /*@{*/ void set_fix_pointer(LAMMPS_NS::Fix * thisFix); - string fix_id() const; + std::string fix_id() const; bool atoms_sorted() const; - bigint natoms() const; + LAMMPS_NS::bigint natoms() const; int nlocal() const; int nghost() const; int nmax() const; @@ -354,6 +339,7 @@ class LammpsInterface { double ** vatom() const; double ** fatom() const; const int * atom_mask() const; + int * atom_mask(); int * atom_type() const; int * atom_tag() const; int * atom_to_molecule() const; @@ -476,8 +462,8 @@ class LammpsInterface { // interface to "single" double pair_force(int i, int j, double rsq, double& fmag_over_rmag) const; // pair class double pair_force(int n, double rsq, double& fmag_over_rmag) const; // bond class - double pair_force(map< pair< int,int >,int >::const_iterator itr, double rsq, double& fmag_over_rmag, int nbonds = 0) const; - double pair_force(pair< pair< int,int >,int > apair, double rsq, double& fmag_over_rmag, int nbonds = 0) const; + double pair_force(std::map< std::pair< int,int >,int >::const_iterator itr, double rsq, double& fmag_over_rmag, int nbonds = 0) const; + double pair_force(std::pair< std::pair< int,int >,int > apair, double rsq, double& fmag_over_rmag, int nbonds = 0) const; double pair_cutoff() const; void pair_reinit() const; int single_enable() const; @@ -543,9 +529,9 @@ class LammpsInterface { /** \name Methods that interface with Group class */ /*@{*/ int ngroup() const; - int group_bit(string name) const; + int group_bit(std::string name) const; int group_bit(int iGroup) const; - int group_index(string name) const; + int group_index(std::string name) const; int group_inverse_mask(int iGroup) const; char * group_name(int iGroup) const; void group_bounds(int iGroup, double * b) const; @@ -578,9 +564,9 @@ class LammpsInterface { /** \name Methods that interface with Update class */ /*@{*/ double dt() const; - bigint ntimestep() const; + LAMMPS_NS::bigint ntimestep() const; int nsteps() const; - bool now(bigint f) { return (ntimestep() % f == 0); } + bool now(LAMMPS_NS::bigint f) { return (ntimestep() % f == 0); } /*@}*/ /** \name Methods that interface with neighbor list */ @@ -593,6 +579,7 @@ class LammpsInterface { int * neighbor_list_ilist() const; int ** neighbor_list_firstneigh() const; int neighbor_ago() const; + int reneighbor_frequency() const; LAMMPS_NS::NeighList * neighbor_list(void) const { return list_;} /*@}*/ @@ -634,7 +621,7 @@ class LammpsInterface { KE_ATOM, NUM_PER_ATOM_COMPUTES}; // computes owned by LAMMPS - COMPUTE_POINTER compute_pointer(string tag) const; + COMPUTE_POINTER compute_pointer(std::string tag) const; int compute_ncols_peratom(COMPUTE_POINTER computePointer) const; double* compute_vector_peratom(COMPUTE_POINTER computePointer) const; double** compute_array_peratom(COMPUTE_POINTER computePointer) const; @@ -646,7 +633,7 @@ class LammpsInterface { // computes owned by ATC int create_compute_pe_peratom(void) const; double * compute_pe_peratom(void) const; - string compute_pe_name(void) const {return atomPeNameBase_;};// +fix_id();}; enables unique names, if desired + std::string compute_pe_name(void) const {return atomPeNameBase_;};// +fix_id();}; enables unique names, if desired void computes_clearstep(void) const {lammps_->modify->clearstep_compute();}; /*@}*/ @@ -683,7 +670,7 @@ class LammpsInterface { mutable double upper_[3],lower_[3],length_[3]; /** registry of computer pointers */ - mutable set<LAMMPS_NS::Compute * > computePointers_; + mutable std::set<LAMMPS_NS::Compute * > computePointers_; /** a random number generator from lammps */ mutable LAMMPS_NS::RanPark * random_; @@ -698,7 +685,7 @@ class LammpsInterface { class HeartBeat { public: - HeartBeat(string name, int freq) : + HeartBeat(std::string name, int freq) : name_(name), freq_(freq), counter_(0) {}; ~HeartBeat(){}; void start() const @@ -708,7 +695,7 @@ class LammpsInterface { void finish() const { ATC::LammpsInterface::instance()->stream_msg_once("done",false,true);} protected: - string name_; + std::string name_; int freq_; mutable int counter_; private: diff --git a/lib/atc/LinearSolver.cpp b/lib/atc/LinearSolver.cpp index cea781b648ff30f0c36acd22958b1c849665465f..c6e1e9cf75495167e702b7ea76790be479b5cbfd 100644 --- a/lib/atc/LinearSolver.cpp +++ b/lib/atc/LinearSolver.cpp @@ -2,7 +2,7 @@ #include "LinearSolver.h" #include <sstream> using std::stringstream; - +using std::set; diff --git a/lib/atc/LinearSolver.h b/lib/atc/LinearSolver.h index b9a922be76a6abe72b15bff8cdb1e9e0d33f1a25..eb84976c36bff34e897fed6dcf4111bc7272fc27 100644 --- a/lib/atc/LinearSolver.h +++ b/lib/atc/LinearSolver.h @@ -9,7 +9,6 @@ // other includes #include <set> #include <map> -using std::pair; #include "LammpsInterface.h" #include "CG.h" @@ -152,8 +151,8 @@ class LinearSolver { DENS_MAT matrixFreeFree_, matrixFreeFixed_; /** maps for free and fixed variables for partitioned matrix - condense */ - set<int> freeSet_, fixedSet_; - map<int,int> freeGlobalToCondensedMap_; + std::set<int> freeSet_, fixedSet_; + std::map<int,int> freeGlobalToCondensedMap_; /** inverse matrix matrix - direct solve */ diff --git a/lib/atc/MPI_Wrappers.cpp b/lib/atc/MPI_Wrappers.cpp index ddf2056b043e68d79c37bea77f0c41abeb39fdde..d69620ecb9dbf702b8ca582b4002833806c7275e 100644 --- a/lib/atc/MPI_Wrappers.cpp +++ b/lib/atc/MPI_Wrappers.cpp @@ -1,7 +1,10 @@ #include "MPI_Wrappers.h" #include "Utility.h" using ATC_Utility::to_string; +#include "ATC_Error.h" +using ATC::ATC_Error; using std::cout; +using std::string; #ifdef ISOLATE_FE #include "Matrix.h" using ATC_Matrix::SparseMatrix; diff --git a/lib/atc/MPI_Wrappers.h b/lib/atc/MPI_Wrappers.h index bff68523d7d5f90720d7131a0d69d7fdc9622e9c..691c9d5250129dfcc8995bf649fd7f190f3939c0 100644 --- a/lib/atc/MPI_Wrappers.h +++ b/lib/atc/MPI_Wrappers.h @@ -3,11 +3,7 @@ #include <iostream> #include <string> -using std::string; #include "mpi.h" -#include "ATC_Error.h" -using ATC::ATC_Error; -//using ATC_matrix::SparseMatrix; namespace MPI_Wrappers { @@ -36,13 +32,13 @@ namespace MPI_Wrappers { void gather(MPI_Comm comm, double send, double * recv); void logical_or(MPI_Comm comm, void *send_buf, int *rec_buf, int count = 1); void barrier(MPI_Comm comm); - void stop(MPI_Comm comm, string msg=""); + void stop(MPI_Comm comm, std::string msg=""); void int_scatter(MPI_Comm comm, int *send_buf, int *rec_buf, int count = 1); // void sparse_allsum(MPI_Comm comm, SparseMatrix<double> &toShare); - void print_msg(MPI_Comm comm, string msg); - void print_msg_once(MPI_Comm comm,string msg,bool prefix=true,bool endline=true); + void print_msg(MPI_Comm comm, std::string msg); + void print_msg_once(MPI_Comm comm,std::string msg,bool prefix=true,bool endline=true); } diff --git a/lib/atc/Material.cpp b/lib/atc/Material.cpp index 188ab1f45ec1f251fb0f535772afbc385421843b..eaeb7c975417cfe1bbad7b884ce4b35f5a849a96 100644 --- a/lib/atc/Material.cpp +++ b/lib/atc/Material.cpp @@ -10,6 +10,18 @@ #include "ViscousStress.h" #include "BodyForce.h" #include "ElectronFlux.h" +#include <sstream> +#include <fstream> +#include <vector> + +using ATC_Utility::command_line; +using ATC_Utility::str2dbl; +using ATC_Utility::str2int; +using std::stringstream; +using std::set; +using std::fstream; +using std::string; +using std::vector; namespace ATC { diff --git a/lib/atc/Material.h b/lib/atc/Material.h index 5b20b619e9e4a5add532d718f133239eb02f76ba..18cccd87926b2d1e7440ad4a5c87cf3f6505c22a 100644 --- a/lib/atc/Material.h +++ b/lib/atc/Material.h @@ -32,21 +32,21 @@ namespace ATC Material(); virtual ~Material(); /** this constructor parses material file */ - Material(string & tag, fstream & fileId); + Material(std::string & tag, std::fstream & fileId); /** initialize */ virtual void initialize(); /** return label */ - string label(void) const {return tag_;} + std::string label(void) const {return tag_;} /** check material has required interfaces */ - bool check_registry(const set<string> functionList) const + bool check_registry(const std::set<std::string> functionList) const { - set<string>::const_iterator itr; + std::set<std::string>::const_iterator itr; for (itr=functionList.begin(); itr!=functionList.end(); itr++) { if (registry_.find(*itr) == registry_.end()) { - stringstream ss; + std::stringstream ss; ss << "WARNING: material: [" << tag_ << "] cannot find " << *itr ; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } @@ -56,9 +56,9 @@ namespace ATC } /** access to material parameters */ - bool parameter(const string name, double & value) const + bool parameter(const std::string name, double & value) const { - map<string,double>::const_iterator iter = parameters_.find(name); + std::map<std::string,double>::const_iterator iter = parameters_.find(name); if ( iter == parameters_.end()) { value = 0.0; return false; @@ -197,11 +197,11 @@ namespace ATC protected: /** material's label */ - string tag_; + std::string tag_; /** dictionary of material parameters */ - map<string,double> parameters_; + std::map<std::string,double> parameters_; /** dictionary of instantiated functions */ - set<string> registry_; + std::set<std::string> registry_; /** per eqn flag of constant density */ Array<bool> constantDensity_; /** per eqn flag of linearity/nonlinearity */ diff --git a/lib/atc/Matrix.h b/lib/atc/Matrix.h index 4f84a575999306c169b7eb9799b5ea79d70c15a5..179bea52b96af762bda7ff64a1ca603215569a38 100644 --- a/lib/atc/Matrix.h +++ b/lib/atc/Matrix.h @@ -21,12 +21,12 @@ public: virtual ~Matrix() {} //* stream output functions - void print(ostream &o) const { o << to_string(); } - void print(ostream &o, const string &name) const; - friend ostream& operator<<(ostream &o, const Matrix<T> &m){m.print(o); return o;} + void print(std::ostream &o) const { o << to_string(); } + void print(std::ostream &o, const std::string &name) const; + friend std::ostream& operator<<(std::ostream &o, const Matrix<T> &m){m.print(o); return o;} void print() const; - virtual void print(const string &name) const; - virtual string to_string() const; + virtual void print(const std::string &name) const; + virtual std::string to_string() const; // element by element operations DenseMatrix<T> operator/(const Matrix<T>& B) const; @@ -35,13 +35,13 @@ public: // functions that return a copy DenseMatrix<T> transpose() const; - void row_partition(const set<int> & rowsIn, set<int> & rows, set<int> & colsC, + void row_partition(const std::set<int> & rowsIn, std::set<int> & rows, std::set<int> & colsC, DenseMatrix<T> & A1, DenseMatrix<T> & A2, bool complement=true) const; - set<int> row_partition(const set<int> & rows, + std::set<int> row_partition(const std::set<int> & rows, DenseMatrix<T> & A1, DenseMatrix<T> & A2) const; - void map(const set<int>& rows, const set<int>& cols, DenseMatrix<T> & A) const; - void insert(const set<int>& rows, const set<int>& cols, const DenseMatrix<T> & A); - void assemble(const set<int>& rows, const set<int>& cols, const DenseMatrix<T> & A); + void map(const std::set<int>& rows, const std::set<int>& cols, DenseMatrix<T> & A) const; + void insert(const std::set<int>& rows, const std::set<int>& cols, const DenseMatrix<T> & A); + void assemble(const std::set<int>& rows, const std::set<int>& cols, const DenseMatrix<T> & A); // matrix to scalar functions T sum() const; @@ -94,14 +94,14 @@ public: //* create restart file virtual void write_restart(FILE *f) const=0; //* writes a matlab command to recreate this in a variable named s - virtual void matlab(ostream &o, const string &s="M") const; + virtual void matlab(std::ostream &o, const std::string &s="M") const; //* writes a mathematica command to recreate this in a variable named s - virtual void mathematica(ostream &o, const string &s="M") const; + virtual void mathematica(std::ostream &o, const std::string &s="M") const; // output to matlab, with variable name s - void matlab(const string &s="M") const; + void matlab(const std::string &s="M") const; // output to mathematica, with variable name s - void mathematica(const string &s="M") const; + void mathematica(const std::string &s="M") const; Matrix<T>& operator+=(const Matrix &r); Matrix<T>& operator-=(const Matrix &r); @@ -286,9 +286,9 @@ void MultAB(const Matrix<T> &A, const Matrix<T> &B, DenseMatrix<T> &C, //----------------------------------------------------------------------------- //* output operator template<typename T> -string Matrix<T>::to_string() const +std::string Matrix<T>::to_string() const { - string s; + std::string s; for (INDEX i=0; i<nRows(); i++) { if (i) s += '\n'; @@ -303,7 +303,7 @@ string Matrix<T>::to_string() const //----------------------------------------------------------------------------- //* output operator that wraps the matrix in a nice labeled box template<typename T> -void Matrix<T>::print(ostream &o, const string &name) const +void Matrix<T>::print(std::ostream &o, const std::string &name) const { o << "------- Begin "<<name<<" -----------------\n"; this->print(o); @@ -314,14 +314,14 @@ void Matrix<T>::print(ostream &o, const string &name) const template<typename T> void Matrix<T>::print() const { - print(cout); + print(std::cout); } //----------------------------------------------------------------------------- //* named print operator, use cout by default template<typename T> -void Matrix<T>::print(const string &name) const +void Matrix<T>::print(const std::string &name) const { - print(cout, name); + print(std::cout, name); } //----------------------------------------------------------------------------- //* element by element division @@ -693,14 +693,14 @@ void Matrix<T>::add_scaled(const Matrix<T> &A, const T& s) //----------------------------------------------------------------------------- //* writes a matlab command to the console template<typename T> -void Matrix<T>::matlab(const string &s) const +void Matrix<T>::matlab(const std::string &s) const { - this->matlab(cout, s); + this->matlab(std::cout, s); } //----------------------------------------------------------------------------- //* Writes a matlab script defining the vector to the stream template<typename T> -void Matrix<T>::matlab(ostream &o, const string &s) const +void Matrix<T>::matlab(std::ostream &o, const std::string &s) const { o << s <<"=zeros(" << nRows() << ","<<nCols()<<");\n"; int szi = this->nRows(); @@ -712,14 +712,14 @@ void Matrix<T>::matlab(ostream &o, const string &s) const //----------------------------------------------------------------------------- //* writes a mathematica command to the console template<typename T> -void Matrix<T>::mathematica(const string &s) const +void Matrix<T>::mathematica(const std::string &s) const { - this->mathematica(cout, s); + this->mathematica(std::cout, s); } //----------------------------------------------------------------------------- //* Writes a mathematica script defining the vector to the stream template<typename T> -void Matrix<T>::mathematica(ostream &o, const string &s) const +void Matrix<T>::mathematica(std::ostream &o, const std::string &s) const { o << s <<" = { \n"; o.precision(15); @@ -822,33 +822,33 @@ inline bool Matrix<T>::check_range(T min, T max) const template<typename T> void ierror(const Matrix<T> &a, const char *FILE, int LINE, INDEX i, INDEX j) { - cout << "Error: Matrix indexing failure "; - cout << "in file: " << FILE << ", line: "<< LINE <<"\n"; - cout << "Tried accessing index (" << i << ", " << j <<")\n"; - cout << "Matrix size was "<< a.nRows() << "x" << a.nCols() << "\n"; + std::cout << "Error: Matrix indexing failure "; + std::cout << "in file: " << FILE << ", line: "<< LINE <<"\n"; + std::cout << "Tried accessing index (" << i << ", " << j <<")\n"; + std::cout << "Matrix size was "<< a.nRows() << "x" << a.nCols() << "\n"; ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } //----------------------------------------------------------------------------- //* Displays custom message and indexing error and quits template<typename T> -void ierror(const Matrix<T> &a, INDEX i, INDEX j, const string m) +void ierror(const Matrix<T> &a, INDEX i, INDEX j, const std::string m) { - cout << m << "\n"; - cout << "Tried accessing index (" << i << ", " << j <<")\n"; - cout << "Matrix size was "<< a.nRows() << "x" << a.nCols() << "\n"; + std::cout << m << "\n"; + std::cout << "Tried accessing index (" << i << ", " << j <<")\n"; + std::cout << "Matrix size was "<< a.nRows() << "x" << a.nCols() << "\n"; ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } //----------------------------------------------------------------------------- //* Displays matrix compatibility error message template<typename T> -void merror(const Matrix<T> &a, const Matrix<T> &b, const string m) +void merror(const Matrix<T> &a, const Matrix<T> &b, const std::string m) { - cout << "Error: " << m << "\n"; - cout << "Matrix sizes were " << a.nRows() << "x" << a.nCols(); - if (&a != &b) cout << ", and "<< b.nRows() << "x" << b.nCols(); - cout << "\n"; + std::cout << "Error: " << m << "\n"; + std::cout << "Matrix sizes were " << a.nRows() << "x" << a.nCols(); + if (&a != &b) std::cout << ", and "<< b.nRows() << "x" << b.nCols(); + std::cout << "\n"; if (a.size() < 100) a.print("Matrix"); ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); @@ -861,8 +861,8 @@ void merror(const Matrix<T> &a, const Matrix<T> &b, const string m) //* rows is the map for A1, (rows,colsC) is the map for A2 template <typename T> -void Matrix<T>::row_partition(const set<int> & rowsIn, -set<int> & rows, set<int> & colsC, +void Matrix<T>::row_partition(const std::set<int> & rowsIn, +std::set<int> & rows, std::set<int> & colsC, DenseMatrix<T> & A1, DenseMatrix<T> & A2, bool complement) const { if (complement) { @@ -891,7 +891,7 @@ DenseMatrix<T> & A1, DenseMatrix<T> & A2, bool complement) const int ncolsC = colsC.size(); A1.reset(nrows,nrows); A2.reset(nrows,ncolsC); - set<int>::const_iterator itrI, itrJ; + std::set<int>::const_iterator itrI, itrJ; INDEX i =0; for (itrI = rows.begin(); itrI != rows.end(); itrI++) { INDEX j = 0; @@ -909,11 +909,11 @@ DenseMatrix<T> & A1, DenseMatrix<T> & A2, bool complement) const } template <typename T> -set<int> Matrix<T>::row_partition(const set<int> & rows, +std::set<int> Matrix<T>::row_partition(const std::set<int> & rows, DenseMatrix<T> & A1, DenseMatrix<T> & A2) const { // complement of set "rows" in set of this.cols is "cols" - set<int> colsC; + std::set<int> colsC; for (INDEX i = 0; i < this->nCols(); i++) { if (rows.find(i) == rows.end() ) colsC.insert(i); } @@ -933,7 +933,7 @@ DenseMatrix<T> & A1, DenseMatrix<T> & A2) const int ncolsC = colsC.size(); A1.reset(nrows,nrows); A2.reset(nrows,ncolsC); - set<int>::const_iterator itrI, itrJ; + std::set<int>::const_iterator itrI, itrJ; INDEX i =0; for (itrI = rows.begin(); itrI != rows.end(); itrI++) { INDEX j = 0; @@ -954,7 +954,7 @@ DenseMatrix<T> & A1, DenseMatrix<T> & A2) const //----------------------------------------------------------------------------- //* returns row & column mapped matrix template <typename T> -void Matrix<T>::map(const set<int> & rows, const set<int> & cols, +void Matrix<T>::map(const std::set<int> & rows, const std::set<int> & cols, DenseMatrix<T> & A ) const { if (rows.size() == 0 || cols.size() == 0 ) { @@ -964,7 +964,7 @@ DenseMatrix<T> & A ) const int nrows = rows.size(); int ncols = cols.size(); A.reset(nrows,ncols); - set<int>::const_iterator itrI, itrJ; + std::set<int>::const_iterator itrI, itrJ; INDEX i =0; for (itrI = rows.begin(); itrI != rows.end(); itrI++) { INDEX j = 0; @@ -978,17 +978,17 @@ DenseMatrix<T> & A ) const //----------------------------------------------------------------------------- //* inserts elements from a smaller matrix template <typename T> -void Matrix<T>::insert(const set<int> & rows, const set<int> & cols, +void Matrix<T>::insert(const std::set<int> & rows, const std::set<int> & cols, const DenseMatrix<T> & A ) { if (rows.size() == 0 || cols.size() == 0 ) return; - set<int>::const_iterator itrI, itrJ; + std::set<int>::const_iterator itrI, itrJ; int i =0; for (itrI = rows.begin(); itrI != rows.end(); itrI++) { int j = 0; for (itrJ = cols.begin(); itrJ != cols.end(); itrJ++) { (*this)(*itrI,*itrJ) = A(i,j); -//cout << *itrI << " " << *itrJ << " : " << (*this)(*itrI,*itrJ) << "\n"; +//std::cout << *itrI << " " << *itrJ << " : " << (*this)(*itrI,*itrJ) << "\n"; j++; } i++; @@ -997,11 +997,11 @@ const DenseMatrix<T> & A ) //----------------------------------------------------------------------------- //* assemble elements from a smaller matrix template <typename T> -void Matrix<T>::assemble(const set<int> & rows, const set<int> & cols, +void Matrix<T>::assemble(const std::set<int> & rows, const std::set<int> & cols, const DenseMatrix<T> & A ) { if (rows.size() == 0 || cols.size() == 0 ) return; - set<int>::const_iterator itrI, itrJ; + std::set<int>::const_iterator itrI, itrJ; int i =0; for (itrI = rows.begin(); itrI != rows.end(); itrI++) { int j = 0; diff --git a/lib/atc/MatrixDef.h b/lib/atc/MatrixDef.h index 3121fa781ac7f6380c45da15f6d5da096af01b2a..d1505e7bf614ff4011de3ee14f9fefd50d2d9f1b 100644 --- a/lib/atc/MatrixDef.h +++ b/lib/atc/MatrixDef.h @@ -21,15 +21,6 @@ #include <iomanip> #include <cmath> #include "Utility.h" -using std::cout; -using std::ostream; -using std::fstream; -using std::map; -using std::vector; -using std::set; -using std::string; -using std::scientific; -using std::showbase; namespace ATC_matrix { @@ -183,8 +174,8 @@ typedef ParDiagonalMatrix<double> PAR_DIAG_MAT; // diagonal matrix of double typ typedef SparseMatrix<double> SPAR_MAT; // sparse matrix of double type typedef ParSparseMatrix<double> PAR_SPAR_MAT; // parallel sparse matrix of doubles typedef SparseVector<double> SPAR_VEC; // sparse matrix of double type -typedef vector<DenseMatrix<double> > DENS_MAT_VEC; -typedef vector<SparseMatrix<double> * > SPAR_MAT_VEC; +typedef std::vector<DenseMatrix<double> > DENS_MAT_VEC; +typedef std::vector<SparseMatrix<double> * > SPAR_MAT_VEC; // int containers typedef DenseMatrix<int> INT_ARRAY; // to become vector<int> or Array2D @@ -193,9 +184,9 @@ typedef DenseVector<int> INT_VECTOR; // to become vector<int> or Array // forward declaration of error messages template<typename T> void ierror(const Matrix<T> &a, const char *FILE, int LINE, INDEX i, INDEX j=0); -template<typename T> void ierror(const Matrix<T> &a, INDEX i, INDEX j, const string m); -template<typename T> void merror(const Matrix<T> &a, const Matrix<T> &b, const string m); -inline void gerror(const string m) { cout<<"Error: "<<m<<"\n"; ERROR_FOR_BACKTRACE ; exit(EXIT_FAILURE); } +template<typename T> void ierror(const Matrix<T> &a, INDEX i, INDEX j, const std::string m); +template<typename T> void merror(const Matrix<T> &a, const Matrix<T> &b, const std::string m); +inline void gerror(const std::string m) { std::cout<<"Error: "<<m<<"\n"; ERROR_FOR_BACKTRACE ; exit(EXIT_FAILURE); } } // end namespace #endif diff --git a/lib/atc/MeshReader.cpp b/lib/atc/MeshReader.cpp index e52134fe42aae28e7ec7d044bf72b3023661d587..0ecb8f6254ac698d1cfd1221839d71debd12bcd0 100644 --- a/lib/atc/MeshReader.cpp +++ b/lib/atc/MeshReader.cpp @@ -7,8 +7,16 @@ #include "exodusII.h" #endif +using ATC_Utility::to_string; +using std::ifstream; +using std::istringstream; +using std::stringstream; +using std::map; +using std::pair; +using std::set; +using std::string; + namespace ATC { - using ATC_Utility::to_string; /** constructor, takes a filename */ MeshReader::MeshReader(string filename, Array<bool> periodicity, @@ -21,7 +29,7 @@ namespace ATC { { conn_ = new Array2D<int>(); nodeCoords_ = new DENS_MAT; - nodeSets_ = new Array< pair< string,set<int> > >(); + nodeSets_ = new Array< std::pair< string,set<int> > >(); size_t idx = filename.rfind('.'); if (idx == string::npos) { @@ -49,6 +57,23 @@ namespace ATC { nodeSets_); } + int MeshReader::number_of_vertices(string str) + { + string temp; + int number=0; + for (unsigned int i=0; i < str.size(); i++) { + if (isdigit(str[i])) { + for (unsigned int a=i; a<str.size(); a++) { + temp += str[a]; + } + break; + } + } + istringstream(temp) >> number; + return number; + } + + /** reads .mesh format file */ void MeshReader::read_mesh_file() { ifstream in; @@ -76,7 +101,7 @@ namespace ATC { else if (section == "Elements") { words >> nElements_; words >> elementType_; - int nVerts = int_from_str(elementType_); + int nVerts = number_of_vertices(elementType_); conn_->reset(nVerts, nElements_); string line; for (int i = 0; i < nElements_; ++i) { @@ -162,7 +187,7 @@ namespace ATC { { throw ATC_Error(meshfile_+" is composed of multiple types"); } lastType = etype; } - int nVerts = int_from_str(elementType_); + int nVerts = number_of_vertices(elementType_); conn_->reset(nVerts, nElements_); int n = 0; for (int i=0; i<nelemblk; i++) { @@ -195,23 +220,4 @@ namespace ATC { if (error > 0) { throw ATC_Error("problem with closing "+meshfile_); } #endif } - - int MeshReader::int_from_str(string str) - { - string temp; - int number=0; - - for (unsigned int i=0; i < str.size(); i++) { - if (isdigit(str[i])) { - for (unsigned int a=i; a<str.size(); a++) { - temp += str[a]; - } - break; - } - } - - istringstream(temp) >> number; - return number; - } - }; // end namespace ATC diff --git a/lib/atc/MeshReader.h b/lib/atc/MeshReader.h index 200eb6a965631e97e5174cfe75ffc6c2c98d77f4..d974b75e11601df5d7acb1132228351e0a8b7fda 100644 --- a/lib/atc/MeshReader.h +++ b/lib/atc/MeshReader.h @@ -6,10 +6,10 @@ #include "MatrixLibrary.h" #include "ATC_Error.h" #include "FE_Mesh.h" - #include <sstream> - -using namespace std; +#include <set> +#include <utility> +#include <string> namespace ATC { @@ -17,7 +17,7 @@ namespace ATC { public: /** constructor, takes a filename */ - MeshReader(string filename, Array<bool> periodicity, double tol=1.e-8); + MeshReader(std::string filename, Array<bool> periodicity, double tol=1.e-8); /** destructor */ ~MeshReader(); @@ -26,25 +26,24 @@ namespace ATC { FE_Mesh* create_mesh(); private: + int number_of_vertices(std::string str); + /** reads .mesh format file */ void read_mesh_file(); /** reads .exo format file */ void read_exo_file(); - /** helper function for parsing mesh type string */ - int int_from_str(string str); - /** Data members for storing necessary information */ - string meshfile_; - Array<bool> periodicity_; - string elementType_; + std::string meshfile_; + ATC_matrix::Array<bool> periodicity_; + std::string elementType_; int nNodes_; int nElements_; int nNodeSets_; - Array2D<int> * conn_; + ATC_matrix::Array2D<int> * conn_; DENS_MAT * nodeCoords_; - Array<pair<string,set<int> > > * nodeSets_; + ATC_matrix::Array<std::pair<std::string,std::set<int> > > * nodeSets_; double coordTol_; }; diff --git a/lib/atc/MoleculeSet.cpp b/lib/atc/MoleculeSet.cpp index 3681fe877d963bbe1e6b9d3d749fb88be76467e3..e1c7da6d8525feee539a7a8e1ce9056f7fc9d5ad 100644 --- a/lib/atc/MoleculeSet.cpp +++ b/lib/atc/MoleculeSet.cpp @@ -4,6 +4,14 @@ #include "LammpsInterface.h" #include "ATC_Error.h" #include <queue> +#include <utility> +#include <sstream> + +using std::multimap; +using std::map; +using std::pair; +using std::set; +using std::stringstream; namespace ATC { diff --git a/lib/atc/MoleculeSet.h b/lib/atc/MoleculeSet.h index 9c30f5352ab3d0f5753fd976a7e1d6bdc96b9b0b..6fa8158766fd15f8e62db51dfaf2b35cecae86cd 100644 --- a/lib/atc/MoleculeSet.h +++ b/lib/atc/MoleculeSet.h @@ -10,8 +10,6 @@ #include <set> #include <vector> -using namespace std; - namespace ATC { // forward declarations @@ -35,7 +33,7 @@ namespace ATC { virtual void clear(); /** initialize global data */ - virtual void initialize(map<int, double> * globalAtomsPerMolecule = NULL); + virtual void initialize(std::map<int, double> * globalAtomsPerMolecule = NULL); /** reset the number of atoms/molecules on this processor */ void reset_nlocal() {this->set_reset();}; @@ -50,10 +48,10 @@ namespace ATC { int local_molecule_count() const {if (need_reset()) reset(); return moleculeToAtoms_.size();}; /** access molecule atoms by lammps id */ - set<int> atoms_by_global_molecule(int id) const; + std::set<int> atoms_by_global_molecule(int id) const; /** access molecules by local indexing */ - const set<int> & atoms_by_local_molecule(int id) const; + const std::set<int> & atoms_by_local_molecule(int id) const; /** access fraction of a locally indexed molecule on this processor */ virtual double local_fraction(int id) const = 0; @@ -81,10 +79,10 @@ namespace ATC { /** multimap from lammps molecule id to ids of consituent atoms, all atoms are real */ // multiple map to account for periodic images - mutable multimap<int, set<int> > moleculeToAtoms_; + mutable std::multimap<int, std::set<int> > moleculeToAtoms_; /** vector in processor-local molecule order to constituent atom sets, atoms include ghosts */ - mutable vector< map<int, set<int> >::const_iterator > localMoleculeToAtoms_; + mutable std::vector< std::map<int, std::set<int> >::const_iterator > localMoleculeToAtoms_; /** resets the quantity based on the latest data */ virtual void reset() const = 0; @@ -122,7 +120,7 @@ namespace ATC { virtual void initialize(); /** access molecule atoms by lammps id */ - set<int> atoms_by_global_molecule(int id) const; + std::set<int> atoms_by_global_molecule(int id) const; /** access fraction of a locally indexed molecule on this processor */ virtual double local_fraction(int id) const; @@ -130,7 +128,7 @@ namespace ATC { protected: /** store the number of atoms in a molecule on this processor */ - //map<int, int> localAtomsPerMolecule_; + //std::map<int, int> localAtomsPerMolecule_; /** resets the quantity based on the latest data */ virtual void reset() const; @@ -142,7 +140,7 @@ namespace ATC { PerAtomQuantity<int> * numBond_; /** removes processor ghosts from a set of atom ids */ - void remove_proc_ghosts(set<int> & atomSet) const; + void remove_proc_ghosts(std::set<int> & atomSet) const; // workspace variable for determining if we've hit an internal atom already mutable Array<bool> _atomFound_; diff --git a/lib/atc/NonLinearSolver.cpp b/lib/atc/NonLinearSolver.cpp index 8018f525a12129d3d56a0bd7d6fc49b628f12bfc..c11ca9474d00983e16fca59f501bee3295743b94 100644 --- a/lib/atc/NonLinearSolver.cpp +++ b/lib/atc/NonLinearSolver.cpp @@ -5,6 +5,8 @@ #include "LammpsInterface.h" +using std::stringstream; + namespace ATC { //=================================================================== // TangentOperator diff --git a/lib/atc/NonLinearSolver.h b/lib/atc/NonLinearSolver.h index 7439153c4c4adc1382ee0eef59b4a860ab1e1f76..d3d906a39a8857f1ef337f4545e06d5404c11b99 100644 --- a/lib/atc/NonLinearSolver.h +++ b/lib/atc/NonLinearSolver.h @@ -9,7 +9,6 @@ // other includes #include <set> #include <map> -using std::pair; namespace ATC { diff --git a/lib/atc/OutputManager.cpp b/lib/atc/OutputManager.cpp index fe8ba89a4735e8ad779c41f6361d9e679a21ff1a..586b4294f01e8c0fb9ac1ab2a9bca314cd13785f 100644 --- a/lib/atc/OutputManager.cpp +++ b/lib/atc/OutputManager.cpp @@ -6,6 +6,15 @@ #include "ATC_Error.h" #include "LammpsInterface.h" +using std::ofstream; +using std::stringstream; +using std::ios_base; +using std::setw; +using std::string; +using std::map; +using std::vector; +using std::set; + namespace ATC { static const int kFieldPrecison = 12; diff --git a/lib/atc/OutputManager.h b/lib/atc/OutputManager.h index c4c70a2e695bef01c95c2765802a5a8231ad3e1e..f63780b77c129fc3c77075018fad64f502aa80fb 100644 --- a/lib/atc/OutputManager.h +++ b/lib/atc/OutputManager.h @@ -2,9 +2,10 @@ #define OUTPUT_MANAGER_H #include "ATC_TypeDefs.h" - #include <map> +#include <vector> #include <string> +#include <set> // 1 -> scalar @@ -13,8 +14,6 @@ // 6 -> tensor xx,yy,zz,xy,zx,yz // 9 -> tensor xx,xy,xz,yx,yy,yz,zx,zy,zz -using namespace std; - namespace ATC { enum OutputType { ENSIGHT=0, GNUPLOT, FULL_GNUPLOT, VTK }; @@ -32,20 +31,20 @@ namespace ATC { public: OutputManager(void); - OutputManager(string outputPrefix, set<int> &otypes); + OutputManager(std::string outputPrefix, std::set<int> &otypes); ~OutputManager(void); /** initialize output */ - void initialize(string outputPrefix, set<int> &otypes); + void initialize(std::string outputPrefix, std::set<int> &otypes); /** set output options */ void set_option(OutputOption option, bool value); // Dump text-based field info to disk for later restart - void write_restart_file(string fileName, RESTART_LIST *data); + void write_restart_file(std::string fileName, RESTART_LIST *data); // Read text-based field file written from write_restart_file - void read_restart_file(string fileName, RESTART_LIST *data); + void read_restart_file(std::string fileName, RESTART_LIST *data); /** write initial/reference geometry default is to write point data, @@ -62,14 +61,14 @@ namespace ATC { const int *node_map=NULL); /** add custom names for any field */ - void add_field_names(const string& name, const vector<string>& list) { + void add_field_names(const std::string& name, const std::vector<std::string>& list) { fieldNames_[name] = list; } /** add a scalar to a text output file */ - void add_global(const string& name, const double& value) { + void add_global(const std::string& name, const double& value) { globalData_[name] = value; } /** delete a scalar from the output */ - void delete_global(const string& name) { globalData_.erase(name); } + void delete_global(const std::string& name) { globalData_.erase(name); } /** reset the stored output scalars */ void reset_globals() { globalData_.clear(); writeGlobalsHeader_=true; } @@ -93,10 +92,10 @@ namespace ATC { else return false; } - bool custom_name(const string field, const int index, string & name) const { - map<string,vector<string> >::const_iterator itr = fieldNames_.find(field); + bool custom_name(const std::string field, const int index, std::string & name) const { + std::map<std::string,std::vector<std::string> >::const_iterator itr = fieldNames_.find(field); if (itr == fieldNames_.end()) return false; - vector<string> names = itr->second; + std::vector<std::string> names = itr->second; name = names[index]; return true; } @@ -106,8 +105,8 @@ namespace ATC { void write_geometry_ensight(void); void write_geometry_text(void); - void write_data_ensight(string name, const MATRIX *data, const int *node_map); - void write_text_data_header(OUTPUT_LIST *data, ofstream & text, int k); + void write_data_ensight(std::string name, const MATRIX *data, const int *node_map); + void write_text_data_header(OUTPUT_LIST *data, std::ofstream & text, int k); void write_data_text(OUTPUT_LIST *data); void write_data_text(OUTPUT_LIST *data, const int *node_map); void write_data_vtk(OUTPUT_LIST *data); @@ -118,7 +117,7 @@ namespace ATC { bool initialized_, firstStep_, firstGlobalsWrite_, writeGlobalsHeader_; /** custom field names */ - map<string,vector<string> > fieldNames_; + std::map<std::string,std::vector<std::string> > fieldNames_; /** pointers to mesh data */ const MATRIX * coordinates_; @@ -130,9 +129,9 @@ namespace ATC { /** data type */ int dataType_; /** base name for output files */ - string outputPrefix_; + std::string outputPrefix_; /** list of output timesteps */ - vector<double> outputTimes_; + std::vector<double> outputTimes_; /** output type flags */ bool ensightOutput_,textOutput_,fullTextOutput_,vtkOutput_; /** output tensor as its components */ @@ -140,7 +139,7 @@ namespace ATC { /** output vector as its components */ bool vectorToComponents_; /** global variables */ - map<string,double> globalData_; + std::map<std::string,double> globalData_; }; } #endif diff --git a/lib/atc/ParDenseMatrix.h b/lib/atc/ParDenseMatrix.h index 06a9549fbe792bda538e0e403cddf1d84a1c9ec4..1c9e75f1711a2e042d894b84b4f878b84a75cabc 100644 --- a/lib/atc/ParDenseMatrix.h +++ b/lib/atc/ParDenseMatrix.h @@ -12,8 +12,6 @@ using ATC::ATC_Error; #include <algorithm> #include <sstream> -using namespace MPI_Wrappers; - namespace ATC_matrix { /** @@ -129,7 +127,7 @@ namespace ATC_matrix { DenseVector<double> c_local = A_local * v_local; // Sum all vectors onto each processor - allsum(_comm, c_local.ptr(), c.ptr(), c_local.size()); + MPI_Wrappers::allsum(_comm, c_local.ptr(), c.ptr(), c_local.size()); #else // Row-major storage diff --git a/lib/atc/ParDiagonalMatrix.cpp b/lib/atc/ParDiagonalMatrix.cpp index 8fbd343b583c58c41e83e9148346159630e2d8ec..15690b32ed81195b1709ee3ea81568f095fd9448 100644 --- a/lib/atc/ParDiagonalMatrix.cpp +++ b/lib/atc/ParDiagonalMatrix.cpp @@ -1,5 +1,7 @@ #include "ParDiagonalMatrix.h" +using MPI_Wrappers::allgatherv; + namespace ATC_matrix { // template<> diff --git a/lib/atc/ParDiagonalMatrix.h b/lib/atc/ParDiagonalMatrix.h index cb854360ab86359741360f2f9e09bc9ea0201954..89f22b783ffc82b7a4d7649173cb75468eb0d3d3 100644 --- a/lib/atc/ParDiagonalMatrix.h +++ b/lib/atc/ParDiagonalMatrix.h @@ -7,8 +7,6 @@ #include "DiagonalMatrix.h" #include "DenseMatrix.h" -using namespace MPI_Wrappers; - namespace ATC_matrix { /** diff --git a/lib/atc/ParSparseMatrix.h b/lib/atc/ParSparseMatrix.h index 5ea20491d734bfc719dec988db1422b3af388f8b..0985115d07725c4b1fdf8d8f1d7bbb5eb57624cd 100644 --- a/lib/atc/ParSparseMatrix.h +++ b/lib/atc/ParSparseMatrix.h @@ -7,8 +7,6 @@ #include "DiagonalMatrix.h" #include <algorithm> -using namespace MPI_Wrappers; - namespace ATC_matrix { /** diff --git a/lib/atc/PerAtomQuantity-inl.h b/lib/atc/PerAtomQuantity-inl.h index 493e681cd72046c9b303253daf382449f8454102..037c3adedad96cf18ca279bb2945500e01f256a3 100644 --- a/lib/atc/PerAtomQuantity-inl.h +++ b/lib/atc/PerAtomQuantity-inl.h @@ -1,6 +1,8 @@ #ifndef PER_ATOM_QUANTITY_INL_H #define PER_ATOM_QUANTITY_INL_H +#include <string> + namespace ATC { //-------------------------------------------------------- @@ -66,17 +68,18 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); if (nCols_==1) { // scalar T * lammpsQuantity = this->lammps_scalar(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); lammpsQuantity[atomIndex] = myQuantity(i,0); } } else{ // vector T ** lammpsQuantity = this->lammps_vector(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < nCols_; j++) { lammpsQuantity[atomIndex][j] = myQuantity(i,j); } @@ -114,19 +117,20 @@ namespace ATC { } // map quantities else { + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); int atomIndex; - + if (nCols_==1) { // scalar const T * lammpsQuantity = this->lammps_scalar(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); myQuantity(i,0) = lammpsQuantity[atomIndex]; } } else { const T * const * lammpsQuantity = this->lammps_vector(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < nCols_; j++) { myQuantity(i,j) = lammpsQuantity[atomIndex][j]; } @@ -201,7 +205,7 @@ namespace ATC { // allocate local atom-based arrays //----------------------------------------------------------------- template <typename T> - void PerAtomQuantity<T>::grow_lammps_array(int nmax, const string & tag) + void PerAtomQuantity<T>::grow_lammps_array(int nmax, const std::string & tag) { if (nCols_ == 1) @@ -341,12 +345,13 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = (PerAtomQuantity<T>::atc_).atc_to_lammps_map(); if (nCols==1) { // scalar T * lammpsQuantity = ProtectedAtomQuantity<T>::lammps_scalar(); for (int i = 0; i < atomMap.nRows(); i++) { int idx = atomMap(i,0); if (idx > -1) { - atomIndex = ProtectedAtomQuantity<T>::quantityToLammps_(i); + atomIndex = quantityToLammps(i); lammpsQuantity[atomIndex] = myQuantity(idx,0); } } @@ -356,7 +361,7 @@ namespace ATC { for (int i = 0; i < atomMap.nRows(); i++) { int idx = atomMap(i,0); if (idx > -1) { - atomIndex = ProtectedAtomQuantity<T>::quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < nCols; j++) { lammpsQuantity[atomIndex][j] = myQuantity(idx,j); } @@ -403,13 +408,13 @@ namespace ATC { // map quantities else { int atomIndex; - + const Array<int> & quantityToLammps = (PerAtomQuantity<T>::atc_).atc_to_lammps_map(); if (nCols==1) { // scalar const T * lammpsQuantity = ProtectedAtomQuantity<T>::lammps_scalar(); for (int i = 0; i < atomMap.nRows(); i++) { int idx = atomMap(i,0); if (idx > -1) { - atomIndex = ProtectedAtomQuantity<T>::quantityToLammps_(i); + atomIndex = quantityToLammps(i); myQuantity(idx,0) = lammpsQuantity[atomIndex]; } } @@ -419,7 +424,7 @@ namespace ATC { for (int i = 0; i < atomMap.nRows(); i++) { int idx = atomMap(i,0); if (idx > -1) { - atomIndex = ProtectedAtomQuantity<T>::quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < nCols; j++) { myQuantity(idx,j) = lammpsQuantity[atomIndex][j]; } @@ -481,9 +486,10 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); T * lammpsQuantity = this->lammps_scalar(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); lammpsQuantity[atomIndex] = myQuantity(i,i); } } @@ -509,9 +515,10 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); const T * lammpsQuantity = this->lammps_scalar(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); myQuantity(i,i) = lammpsQuantity[atomIndex]; } } @@ -567,7 +574,7 @@ namespace ATC { // allocate local atom-based arrays //----------------------------------------------------------------- template <typename T> - void PerAtomDiagonalMatrix<T>::grow_lammps_array(int nmax, const string & tag) + void PerAtomDiagonalMatrix<T>::grow_lammps_array(int nmax, const std::string & tag) { this->lammpsScalar_ = lammpsInterface_->grow_array(this->lammpsScalar_,nmax,tag.c_str()); } @@ -647,16 +654,18 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); T ** lammpsQuantity = this->lammps_vector(); int ** lammpsColIndices = this->lammps_column_indices(); for (int i = 0; i < myQuantity.nRows(); i++) { myQuantity.row(i,_values_,_colIndices_); - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < _values_.size(); j++) { lammpsQuantity[atomIndex][j] = _values_(j); lammpsColIndices[atomIndex][j] = _colIndices_(j); } for (int j = _values_.size(); j < maxEntriesPerRow_; j++) { + lammpsQuantity[atomIndex][j] = 0; lammpsColIndices[atomIndex][j] = -1; } } @@ -689,10 +698,11 @@ namespace ATC { // map quantities else { int atomIndex; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); const T * const * lammpsQuantity = this->lammps_vector(); const int * const * lammpsColIndices = this->lammps_column_indices(); for (int i = 0; i < myQuantity.nRows(); i++) { - atomIndex = quantityToLammps_(i); + atomIndex = quantityToLammps(i); for (int j = 0; j < maxEntriesPerRow_; j++) { if (lammpsColIndices[atomIndex][j] < 0) { break; @@ -713,12 +723,12 @@ namespace ATC { int PerAtomSparseMatrix<T>::pack_exchange(int i, double *buffer) { int idx = 0; + T ** lammpsVector = this->lammps_vector(); for (int j = 0; j < maxEntriesPerRow_; j++) { - T ** lammpsVector = this->lammps_vector(); buffer[idx++] = static_cast<double>(lammpsVector[i][j]); } + int ** lammpsColIndices = this->lammps_column_indices(); for (int j = 0; j < maxEntriesPerRow_; j++) { - int ** lammpsColIndices = this->lammps_column_indices(); buffer[idx++] = static_cast<double>(lammpsColIndices[i][j]); } return 2*maxEntriesPerRow_; @@ -731,12 +741,12 @@ namespace ATC { int PerAtomSparseMatrix<T>::unpack_exchange(int i, double *buffer) { int idx = 0; + T ** lammpsVector = this->lammps_vector(); for (int j = 0; j < maxEntriesPerRow_; j++) { - T ** lammpsVector = this->lammps_vector(); lammpsVector[i][j] = static_cast<T>(buffer[idx++]); } + int ** lammpsColIndices = this->lammps_column_indices(); for (int j = 0; j < maxEntriesPerRow_; j++) { - int ** lammpsColIndices = this->lammps_column_indices(); lammpsColIndices[i][j] = static_cast<int>(buffer[idx++]); } return 2*maxEntriesPerRow_; @@ -749,7 +759,7 @@ namespace ATC { int PerAtomSparseMatrix<T>::pack_comm(int index, double *buf, int pbc_flag, int *pbc) { - return maxEntriesPerRow_; + return 0; } //----------------------------------------------------------------- @@ -758,18 +768,18 @@ namespace ATC { template <typename T> int PerAtomSparseMatrix<T>::unpack_comm(int index, double *buf) { - return maxEntriesPerRow_; + return 0; } //----------------------------------------------------------------- // allocate local atom-based arrays //----------------------------------------------------------------- template <typename T> - void PerAtomSparseMatrix<T>::grow_lammps_array(int nmax, const string & tag) + void PerAtomSparseMatrix<T>::grow_lammps_array(int nmax, const std::string & tag) { this->lammpsVector_ = lammpsInterface_->grow_array(this->lammpsVector_,nmax,maxEntriesPerRow_,tag.c_str()); - string myString(tag+string("Columns")); + std::string myString(tag+std::string("Columns")); this->lammpsColIndices_ = lammpsInterface_->grow_array(this->lammpsColIndices_,nmax,maxEntriesPerRow_,myString.c_str()); } diff --git a/lib/atc/PerAtomQuantity.h b/lib/atc/PerAtomQuantity.h index 69daf2c4b77d5a2e6c6c8b20b6032ea8008bb61e..a4e8c78aadd4cae372447a1eaa8ff6d9fdcfa200 100644 --- a/lib/atc/PerAtomQuantity.h +++ b/lib/atc/PerAtomQuantity.h @@ -8,10 +8,9 @@ #include "DependencyManager.h" #include "PaqAtcUtility.h" #include <set> +#include <string> #include <vector> -using namespace std; - namespace ATC { // forward declarations @@ -98,7 +97,7 @@ namespace ATC { virtual int size_comm() const {return nCols_;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag); + virtual void grow_lammps_array(int nmax, const std::string & tag); /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j); @@ -291,7 +290,7 @@ namespace ATC { virtual int size_comm() {return 0;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag) {}; + virtual void grow_lammps_array(int nmax, const std::string & tag) {}; /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j) {}; @@ -741,7 +740,7 @@ namespace ATC { virtual int unpack_exchange(int i, double *buffer) {return 0;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag) {}; + virtual void grow_lammps_array(int nmax, const std::string & tag) {}; /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j) {}; @@ -798,7 +797,7 @@ namespace ATC { virtual int unpack_exchange(int i, double *buffer) {return 0;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag) {}; + virtual void grow_lammps_array(int nmax, const std::string & tag) {}; /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j) {}; @@ -957,7 +956,7 @@ namespace ATC { virtual int size_comm() const {return 1;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag); + virtual void grow_lammps_array(int nmax, const std::string & tag); /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j); @@ -1201,7 +1200,7 @@ namespace ATC { virtual int size_comm() const {return 2*maxEntriesPerRow_;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag); + virtual void grow_lammps_array(int nmax, const std::string & tag); /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j); @@ -1213,8 +1212,7 @@ namespace ATC { virtual void lammps_force_reset() {}; /** resets local storage */ - //WIP_JAT revert this to force_reset when reset_nlocal is functioning correctly (see comment by ATC_Method::reset_nlocal - interscaleManager_.reset_nlocal()) - virtual void reset_nlocal() { this->set_reset();} + virtual void reset_nlocal() { this->set_reset();}; protected: @@ -1439,7 +1437,7 @@ namespace ATC { virtual int size_comm() const {return 0;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag) {}; + virtual void grow_lammps_array(int nmax, const std::string & tag) {}; /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j) {}; diff --git a/lib/atc/PerAtomQuantityLibrary.cpp b/lib/atc/PerAtomQuantityLibrary.cpp index 29c2b117d24675d011075bf3ef5db25ce4187da3..c7f57fd7230ba89a8954d3da804e1ff1a21f6354 100644 --- a/lib/atc/PerAtomQuantityLibrary.cpp +++ b/lib/atc/PerAtomQuantityLibrary.cpp @@ -4,6 +4,17 @@ #include "FE_Engine.h" #include "LammpsInterface.h" #include <typeinfo> +#include <sstream> +#include <iostream> + +using std::map; +using std::ifstream; +using std::stringstream; +using std::set; +using std::string; +using std::vector; + +using ATC_Utility::to_string; namespace ATC { @@ -96,10 +107,11 @@ namespace ATC { INT_ARRAY map = map_->quantity(); int * type = ATC::LammpsInterface::instance()->atom_type(); ESET::const_iterator itr; + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); for (int i = 0; i < map.size(); i++) { for (itr=eset_.begin(); itr != eset_.end(); itr++) { if (map(i,0) == *itr) { - int a = quantityToLammps_(i); + int a = quantityToLammps(i); if (type[a] == type_) { list_.push_back(ID_PAIR(i,a)); break; @@ -577,10 +589,11 @@ namespace ATC { //PerAtomQuantity<double>::reset(); int nlocal = atc_->nlocal(); quantity_.reset(nlocal,typeList_.size()+groupList_.size()); + const Array<int> & quantityToLammps = (PerAtomQuantity<double>::atc_).atc_to_lammps_map(); if (typeList_.size()) { int * type = ATC::LammpsInterface::instance()->atom_type(); for (int i = 0; i < nlocal; i++) { - int a = quantityToLammps_(i); + int a = quantityToLammps(i); int index = index_[type[a]-1]; if (index > -1) quantity_(i,index) = 1; } @@ -591,7 +604,7 @@ namespace ATC { for (unsigned int j = 0; j < groupList_.size(); j++) { int group = groupList_[j]; for (int i = 0; i < nlocal; i++) { - int a = quantityToLammps_(i); + int a = quantityToLammps(i); if (mask[a] & group) quantity_(i,index) = 1; } index++; @@ -1539,8 +1552,9 @@ namespace ATC { size_ = 0; const int * type = lammpsInterface_->atom_type(); + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); for (int i = 0; i < quantity_.nRows(); ++i) { - int atomIdx = quantityToLammps_(i); + int atomIdx = quantityToLammps(i); if (type[atomIdx] == type_) { quantity_(i,0) = size_; ++size_; @@ -1579,8 +1593,9 @@ namespace ATC { size_ = 0; const int * mask = lammpsInterface_->atom_mask(); + const Array<int> & quantityToLammps = atc_.atc_to_lammps_map(); for (int i = 0; i < quantity_.nRows(); ++i) { - int atomIdx = quantityToLammps_(i); + int atomIdx = quantityToLammps(i); if (mask[atomIdx] & group_) { quantity_(i,0) = size_; ++size_; @@ -2117,7 +2132,7 @@ namespace ATC { PerAtomKernelFunction::PerAtomKernelFunction(ATC_Method * atc, PerAtomQuantity<double> * atomPositions, AtomType atomType) : - ProtectedAtomSparseMatrix<double>(atc,(atc->fe_engine())->num_nodes(),(atc->fe_engine())->num_nodes(),atomType), + ProtectedAtomSparseMatrix<double>(atc,(atc->fe_engine())->num_nodes(),atc->accumulant_bandwidth(),atomType), atomPositions_(atomPositions), feEngine_(atc->fe_engine()) { diff --git a/lib/atc/PerAtomQuantityLibrary.h b/lib/atc/PerAtomQuantityLibrary.h index 16664dde4de5be6c926793ef4a9ca24f40192052..e6847ef6afd0528e76306df02060c36d64f2550b 100644 --- a/lib/atc/PerAtomQuantityLibrary.h +++ b/lib/atc/PerAtomQuantityLibrary.h @@ -3,14 +3,12 @@ #ifndef PER_ATOM_QUANTITY_LIBRARY_H #define PER_ATOM_QUANTITY_LIBRARY_H -// ATC_Method headers #include "PerAtomQuantity.h" #include "FundamentalAtomicQuantity.h" #include <set> +#include <map> #include <vector> - -using namespace std; - +#include <string> namespace ATC { @@ -60,9 +58,9 @@ namespace ATC { public: // constructor - AtomTypeVector(ATC_Method * atc, vector<int> typeList, + AtomTypeVector(ATC_Method * atc, std::vector<int> typeList, AtomType atomType = INTERNAL); - AtomTypeVector(ATC_Method * atc, vector<int> typeList, vector<int> grpList, + AtomTypeVector(ATC_Method * atc, std::vector<int> typeList, std::vector<int> grpList, AtomType atomType = INTERNAL); // destructor @@ -74,8 +72,8 @@ namespace ATC { protected: ATC_Method * atc_; int ntypes_; - vector<int> typeList_,index_; // lammps->atc & atc->lammps - vector<int> groupList_; + std::vector<int> typeList_,index_; // lammps->atc & atc->lammps + std::vector<int> groupList_; private: AtomTypeVector(); // do not define @@ -202,7 +200,7 @@ namespace ATC { // constructor AtomVolumeUser(ATC_Method * atc, - map<int,double> & atomGroupVolume, + std::map<int,double> & atomGroupVolume, AtomType atomType = INTERNAL); // destructor @@ -214,7 +212,7 @@ namespace ATC { virtual void reset() const; /** reference to the map of atom group ids to atom volumes */ - map<int,double> & atomGroupVolume_; + std::map<int,double> & atomGroupVolume_; /** pointer to lammps interface */ const LammpsInterface * lammpsInterface_; @@ -231,7 +229,7 @@ namespace ATC { /** * @class AtomVolumeGroup - * @brief Class for defining the volume per atom based on the atom count in a group and it's volume + * @brief Class for defining the volume per atom based on the atom count in a group and its volume */ class AtomVolumeGroup : public AtomVolumeUser { @@ -240,7 +238,7 @@ namespace ATC { // constructor AtomVolumeGroup(ATC_Method * atc, - map<int,double> & atomGroupVolume, + std::map<int,double> & atomGroupVolume, AtomType atomType = INTERNAL); // destructor @@ -249,7 +247,7 @@ namespace ATC { protected: /** map from group to group atom volume */ - map<int,double> atomGroupVolume_; + std::map<int,double> atomGroupVolume_; /** pointer to lammps interface */ const LammpsInterface * lammpsInterface_; @@ -389,7 +387,7 @@ namespace ATC { // constructor AtomVolumeFile(ATC_Method * atc, - const string & atomVolumeFile, + const std::string & atomVolumeFile, AtomType atomType = INTERNAL); // destructor @@ -401,7 +399,7 @@ namespace ATC { virtual void reset() const; /** file name containing the atomic information */ - const string & atomVolumeFile_; + const std::string & atomVolumeFile_; /** pointer to lammps interface */ const LammpsInterface * lammpsInterface_; @@ -1063,7 +1061,7 @@ namespace ATC { virtual int size_comm() {return 0;}; /** changes size of temperary lammps storage data if transfer is being used */ - virtual void grow_lammps_array(int nmax, const string & tag) {}; + virtual void grow_lammps_array(int nmax, const std::string & tag) {}; /** rearrange memory of temporary lammps storage data, called from copy_array */ virtual void copy_lammps_array(int i, int j) {}; @@ -1607,9 +1605,6 @@ namespace ATC { // do not define PerAtomShapeFunction(); - mutable DENS_MAT OLDPOS; - mutable INT_ARRAY OLDELS; - }; /** diff --git a/lib/atc/PerPairQuantity.cpp b/lib/atc/PerPairQuantity.cpp index c600bcd14fbd5102be277b5c395aadeb654309f6..fa3bbe37e88e2ee28087b56820bec5da9ee92634 100644 --- a/lib/atc/PerPairQuantity.cpp +++ b/lib/atc/PerPairQuantity.cpp @@ -6,6 +6,8 @@ #include "Quadrature.h" using ATC::HeartBeat; +using std::pair; +using std::map; namespace ATC { @@ -24,37 +26,7 @@ PairMapNeighbor::PairMapNeighbor(LammpsInterface * lammpsInterface, int groupbit PairMap(lammpsInterface,groupbit) { }; -bool PairMapNeighbor::need_reset(void) const -{ - int inum = lammpsInterface_->neighbor_list_inum(); - int *ilist = lammpsInterface_->neighbor_list_ilist(); - int *numneigh = lammpsInterface_->neighbor_list_numneigh(); - int **firstneigh = lammpsInterface_->neighbor_list_firstneigh(); - const int * mask = lammpsInterface_->atom_mask(); - pair< int,int > pair_ij; - map< pair< int,int >,int >::iterator pairMapIterator; - - int npairs = 0; - for (int i = 0; i < inum; i++) { - int lammps_i = ilist[i]; - if (mask[lammps_i] & groupbit_) { - for (int j = 0; j < numneigh[lammps_i]; j++) { - int lammps_j = firstneigh[lammps_i][j]; - pair_ij.first = lammps_i; - pair_ij.second = lammps_j; - pairMapIterator = pairMap_.find(pair_ij); - if (pairMapIterator == pairMap_.end()) { - return true; - } - npairs++; - } - } - } - if (npairs != (int) pairMap_.size()) return true; - nPairs_ = npairs; - return false; -} void PairMapNeighbor::reset(void) const { int inum = lammpsInterface_->neighbor_list_inum(); @@ -65,7 +37,7 @@ void PairMapNeighbor::reset(void) const pairMap_.clear(); int pairIndex = nBonds_; - pair< int,int > pair_ij; + std::pair< int,int > pair_ij; for (int i = 0; i < inum; i++) { int lammps_i = ilist[i]; if (mask[lammps_i] & groupbit_) { @@ -80,6 +52,7 @@ void PairMapNeighbor::reset(void) const } } nPairs_ = pairIndex; + needReset_ = false; } //========================================================== @@ -306,7 +279,7 @@ void BondMatrixKernel::reset(void) const int nNodes = feMesh_->num_nodes_unique(); quantity_.reset(nNodes,nPairs); double lam1,lam2; - pair< int,int > pair_jk; + std::pair< int,int > pair_jk; int heartbeatFreq = (nNodes <= 10 ? 1 : (int) nNodes / 10); HeartBeat beat("computing bond matrix ",heartbeatFreq); beat.start(); @@ -362,7 +335,7 @@ void BondMatrixPartitionOfUnity::reset(void) const int nodes_per_element = feMesh_->num_nodes_per_element(); Array<int> node_list(nodes_per_element); DENS_VEC shp(nodes_per_element); - pair< int,int > pair_jk; + std::pair< int,int > pair_jk; int heartbeatFreq = (int) nPairs / 10; HeartBeat beat("computing bond matrix ",heartbeatFreq); beat.start(); diff --git a/lib/atc/PerPairQuantity.h b/lib/atc/PerPairQuantity.h index 8178d2ff201f5d0a83c0883403e499aa8553210c..2c391f99a8624c44121561f92a78112dfeb2194d 100644 --- a/lib/atc/PerPairQuantity.h +++ b/lib/atc/PerPairQuantity.h @@ -8,15 +8,14 @@ #include "DependencyManager.h" #include "PerAtomQuantity.h" #include <map> - -using std::map; -using std::pair; +#include <utility> +#include <string> namespace ATC { /** mapping of atomic pairs to pair index value */ - typedef map< pair< int,int >,int > PAIR_MAP; - typedef map< pair< int,int >,int >::const_iterator PAIR_MAP_ITERATOR; - typedef pair< pair< int,int >,int > ATOM_PAIR; + typedef std::map< std::pair< int,int >,int > PAIR_MAP; + typedef std::map< std::pair< int,int >,int >::const_iterator PAIR_MAP_ITERATOR; + typedef std::pair< std::pair< int,int >,int > ATOM_PAIR; /** * @class PairMap @@ -27,13 +26,18 @@ namespace ATC { public: PairMap(LammpsInterface * lammpsInterface, int groupbit); virtual ~PairMap(void); - virtual bool need_reset(void) const = 0; + virtual void reset(void) const = 0; void quantity() {}; void set_quantity() { throw ATC_Error("inappropriate access to pair map");} + + // lammps communication + virtual void post_exchange() {this->force_reset();}; + virtual void rest_nlocal() {this->force_reset();}; + // iterator interface int size(void) const { - if (need_reset()) reset(); + if (this->need_reset()) reset(); return nPairs_+nBonds_; } int num_bonds(void) const { return nBonds_; } @@ -55,10 +59,10 @@ namespace ATC { public: PairMapNeighbor(LammpsInterface * lammpsInterface, int groupbit); virtual ~PairMapNeighbor(void) {}; - virtual bool need_reset(void) const; + virtual void reset(void) const; virtual ATOM_PAIR start(void) const { - if (need_reset()) reset(); + if (this->need_reset()) reset(); iterator_ = pairMap_.begin(); return *iterator_;} virtual ATOM_PAIR next(void) const { iterator_++; return *iterator_;} @@ -85,12 +89,12 @@ namespace ATC { bool finished() const { return index_==nBonds_; } ATOM_PAIR atom_pair(int n) const { if ( !(n<nBonds_) ) { - pair<int,int> pair_ij(-1,-1); // this is the "end" value + std::pair<int,int> pair_ij(-1,-1); // this is the "end" value ATOM_PAIR p(pair_ij,n); return p; } int * bond = (lammpsInterface_->bond_list())[n]; - pair<int,int> pair_ij(bond[0],bond[1]); + std::pair<int,int> pair_ij(bond[0],bond[1]); ATOM_PAIR p(pair_ij,n); return p; } @@ -124,7 +128,7 @@ namespace ATC { } ATOM_PAIR atom_pair(int n) const { int * bond = (lammpsInterface_->bond_list())[n]; - pair<int,int> pair_ij(bond[0],bond[1]); + std::pair<int,int> pair_ij(bond[0],bond[1]); ATOM_PAIR p(pair_ij,n); return p; } diff --git a/lib/atc/PhysicsModel.cpp b/lib/atc/PhysicsModel.cpp index 4e9cf645c255008c62b7ef360e9b94a07f00a252..77cc41e9726887efa0726c6a62f8968bae67c871 100644 --- a/lib/atc/PhysicsModel.cpp +++ b/lib/atc/PhysicsModel.cpp @@ -10,15 +10,23 @@ #include "WeakEquationPhononTemperature.h" #include "WeakEquationPoisson.h" #include "WeakEquationSchrodinger.h" - #include "ATC_Coupling.h" // for tangent operator - -#include <string> #include <iostream> #include <fstream> +#include <sstream> +#include <utility> -namespace ATC { +using ATC_Utility::command_line; +using ATC_Utility::to_lower; +using std::fstream; +using std::stringstream; +using std::pair; +using std::string; +using std::map; +using std::set; +using std::vector; +namespace ATC { //--------------------------------------------------------------------- // PhysicsModel diff --git a/lib/atc/PhysicsModel.h b/lib/atc/PhysicsModel.h index a794d7d89f5bf91fdabc83ba7a70e28b6c1ede17..86b8e2773d3d2a70d57c061cf6d78e3737ccf94d 100644 --- a/lib/atc/PhysicsModel.h +++ b/lib/atc/PhysicsModel.h @@ -2,6 +2,8 @@ #define PHYSICS_MODEL_H #include <map> +#include <vector> +#include <string> #include "Array2D.h" #include "MatrixLibrary.h" #include "ATC_Error.h" @@ -11,9 +13,6 @@ #include "ATC_TypeDefs.h" #include "Utility.h" -using namespace std; -using namespace ATC_Utility; - namespace ATC { class ATC_Coupling; @@ -36,13 +35,13 @@ namespace ATC public: // constructor - PhysicsModel(string fileName); + PhysicsModel(std::string fileName); // destructor virtual ~PhysicsModel(); /** parse material file */ - void parse_material_file(string fileName); + void parse_material_file(std::string fileName); /** initialize */ void initialize(void); @@ -54,22 +53,22 @@ namespace ATC int nMaterials(void) const { return materials_.size(); } /** access material index from name */ - int material_index(const string & name) const; + int material_index(const std::string & name) const; /** access material from index */ const Material * material(const int index) const {return materials_[index];} /** access to parameter values */ - bool parameter_value(const string& name, double& value, + bool parameter_value(const std::string& name, double& value, const int imat = 0) const ; /** return fields ids and length */ - void num_fields(map<FieldName,int> & fieldSizes, + void num_fields(std::map<FieldName,int> & fieldSizes, Array2D<bool> & rhsMask) const; /** is the material model linear */ bool is_linear(FieldName name) const { - vector< Material* >::const_iterator iter; + std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; bool linear = mat->linear_flux(name) @@ -82,7 +81,7 @@ namespace ATC /** is rhs linear */ bool has_linear_rhs(FieldName name) const { - vector< Material* >::const_iterator iter; + std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; bool constant = mat->linear_flux(name) && mat->linear_source(name); @@ -93,7 +92,7 @@ namespace ATC /** is mass matrix constant */ bool has_constant_mass(FieldName name) const { - vector< Material* >::const_iterator iter; + std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; bool constant = mat->constant_density(name); @@ -105,7 +104,7 @@ namespace ATC /** access to weak equations */ const WeakEquation * weak_equation(FieldName field) const { - map<FieldName,WeakEquation *>::const_iterator itr = weakEqns_.find(field); + std::map<FieldName,WeakEquation *>::const_iterator itr = weakEqns_.find(field); if (itr == weakEqns_.end()) return NULL; return (weakEqns_.find(field))->second; } @@ -124,20 +123,20 @@ namespace ATC protected: /** parameter values */ - map<string, double> parameterValues_; + std::map<std::string, double> parameterValues_; /** material models */ - vector<Material *> materials_; - map<string,int> materialNameToIndexMap_;// maps tag to index + std::vector<Material *> materials_; + std::map<std::string,int> materialNameToIndexMap_;// maps tag to index /** weak equations */ - map<FieldName,WeakEquation *> weakEqns_; + std::map<FieldName,WeakEquation *> weakEqns_; /** null weak equations per material */ Array2D<int> null_; /** type tag */ - string type_; + std::string type_; }; @@ -151,7 +150,7 @@ namespace ATC class PhysicsModelThermal : public PhysicsModel { public: - PhysicsModelThermal(string filename); + PhysicsModelThermal(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelElastic @@ -159,7 +158,7 @@ namespace ATC class PhysicsModelElastic : public PhysicsModel { public: - PhysicsModelElastic(string filename); + PhysicsModelElastic(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelThemoMechanical @@ -167,7 +166,7 @@ namespace ATC class PhysicsModelThermoElastic : public PhysicsModel { public: - PhysicsModelThermoElastic(string filename); + PhysicsModelThermoElastic(std::string filename); }; //------------------------------------------------------------------- @@ -176,7 +175,7 @@ namespace ATC class PhysicsModelShear : public PhysicsModel { public: - PhysicsModelShear(string filename); + PhysicsModelShear(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelThemoShear @@ -184,7 +183,7 @@ namespace ATC class PhysicsModelThermoShear : public PhysicsModel { public: - PhysicsModelThermoShear(string filename); + PhysicsModelThermoShear(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelSpecies @@ -192,7 +191,7 @@ namespace ATC class PhysicsModelSpecies : public PhysicsModel { public: - PhysicsModelSpecies(string filename); + PhysicsModelSpecies(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelTwoTemperature @@ -200,7 +199,7 @@ namespace ATC class PhysicsModelTwoTemperature : public PhysicsModel { public: - PhysicsModelTwoTemperature(string filename); + PhysicsModelTwoTemperature(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusion @@ -208,7 +207,7 @@ namespace ATC class PhysicsModelDriftDiffusion : public PhysicsModel { public: - PhysicsModelDriftDiffusion(string filename); + PhysicsModelDriftDiffusion(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionEquilibrium @@ -216,7 +215,7 @@ namespace ATC class PhysicsModelDriftDiffusionEquilibrium : public PhysicsModel { public: - PhysicsModelDriftDiffusionEquilibrium(string filename); + PhysicsModelDriftDiffusionEquilibrium(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionSchrodinger @@ -224,7 +223,7 @@ namespace ATC class PhysicsModelDriftDiffusionSchrodinger : public PhysicsModel { public: - PhysicsModelDriftDiffusionSchrodinger(string filename); + PhysicsModelDriftDiffusionSchrodinger(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionConvection @@ -232,7 +231,7 @@ namespace ATC class PhysicsModelDriftDiffusionConvection : public PhysicsModel { public: - PhysicsModelDriftDiffusionConvection(string filename); + PhysicsModelDriftDiffusionConvection(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionEquilibrium @@ -240,7 +239,7 @@ namespace ATC class PhysicsModelDriftDiffusionConvectionEquilibrium : public PhysicsModel { public: - PhysicsModelDriftDiffusionConvectionEquilibrium(string filename); + PhysicsModelDriftDiffusionConvectionEquilibrium(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionSchrodinger @@ -248,7 +247,7 @@ namespace ATC class PhysicsModelDriftDiffusionConvectionSchrodinger : public PhysicsModel { public: - PhysicsModelDriftDiffusionConvectionSchrodinger(string filename); + PhysicsModelDriftDiffusionConvectionSchrodinger(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelDriftDiffusionSchrodingerSlice @@ -256,7 +255,7 @@ namespace ATC class PhysicsModelDriftDiffusionSchrodingerSlice : public PhysicsModel { public: - PhysicsModelDriftDiffusionSchrodingerSlice(string filename); + PhysicsModelDriftDiffusionSchrodingerSlice(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelElectrostatic @@ -264,7 +263,7 @@ namespace ATC class PhysicsModelElectrostatic : public PhysicsModel { public: - PhysicsModelElectrostatic(string filename); + PhysicsModelElectrostatic(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelElectrostaticEquilibrium @@ -272,7 +271,7 @@ namespace ATC class PhysicsModelElectrostaticEquilibrium : public PhysicsModel { public: - PhysicsModelElectrostaticEquilibrium(string filename); + PhysicsModelElectrostaticEquilibrium(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelElectrostatic @@ -280,7 +279,7 @@ namespace ATC class PhysicsModelSpeciesElectrostatic : public PhysicsModel { public: - PhysicsModelSpeciesElectrostatic(string filename); + PhysicsModelSpeciesElectrostatic(std::string filename); }; //------------------------------------------------------------------- // @class PhysicsModelTangentOperator diff --git a/lib/atc/PoissonSolver.cpp b/lib/atc/PoissonSolver.cpp index 41df343fad1d7fbce99f95327ca4ba26687afd4f..c2c062edeb277c17192115dbcee73ed27bb972e6 100644 --- a/lib/atc/PoissonSolver.cpp +++ b/lib/atc/PoissonSolver.cpp @@ -4,6 +4,10 @@ #include "PhysicsModel.h" #include "PrescribedDataManager.h" #include "LinearSolver.h" +#include <utility> +#include <iostream> + +using std::pair; diff --git a/lib/atc/PrescribedDataManager.cpp b/lib/atc/PrescribedDataManager.cpp index 2ed390db77627e2f23123469bfb081936ded0c97..8d27f7c21119aa8e4a503f71996710a54b981716 100644 --- a/lib/atc/PrescribedDataManager.cpp +++ b/lib/atc/PrescribedDataManager.cpp @@ -1,8 +1,16 @@ #include "PrescribedDataManager.h" #include "FE_Engine.h" #include "ATC_Error.h" +#include <sstream> +#include <iostream> -#include <set> +using std::stringstream; +using std::make_pair; +using std::map; +using std::set; +using std::pair; +using std::string; +using std::cout; namespace ATC { @@ -117,20 +125,29 @@ namespace ATC { // fix_field //------------------------------------------------------------------------- void PrescribedDataManager::fix_field - (const string nodesetName, + (const std::set<int> nodeSet, const FieldName thisField, const int thisIndex, const XT_Function * f) { using std::set; // fix fields - set<int> nodeSet = (feEngine_->fe_mesh())->nodeset(nodesetName); set<int>::const_iterator iset; for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { int inode = *iset; bcs_[thisField](inode,thisIndex) = (XT_Function*) f; } } + void PrescribedDataManager::fix_field + (const string nodesetName, + const FieldName thisField, + const int thisIndex, + const XT_Function * f) + { + using std::set; + set<int> nodeSet = (feEngine_->fe_mesh())->nodeset(nodesetName); + fix_field(nodeSet,thisField,thisIndex,f); + } //------------------------------------------------------------------------- // unfix_field //------------------------------------------------------------------------- diff --git a/lib/atc/PrescribedDataManager.h b/lib/atc/PrescribedDataManager.h index 851ea5fde01e5c728b6adaef71e00ccc115e0860..1801360a8c67ab184ef63fdec394570d2932879f 100644 --- a/lib/atc/PrescribedDataManager.h +++ b/lib/atc/PrescribedDataManager.h @@ -3,7 +3,9 @@ #include <vector> #include <map> +#include <set> #include <string> +#include <utility> #include "ATC_TypeDefs.h" #include "Function.h" @@ -15,9 +17,6 @@ namespace ATC { - using std::vector; - using std::pair; - using std::map; /** * @class PrescribedDataManager @@ -31,7 +30,7 @@ namespace ATC { //enum Bc_Type {FREE=0,FIELD,SOURCE}; PrescribedDataManager(FE_Engine * feEngine, - const map<FieldName,int> & fieldSize); + const std::map<FieldName,int> & fieldSize); ~PrescribedDataManager(); /** add/remove a field */ @@ -39,13 +38,13 @@ namespace ATC { void remove_field(FieldName fieldName); /** direct access to ics */ - map < FieldName, Array2D < XT_Function * > > * + std::map < FieldName, Array2D < XT_Function * > > * ics(void) { return & ics_; } const Array2D < XT_Function * > * ics(FieldName fieldName) { return & ics_[fieldName]; } /** direct access to bcs */ - const map < FieldName, BCS > & bcs(void) const + const std::map < FieldName, BCS > & bcs(void) const { return bcValues_; } @@ -56,10 +55,10 @@ namespace ATC { } /** */ void bcs - (const FieldName fieldName, const set<int> nodes, BCS & bcs, + (const FieldName fieldName, const std::set<int> nodes, BCS & bcs, bool local = false) const; /** */ - map < FieldName, Array2D < XT_Function * > > * + std::map < FieldName, Array2D < XT_Function * > > * bc_functions(void) { return & bcs_; } /** */ const Array2D < XT_Function * > * @@ -70,7 +69,7 @@ namespace ATC { return ((faceSourcesRobin_.find(fieldName)->second).size() > 0) ; } /** */ - const map<PAIR, Array<UXT_Function*> > * + const std::map<PAIR, Array<UXT_Function*> > * robin_functions(FieldName fieldName) { return & faceSourcesRobin_[fieldName]; } /** query initial state */ @@ -89,11 +88,11 @@ namespace ATC { } /** */ - set<int> fixed_nodes( + std::set<int> fixed_nodes( const FieldName thisField, const int thisIndex=0) const { - set<int> fixed; + std::set<int> fixed; const Array2D < XT_Function *> & bcs = bcs_.find(thisField)->second; for (int node = 0; node < bcs.nRows() ; node++) { if (bcs(node,thisIndex)) fixed.insert(node); @@ -103,7 +102,7 @@ namespace ATC { /** */ void fixed_nodes( const FieldName thisField, - set<int> & fixed, + std::set<int> & fixed, const int thisIndex=0) const { const Array2D < XT_Function *> & bcs = bcs_.find(thisField)->second; @@ -139,18 +138,18 @@ namespace ATC { } /** */ - set<int> flux_face_nodes( + std::set<int> flux_face_nodes( const FieldName thisField, const int thisIndex=0) const { - set<int> fluxes; + std::set<int> fluxes; //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int toInsert[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; - const map < pair <int, int>, Array < XT_Function * > > & sources = faceSources_.find(thisField)->second; - map < pair <int, int>, Array < XT_Function * > >::const_iterator fset_iter; + const std::map < std::pair <int, int>, Array < XT_Function * > > & sources = faceSources_.find(thisField)->second; + std::map < std::pair <int, int>, Array < XT_Function * > >::const_iterator fset_iter; for (fset_iter = sources.begin(); fset_iter != sources.end(); fset_iter++) { int ielem = fset_iter->first.first; // if this is not our element, do not do calculations @@ -176,7 +175,7 @@ namespace ATC { /** */ void flux_face_nodes( const FieldName thisField, - set<int> fluxes, + std::set<int> fluxes, const int thisIndex=0) const { //list of nodes to insert. @@ -184,8 +183,8 @@ namespace ATC { int toInsert[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; - const map < pair <int, int>, Array < XT_Function * > > & sources = faceSources_.find(thisField)->second; - map < pair <int, int>, Array < XT_Function * > >::const_iterator fset_iter; + const std::map < std::pair <int, int>, Array < XT_Function * > > & sources = faceSources_.find(thisField)->second; + std::map < std::pair <int, int>, Array < XT_Function * > >::const_iterator fset_iter; for (fset_iter = sources.begin(); fset_iter != sources.end(); fset_iter++) { int ielem = fset_iter->first.first; // if this is not our element, do not do calculations @@ -208,11 +207,11 @@ namespace ATC { } /** */ - set<int> flux_element_nodes( + std::set<int> flux_element_nodes( const FieldName thisField, const int thisIndex=0) const { - set<int> fluxes; + std::set<int> fluxes; //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int toInsert[nNodes_]; @@ -242,7 +241,7 @@ namespace ATC { /** */ void flux_element_nodes( const FieldName thisField, - set<int> fluxes, + std::set<int> fluxes, const int thisIndex=0) const { //list of nodes to insert. @@ -280,16 +279,21 @@ namespace ATC { } /** set initial field values */ - void fix_initial_field (const string nodesetName, + void fix_initial_field (const std::string nodesetName, const FieldName thisField, const int thisIndex, const XT_Function * f); /** un/set field values at fixed nodesets */ - void fix_field (const string nodesetName, + void fix_field (const std::set<int> nodeset, const FieldName thisField, const int thisIndex, const XT_Function * f); - void unfix_field (const string nodesetName, + /** un/set field values at fixed nodesets */ + void fix_field (const std::string nodesetName, + const FieldName thisField, + const int thisIndex, + const XT_Function * f); + void unfix_field (const std::string nodesetName, const FieldName thisField, const int thisIndex); /** un/set field values at fixed nodes */ @@ -301,26 +305,26 @@ namespace ATC { const FieldName thisField, const int thisIndex); /** un/set fluxes */ - void fix_flux (const string facesetName, + void fix_flux (const std::string facesetName, const FieldName thisField, const int thisIndex, const XT_Function * f); - void unfix_flux(const string facesetName, + void unfix_flux(const std::string facesetName, const FieldName thisField, const int thisIndex); - void fix_robin (const string facesetName, + void fix_robin (const std::string facesetName, const FieldName thisField, const int thisIndex, const UXT_Function * f); - void unfix_robin(const string facesetName, + void unfix_robin(const std::string facesetName, const FieldName thisField, const int thisIndex); /** un/set sources */ - void fix_source(const string nodesetName, + void fix_source(const std::string nodesetName, const FieldName thisField, const int thisIndex, const XT_Function * f); - void unfix_source(const string nodesetName, + void unfix_source(const std::string nodesetName, const FieldName thisField, const int thisIndex); /** get initial conditions */ @@ -358,7 +362,7 @@ namespace ATC { int nElems_; /** names and sizes of fields */ - map<FieldName,int> fieldSizes_; + std::map<FieldName,int> fieldSizes_; /** access to all the FE computations */ FE_Engine * feEngine_; @@ -366,22 +370,22 @@ namespace ATC { // node numbering & dof numbering : contiguous // fieldname & bc_type : types/enums /** ics : XT_Function * f = ics_[field](inode,idof) */ - map < FieldName, Array2D < XT_Function * > > ics_; + std::map < FieldName, Array2D < XT_Function * > > ics_; /** bcs: essential bcs XT_Function * f = bcs_[field][face](idof) */ - map < FieldName, Array2D < XT_Function * > > bcs_; + std::map < FieldName, Array2D < XT_Function * > > bcs_; /** sources : XT_Function * f = faceSources_[field][face](idof) */ - map < FieldName, map < pair <int, int>, Array < XT_Function * > > > + std::map < FieldName, std::map < std::pair <int, int>, Array < XT_Function * > > > faceSources_; /** sources : UXT_Function * f = faceSourcesRobin_[field][face](idof) */ - map < FieldName, map < pair <int, int>, Array < UXT_Function * > > > + std::map < FieldName, std::map < std::pair <int, int>, Array < UXT_Function * > > > faceSourcesRobin_; /** sources : XT_Function * f = elementSources_[field](ielem,idof) */ - map < FieldName, Array2D < XT_Function * > > elementSources_; + std::map < FieldName, Array2D < XT_Function * > > elementSources_; /** values of bcs in a compact set */ - map < FieldName, BCS > bcValues_; + std::map < FieldName, BCS > bcValues_; }; } diff --git a/lib/atc/Quadrature.h b/lib/atc/Quadrature.h index 1b87a232c4b98a0541db6a77100e284aa1b45181..7854e9c3f340c06a1af17ca5498de468ee6fbeb3 100644 --- a/lib/atc/Quadrature.h +++ b/lib/atc/Quadrature.h @@ -23,5 +23,4 @@ class Quadrature { static Quadrature * myInstance_; }; } - #endif diff --git a/lib/atc/SchrodingerSolver.cpp b/lib/atc/SchrodingerSolver.cpp index f6686433768345a3fe7d854ea0229820e96970f2..191ddbb46670adf23e3ad8a452f380e077c351f2 100644 --- a/lib/atc/SchrodingerSolver.cpp +++ b/lib/atc/SchrodingerSolver.cpp @@ -9,6 +9,11 @@ #include "PoissonSolver.h" +#include <utility> + +using std::pair; +using std::set; + const double tol = 1.e-8; const double zero_tol = 1.e-12; const double f_tol = 1.e-8; @@ -114,7 +119,8 @@ double fermi_dirac(const double E, const double T) const int solverType, bool parallel ) - : SchrodingerSolver(fieldName, physicsModel, feEngine, prescribedDataMgr, atc, solverType, parallel), + : SchrodingerSolver(fieldName, physicsModel, feEngine, prescribedDataMgr, + atc, solverType, parallel), oneDslices_(oneDslices) { } @@ -272,11 +278,13 @@ double fermi_dirac(const double E, const double T) { SchrodingerPoissonSolver * ptr; if (oneD_) { - ptr = new SliceSchrodingerPoissonSolver(atc,schrodingerSolver,poissonSolver,physicsModel,maxConsistencyIter_, - maxConstraintIter_, oneDconserve_, Ef_shift_, safe_dEf_); + ptr = new SliceSchrodingerPoissonSolver(atc, + schrodingerSolver,poissonSolver,physicsModel,maxConsistencyIter_, + maxConstraintIter_, oneDconserve_, Ef_shift_, safe_dEf_); } else { - ptr = new SchrodingerPoissonSolver(atc,schrodingerSolver,poissonSolver,physicsModel,maxConsistencyIter_); + ptr = new SchrodingerPoissonSolver(atc, + schrodingerSolver,poissonSolver,physicsModel,maxConsistencyIter_); } return ptr; } @@ -305,6 +313,10 @@ double fermi_dirac(const double E, const double T) void SchrodingerPoissonSolver::solve(FIELDS & rhs, GRAD_FIELD_MATS & fluxes) { + if ((atc_->prescribed_data_manager()->all_fixed(ELECTRON_WAVEFUNCTION)) + && (atc_->prescribed_data_manager()->all_fixed(ELECTRIC_POTENTIAL))) { + return; + } double norm = 1.0, norm0 = 1.0; // normPrev = 1.0; DENS_MAT nPrev,psiPrev,phiPrev; diff --git a/lib/atc/SchrodingerSolver.h b/lib/atc/SchrodingerSolver.h index a2c3a94f0165e495e5840625d3cb8a1b7f18e03a..e190c8eae6fb254363acbf4f67e5f1e5c845f1d9 100644 --- a/lib/atc/SchrodingerSolver.h +++ b/lib/atc/SchrodingerSolver.h @@ -8,6 +8,7 @@ // other includes #include <vector> #include <map> +#include <set> namespace ATC { @@ -98,7 +99,7 @@ class SliceSchrodingerSolver : public SchrodingerSolver { const FE_Engine * feEngine, const PrescribedDataManager * prescribedDataMgr, /*const*/ ATC_Coupling * atc, - const Array< set<int> > & oneDslices, + const Array< std::set<int> > & oneDslices, const int solverType = ATC::LinearSolver::DIRECT_SOLVE, bool parallel = false ); @@ -115,11 +116,11 @@ class SliceSchrodingerSolver : public SchrodingerSolver { /** solve */ virtual bool solve(FIELDS & fields); - Array< set<int> > & slices(void){ return oneDslices_;} + Array< std::set<int> > & slices(void){ return oneDslices_;} protected: - Array< set<int> > oneDslices_; + Array< std::set<int> > oneDslices_; }; @@ -172,7 +173,7 @@ class SliceSchrodingerPoissonSolver : public SchrodingerPoissonSolver { int oneDcoor_; double Ef_shift_; double safe_dEf_; - Array< set<int> > & oneDslices_; + Array< std::set<int> > & oneDslices_; Array2D<double> EfHistory_; }; diff --git a/lib/atc/SparseMatrix-inl.h b/lib/atc/SparseMatrix-inl.h index 56401f64d10e65f4ae6450ab11b2d557aa1f8ba6..066a3a121197c2689ab932d01b14f54fba3c6e21 100644 --- a/lib/atc/SparseMatrix-inl.h +++ b/lib/atc/SparseMatrix-inl.h @@ -73,7 +73,7 @@ void SparseMatrix<T>::_create(INDEX size, INDEX nrows) } catch (std::exception &e) { - cout << "Could not allocate SparseMatrix of "<< _size << " nonzeros.\n"; + std::cout << "Could not allocate SparseMatrix of "<< _size << " nonzeros.\n"; ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } @@ -89,7 +89,7 @@ template<typename T> void SparseMatrix<T>::_delete() { - vector<TRI_COORD<T> >().swap(_tri); // completely deletes _tri + std::vector<TRI_COORD<T> >().swap(_tri); // completely deletes _tri if (_val) delete [] _val; if (_ia) delete [] _ia; if (_ja) delete [] _ja; @@ -139,7 +139,7 @@ void SparseMatrix<T>::_set_equal(const Matrix<T> &r) else if (dynamic_cast<const DenseMatrix<T>*>(ptr_r)) this->reset(r); else { - cout <<"Error in general sparse matrix assignment\n"; + std::cout <<"Error in general sparse matrix assignment\n"; exit(1); } } @@ -332,7 +332,7 @@ void SparseMatrix<T>::compress() nextCRS = TRI_COORD<T>(crs_row, _ja[crs_pt], _val[crs_pt]); } } - else cout << "SparseMatrix - Error in compressing CRS\n"; + else std::cout << "SparseMatrix - Error in compressing CRS\n"; // Add next to the new CRS structure. // Is this a new row (is j>0 and is ja[j] == 0)? @@ -361,7 +361,7 @@ INDEX SparseMatrix<T>::CountUniqueTriplets() std::sort(_tri.begin(), _tri.end(), triplet_comparision<T>); INDEX nUnique=1 + _size; - typename vector<TRI_COORD<T> >::reverse_iterator t; + typename std::vector<TRI_COORD<T> >::reverse_iterator t; // Loop backwards over all new triplets. for (t = _tri.rbegin(); t+1!=_tri.rend(); ++t) { // If this triplet is the same as the preceding one. @@ -440,7 +440,7 @@ T& SparseMatrix<T>::operator()(INDEX i, INDEX j) // NEVER use index operator as LHS to modify values not already in the // sparcity pattern - the crude check below will only catch this on the // second infraction. - if (_zero != T(0)) cout << "Use add or set for SparseMatrix\n"; + if (_zero != T(0)) std::cout << "Use add or set for SparseMatrix\n"; return _zero; } //----------------------------------------------------------------------------- @@ -547,7 +547,7 @@ void SparseMatrix<T>::reset(const DenseMatrix<T>& D, double TOL) template<typename T> void SparseMatrix<T>::copy(const T * ptr, INDEX rows, INDEX cols) { - cout << "SparseMatrix<T>::copy() has no effect.\n"; + std::cout << "SparseMatrix<T>::copy() has no effect.\n"; throw; } //----------------------------------------------------------------------------- @@ -884,10 +884,10 @@ DiagonalMatrix<T> SparseMatrix<T>::row_sum_lump() const // output function - builds a string with each nonzero triplet value //----------------------------------------------------------------------------- template<typename T> -string SparseMatrix<T>::to_string() const +std::string SparseMatrix<T>::to_string() const { compress(*this); - string out; + std::string out; INDEX i, ij; for(i=0; i<_nRowsCRS; i++) { @@ -931,18 +931,18 @@ T SparseMatrix<T>::row_min(INDEX row) const // prints a histogram of the values of a row to the screen //----------------------------------------------------------------------------- template<typename T> -void SparseMatrix<T>::print_row_histogram(const string &name, INDEX nbins) const +void SparseMatrix<T>::print_row_histogram(const std::string &name, INDEX nbins) const { compress(*this); - cout << "Begin histogram " << name << "\n"; - cout << "# rows: " << _nRows << " columns: " << _nCols + std::cout << "Begin histogram " << name << "\n"; + std::cout << "# rows: " << _nRows << " columns: " << _nCols << " size: " << _size << "\n"; for(INDEX i=0; i<_nRows; i++) { print_row_histogram(i, nbins); - cout << "\n"; + std::cout << "\n"; } - cout << "End histogram " << name << "\n"; + std::cout << "End histogram " << name << "\n"; } //----------------------------------------------------------------------------- // prints a histogram of the values of a row to the screen @@ -952,7 +952,7 @@ void SparseMatrix<T>::print_row_histogram(INDEX row, INDEX nbins) const { compress(*this); if (!nbins) nbins++; - vector<INDEX> counts(nbins, 0); + std::vector<INDEX> counts(nbins, 0); const T min = row_min(row); const T max = row_max(row); const T range = max-min; @@ -966,14 +966,14 @@ void SparseMatrix<T>::print_row_histogram(INDEX row, INDEX nbins) const counts[bin-(bin==nbins)]++; } } - cout<<showbase<<scientific; - cout<<"# Histogram: row "<<row<<" min "<<min<<" max "<<max<<" cnt " <<RowSize(row)<<"\n"; + std::cout<<std::showbase<<std::scientific; + std::cout<<"# Histogram: row "<<row<<" min "<<min<<" max "<<max<<" cnt " <<RowSize(row)<<"\n"; T bin_start = min; for(INDEX i=0; i<nbins; i++) { - cout << "(" << bin_start << ","; + std::cout << "(" << bin_start << ","; bin_start += bin_size; - cout << bin_start << ") " << counts[i] << "\n"; + std::cout << bin_start << ") " << counts[i] << "\n"; } } //----------------------------------------------------------------------------- @@ -982,8 +982,8 @@ void SparseMatrix<T>::print_row_histogram(INDEX row, INDEX nbins) const template<typename T> void SparseMatrix<T>::print_triplets() const { - typename vector<TRI_COORD<T> >::const_iterator t; - string out; + typename std::vector<TRI_COORD<T> >::const_iterator t; + std::string out; out += "==================BEGIN TRIPLETS=======================\n"; // Loop backwards over all new triplets. for (t = _tri.begin(); t!=_tri.end(); ++t) { @@ -993,18 +993,18 @@ void SparseMatrix<T>::print_triplets() const out += "\n"; } out += "===================END TRIPLETS========================\n"; - cout << out; + std::cout << out; } //----------------------------------------------------------------------------- // Outputs a string to a sparse Matlab type //----------------------------------------------------------------------------- template<typename T> -void SparseMatrix<T>::matlab(ostream &o, const string &s) const +void SparseMatrix<T>::matlab(std::ostream &o, const std::string &s) const { compress(*this); INDEX i, ij; o << s <<" = sparse(" << nRows() << "," << nCols() << ");\n"; - o << showbase << scientific; + o << std::showbase << std::scientific; for(i=0; i<_nRowsCRS; i++) for(ij=_ia[i]; ij<_ia[i+1]; ij++) o<<s<<"("<<i+1<<","<<_ja[ij]+1<<")="<<_val[ij]<<";\n"; diff --git a/lib/atc/SparseMatrix.h b/lib/atc/SparseMatrix.h index 3cf41a3372c260293891efe427db1d36ea8ac675..35393187cda46bbf1d95c1db7ef45662332915f1 100644 --- a/lib/atc/SparseMatrix.h +++ b/lib/atc/SparseMatrix.h @@ -233,12 +233,12 @@ public: * \section I/O functions */ //* outputs this SparseMatrix to a formatted string - string to_string() const; + std::string to_string() const; using Matrix<T>::matlab; //* writes a command to recreate this matrix in matlab to a stream - void matlab(ostream &o, const string &name="S") const; + void matlab(std::ostream &o, const std::string &name="S") const; //* prints a row histogram for each row - void print_row_histogram(const string &name, INDEX nbins = 10) const; + void print_row_histogram(const std::string &name, INDEX nbins = 10) const; //* prints a histogram of the values in a row void print_row_histogram(INDEX row, INDEX nbins) const; //* prints the current triplets @@ -284,7 +284,7 @@ protected: void copy(const SparseMatrix<T> &C); //* new (unsorted triplet values - won't intersect CRS values) - mutable vector<TRI_COORD<T> > _tri; + mutable std::vector<TRI_COORD<T> > _tri; /* * \section User specified variables */ diff --git a/lib/atc/SparseVector-inl.h b/lib/atc/SparseVector-inl.h index c03528f8858f06453eeb65e89d69522ee39fe962..204c412d6da3374ce72c82bef05393ae90464b84 100644 --- a/lib/atc/SparseVector-inl.h +++ b/lib/atc/SparseVector-inl.h @@ -216,10 +216,10 @@ void SparseVector<T>::write_restart(FILE *F) const // writes a stream to a matlab script to recreate this variable template<class T> -void SparseVector<T>::matlab(ostream &o, const string &s) const +void SparseVector<T>::matlab(std::ostream &o, const std::string &s) const { o << s << "=sparse(" << nRows() << ",1);\n"; - o << showbase << scientific; + o << std::showbase << std::scientific; STORE::const_iterator it; for (it=data_.begin(); it!=data_.end(); it++) o << s << "(" << it->first+1 << ") = " << it->second << ";\n"; diff --git a/lib/atc/SparseVector.h b/lib/atc/SparseVector.h index 594182c9e9d3ad08cb59554f65f6e0a022634be7..4219bb26272a170d53375d7eae90563c13e8a1c1 100644 --- a/lib/atc/SparseVector.h +++ b/lib/atc/SparseVector.h @@ -81,7 +81,7 @@ public: // output to matlab (is this needed) // using Matrix<T>::matlab; //* Writes a matlab string to a stream that creates this object with a name. - void matlab(ostream &o, const string &s="v") const; + void matlab(std::ostream &o, const std::string &s="v") const; protected: //* Banned operators diff --git a/lib/atc/SpeciesTimeIntegrator.cpp b/lib/atc/SpeciesTimeIntegrator.cpp index ac9ae1f3d6867cfa29a121fb7facc1f47f3b7b12..bf9f1a8888516dc1105306f4cca17815f2368245 100644 --- a/lib/atc/SpeciesTimeIntegrator.cpp +++ b/lib/atc/SpeciesTimeIntegrator.cpp @@ -9,6 +9,10 @@ #include "AtomToMoleculeTransfer.h" #include "MoleculeSet.h" +using std::pair; +using std::map; +using std::string; + namespace ATC { //-------------------------------------------------------- @@ -24,7 +28,6 @@ namespace ATC { SpeciesTimeIntegrator::SpeciesTimeIntegrator(ATC_CouplingMass * atc, TimeIntegrationType timeIntegrationType) : TimeIntegrator(atc, timeIntegrationType), - speciesIds_(atc->species_ids()), moleculeIds_(atc->molecule_ids()) { // do nothing @@ -65,14 +68,16 @@ namespace ATC { if (timeFilterManager_->filter_dynamics()) { switch (timeIntegrationType_) { case FRACTIONAL_STEP: { - timeIntegrationMethod_ = new SpeciesTimeIntegratorFractionalStepFiltered(this,speciesIds_,moleculeIds_); + timeIntegrationMethod_ = new SpeciesTimeIntegratorFractionalStepFiltered(this, + moleculeIds_); } default: throw ATC_Error("Unknown time integration type in SpeciesTimeIntegrator::Initialize()"); } } else { - timeIntegrationMethod_ = new SpeciesTimeIntegratorFractionalStep(this,speciesIds_,moleculeIds_); + timeIntegrationMethod_ = new SpeciesTimeIntegratorFractionalStep(this, + moleculeIds_); } } } @@ -98,7 +103,6 @@ namespace ATC { // Grab data from ATC //-------------------------------------------------------- SpeciesIntegrationMethod::SpeciesIntegrationMethod(SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, const map<string,pair<MolSize,int> > & moleculeIds) : TimeIntegrationMethod(speciesTimeIntegrator), timeFilter_(speciesTimeIntegrator->time_filter()), @@ -108,7 +112,6 @@ namespace ATC { speciesConcentration_(atc_->field(SPECIES_CONCENTRATION)), nodalAtomicSpeciesConcentration_(NULL), nodalAtomicSpeciesConcentrationFiltered_(speciesTimeIntegrator->nodal_atomic_species_concentration_filtered()), - speciesIds_(speciesIds), moleculeIds_(moleculeIds) { // do nothing @@ -138,9 +141,8 @@ namespace ATC { // Constructor //-------------------------------------------------------- SpeciesTimeIntegratorFractionalStep::SpeciesTimeIntegratorFractionalStep(SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, const map<string,pair<MolSize,int> > & moleculeIds) : - SpeciesIntegrationMethod(speciesTimeIntegrator,speciesIds,moleculeIds) + SpeciesIntegrationMethod(speciesTimeIntegrator,moleculeIds) { // do nothing } @@ -233,9 +235,8 @@ namespace ATC { SpeciesTimeIntegratorFractionalStepFiltered::SpeciesTimeIntegratorFractionalStepFiltered( SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, const map<string,pair<MolSize,int> > & moleculeIds) : - SpeciesTimeIntegratorFractionalStep(speciesTimeIntegrator,speciesIds,moleculeIds) + SpeciesTimeIntegratorFractionalStep(speciesTimeIntegrator,moleculeIds) { throw ATC_Error("SpeciesTimeIntegratorFractionalStepFiltered work in progress"); // do nothing diff --git a/lib/atc/SpeciesTimeIntegrator.h b/lib/atc/SpeciesTimeIntegrator.h index 4c799b747c8b3fec4d9d28aaa7639e42d4510e9d..5d6c962d719336373935d32f9d193f1206783d06 100644 --- a/lib/atc/SpeciesTimeIntegrator.h +++ b/lib/atc/SpeciesTimeIntegrator.h @@ -1,10 +1,13 @@ #ifndef SPECIES_TIME_INTEGRATOR_H #define SPECIES_TIME_INTEGRATOR_H +#include <map> +#include <utility> +#include <string> + // ATC headers #include "TimeIntegrator.h" -using namespace std; namespace ATC { // forward declarations @@ -41,10 +44,8 @@ namespace ATC { protected: - /** sets of species tracked */ - const map<string,pair<IdType,int> > & speciesIds_; /** sets of molecules tracked */ - const map<string,pair<MolSize,int> > & moleculeIds_; + const std::map<std::string,std::pair<MolSize,int> > & moleculeIds_; /** data */ DENS_MAN nodalAtomicSpeciesConcentrationFiltered_; @@ -67,8 +68,7 @@ namespace ATC { // constructor SpeciesIntegrationMethod(SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, - const map<string,pair<MolSize,int> > & moleculeIds); + const std::map<std::string,std::pair<MolSize,int> > & moleculeIds); // destructor virtual ~SpeciesIntegrationMethod() {nodalAtomicMassDensity_=NULL;}; @@ -92,10 +92,9 @@ namespace ATC { DENS_MAN & speciesConcentration_; DENS_MAN * nodalAtomicSpeciesConcentration_; DENS_MAN & nodalAtomicSpeciesConcentrationFiltered_; - /** sets of species tracked */ - const map<string,pair<IdType,int> > & speciesIds_; + /** sets of molecules tracked */ - const map<string,pair<MolSize,int> > & moleculeIds_; + const std::map<std::string,std::pair<MolSize,int> > & moleculeIds_; private: @@ -117,8 +116,7 @@ namespace ATC { // constructor SpeciesTimeIntegratorFractionalStep(SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, - const map<string,pair<MolSize,int> > & moleculeIds); + const std::map<std::string,std::pair<MolSize,int> > & moleculeIds); // destructor virtual ~SpeciesTimeIntegratorFractionalStep(){}; @@ -153,8 +151,7 @@ namespace ATC { // constructor SpeciesTimeIntegratorFractionalStepFiltered(SpeciesTimeIntegrator * speciesTimeIntegrator, - const map<string,pair<IdType,int> > & speciesIds, - const map<string,pair<MolSize,int> > & moleculeIds); + const std::map<std::string,std::pair<MolSize,int> > & moleculeIds); // destructor virtual ~SpeciesTimeIntegratorFractionalStepFiltered(){}; diff --git a/lib/atc/Stress.cpp b/lib/atc/Stress.cpp index c1747c3e91961dd46a7bf3337baffef01e022919..df329f9faf3b0600e1ef07d34747413bb955469b 100644 --- a/lib/atc/Stress.cpp +++ b/lib/atc/Stress.cpp @@ -8,16 +8,19 @@ #include "LammpsInterface.h" #include "VoigtOperations.h" #include <iostream> -#include <fstream> +using ATC_Utility::command_line; +using ATC_Utility::str2dbl; using voigt3::voigt_idx1; using voigt3::voigt_idx2; -//using voigt3::voigt_idx1_symm; -//using voigt3::voigt_idx2_symm; using voigt3::to_voigt_unsymmetric; using voigt3::from_voigt_unsymmetric; using voigt3::to_voigt; using voigt3::from_voigt; +using std::stringstream; +using std::vector; +using std::string; +using std::fstream; namespace ATC { //============================================================================= diff --git a/lib/atc/Stress.h b/lib/atc/Stress.h index 66394f1e6fe911740329c58fe0a4ee5de134debd..bf406551928827f5d76d7f9156c1cb8c8d2bf39c 100644 --- a/lib/atc/Stress.h +++ b/lib/atc/Stress.h @@ -4,18 +4,12 @@ #include <map> #include <string> #include <vector> - -using std::map; -using std::string; - +#include <fstream> #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" #include "ATC_TypeDefs.h" #include "NonLinearSolver.h" -using ATC_Utility::command_line; -using ATC_Utility::str2dbl; - namespace ATC { enum ElasticityTensorType {FIRST_ELASTICITY_TENSOR=0, SECOND_ELASTICITY_TENSOR}; /** @@ -30,7 +24,7 @@ namespace ATC { virtual ~Stress() {}; virtual void initialize(void){}; //* Returns parameter values, (Nothing uses this). - virtual void parameters(map<string,double> ¶meters) {} + virtual void parameters(std::map<std::string,double> ¶meters) {} //* Computes stress given a displacement gradient. //* Units: mvv/L^3 (i.e. for units Real: g/(mol ps^2 A^2) ) virtual void stress(const FIELD_MATS &fields, @@ -56,7 +50,7 @@ namespace ATC { { public: StressCubicElastic():c11_(0),c12_(0),c44_(0){}; - StressCubicElastic(fstream &matfile); + StressCubicElastic(std::fstream &matfile); StressCubicElastic(double c11, double c12, double c44) : c11_(c11), c12_(c12), c44_(c44) { } void stress(const FIELD_MATS &fields, @@ -80,7 +74,7 @@ namespace ATC { class StressCubicElasticDamped : public StressCubicElastic { public: - StressCubicElasticDamped(fstream &matfile); + StressCubicElasticDamped(std::fstream &matfile); StressCubicElasticDamped(double c11, double c12, double c44, double gamma) : StressCubicElastic(c11,c12,c44), gamma_(gamma) { } void stress(const FIELD_MATS &fields, @@ -98,7 +92,7 @@ namespace ATC { class StressLinearElastic : public StressCubicElastic { public: - StressLinearElastic(fstream &matfile); + StressLinearElastic(std::fstream &matfile); void stress(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT_VEC &flux); @@ -134,7 +128,7 @@ namespace ATC { class StressCauchyBorn : public Stress { public: - StressCauchyBorn(fstream &matfile, CbData &cb); + StressCauchyBorn(std::fstream &matfile, CbData &cb); virtual ~StressCauchyBorn(); virtual void initialize(void); //* Returns the stress computed from a 0K Cauchy-Born approxmation. diff --git a/lib/atc/ThermalTimeIntegrator.cpp b/lib/atc/ThermalTimeIntegrator.cpp index d2de5e858ca78a49c90e494378118cc9e1a8ca67..8186437bfaab0feeb259ba8f195bf8bb11ba0788 100644 --- a/lib/atc/ThermalTimeIntegrator.cpp +++ b/lib/atc/ThermalTimeIntegrator.cpp @@ -34,26 +34,23 @@ namespace ATC { int argIndex = 0; // time integration scheme - /*! \page man_time_integration fix_modify AtC time_integration + /*! \page man_thermal_time_integration fix_modify AtC time_integration (thermal) \section syntax fix_modify AtC time_integration <descriptor> \n - descriptor (string) = time integration type \n various time integration methods for the finite elements\n \section description - GEAR - atomic velocity update with 2nd order Verlet \n - nodal temperature update with 3rd or 4th order Gear \n - thermostats based on controlling power \n - FRACTIONAL_STEP - atomic velocity update with 2nd order Verlet \n - mixed nodal temperature update, 3/4 Gear for continuum and 2 Verlet for atomic contributions\n - thermostats based on controlling discrete energy changes\n + gear - atomic velocity update with 2nd order Verlet, nodal temperature update with 3rd or 4th order Gear, thermostats based on controlling power \n + fractional_step - atomic velocity update with 2nd order Verlet, mixed nodal temperature update, 3/4 Gear for continuum and 2 Verlet for atomic contributions, thermostats based on controlling discrete energy changes\n \section examples <TT> fix_modify atc time_integration gear </TT> \n <TT> fix_modify atc time_integration fractional_step </TT> \n \section description \section related + see \ref man_fix_atc \section default - Gear + none */ if (strcmp(arg[argIndex],"gear")==0) { timeIntegrationType_ = GEAR; diff --git a/lib/atc/ThermalTimeIntegrator.h b/lib/atc/ThermalTimeIntegrator.h index 86d638be0361b57f4167fb0fac19ee137b9469f4..f0ce73b9b4ae596d36ea0506e97e38c35b3cf68a 100644 --- a/lib/atc/ThermalTimeIntegrator.h +++ b/lib/atc/ThermalTimeIntegrator.h @@ -4,7 +4,6 @@ // ATC headers #include "TimeIntegrator.h" -using namespace std; namespace ATC { // forward declarations diff --git a/lib/atc/Thermostat.cpp b/lib/atc/Thermostat.cpp index 1cba968ad5a5ef743b355ef696bdcb655585779c..110d633ac70f6c10503f0d8527970665b19590e7 100644 --- a/lib/atc/Thermostat.cpp +++ b/lib/atc/Thermostat.cpp @@ -40,17 +40,17 @@ namespace ATC { argIndex++; // thermostat type - /*! \page man_control_thermal fix_modify AtC control thermal + /*! \page man_control_thermal fix_modify AtC control thermal \section syntax - fix_modify AtC control thermal <control_type> <optional args>\n + fix_modify AtC control thermal <control_type> <optional_args> - control_type (string) = none | rescale | hoover | flux\n - fix_modify AtC control thermal rescale <frequency>\n + fix_modify AtC control thermal rescale <frequency> \n - frequency (int) = time step frequency for applying velocity rescaling \n fix_modify AtC control thermal hoover \n - fix_modify AtC control thermal flux <boundary_integration_type> <face_set_id(optional)>\n + fix_modify AtC control thermal flux <boundary_integration_type(optional)> <face_set_id(optional)>\n - boundary_integration_type (string) = faceset | interpolate\n - face_set_id (string), optional = id of boundary face set, if not specified (or not possible when the atomic domain does not line up with @@ -60,7 +60,8 @@ namespace ATC { <TT> fix_modify AtC control thermal none </TT> \n <TT> fix_modify AtC control thermal rescale 10 </TT> \n <TT> fix_modify AtC control thermal hoover </TT> \n - <TT> fix_modify AtC control thermal flux bndy_faces </TT> \n + <TT> fix_modify AtC control thermal flux </TT> \n + <TT> fix_modify AtC control thermal flux faceset bndy_faces </TT> \n \section description Sets the energy exchange mechansim from the finite elements to the atoms, managed through a control algorithm. Rescale computes a scale factor for each atom to match the finite element temperature. Hoover is a Gaussian least-constraint isokinetic thermostat enforces that the nodal restricted atomic temperature matches the finite element temperature. Flux is a similar mode, but rather adds energy to the atoms based on conservation of energy. Hoover and flux allows the prescription of sources or fixed temperatures on the atoms. \section restrictions @@ -112,7 +113,7 @@ namespace ATC { // set parameters for numerical matrix solutions unique to this thermostat /*! \page man_control_thermal_correction_max_iterations fix_modify AtC control thermal correction_max_iterations \section syntax - fix_modify AtC control thermal correction_max_iterations <value>\n + fix_modify AtC control thermal correction_max_iterations <max_iterations> - max_iterations (int) = maximum number of iterations that will be used by iterative matrix solvers\n \section examples diff --git a/lib/atc/Thermostat.h b/lib/atc/Thermostat.h index 7d1639312438f347f54f9fbe517e3bc0ae9650e9..aa265815652dd5876127c1ee7282a0601ea82d00 100644 --- a/lib/atc/Thermostat.h +++ b/lib/atc/Thermostat.h @@ -1,13 +1,11 @@ #ifndef THERMOSTAT_H #define THERMOSTAT_H -// ATC headers #include "AtomicRegulator.h" #include "PerAtomQuantityLibrary.h" - -// other headers #include <map> #include <set> +#include <string> namespace ATC { @@ -29,7 +27,7 @@ namespace ATC { // constructor Thermostat(ATC_Coupling * atc, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); // destructor virtual ~Thermostat(){}; @@ -51,9 +49,9 @@ namespace ATC { // data regarding fixed nodes and applied fluxes /** set of all fixed nodes */ - set<int> fixedNodes_; + std::set<int> fixedNodes_; /** set of all nodes which have a flux applied */ - set<int> fluxNodes_; + std::set<int> fluxNodes_; /** maximum number of iterations used in iterative solve for lambda */ int lambdaMaxIterations_; @@ -77,7 +75,7 @@ namespace ATC { public: ThermostatShapeFunction(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatShapeFunction() {}; @@ -208,7 +206,7 @@ namespace ATC { public: ThermostatGlcFs(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatGlcFs() {}; @@ -342,7 +340,7 @@ namespace ATC { public: ThermostatFlux(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatFlux() {}; @@ -387,7 +385,7 @@ namespace ATC { public: ThermostatFixed(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatFixed() {}; @@ -487,7 +485,7 @@ namespace ATC { public: ThermostatFluxFiltered(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatFluxFiltered() {}; @@ -535,7 +533,7 @@ namespace ATC { public: ThermostatFixedFiltered(Thermostat * thermostat, - const string & regulatorPrefix = ""); + const std::string & regulatorPrefix = ""); virtual ~ThermostatFixedFiltered() {}; diff --git a/lib/atc/TimeFilter.cpp b/lib/atc/TimeFilter.cpp index 8580bb1082b25fc6b86d1ccdf0420eb46c65ef8a..cb6aff9bebb1762ca83db340dd422034b7f60243 100644 --- a/lib/atc/TimeFilter.cpp +++ b/lib/atc/TimeFilter.cpp @@ -1,6 +1,8 @@ #include "ATC_Transfer.h" #include "TimeFilter.h" +using std::set; + namespace ATC { //-------------------------------------------------------- @@ -128,7 +130,7 @@ namespace ATC { // filter type /*! \page man_filter_type fix_modify AtC filter type \section syntax - fix_modify AtC filter type <exponential | no_filter> \n + fix_modify AtC filter type <exponential | step | no_filter> \n \section examples <TT> fix_modify AtC filter type exponential </TT> \n diff --git a/lib/atc/TimeFilter.h b/lib/atc/TimeFilter.h index 06a88b40ce40975f148df02d4230eecfb53c863f..976884eb98471386d149e9817a12d9846ce9d4fb 100644 --- a/lib/atc/TimeFilter.h +++ b/lib/atc/TimeFilter.h @@ -5,11 +5,12 @@ #ifndef TIME_FILTER_H #define TIME_FILTER_H +#include <set> + #include "ATC_TypeDefs.h" #include "MatrixLibrary.h" #include "ATC_Error.h" -using namespace std; namespace ATC { // forward declarations @@ -111,7 +112,7 @@ namespace ATC { bool endEquilibrate_; /** set to store all time filters for later deletion */ - set<TimeFilter * > timeFilterSet_; + std::set<TimeFilter * > timeFilterSet_; }; diff --git a/lib/atc/TimeIntegrator.cpp b/lib/atc/TimeIntegrator.cpp index 18da58548c5346799427dee5110464eee0443c47..26db421b5ca434f693669fae80fc60af06afc10d 100644 --- a/lib/atc/TimeIntegrator.cpp +++ b/lib/atc/TimeIntegrator.cpp @@ -5,6 +5,80 @@ namespace ATC { + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class AtomTimeIntegratorType + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + AtomTimeIntegratorType::AtomTimeIntegratorType(ATC_Method * atc, AtomType atomType) : + atc_(atc), + atomType_(atomType), + mass_(NULL), + position_(NULL), + velocity_(NULL), + force_(NULL) + { + // do nothing + } + + //-------------------------------------------------------- + // construct_transfers + // sets/constructs all required dependency managed data + //-------------------------------------------------------- + void AtomTimeIntegratorType::construct_transfers() + { + InterscaleManager & interscaleManager(atc_->interscale_manager()); + mass_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,atomType_); + position_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION,atomType_); + velocity_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY,atomType_); + force_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE,atomType_); + } + + //-------------------------------------------------------- + // initial_integrate_velocity + // velocity update in first part of velocity-verlet + //-------------------------------------------------------- + void AtomTimeIntegratorType::init_integrate_velocity(double dt) + { + const DENS_MAT & m(mass_->quantity()); + + _deltaQuantity_ = force_->quantity(); + _deltaQuantity_ /= m; + _deltaQuantity_ *= 0.5*dt; + + (*velocity_) += _deltaQuantity_; + } + + //-------------------------------------------------------- + // initial_integrate_position + // position update in first part of velocity-verlet + //-------------------------------------------------------- + void AtomTimeIntegratorType::init_integrate_position(double dt) + { + _deltaQuantity_ = velocity_->quantity(); + _deltaQuantity_ *= dt; + (*position_) += _deltaQuantity_; + } + + //-------------------------------------------------------- + // final_integrate + // velocity update in second part of velocity-verlet + //-------------------------------------------------------- + void AtomTimeIntegratorType::final_integrate(double dt) + { + const DENS_MAT & m(mass_->quantity()); + + _deltaQuantity_ = force_->quantity(); + _deltaQuantity_ /= m; + _deltaQuantity_ *= 0.5*dt; + + (*velocity_) += _deltaQuantity_; + } + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeIntegrator diff --git a/lib/atc/TimeIntegrator.h b/lib/atc/TimeIntegrator.h index 9bca8af94a053db6ebd1ebe87c3b16f3923ab579..5c29a6e121a2b50db20e4fffe4c354f2d8713be7 100644 --- a/lib/atc/TimeIntegrator.h +++ b/lib/atc/TimeIntegrator.h @@ -1,18 +1,103 @@ #ifndef TIME_INTEGRATOR_H #define TIME_INTEGRATOR_H -// ATC headers #include "MatrixLibrary.h" #include "TimeFilter.h" #include "ATC_TypeDefs.h" -using namespace std; namespace ATC { // forward declarations + class ATC_Method; class ATC_Coupling; class TimeIntegrationMethod; + /** + * @class AtomTimeIntegrator + * @brief Base class for various time integrators for atomic quantities (replacing other lammps fixes) + */ + + class AtomTimeIntegrator { + + public: + + // constructor + AtomTimeIntegrator(){}; + + // destructor + virtual ~AtomTimeIntegrator(){}; + + /** create and get necessary transfer operators */ + virtual void construct_transfers(){}; + + /** Predictor phase, Verlet first step for velocity */ + virtual void init_integrate_velocity(double dt){}; + + /** Predictor phase, Verlet first step for position */ + virtual void init_integrate_position(double dt){}; + + /** Corrector phase, Verlet second step for velocity */ + virtual void final_integrate(double dt){}; + + }; + + /** + * @class AtomTimeIntegratorType + * @brief class for applying velocity-verlet based on atom type + */ + + class AtomTimeIntegratorType : public AtomTimeIntegrator { + + public: + + // constructor + AtomTimeIntegratorType(ATC_Method * atc, AtomType atomType); + + // destructor + virtual ~AtomTimeIntegratorType(){}; + + /** create and get necessary transfer operators */ + virtual void construct_transfers(); + + /** Predictor phase, Verlet first step for velocity */ + virtual void init_integrate_velocity(double dt); + + /** Predictor phase, Verlet first step for position */ + virtual void init_integrate_position(double dt); + + /** Corrector phase, Verlet second step for velocity */ + virtual void final_integrate(double dt); + + protected: + + /** pointer to atc object */ + ATC_Method * atc_; + + /** atom type this is applied to */ + AtomType atomType_; + + /** atomic masses */ + DENS_MAN * mass_; + + /** atomic positions */ + DENS_MAN * position_; + + /** atomic velocities */ + DENS_MAN * velocity_; + + /** atomic forces */ + DENS_MAN * force_; + + // workspace + DENS_MAT _deltaQuantity_; + + private: + + // DO NOT define this + AtomTimeIntegratorType(); + + }; + /** * @class TimeIntegrator * @brief Base class for various time integrators for FE quantities diff --git a/lib/atc/TransferLibrary.cpp b/lib/atc/TransferLibrary.cpp index e921875e448451501db51c01ed8bd53b787bc71c..f4cdb172aa502e68cc8c467432e60cc19d9dbef2 100644 --- a/lib/atc/TransferLibrary.cpp +++ b/lib/atc/TransferLibrary.cpp @@ -8,6 +8,17 @@ #include "MoleculeSet.h" //#include <typeinfo> +#include <set> +#include <sstream> +#include <utility> +#include <vector> + +using std::set; +using std::map; +using std::string; +using std::stringstream; +using std::pair; +using std::vector; namespace ATC { @@ -352,6 +363,51 @@ namespace ATC { } } + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class AtomElementMask + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + AtomElementMask::AtomElementMask(ATC_Coupling * atc, + MatrixDependencyManager<DenseMatrix, int> * hasAtoms) : + hasAtoms_(hasAtoms), + feEngine_(atc->fe_engine()) + { + if (!hasAtoms_) { + hasAtoms_ = (atc->interscale_manager()).dense_matrix_int("ElementHasInternal"); + } + if (!hasAtoms_) { + throw ATC_Error("AtomElementMask::AtomElementMask - no element has atoms transfer provided"); + } + hasAtoms_->register_dependence(this); + } + + //-------------------------------------------------------- + // reset_quantity + //-------------------------------------------------------- + void AtomElementMask::reset_quantity() const + { + const INT_ARRAY & hasAtoms(hasAtoms_->quantity()); + int nElts = hasAtoms.size(); + quantity_.resize(nElts,1); + + for (int i = 0; i < nElts; ++i) { + quantity_(i,0) = hasAtoms(i,0); + } + + // this seems to cause problems because many materials end up being null + const set<int> & nullElements = feEngine_->null_elements(); + set<int>::const_iterator iset; + for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { + int ielem = *iset; + quantity_(ielem,0) = false; + } + } + //-------------------------------------------------------- //-------------------------------------------------------- // Class ElementMaskNodeSet @@ -490,6 +546,84 @@ namespace ATC { } } + //-------------------------------------------------------- + //-------------------------------------------------------- + // Class NodalGeometryTypeElementSet + //-------------------------------------------------------- + //-------------------------------------------------------- + + //-------------------------------------------------------- + // Constructor + //-------------------------------------------------------- + NodalGeometryTypeElementSet::NodalGeometryTypeElementSet(ATC_Coupling * atc, + MatrixDependencyManager<DenseMatrix, int> * hasInternal) : + hasInternal_(hasInternal), + feEngine_(atc->fe_engine()), + nNodes_(atc->num_nodes()), + nElts_((atc->fe_engine())->num_elements()) + { + if (!hasInternal_) { + hasInternal_ = (atc->interscale_manager()).dense_matrix_int("ElementHasInternal"); + } + if (!hasInternal_) { + throw ATC_Error("NodalGeometryTypeElementSet: No ElementHasInternal object provided or exists"); + } + hasInternal_->register_dependence(this); + } + + //-------------------------------------------------------- + // reset_quantity + //-------------------------------------------------------- + void NodalGeometryTypeElementSet::reset_quantity() const + { + const INT_ARRAY & hasInternal(hasInternal_->quantity()); + _nodesInternal_.resize(nNodes_); + _nodesInternal_ = 0; + _nodesGhost_.reset(nNodes_); + _nodesGhost_ = 0; + Array<int> nodes; + + + + vector<int> myElems = feEngine_->fe_mesh()->owned_elts(); + // iterate through all elements owned by this processor + for (vector<int>::iterator elemsIter = myElems.begin(); + elemsIter != myElems.end(); + ++elemsIter) + { + int ielem = *elemsIter; + if (hasInternal(ielem,0)) { + feEngine_->element_connectivity(ielem,nodes); + for (int j = 0; j < nodes.size(); j++) { + _nodesInternal_(nodes(j)) = 1; + } + } + else { + feEngine_->element_connectivity(ielem,nodes); + for (int j = 0; j < nodes.size(); j++) { + _nodesGhost_(nodes(j)) = 1; + } + } + } + + // sum up partial result arrays + lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesInternal_.ptr(), _nodesInternal_.size()); + lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesGhost_.ptr(), _nodesGhost_.size()); + + quantity_.resize(nNodes_,1); + for (int i = 0; i < nNodes_; i++) { + if (_nodesInternal_(i) && _nodesGhost_(i)) { + quantity_(i,0) = BOUNDARY; + } + else if (_nodesInternal_(i)) { + quantity_(i,0) = MD_ONLY; + } + else { + quantity_(i,0) = FE_ONLY; + } + } + } + //-------------------------------------------------------- //-------------------------------------------------------- // Class NodeToSubset @@ -1487,10 +1621,11 @@ namespace ATC { KernelFunction* kernelFunction, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, - const DENS_MAT * reference): + DENS_MAN * reference): OnTheFlyKernelAccumulationNormalized(atc,source,kernelFunction,atomCoarseGrainingPositions,weights), reference_(reference) { + reference_->register_dependence(this); } //-------------------------------------------------------- @@ -1499,7 +1634,7 @@ namespace ATC { void OnTheFlyKernelAccumulationNormalizedReferenced::reset_quantity() const { OnTheFlyKernelAccumulationNormalized::reset_quantity(); - quantity_ -= *reference_; + quantity_ -= reference_->quantity(); } //-------------------------------------------------------- @@ -1734,10 +1869,11 @@ namespace ATC { PerAtomQuantity<double> * source, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, - const DENS_MAT * reference): + DENS_MAN * reference): OnTheFlyMeshAccumulationNormalized(atc,source,atomCoarseGrainingPositions,weights), reference_(reference) { + reference_->register_dependence(this); } //-------------------------------------------------------- @@ -1746,7 +1882,7 @@ namespace ATC { void OnTheFlyMeshAccumulationNormalizedReferenced::reset_quantity() const { OnTheFlyMeshAccumulationNormalized::reset_quantity(); - quantity_ -= *reference_; + quantity_ -= reference_->quantity(); } //-------------------------------------------------------- diff --git a/lib/atc/TransferLibrary.h b/lib/atc/TransferLibrary.h index 6f615bdb9073e504cb3b8051f3a17a65f613959c..380cb6dcf3a41f17c9f29513399f90e4b0fc37f2 100644 --- a/lib/atc/TransferLibrary.h +++ b/lib/atc/TransferLibrary.h @@ -3,11 +3,13 @@ #ifndef TRANSFER_LIBRARY_H #define TRANSFER_LIBRARY_H +#include <string> +#include <map> +#include <vector> + // ATC_Method headers #include "TransferOperator.h" -using namespace std; - namespace ATC { // forward declarations @@ -239,6 +241,41 @@ namespace ATC { }; + /** + * @class AtomElementMask + * @brief determines which elements should be used for FE quadrature based on presence of atoms + */ + class AtomElementMask : public DenseMatrixTransfer<bool> { + + public: + + // constructor + AtomElementMask(ATC_Coupling * atc, + MatrixDependencyManager<DenseMatrix, int> * hasAtoms = NULL); + + // destructor + virtual ~AtomElementMask() { + hasAtoms_->remove_dependence(this); + }; + + /** apply transfer operator */ + virtual void reset_quantity() const; + + protected: + + /** shape function matrix over the atoms used to help define the geometry */ + MatrixDependencyManager<DenseMatrix, int> * hasAtoms_; + + /** finite element engine */ + const FE_Engine * feEngine_; + + private: + + // do not define + AtomElementMask(); + + }; + /** * @class NodalGeometryType * @brief Computes the computational geometry associated with each node with respect to the FE and MD regions @@ -290,6 +327,52 @@ namespace ATC { }; + /** + * @class NodalGeometryTypeElementSet + * @brief Divdes nodes into MD, FE, and boundary based on if they are connected to nodes in internal and not internal + */ + + class NodalGeometryTypeElementSet : public DenseMatrixTransfer<int> { + + public: + + // constructor + NodalGeometryTypeElementSet(ATC_Coupling * atc, + MatrixDependencyManager<DenseMatrix, int> * hasInternal = NULL); + + // destructor + virtual ~NodalGeometryTypeElementSet() { + hasInternal_->remove_dependence(this); + }; + + /** apply transfer operator */ + virtual void reset_quantity() const; + + protected: + + /** shape function matrix over the internal atoms used to help define the geometry */ + MatrixDependencyManager<DenseMatrix, int> * hasInternal_; + + /** finite element engine */ + const FE_Engine * feEngine_; + + /** number of nodes in the mesh */ + int nNodes_; + + /** number of elements in the mesh */ + int nElts_; + + // workspace + // ints so they can be shared through MPI + mutable Array<int> _nodesInternal_, _nodesGhost_; + + private: + + // do not define + NodalGeometryTypeElementSet(); + + }; + /** * @class LargeToSmallMap * @brief mapping from a larger set to a smaller set @@ -589,7 +672,7 @@ namespace ATC { virtual void reset_quantity() const; /** map from fields to their sizes */ - map<FieldName,int> fieldSizes_; + std::map<FieldName,int> fieldSizes_; /** map from atom to element in which it resides */ MatrixDependencyManager<DenseMatrix, int> * nodalGeometryType_; @@ -971,7 +1054,7 @@ namespace ATC { PerAtomShapeFunctionGradient(ATC_Method * atc, MatrixDependencyManager<DenseMatrix, int>* atomToElementMap = NULL, DENS_MAN* atomPositions = NULL, - const string & tag = "AtomicShapeFunctionGradient", + const std::string & tag = "AtomicShapeFunctionGradient", AtomType atomType = INTERNAL); // destructor @@ -994,7 +1077,7 @@ namespace ATC { const FE_Engine * feEngine_; /** container for dependency managers */ - vector<AtcAtomSparseMatrix<double> * > matrices_; + std::vector<AtcAtomSparseMatrix<double> * > matrices_; private: @@ -1248,11 +1331,11 @@ namespace ATC { KernelFunction* kernelFunction, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, - const DENS_MAT * reference); + DENS_MAN * reference); // destructor virtual ~OnTheFlyKernelAccumulationNormalizedReferenced() { - atomCoarseGrainingPositions_->remove_dependence(this); + reference_->remove_dependence(this); }; /** do nothing */ @@ -1260,7 +1343,8 @@ namespace ATC { protected: - const DENS_MAT * reference_; + /** reference value */ + DENS_MAN * reference_; private: @@ -1503,11 +1587,11 @@ namespace ATC { PerAtomQuantity<double> * source, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, - const DENS_MAT * reference); + DENS_MAN * reference); // destructor virtual ~OnTheFlyMeshAccumulationNormalizedReferenced() { - atomCoarseGrainingPositions_->remove_dependence(this); + reference_->remove_dependence(this); }; /** do nothing */ @@ -1515,7 +1599,8 @@ namespace ATC { protected: - const DENS_MAT * reference_; + /** reference value */ + DENS_MAN * reference_; private: diff --git a/lib/atc/TransferOperator.cpp b/lib/atc/TransferOperator.cpp index a562d9c25f255bcf8f9ab3ee1644e22077f7b830..efa4bc1da2e3d01d3344314c9c17d010e97c86a1 100644 --- a/lib/atc/TransferOperator.cpp +++ b/lib/atc/TransferOperator.cpp @@ -72,8 +72,9 @@ namespace ATC { // Constructor //-------------------------------------------------------- FeToAtomTransfer::FeToAtomTransfer(ATC_Method * atc, - DENS_MAN * source) : - ProtectedAtomQuantity<double>(atc,source->nCols()), + DENS_MAN * source, + AtomType atomType) : + ProtectedAtomQuantity<double>(atc,source->nCols(),atomType), source_(source) { source_->register_dependence(this); @@ -378,11 +379,12 @@ namespace ATC { AtfProjectionReferenced::AtfProjectionReferenced(ATC_Method * atc, PerAtomQuantity<double> * source, SPAR_MAN * accumulant, - const DENS_MAT * reference, + DENS_MAN * reference, DIAG_MAN * weights) : AtfProjection(atc,source,accumulant,weights), reference_(reference) { + if(reference_) reference_->register_dependence(this); } //-------------------------------------------------------- @@ -390,6 +392,7 @@ namespace ATC { //-------------------------------------------------------- AtfProjectionReferenced::~AtfProjectionReferenced() { + if(reference_) reference_->remove_dependence(this); } //-------------------------------------------------------- @@ -398,7 +401,7 @@ namespace ATC { void AtfProjectionReferenced::reset_quantity() const { global_restriction(); - quantity_ -= *reference_; + quantity_ -= (reference_->quantity()); } //-------------------------------------------------------- @@ -743,12 +746,13 @@ namespace ATC { // Constructor //-------------------------------------------------------- AtfShapeFunctionMdProjectionReferenced::AtfShapeFunctionMdProjectionReferenced(ATC_Method * atc, - DENS_MAN * source, - const DENS_MAT * reference, - FieldName thisField) : + DENS_MAN * source, + DENS_MAN * reference, + FieldName thisField) : AtfShapeFunctionMdProjection(atc,source,thisField), reference_(reference) { + reference_->register_dependence(this); } //-------------------------------------------------------- @@ -756,6 +760,7 @@ namespace ATC { //-------------------------------------------------------- AtfShapeFunctionMdProjectionReferenced::~AtfShapeFunctionMdProjectionReferenced() { + reference_->remove_dependence(this); } //-------------------------------------------------------- @@ -764,7 +769,7 @@ namespace ATC { void AtfShapeFunctionMdProjectionReferenced::reset_quantity() const { quantity_ = source_->quantity(); - quantity_ -= *reference_; + quantity_ -= reference_->quantity(); atc_->apply_inverse_md_mass_matrix(quantity_,thisField_); } @@ -779,8 +784,9 @@ namespace ATC { //-------------------------------------------------------- FtaShapeFunctionProlongation::FtaShapeFunctionProlongation(ATC_Method * atc, DENS_MAN * source, - SPAR_MAN * shapeFunction) : - FeToAtomTransfer(atc,source), + SPAR_MAN * shapeFunction, + AtomType atomType) : + FeToAtomTransfer(atc,source,atomType), shapeFunction_(shapeFunction) { shapeFunction_->register_dependence(this); diff --git a/lib/atc/TransferOperator.h b/lib/atc/TransferOperator.h index bf85b2081b2ef2602355b22d190d9027edc2e15f..333e8d2a698b774b3d16d30c76970f7edf22d388 100644 --- a/lib/atc/TransferOperator.h +++ b/lib/atc/TransferOperator.h @@ -3,13 +3,10 @@ #ifndef TRANSFER_OPERATOR_H #define TRANSFER_OPERATOR_H -// ATC_Method headers #include "PerAtomQuantityLibrary.h" #include <set> #include <vector> -using namespace std; - namespace ATC { // forward declarations @@ -253,10 +250,10 @@ namespace ATC { virtual ~SetTransfer() {}; /** apply transfer operator */ - virtual const set<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); SetDependencyManager<T>::needReset_ = false;} return SetDependencyManager<T>::quantity_;}; + virtual const std::set<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); SetDependencyManager<T>::needReset_ = false;} return SetDependencyManager<T>::quantity_;}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ - virtual set<T> & set_quantity() + virtual std::set<T> & set_quantity() {throw ATC_Error("SetTransfer::set_quantity - Cannot modify protected quantities"); return this->quantity_;}; protected: @@ -283,10 +280,10 @@ namespace ATC { virtual ~VectorTransfer() {}; /** apply transfer operator */ - virtual const vector<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); VectorDependencyManager<T>::needReset_ = false;} return VectorDependencyManager<T>::quantity_;}; + virtual const std::vector<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); VectorDependencyManager<T>::needReset_ = false;} return VectorDependencyManager<T>::quantity_;}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ - virtual vector<T> & set_quantity() + virtual std::vector<T> & set_quantity() {throw ATC_Error("VectorTransfer::set_quantity - Cannot modify protected quantities"); return this->quantity_;}; protected: @@ -369,7 +366,8 @@ namespace ATC { // constructor FeToAtomTransfer(ATC_Method * atc, - DENS_MAN * source); + DENS_MAN * source, + AtomType atomType = INTERNAL); // destructor virtual ~FeToAtomTransfer(); @@ -621,7 +619,7 @@ namespace ATC { AtfProjectionReferenced(ATC_Method * atc, PerAtomQuantity<double> * source, SPAR_MAN * accumulant, - const DENS_MAT * reference, + DENS_MAN * reference, DIAG_MAN * weights = NULL); // destructor @@ -632,7 +630,8 @@ namespace ATC { protected: - const DENS_MAT * reference_; + /** reference value */ + DENS_MAN * reference_; private: @@ -835,7 +834,7 @@ namespace ATC { // constructor AtfShapeFunctionMdProjectionReferenced(ATC_Method * atc, DENS_MAN * source, - const DENS_MAT * reference, + DENS_MAN * reference, FieldName thisField); // destructor @@ -847,7 +846,7 @@ namespace ATC { protected: /** reference value */ - const DENS_MAT * reference_; + DENS_MAN * reference_; private: @@ -994,7 +993,8 @@ namespace ATC { // constructor FtaShapeFunctionProlongation(ATC_Method * atc, DENS_MAN * source, - SPAR_MAN * shapeFunction); + SPAR_MAN * shapeFunction, + AtomType atomType = INTERNAL); // destructor virtual ~FtaShapeFunctionProlongation(); diff --git a/lib/atc/Utility.h b/lib/atc/Utility.h index 1b7017d5103007b45bda3ea861dd8e0b41ebc48d..aa5104293ff9ba47eb3ddc4b3d1d7e1761a6d351 100644 --- a/lib/atc/Utility.h +++ b/lib/atc/Utility.h @@ -7,7 +7,6 @@ #undef near #include <vector> -using std::vector; #include <fstream> #include <cstring> #include <string> @@ -18,13 +17,6 @@ using std::vector; #include "ATC_Error.h" -using std::transform; -using std::fstream; -using std::vector; -using std::string; -using std::strcmp; - - namespace ATC_Utility { /** constants */ @@ -73,15 +65,15 @@ namespace ATC_Utility inline double parse_min(const char * arg) { - if (strcmp(arg,"INF") == 0) return -parsebig; + if (std::strcmp(arg,"INF") == 0) return -parsebig; else return atof(arg); } inline double parse_max(const char * arg) { - if (strcmp(arg,"INF") == 0) return parsebig; + if (std::strcmp(arg,"INF") == 0) return parsebig; else return atof(arg); } inline double parse_minmax(const char * arg) { - if (strcmp(arg,"-INF") == 0) return -parsebig; - else if (strcmp(arg,"INF") == 0) return parsebig; + if (std::strcmp(arg,"-INF") == 0) return -parsebig; + else if (std::strcmp(arg,"INF") == 0) return parsebig; else return atof(arg); } inline void split_values(double & min, double & max) { double eps = std::max(parsetol,parsetol*fabs(min)); @@ -167,9 +159,10 @@ namespace ATC_Utility /** A collection of string convesion/manipulation routines */ //=================================================================== + /** converts anything that has iostream::<< defined to a string */ template<typename T> - inline string to_string(const T &v, int precision=0) + inline std::string to_string(const T &v, int precision=0) { std::ostringstream out; if (precision) out << std::setprecision(precision); @@ -178,23 +171,23 @@ namespace ATC_Utility } /** conversion to string */ - inline string true_false(const double &v) + inline std::string true_false(const double &v) { if (v) return "TRUE"; else return "FALSE"; } /** test conversion to double */ - inline bool is_numeric(const string &s) + inline bool is_numeric(const std::string &s) { double v; std::istringstream in(s); return (in >> v); } - /** convert a string to anything that has iostream::>> defined */ + /** convert a string to anything that has iostream::>> defined, second arg is to disambibuate type */ template<typename T> - inline T str2T(const string &s, T v) + inline T str2T(const std::string &s, T v) { std::istringstream in(s); if (!(in >> v)) throw ATC::ATC_Error("str2T invalid string conversion"); @@ -202,10 +195,10 @@ namespace ATC_Utility } /** convert a string to a double */ - inline double str2dbl(const string &s) { return str2T(s, double(0.0)); } + inline double str2dbl(const std::string &s) { return str2T(s, double(0.0)); } /** tests if conversion to double is possible */ - inline bool is_dbl(const string &s) + inline bool is_dbl(const std::string &s) { char *endptr; strtod(s.c_str(), &endptr); @@ -214,17 +207,17 @@ namespace ATC_Utility } /** convert a string to an int */ - inline int str2int(const string &s) { return str2T(s, int(0)); } + inline int str2int(const std::string &s) { return str2T(s, int(4)); } //* replaces all characters in a set of characters with a character //* @param str input string //* @param *s pointer to array of characters that will be replaced //* @param r character to replace characters in s[] with - static void replace_all_of(string &str, const char *s, const char r) + static void replace_all_of(std::string &str, const char *s, const char r) { size_t found; found = str.find_first_of(s); - while (found != string::npos) + while (found != std::string::npos) { str[found] = r; found = str.find_first_of(s, found+1); @@ -232,55 +225,55 @@ namespace ATC_Utility } /** converts the string to lowercase */ - inline string& to_lower(string &s) + inline std::string& to_lower(std::string &s) { - transform(s.begin(),s.end(),s.begin(),static_cast<int(*)(int)>(tolower)); + std::transform(s.begin(),s.end(),s.begin(),static_cast<int(*)(int)>(tolower)); return s; } /** converts the string to uppercase */ - inline string& to_upper(string &s) + inline std::string& to_upper(std::string &s) { - transform(s.begin(),s.end(),s.begin(),static_cast<int(*)(int)>(toupper)); + std::transform(s.begin(),s.end(),s.begin(),static_cast<int(*)(int)>(toupper)); return s; } /** removes any whitespace from the beginning or end of string */ - static string& trim(string &s) + static std::string& trim(std::string &s) { if (s.empty()) return s; size_t found = s.find_last_not_of(" \t\n"); if (found < s.size()-1) s.erase(found+1); found = s.find_first_not_of(" \t\n"); - if (found != string::npos) s = s.substr(found); + if (found != std::string::npos) s = s.substr(found); return s; } /** splits delimited string into a vector of strings */ - static void split(const string &s, vector<string> &ss, char del=' ') + static void split(const std::string &s, std::vector<std::string> &ss, char del=' ') { ss.clear(); size_t begin=0, end=0; - while (end != string::npos) + while (end != std::string::npos) { begin = s.find_first_not_of(del, end); // find beginning of fragment end = s.find_first_of(del,begin); - if (begin != string::npos) // safe if end is npos-1 + if (begin != std::string::npos) // safe if end is npos-1 ss.push_back(s.substr(begin,end-begin)); } } - static string cap(string & s) { + static std::string cap(std::string & s) { s[0] = toupper(s[0]); return s; } /* turns Aa_Bb_Cc into aa_bb_cc */ - static string to_cap(const string &s) { - vector<string> words; - string delimiter = "_"; + static std::string to_cap(const std::string &s) { + std::vector<std::string> words; + std::string delimiter = "_"; split(s,words,(delimiter.c_str())[0]); - string name = ""; + std::string name = ""; for (unsigned int i = 0; i < words.size(); i++) { name = name + cap(words[i]); } @@ -290,9 +283,9 @@ namespace ATC_Utility //* scans a string for a list of commands delimited by ', \t' with # comments //* @param line The input line to be parsed //* @cs A vector of strings parsed from the input line - static void command_strings(string line, vector<string> &cs) + static void command_strings(std::string line, std::vector<std::string> &cs) { - if (line.find('#') != string::npos) line.erase(line.find("#")); + if (line.find('#') != std::string::npos) line.erase(line.find("#")); replace_all_of(line, "\t,", ' '); to_lower(trim(line)); split(line, cs); @@ -300,9 +293,9 @@ namespace ATC_Utility //* reads a single line from a file and splits it into a vector of strings //* returns the number of strings in the vector - inline int command_line(fstream &fid, vector<string> &cs) + inline int command_line(std::fstream &fid, std::vector<std::string> &cs) { - string line; + std::string line; getline(fid, line); command_strings(line, cs); return cs.size(); diff --git a/lib/atc/Vector.h b/lib/atc/Vector.h index 2d4482ce463c250f2898d8ca18b7d4c2c66ac58f..5630b0ee1347852766bcc4243905e49b1efe6f9e 100644 --- a/lib/atc/Vector.h +++ b/lib/atc/Vector.h @@ -26,7 +26,7 @@ public: Vector(const Vector<T> &c); // do not implement! virtual ~Vector() {} - string to_string() const; + std::string to_string() const; // pure virtual functions virtual T operator()(INDEX i, INDEX j=0) const=0; @@ -43,7 +43,7 @@ public: // output to matlab using Matrix<T>::matlab; - void matlab(ostream &o, const string &s="v") const; + void matlab(std::ostream &o, const std::string &s="v") const; using Matrix<T>::operator=; INDEX nCols() const; @@ -144,18 +144,18 @@ DenseVector<T> operator-(const Vector<T> &a, const Vector<T> &b) /////////////////////////////////////////////////////////////////////////////// //* output operator template<typename T> -string Vector<T>::to_string() const +std::string Vector<T>::to_string() const { - string s; + std::string s; int sz = this->size(); for (INDEX i = 0; i < sz; i++) - s += string(i?"\t":"") + ATC_Utility::to_string((*this)[i],myPrecision); + s += std::string(i?"\t":"") + ATC_Utility::to_string((*this)[i],myPrecision); return s; } /////////////////////////////////////////////////////////////////////////////// //* Writes a matlab script defining the vector to the stream template<typename T> -void Vector<T>::matlab(ostream &o, const string &s) const +void Vector<T>::matlab(std::ostream &o, const std::string &s) const { o << s <<"=zeros(" << this->size() << ",1);\n"; int sz = this->size(); diff --git a/lib/atc/ViscousStress.cpp b/lib/atc/ViscousStress.cpp index 77c789b8dbc3d4fad3cef181ca76092d8ac4b694..4053cf6cb703d5ef88a38c2413bc6dbf8554bd6b 100644 --- a/lib/atc/ViscousStress.cpp +++ b/lib/atc/ViscousStress.cpp @@ -2,7 +2,12 @@ #include "ATC_Error.h" #include "LammpsInterface.h" #include <iostream> -#include <fstream> + +using ATC_Utility::command_line; +using ATC_Utility::str2dbl; +using std::string; +using std::vector; +using std::fstream; namespace ATC { diff --git a/lib/atc/ViscousStress.h b/lib/atc/ViscousStress.h index 3a51702a6a4b05ca80c9940c1b905ac3ba5aa82d..d9da270452ce1bb94ff7ef71fbeb4acee5f35e07 100644 --- a/lib/atc/ViscousStress.h +++ b/lib/atc/ViscousStress.h @@ -4,16 +4,10 @@ #include <map> #include <string> #include <vector> - -using std::map; -using std::string; - +#include <fstream> #include "MatrixLibrary.h" #include "ATC_TypeDefs.h" -using ATC_Utility::command_line; -using ATC_Utility::str2dbl; - namespace ATC { /** @@ -28,7 +22,7 @@ namespace ATC { virtual ~ViscousStress() {}; virtual void initialize(void){}; //* Returns parameter values, (Nothing uses this). - virtual void parameters(map<string,double> ¶meters) {} + virtual void parameters(std::map<std::string,double> ¶meters) {} //* Computes viscous stress given a strain rate tensor. //* Units: mvv/L^3 (i.e. for units Real: g/(mol ps^2 A^2) ) virtual void viscous_stress(const FIELD_MATS &fields, @@ -53,7 +47,7 @@ namespace ATC { { public: ViscousStressConstant():viscosity_(0.){}; - ViscousStressConstant(fstream &matfile); + ViscousStressConstant(std::fstream &matfile); ViscousStressConstant(double viscosity) : viscosity_(viscosity) {}; void viscous_stress(const FIELD_MATS &fields, diff --git a/lib/atc/WeakEquation.h b/lib/atc/WeakEquation.h index 9e10832fc1e8c52f12d4121640a7e29a28862eac..606f09c83decc964364efe3c0fa981e324536385 100644 --- a/lib/atc/WeakEquation.h +++ b/lib/atc/WeakEquation.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_H #define WEAK_EQUATION_H +#include <string> +#include <set> + #include "ATC_TypeDefs.h" namespace ATC{ @@ -84,7 +87,7 @@ class WeakEquation { int field_size(void) const {return fieldSize_;} /** list of require interfaces */ - virtual set<string> needs_material_functions(void) const = 0; + virtual std::set<std::string> needs_material_functions(void) const = 0; protected: /** type of equation */ diff --git a/lib/atc/WeakEquationChargeDiffusion.cpp b/lib/atc/WeakEquationChargeDiffusion.cpp index fae0617ad625fc4ecabd5945b1f691b4f94a515a..05152579fc665d63f37ec3724ac3515d3ce191be 100644 --- a/lib/atc/WeakEquationChargeDiffusion.cpp +++ b/lib/atc/WeakEquationChargeDiffusion.cpp @@ -1,7 +1,6 @@ #include "ATC_Transfer.h" #include "WeakEquationChargeDiffusion.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationChargeDiffusion.h b/lib/atc/WeakEquationChargeDiffusion.h index 7dbe98bdb922752fd73d687d4bf7f169e16a5d96..314790b6367adbd7918e4e549076b51fa7347297 100644 --- a/lib/atc/WeakEquationChargeDiffusion.h +++ b/lib/atc/WeakEquationChargeDiffusion.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_CHARGE_DIFFUSION_H #define WEAK_EQUATION_CHARGE_DIFFUSION_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -27,9 +30,9 @@ class WeakEquationChargeDiffusion : public WeakEquation { const Material * material, DENS_MAT &density ) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; return needs; } }; diff --git a/lib/atc/WeakEquationDiffusion.cpp b/lib/atc/WeakEquationDiffusion.cpp index 6ad167d2a7193226cc84e9072f049dd4b46691c2..1af7d2f7f3ad01440d7bd75b18efeace01e8a4d4 100644 --- a/lib/atc/WeakEquationDiffusion.cpp +++ b/lib/atc/WeakEquationDiffusion.cpp @@ -1,7 +1,6 @@ #include "ATC_Transfer.h" #include "WeakEquationDiffusion.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationDiffusion.h b/lib/atc/WeakEquationDiffusion.h index 26d2c8a48629959d95ab16bdf7074f479f50c389..057f499382df197825088b18d7e838857efdbd29 100644 --- a/lib/atc/WeakEquationDiffusion.h +++ b/lib/atc/WeakEquationDiffusion.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_DIFFUSION_H #define WEAK_EQUATION_DIFFUSION_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -36,9 +39,9 @@ class WeakEquationDiffusion : public WeakEquation { DENS_MAT_VEC &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; return needs; } }; diff --git a/lib/atc/WeakEquationElectronContinuity.cpp b/lib/atc/WeakEquationElectronContinuity.cpp index e066b2a845ecc8c51b8b84a4de4ff81540c6d620..67ffc581d8de08f9c7a85e48b2b87735c6e36094 100644 --- a/lib/atc/WeakEquationElectronContinuity.cpp +++ b/lib/atc/WeakEquationElectronContinuity.cpp @@ -1,6 +1,5 @@ #include "WeakEquationElectronContinuity.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationElectronContinuity.h b/lib/atc/WeakEquationElectronContinuity.h index f6be1336df13efcedc495e24b4d9aa64a859496e..e12dce45ad69dcd9865aecf0ea743bda19b79dba 100644 --- a/lib/atc/WeakEquationElectronContinuity.h +++ b/lib/atc/WeakEquationElectronContinuity.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_ELECTRON_CONTINUITY_H #define WEAK_EQUATION_ELECTRON_CONTINUITY_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -43,10 +46,10 @@ class WeakEquationElectronContinuity : public WeakEquation { DENS_MAT &flux) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[2] = {"electron_flux","electron_recombination"}; - set<string> needs(list,list+2); + std::string list[2] = {"electron_flux","electron_recombination"}; + std::set<std::string> needs(list,list+2); return needs; } @@ -93,9 +96,9 @@ class WeakEquationElectronEquilibrium : public WeakEquation { /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; needs.insert("electron_charge_density"); return needs; } diff --git a/lib/atc/WeakEquationElectronMomentum.h b/lib/atc/WeakEquationElectronMomentum.h index e1fb135618a3e4a559680eb74a35b632a30e1929..a3bc62bef71a323428cc6c64077816825cafa874 100644 --- a/lib/atc/WeakEquationElectronMomentum.h +++ b/lib/atc/WeakEquationElectronMomentum.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_ELECTRON_MOMENTUM_H #define WEAK_EQUATION_ELECTRON_MOMENTUM_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -37,10 +40,10 @@ namespace ATC{ DENS_MAT_VEC &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[2] = {"inv_effective_mass","electron_heat_capacity"}; - set<string> needs(list,list+2); + std::string list[2] = {"inv_effective_mass","electron_heat_capacity"}; + std::set<std::string> needs(list,list+2); return needs; } @@ -88,9 +91,9 @@ namespace ATC{ DENS_MAT &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs + std::set<std::string> needs = WeakEquationElectronMomentum::needs_material_functions(); needs.insert("electron_drag_coefficient"); needs.insert("electron_heat_capacity"); diff --git a/lib/atc/WeakEquationElectronTemperature.cpp b/lib/atc/WeakEquationElectronTemperature.cpp index 182dd61a00107eeb89d3e2df2f94cd7341cbabae..3841f619ad8cd5e177ecf99fcb13468a1964c9a6 100644 --- a/lib/atc/WeakEquationElectronTemperature.cpp +++ b/lib/atc/WeakEquationElectronTemperature.cpp @@ -1,6 +1,5 @@ #include "WeakEquationElectronTemperature.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationElectronTemperature.h b/lib/atc/WeakEquationElectronTemperature.h index c27a0d080b3a8f75ea0fdcbb87097e1e784c50f1..8680de31a58f891eba56690e4f28deb477429e12 100644 --- a/lib/atc/WeakEquationElectronTemperature.h +++ b/lib/atc/WeakEquationElectronTemperature.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_ELECTRON_TEMPERATURE_H #define WEAK_EQUATION_ELECTRON_TEMPERATURE_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -50,13 +53,13 @@ class WeakEquationElectronTemperature : public WeakEquation { DENS_MAT &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[4] = {"electron_thermal_energy", + std::string list[4] = {"electron_thermal_energy", "electron_heat_capacity", "electron_phonon_exchange", "electron_heat_flux"}; - set<string> needs(list,list+4); + std::set<std::string> needs(list,list+4); return needs; } @@ -108,9 +111,9 @@ class WeakEquationElectronTemperatureJouleHeating : DENS_MAT &flux) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs + std::set<std::string> needs = WeakEquationElectronTemperature::needs_material_functions(); needs.insert("electric_field"); return needs; @@ -158,9 +161,9 @@ class WeakEquationElectronTemperatureConvection : DENS_MAT &flux) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs + std::set<std::string> needs = WeakEquationElectronTemperature::needs_material_functions(); needs.insert("electron_drag_power"); return needs; diff --git a/lib/atc/WeakEquationMassDiffusion.cpp b/lib/atc/WeakEquationMassDiffusion.cpp index fd501bb42951c1d7578cd0722628cc56260f7f1f..5e4445442b8aacf266b60a90f8d5486c2b4edbf5 100644 --- a/lib/atc/WeakEquationMassDiffusion.cpp +++ b/lib/atc/WeakEquationMassDiffusion.cpp @@ -1,7 +1,6 @@ #include "ATC_Transfer.h" #include "WeakEquationMassDiffusion.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationMassDiffusion.h b/lib/atc/WeakEquationMassDiffusion.h index 70e5be537a082029efde4be8cbcc8025788b6127..5b3a6543003cbaadf04da50fd84e35104e86ef38 100644 --- a/lib/atc/WeakEquationMassDiffusion.h +++ b/lib/atc/WeakEquationMassDiffusion.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_MASS_DIFFUSION_H #define WEAK_EQUATION_MASS_DIFFUSION_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -36,10 +39,10 @@ class WeakEquationMassDiffusion : public WeakEquation { DENS_MAT_VEC &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[1] = {"mass_density"}; - set<string> needs(list,list+1); + std::string list[1] = {"mass_density"}; + std::set<std::string> needs(list,list+1); return needs; } diff --git a/lib/atc/WeakEquationMomentum.h b/lib/atc/WeakEquationMomentum.h index 2fdb8671dd6afe38a36c63c79c6675ced4d6c7dd..cb1e829e98a137c9bfbd4ee44df00f0976616e83 100644 --- a/lib/atc/WeakEquationMomentum.h +++ b/lib/atc/WeakEquationMomentum.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_MOMENTUM_H #define WEAK_EQUATION_MOMENTUM_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -52,10 +55,10 @@ class WeakEquationMomentum : public WeakEquation { DENS_MAT_VEC &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[4] = {"mass_density","stress","elastic_energy","body_force"}; - set<string> needs(list,list+4); + std::string list[4] = {"mass_density","stress","elastic_energy","body_force"}; + std::set<std::string> needs(list,list+4); return needs; } @@ -101,9 +104,9 @@ class WeakEquationMomentumElectrostatic : public WeakEquationMomentum { DENS_MAT &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs + std::set<std::string> needs = WeakEquationMomentum::needs_material_functions(); needs.insert("electric_field"); return needs; @@ -159,10 +162,10 @@ class WeakEquationMomentumDiffusion : public WeakEquation { DENS_MAT &coefs) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[4] = {"mass_density","viscous_stress","body_force"}; - set<string> needs(list,list+3); + std::string list[4] = {"mass_density","viscous_stress","body_force"}; + std::set<std::string> needs(list,list+3); return needs; } diff --git a/lib/atc/WeakEquationPhononTemperature.cpp b/lib/atc/WeakEquationPhononTemperature.cpp index 51aa7f36254a39c3244a14a67494faea23fa3794..aef1cd4c539c388ed1c05b1bbf2cf6324bc548e3 100644 --- a/lib/atc/WeakEquationPhononTemperature.cpp +++ b/lib/atc/WeakEquationPhononTemperature.cpp @@ -1,7 +1,6 @@ #include "ATC_Transfer.h" #include "WeakEquationPhononTemperature.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationPhononTemperature.h b/lib/atc/WeakEquationPhononTemperature.h index 6b1a625a054a7d08b16f7a141a1264956e0c7f26..f3dfcac5270755abc0c4a5bf2d966ef27ddc19c2 100644 --- a/lib/atc/WeakEquationPhononTemperature.h +++ b/lib/atc/WeakEquationPhononTemperature.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_PHONON_TEMPERATURE_H #define WEAK_EQUATION_PHONON_TEMPERATURE_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -43,10 +46,10 @@ class WeakEquationPhononTemperature : public WeakEquation { DENS_MAT_VEC &flux) const ; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - string list[3] = {"thermal_energy","heat_capacity","heat_flux"}; - set<string> needs(list,list+3); + std::string list[3] = {"thermal_energy","heat_capacity","heat_flux"}; + std::set<std::string> needs(list,list+3); return needs; } @@ -99,9 +102,9 @@ class WeakEquationPhononTemperatureExchange : DENS_MAT &flux) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs + std::set<std::string> needs = WeakEquationPhononTemperature::needs_material_functions(); needs.insert("electron_phonon_exchange"); return needs; diff --git a/lib/atc/WeakEquationPoisson.cpp b/lib/atc/WeakEquationPoisson.cpp index 6970a138a82a94a6da7334536cd37b24c8a32861..02e8655dc0e6161a697be41883bee6c4d39d5048 100644 --- a/lib/atc/WeakEquationPoisson.cpp +++ b/lib/atc/WeakEquationPoisson.cpp @@ -1,6 +1,5 @@ #include "WeakEquationPoisson.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationPoisson.h b/lib/atc/WeakEquationPoisson.h index 434090d68a43f67823077e23c7e1f93d68f9760e..667034525d17381a59e9de200f2452cc64b99157 100644 --- a/lib/atc/WeakEquationPoisson.h +++ b/lib/atc/WeakEquationPoisson.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_POISSON_H #define WEAK_EQUATION_POISSON_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -53,9 +56,9 @@ class WeakEquationPoisson : public WeakEquation { DENS_MAT &coefs) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; needs.insert("electric_displacement"); needs.insert("electron_charge_density"); return needs; @@ -100,9 +103,9 @@ class WeakEquationPoissonConstantRHS : public WeakEquationPoisson { const Material * material, DENS_MAT &coefs) const {}; - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; needs.insert("electric_displacement"); return needs; } diff --git a/lib/atc/WeakEquationSchrodinger.cpp b/lib/atc/WeakEquationSchrodinger.cpp index 3163a8336652c961e7655d49b00061f8cdb63b02..3663b8c80642333b3027a63cdfc256de9a7c36c0 100644 --- a/lib/atc/WeakEquationSchrodinger.cpp +++ b/lib/atc/WeakEquationSchrodinger.cpp @@ -1,6 +1,5 @@ #include "WeakEquationSchrodinger.h" #include "Material.h" -#include <string> #include <iostream> #include <fstream> diff --git a/lib/atc/WeakEquationSchrodinger.h b/lib/atc/WeakEquationSchrodinger.h index f5fe81901189cdc8e2f5d0f2651619ca61ed779b..c7d46fa5d246450dbf75c408481dae9a48c69d65 100644 --- a/lib/atc/WeakEquationSchrodinger.h +++ b/lib/atc/WeakEquationSchrodinger.h @@ -1,6 +1,9 @@ #ifndef WEAK_EQUATION_SCHRODINGER_H #define WEAK_EQUATION_SCHRODINGER_H +#include <set> +#include <string> + #include "WeakEquation.h" namespace ATC{ @@ -35,9 +38,9 @@ class WeakEquationSchrodinger : public WeakEquation { DENS_MAT &coefs) const; /** necessary interfaces */ - virtual set<string> needs_material_functions(void) const + virtual std::set<std::string> needs_material_functions(void) const { - set<string> needs; + std::set<std::string> needs; needs.insert("inv_effective_mass"); needs.insert("band_edge_potential"); return needs;