ATC version 2.0, date: Aug21

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10638 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
rjones
2013-08-21 23:06:07 +00:00
parent 0f69054d68
commit d77ab2f96a
161 changed files with 3811 additions and 2548 deletions

View File

@ -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);
}
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
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();
@ -811,6 +818,7 @@ namespace ATC {
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,
masked_atom_domain_rhs_integral(rhsMask,
fields,
physicsModel,
atomMaterialGroupsMask_,
atomicWeightsMask_->quantity(),
shpFcnMask_->quantity(),
shpFcnDerivsMask_->quantity(),
rhsAtomDomain_);
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,
masked_atom_domain_rhs_integral(rhsMask,
fields,
physicsModel,
atomMaterialGroupsMask_,
atomicWeightsMask_->quantity(),
shpFcnMask_->quantity(),
shpFcnDerivsMask_->quantity(),
rhs);
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,
masked_atom_domain_rhs_integral(rhsMaskMD,
fields,
physicsModel,
atomMaterialGroupsMask_,
atomicWeightsMask_->quantity(),
shpFcnMask_->quantity(),
shpFcnDerivsMask_->quantity(),
rhsAtomDomain_);
rhsAtomDomain_,
physicsModel);
for (FIELDS::const_iterator field = fields.begin();
field != fields.end(); field++) {
FieldName thisFieldName = field->first;
@ -1123,36 +1173,14 @@ namespace ATC {
}
}
//--------------------------------------------------------
// set_computational_geometry
// constructs needed transfer operators which define
// hybrid atom/FE computational geometry
// create_full_element_mask
// constructs element mask which only masks out
// null elements
//--------------------------------------------------------
void ATC_Coupling::set_computational_geometry()
MatrixDependencyManager<DenseMatrix, bool> * ATC_Coupling::create_full_element_mask()
{
ATC_Method::set_computational_geometry();
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_) {
ghostElement_ = new AtomTypeElement(this,atomGhostElement_);
interscaleManager_.add_dense_matrix_int(ghostElement_,
"ElementHasGhost");
}
// element masking for FE quadrature
if (atomQuadForInternal_) {
elementMask_ = new MatrixDependencyManager<DenseMatrix, bool>(feEngine_->num_elements(),1);
DenseMatrix<bool> & elementMask(elementMask_->set_quantity());
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();
@ -1161,40 +1189,123 @@ namespace ATC {
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
//--------------------------------------------------------
void ATC_Coupling::set_computational_geometry()
{
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 ghost atoms
ghostElement_ = new AtomTypeElement(this,atomGhostElement_);
interscaleManager_.add_dense_matrix_int(ghostElement_,
"ElementHasGhost");
}
// element masking for approximate right-hand side FE atomic quadrature
if (atomQuadForInternal_) {
elementMask_ = create_full_element_mask();
}
else {
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
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");
}
//--------------------------------------------------------
// 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_) {
@ -1210,29 +1321,63 @@ namespace ATC {
mdMassNormalization_ = false;
}
// add species transfer operators
this->create_atom_volume();
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);
// masked atom weights
if (atomQuadForInternal_) {
atomicWeightsMask_ = atomVolume_;
}
else { // if ((specie->second).first == ATOM_GROUP)
specieMap = new AtomToGroup(this,(specid->second).second);
interscaleManager_.add_per_atom_int_quantity(specieMap,
"AtomMap"+specie);
}
ReducedSparseMatrix * accumulantSpecie = new ReducedSparseMatrix(this,
accumulant_,
specieMap);
interscaleManager_.add_sparse_matrix(accumulantSpecie,"Accumulant"+specie);
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");
// add molecule transfer operators
// 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;
}
}
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");
}
}
}
//--------------------------------------------------------
// 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
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;

View File

@ -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,
@ -138,7 +135,12 @@ namespace ATC {
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_;
/*@}*/
//----------------------------------------------------------------

View File

@ -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,19 +191,32 @@ 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");
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");
/////////////////////////////////////
FieldManager fmgr(this);
fmgr.nodal_atomic_field(REFERENCE_POTENTIAL_ENERGY);
PerAtomQuantity<double> * atomicReferencePotential =
interscaleManager_.per_atom_quantity("AtomicReferencePotential");
/////////////////////////////////////
// fluctuating potential energy
AtomicEnergyForTemperature * atomicFluctuatingPotentialEnergy = new FluctuatingPotentialEnergy(this,
AtomicEnergyForTemperature * atomicFluctuatingPotentialEnergy =
new FluctuatingPotentialEnergy(this,
atomicPotentialEnergy,
atomicReferencePotential);
interscaleManager_.add_per_atom_quantity(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

View File

@ -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);
};

View File

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

View File

@ -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_;

View File

@ -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
@ -546,18 +500,12 @@ 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

View File

@ -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_;

View File

@ -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,10 +320,10 @@ namespace ATC {
else {
atomicReferencePotential = static_cast<AtcAtomQuantity<double> * >(interscaleManager_.per_atom_quantity("AtomicReferencePotential"));
}
AtfShapeFunctionRestriction * nodalAtomicReferencePotential = new AtfShapeFunctionRestriction(this,
nodalRefPotentialEnergy_ = new AtfShapeFunctionRestriction(this,
atomicReferencePotential,
shpFcn_);
interscaleManager_.add_dense_matrix(nodalAtomicReferencePotential,
interscaleManager_.add_dense_matrix(nodalRefPotentialEnergy_,
"NodalAtomicReferencePotential");
// fluctuating potential energy
@ -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
@ -613,18 +586,12 @@ 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];
}
}
}
}
};

View File

@ -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_;
};

View File

@ -17,10 +17,6 @@
#define HACK(l,m)
namespace ATC {
/**
* @class ATC_Error

View File

@ -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];
@ -1720,27 +1831,28 @@ ments. If this allocation fails, on-the-fly is activated. \n
const int * mask = lammpsInterface_->atom_mask();
nLocal_ = 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);

View File

@ -16,19 +16,22 @@
#include "ExtrinsicModel.h"
#include "InterscaleOperators.h"
#include "TransferLibrary.h"
#include "GhostManager.h"
// Other headers
#include <vector>
#include <set>
using namespace std;
#include <utility>
#include <string>
#include <map>
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_;
@ -620,6 +635,9 @@ namespace ATC {
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 */

View File

@ -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,77 +350,16 @@ namespace ATC {
"AccumulantWeights");
}
}
bool needsBondMatrix = (! bondOnTheFly_ ) &&
(fieldFlags_(STRESS)
|| fieldFlags_(ESHELBY_STRESS)
|| fieldFlags_(HEAT_FLUX));
if (needsBondMatrix) {
if (hasPairs_ && hasBonds_) {
pairMap_ = new PairMapBoth(lammpsInterface_,groupbit_);
}
else if (hasBonds_) {
pairMap_ = new PairMapBond(lammpsInterface_,groupbit_);
}
else if (hasPairs_) {
pairMap_ = new PairMapNeighbor(lammpsInterface_,groupbit_);
}
}
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();
if (!kernelBased_) {
bondMatrix_ = new BondMatrixPartitionOfUnity(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,accumulantInverseVolumes_);
}
else {
bondMatrix_ = new BondMatrixKernel(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,kernelFunction_);
}
}
if (bondMatrix_) interscaleManager_.add_sparse_matrix(bondMatrix_,"BondMatrix");
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) {
pairVirial_ = new PairVirialEulerian(lammpsInterface_,*pairMap_);
}
else {
throw ATC_Error("no atom to element map specified");
}
}
if (pairVirial_) interscaleManager_.add_dense_matrix(pairVirial_,"PairVirial");
if ( fieldFlags_(HEAT_FLUX) ) {
if (atomToElementMapType_ == LAGRANGIAN) {
pairHeatFlux_ = new PairPotentialHeatFluxLagrangian(lammpsInterface_,*pairMap_,xref_);
}
else if (atomToElementMapType_ == EULERIAN) {
pairHeatFlux_ = new PairPotentialHeatFluxEulerian(lammpsInterface_,*pairMap_);
}
else {
throw ATC_Error("no atom to element map specified");
}
}
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;
}
}
//-------------------------------------------------------------------
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;
@ -443,6 +385,88 @@ namespace ATC {
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)
|| fieldFlags_(ESHELBY_STRESS)
|| fieldFlags_(HEAT_FLUX));
if (needsBondMatrix) {
if (hasPairs_ && hasBonds_) {
pairMap_ = new PairMapBoth(lammpsInterface_,groupbit_);
}
else if (hasBonds_) {
pairMap_ = new PairMapBond(lammpsInterface_,groupbit_);
}
else if (hasPairs_) {
pairMap_ = new PairMapNeighbor(lammpsInterface_,groupbit_);
}
}
if (pairMap_) interscaleManager_.add_pair_map(pairMap_,"PairMap");
if ( fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) || fieldFlags_(HEAT_FLUX) ) {
const FE_Mesh * fe_mesh = feEngine_->fe_mesh();
if (!kernelBased_) {
bondMatrix_ = new BondMatrixPartitionOfUnity(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,accumulantInverseVolumes_);
}
else {
bondMatrix_ = new BondMatrixKernel(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,kernelFunction_);
}
}
if (bondMatrix_) interscaleManager_.add_sparse_matrix(bondMatrix_,"BondMatrix");
if ( fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) ) {
if (atomToElementMapType_ == LAGRANGIAN) {
pairVirial_ = new PairVirialLagrangian(lammpsInterface_,*pairMap_,xref_);
}
else if (atomToElementMapType_ == EULERIAN) {
pairVirial_ = new PairVirialEulerian(lammpsInterface_,*pairMap_);
}
else {
throw ATC_Error("no atom to element map specified");
}
}
if (pairVirial_) interscaleManager_.add_dense_matrix(pairVirial_,"PairVirial");
if ( fieldFlags_(HEAT_FLUX) ) {
if (atomToElementMapType_ == LAGRANGIAN) {
pairHeatFlux_ = new PairPotentialHeatFluxLagrangian(lammpsInterface_,*pairMap_,xref_);
}
else if (atomToElementMapType_ == EULERIAN) {
pairHeatFlux_ = new PairPotentialHeatFluxEulerian(lammpsInterface_,*pairMap_);
}
else {
throw ATC_Error("no atom to element map specified");
}
}
if (pairHeatFlux_) interscaleManager_.add_dense_matrix(pairHeatFlux_,"PairHeatFlux");
FieldManager fmgr(this);
@ -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

View File

@ -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

View File

@ -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++) {

View File

@ -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)

View File

@ -2,6 +2,8 @@
#include "AtomToMoleculeTransfer.h"
#include "ATC_Method.h"
using std::set;
namespace ATC {
//--------------------------------------------------------

View File

@ -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);

View File

@ -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");

View File

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

View File

@ -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;

View File

@ -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,

View File

@ -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";

View File

@ -7,7 +7,6 @@
#include "MatrixLibrary.h"
#include "ATC_TypeDefs.h"
using std::vector;
namespace ATC
{
class CbPotential; // forward definition for potentials.

View File

@ -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

View File

@ -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)

View File

@ -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_;

View File

@ -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;
}
//-----------------------------------------------------------------------------

View File

@ -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.;

View File

@ -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

View File

@ -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;

View File

@ -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_;
};

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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

View File

@ -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(

View File

@ -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
{

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -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> &parameters,
ElectronHeatFluxPowerLaw(std::fstream &matfile,std::map<std::string,double> &parameters,
/*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() {};

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -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_;};

View File

@ -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;

View File

@ -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 */

View File

@ -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 =
@ -174,20 +190,6 @@ namespace ATC {
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
const map<string,pair<MolSize,int> > & moleculeIds(atc_->molecule_ids());
@ -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);
}
}

View File

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

View File

@ -7,6 +7,8 @@
#include "PrescribedDataManager.h"
#include "PhysicsModel.h"
using std::string;
namespace ATC {
//--------------------------------------------------------

View File

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

View File

@ -12,6 +12,7 @@
using ATC_Utility::dbl_geq;
using ATC_Utility::det3;
using std::vector;
namespace ATC {

View File

@ -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,

View File

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

View File

@ -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_;

View File

@ -7,6 +7,9 @@
// Other headers
#include "math.h"
using std::map;
using std::vector;
namespace ATC {
FE_Interpolate::FE_Interpolate(FE_Element *feElement)

View File

@ -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_;
};

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -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());
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");
}
} else {
c = new AtfProjection(atc_, atomSpecies,
atc_->accumulant(),
atc_->accumulant_inverse_volumes());
}
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)
{
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);
}
return projected_atom_quantity(REFERENCE_POTENTIAL_ENERGY,"NodalAtomicReferencePotential",atomic,MASS_DENSITY,atc_->accumulant_inverse_volumes());
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 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,7 +522,9 @@ typedef PerAtomQuantity<double> PAQ;
}
return atomic;
}
//-----------------------------------------------------------------------------
//* Prolonged coarse scale field
//-----------------------------------------------------------------------------
PAQ * FieldManager::prolonged_field(FieldName field)
{
PAQ * quantity = interscaleManager_.per_atom_quantity(field_to_prolongation_name(field));
@ -500,5 +545,4 @@ typedef PerAtomQuantity<double> PAQ;
}
return quantity;
}
}

View File

@ -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);

View File

@ -3,6 +3,11 @@
#include "LammpsInterface.h"
#include <sstream>
using std::stringstream;
using std::string;
using std::set;
using std::fstream;
namespace ATC {
//====================================================================

View File

@ -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;

View File

@ -1,5 +1,7 @@
#include "FundamentalAtomicQuantity.h"
using std::string;
namespace ATC {
//--------------------------------------------------------

View File

@ -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_;

499
lib/atc/GhostManager.cpp Normal file
View File

@ -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
}
}
}
};

327
lib/atc/GhostManager.h Normal file
View File

@ -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

View File

@ -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_);
}
//--------------------------------------------------------

View File

@ -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);
};

View File

@ -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) {

View File

@ -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_;

View File

@ -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_;
};
/**

View File

@ -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;
}

View File

@ -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() {}; */

View File

@ -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

View File

@ -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(){};

View File

@ -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
// -----------------------------------------------------------------

View File

@ -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:

View File

@ -2,7 +2,7 @@
#include "LinearSolver.h"
#include <sstream>
using std::stringstream;
using std::set;

View File

@ -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 */

View File

@ -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;

View File

@ -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);
}

View File

@ -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 {

View File

@ -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 */

View File

@ -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;

View File

@ -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

View File

@ -7,8 +7,16 @@
#include "exodusII.h"
#endif
namespace ATC {
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 {
/** 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

View File

@ -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_;
};

View File

@ -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 {

View File

@ -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_;

View File

@ -5,6 +5,8 @@
#include "LammpsInterface.h"
using std::stringstream;
namespace ATC {
//===================================================================
// TangentOperator

View File

@ -9,7 +9,6 @@
// other includes
#include <set>
#include <map>
using std::pair;
namespace ATC {

View File

@ -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;

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More