From 92b5b159e5ff1399d00619de0334284bce5bef72 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 22 Aug 2021 20:45:24 -0400 Subject: [PATCH] replace tabs and remove trailing whitespace in lib folder with updated script --- lib/README | 2 +- lib/atc/ATC_Coupling.cpp | 316 ++++----- lib/atc/ATC_Coupling.h | 62 +- lib/atc/ATC_CouplingEnergy.cpp | 54 +- lib/atc/ATC_CouplingEnergy.h | 8 +- lib/atc/ATC_CouplingMass.cpp | 46 +- lib/atc/ATC_CouplingMass.h | 12 +- lib/atc/ATC_CouplingMomentum.cpp | 44 +- lib/atc/ATC_CouplingMomentum.h | 8 +- lib/atc/ATC_CouplingMomentumEnergy.cpp | 66 +- lib/atc/ATC_CouplingMomentumEnergy.h | 6 +- lib/atc/ATC_Method.cpp | 432 ++++++------ lib/atc/ATC_Method.h | 88 +-- lib/atc/ATC_Transfer.cpp | 326 ++++----- lib/atc/ATC_Transfer.h | 54 +- lib/atc/ATC_TransferKernel.cpp | 76 +- lib/atc/ATC_TransferKernel.h | 6 +- lib/atc/ATC_TransferPartitionOfUnity.cpp | 48 +- lib/atc/ATC_TransferPartitionOfUnity.h | 6 +- lib/atc/ATC_TypeDefs.h | 60 +- lib/atc/Array.h | 24 +- lib/atc/Array2D.h | 20 +- lib/atc/AtomToMoleculeTransfer.cpp | 30 +- lib/atc/AtomToMoleculeTransfer.h | 82 +-- lib/atc/AtomicRegulator.cpp | 64 +- lib/atc/AtomicRegulator.h | 104 +-- lib/atc/BodyForce.cpp | 4 +- lib/atc/BodyForce.h | 12 +- lib/atc/CBLattice.cpp | 16 +- lib/atc/CBLattice.h | 20 +- lib/atc/CG.h | 26 +- lib/atc/CauchyBorn.cpp | 86 +-- lib/atc/CauchyBorn.h | 16 +- lib/atc/CbEam.h | 54 +- lib/atc/CbLjCut.h | 8 +- lib/atc/CbLjSmoothLinear.h | 18 +- lib/atc/CbPotential.cpp | 10 +- lib/atc/CbPotential.h | 4 +- lib/atc/ChargeRegulator.cpp | 138 ++-- lib/atc/ChargeRegulator.h | 88 +-- lib/atc/CloneVector.h | 24 +- lib/atc/ConcentrationRegulator.cpp | 100 +-- lib/atc/ConcentrationRegulator.h | 38 +- lib/atc/DenseMatrix.h | 96 +-- lib/atc/DenseVector.h | 10 +- lib/atc/DependencyManager.h | 40 +- lib/atc/DiagonalMatrix.h | 82 +-- lib/atc/ElasticTimeIntegrator.cpp | 52 +- lib/atc/ElasticTimeIntegrator.h | 102 +-- lib/atc/ElectronChargeDensity.cpp | 18 +- lib/atc/ElectronChargeDensity.h | 66 +- lib/atc/ElectronDragPower.cpp | 6 +- lib/atc/ElectronDragPower.h | 10 +- lib/atc/ElectronFlux.cpp | 10 +- lib/atc/ElectronFlux.h | 44 +- lib/atc/ElectronHeatCapacity.cpp | 8 +- lib/atc/ElectronHeatCapacity.h | 42 +- lib/atc/ElectronHeatFlux.cpp | 8 +- lib/atc/ElectronHeatFlux.h | 38 +- lib/atc/ElectronPhononExchange.cpp | 8 +- lib/atc/ElectronPhononExchange.h | 24 +- lib/atc/ExtrinsicModel.cpp | 32 +- lib/atc/ExtrinsicModel.h | 16 +- lib/atc/ExtrinsicModelDriftDiffusion.cpp | 102 +-- lib/atc/ExtrinsicModelDriftDiffusion.h | 12 +- lib/atc/ExtrinsicModelElectrostatic.cpp | 136 ++-- lib/atc/ExtrinsicModelElectrostatic.h | 20 +- lib/atc/ExtrinsicModelTwoTemperature.cpp | 20 +- lib/atc/ExtrinsicModelTwoTemperature.h | 4 +- lib/atc/FE_Element.cpp | 260 +++---- lib/atc/FE_Element.h | 100 +-- lib/atc/FE_Engine.cpp | 634 ++++++++--------- lib/atc/FE_Engine.h | 150 ++-- lib/atc/FE_Interpolate.cpp | 146 ++-- lib/atc/FE_Interpolate.h | 22 +- lib/atc/FE_Mesh.cpp | 502 +++++++------- lib/atc/FE_Mesh.h | 150 ++-- lib/atc/FE_Quadrature.h | 582 ++++++++-------- lib/atc/FieldEulerIntegrator.cpp | 44 +- lib/atc/FieldEulerIntegrator.h | 2 +- lib/atc/FieldManager.cpp | 82 +-- lib/atc/FieldManager.h | 22 +- lib/atc/Function.cpp | 56 +- lib/atc/Function.h | 84 +-- lib/atc/FundamentalAtomicQuantity.cpp | 10 +- lib/atc/FundamentalAtomicQuantity.h | 4 +- lib/atc/GMRES.h | 34 +- lib/atc/GhostManager.cpp | 54 +- lib/atc/GhostManager.h | 16 +- lib/atc/ImplicitSolveOperator.cpp | 12 +- lib/atc/ImplicitSolveOperator.h | 2 +- lib/atc/InterscaleOperators.cpp | 8 +- lib/atc/InterscaleOperators.h | 18 +- lib/atc/KD_Tree.cpp | 20 +- lib/atc/KD_Tree.h | 16 +- lib/atc/KernelFunction.cpp | 138 ++-- lib/atc/KernelFunction.h | 74 +- lib/atc/KinetoThermostat.cpp | 32 +- lib/atc/KinetoThermostat.h | 142 ++-- lib/atc/Kinetostat.cpp | 156 ++--- lib/atc/Kinetostat.h | 184 ++--- lib/atc/LammpsInterface.cpp | 228 +++--- lib/atc/LammpsInterface.h | 62 +- lib/atc/LinearSolver.cpp | 52 +- lib/atc/LinearSolver.h | 40 +- lib/atc/MPI_Wrappers.cpp | 28 +- lib/atc/Material.cpp | 94 +-- lib/atc/Material.h | 58 +- lib/atc/Matrix.cpp | 74 +- lib/atc/Matrix.h | 198 +++--- lib/atc/MatrixDef.h | 18 +- lib/atc/MatrixLibrary.h | 6 +- lib/atc/MeshReader.cpp | 40 +- lib/atc/MoleculeSet.cpp | 18 +- lib/atc/MoleculeSet.h | 2 +- lib/atc/NonLinearSolver.cpp | 16 +- lib/atc/NonLinearSolver.h | 10 +- lib/atc/OutputManager.cpp | 218 +++--- lib/atc/OutputManager.h | 28 +- lib/atc/ParDenseMatrix.h | 2 +- lib/atc/ParDiagonalMatrix.cpp | 12 +- lib/atc/ParDiagonalMatrix.h | 2 +- lib/atc/ParSparseMatrix.cpp | 4 +- lib/atc/ParSparseMatrix.h | 10 +- lib/atc/PerAtomQuantity-inl.h | 68 +- lib/atc/PerAtomQuantity.h | 84 +-- lib/atc/PerAtomQuantityLibrary.cpp | 140 ++-- lib/atc/PerAtomQuantityLibrary.h | 232 +++---- lib/atc/PerPairQuantity.cpp | 96 +-- lib/atc/PerPairQuantity.h | 90 +-- lib/atc/PhysicsModel.cpp | 30 +- lib/atc/PhysicsModel.h | 72 +- lib/atc/PoissonSolver.cpp | 42 +- lib/atc/PoissonSolver.h | 12 +- lib/atc/PolynomialSolver.cpp | 10 +- lib/atc/PrescribedDataManager.cpp | 170 ++--- lib/atc/PrescribedDataManager.h | 142 ++-- lib/atc/Quadrature.cpp | 4 +- lib/atc/Quadrature.h | 6 +- lib/atc/SchrodingerSolver.cpp | 174 ++--- lib/atc/SchrodingerSolver.h | 20 +- lib/atc/ShapeFunction.h | 42 +- lib/atc/SparseMatrix-inl.h | 208 +++--- lib/atc/SparseMatrix.h | 28 +- lib/atc/SparseVector-inl.h | 24 +- lib/atc/SparseVector.h | 18 +- lib/atc/SpeciesTimeIntegrator.cpp | 30 +- lib/atc/SpeciesTimeIntegrator.h | 66 +- lib/atc/Stress.cpp | 112 +-- lib/atc/Stress.h | 42 +- lib/atc/ThermalTimeIntegrator.cpp | 36 +- lib/atc/ThermalTimeIntegrator.h | 66 +- lib/atc/Thermostat.cpp | 172 ++--- lib/atc/Thermostat.h | 184 ++--- lib/atc/TimeFilter.cpp | 68 +- lib/atc/TimeFilter.h | 238 +++---- lib/atc/TimeIntegrator.cpp | 16 +- lib/atc/TimeIntegrator.h | 48 +- lib/atc/TransferLibrary.cpp | 84 +-- lib/atc/TransferLibrary.h | 234 +++---- lib/atc/TransferOperator.cpp | 20 +- lib/atc/TransferOperator.h | 200 +++--- lib/atc/Utility.h | 50 +- lib/atc/Vector.cpp | 6 +- lib/atc/Vector.h | 36 +- lib/atc/ViscousStress.cpp | 6 +- lib/atc/ViscousStress.h | 10 +- lib/atc/VoigtOperations.h | 70 +- lib/atc/WeakEquation.h | 20 +- lib/atc/WeakEquationChargeDiffusion.cpp | 2 +- lib/atc/WeakEquationChargeDiffusion.h | 12 +- lib/atc/WeakEquationDiffusion.cpp | 4 +- lib/atc/WeakEquationDiffusion.h | 10 +- lib/atc/WeakEquationElectronContinuity.cpp | 4 +- lib/atc/WeakEquationElectronContinuity.h | 26 +- lib/atc/WeakEquationElectronMomentum.cpp | 16 +- lib/atc/WeakEquationElectronMomentum.h | 24 +- lib/atc/WeakEquationElectronTemperature.cpp | 26 +- lib/atc/WeakEquationElectronTemperature.h | 44 +- lib/atc/WeakEquationMassDiffusion.cpp | 2 +- lib/atc/WeakEquationMassDiffusion.h | 8 +- lib/atc/WeakEquationMomentum.cpp | 14 +- lib/atc/WeakEquationMomentum.h | 14 +- lib/atc/WeakEquationPhononTemperature.cpp | 6 +- lib/atc/WeakEquationPhononTemperature.h | 18 +- lib/atc/WeakEquationPoisson.cpp | 6 +- lib/atc/WeakEquationPoisson.h | 14 +- lib/atc/WeakEquationSchrodinger.h | 10 +- lib/awpmd/README | 2 +- lib/awpmd/ivutils/include/lapack_inter.h | 16 +- lib/awpmd/ivutils/include/logexc.h | 58 +- lib/awpmd/ivutils/include/wavepacket.h | 12 +- lib/awpmd/systems/interact/TCP/tcpdefs.h | 2 +- lib/awpmd/systems/interact/TCP/wpmd.cpp | 90 +-- lib/awpmd/systems/interact/TCP/wpmd_split.h | 54 +- lib/colvars/colvarproxy.cpp | 8 +- lib/gpu/cudpp_mini/cudpp.cpp | 174 ++--- lib/gpu/cudpp_mini/cudpp.h | 284 ++++---- lib/gpu/cudpp_mini/cudpp_globals.h | 10 +- lib/gpu/cudpp_mini/cudpp_maximal_launch.cpp | 14 +- lib/gpu/cudpp_mini/cudpp_maximal_launch.h | 14 +- lib/gpu/cudpp_mini/cudpp_plan.cpp | 176 ++--- lib/gpu/cudpp_mini/cudpp_plan.h | 2 +- lib/gpu/cudpp_mini/cudpp_plan_manager.cpp | 46 +- lib/gpu/cudpp_mini/cudpp_plan_manager.h | 18 +- lib/gpu/cudpp_mini/cudpp_radixsort.h | 8 +- lib/gpu/cudpp_mini/cudpp_scan.h | 12 +- lib/gpu/cudpp_mini/cudpp_util.h | 82 +-- lib/gpu/cudpp_mini/sharedmem.h | 56 +- lib/gpu/geryon/README | 10 +- lib/gpu/geryon/file_to_cstr.sh | 10 +- lib/gpu/geryon/hip_device.h | 4 +- lib/gpu/geryon/hip_kernel.h | 4 +- lib/gpu/geryon/hip_texture.h | 10 +- lib/gpu/geryon/nvd_device.h | 2 +- lib/gpu/geryon/nvd_texture.h | 4 +- lib/gpu/geryon/ocl_device.h | 86 +-- lib/gpu/geryon/ocl_kernel.h | 66 +- lib/gpu/geryon/ucl_get_devices.cpp | 2 +- lib/gpu/geryon/ucl_vector.h | 2 +- lib/gpu/lal_lj_smooth.cpp | 4 +- lib/gpu/lal_lj_smooth.h | 4 +- lib/h5md/README | 2 +- lib/latte/README | 2 +- lib/mdi/.gitignore | 2 +- lib/mesont/README | 66 +- lib/message/Install.py | 2 +- lib/message/cslib/src/cslib.cpp | 158 ++--- lib/message/cslib/src/cslib.h | 2 +- lib/message/cslib/src/cslib.py | 66 +- lib/message/cslib/src/cslib_wrap.cpp | 18 +- lib/message/cslib/src/cslib_wrap.h | 4 +- lib/message/cslib/src/msg_file.cpp | 16 +- lib/message/cslib/src/msg_mpi_one.cpp | 2 +- lib/message/cslib/src/msg_mpi_two.cpp | 12 +- lib/message/cslib/src/msg_zmq.cpp | 2 +- lib/molfile/README | 2 +- lib/pace/Install.py | 8 +- lib/poems/README | 6 +- lib/poems/bodies.h | 4 +- lib/poems/body.cpp | 6 +- lib/poems/body.h | 16 +- lib/poems/body23joint.cpp | 220 +++--- lib/poems/colmatmap.cpp | 186 ++--- lib/poems/colmatmap.h | 4 +- lib/poems/colmatrix.cpp | 208 +++--- lib/poems/eulerparameters.cpp | 64 +- lib/poems/eulerparameters.h | 6 +- lib/poems/fastmatrixops.cpp | 142 ++-- lib/poems/fastmatrixops.h | 4 +- lib/poems/fixedpoint.cpp | 6 +- lib/poems/fixedpoint.h | 6 +- lib/poems/freebodyjoint.cpp | 126 ++-- lib/poems/freebodyjoint.h | 8 +- lib/poems/inertialframe.cpp | 4 +- lib/poems/inertialframe.h | 4 +- lib/poems/joint.cpp | 50 +- lib/poems/joints.h | 4 +- lib/poems/mat3x3.cpp | 6 +- lib/poems/mat3x3.h | 12 +- lib/poems/mat4x4.cpp | 6 +- lib/poems/mat4x4.h | 8 +- lib/poems/mat6x6.cpp | 4 +- lib/poems/mat6x6.h | 4 +- lib/poems/matrices.h | 4 +- lib/poems/matrix.cpp | 4 +- lib/poems/matrix.h | 6 +- lib/poems/matrixfun.cpp | 438 ++++++------ lib/poems/mixedjoint.cpp | 198 +++--- lib/poems/norm.cpp | 54 +- lib/poems/norm.h | 4 +- lib/poems/onbody.cpp | 352 +++++----- lib/poems/onfunctions.cpp | 32 +- lib/poems/onfunctions.h | 4 +- lib/poems/onsolver.cpp | 112 +-- lib/poems/particle.cpp | 4 +- lib/poems/particle.h | 6 +- lib/poems/poemsobject.cpp | 6 +- lib/poems/poemsobject.h | 8 +- lib/poems/poemstreenode.cpp | 14 +- lib/poems/point.cpp | 4 +- lib/poems/point.h | 14 +- lib/poems/prismaticjoint.cpp | 10 +- lib/poems/prismaticjoint.h | 4 +- lib/poems/revolutejoint.cpp | 6 +- lib/poems/revolutejoint.h | 6 +- lib/poems/rigidbody.cpp | 4 +- lib/poems/rigidbody.h | 6 +- lib/poems/rowmatrix.cpp | 4 +- lib/poems/rowmatrix.h | 4 +- lib/poems/solver.cpp | 16 +- lib/poems/solver.h | 16 +- lib/poems/sphericaljoint.cpp | 202 +++--- lib/poems/sphericaljoint.h | 4 +- lib/poems/system.cpp | 610 ++++++++--------- lib/poems/vect3.cpp | 12 +- lib/poems/vect3.h | 6 +- lib/poems/vect4.cpp | 4 +- lib/poems/vect4.h | 6 +- lib/poems/vect6.cpp | 14 +- lib/poems/vect6.h | 4 +- lib/poems/virtualcolmatrix.cpp | 14 +- lib/poems/virtualmatrix.cpp | 62 +- lib/poems/virtualrowmatrix.cpp | 12 +- lib/poems/virtualrowmatrix.h | 8 +- lib/poems/workspace.cpp | 724 ++++++++++---------- lib/qmmm/README | 16 +- lib/qmmm/libqmmm.c | 6 +- lib/qmmm/libqmmm.h | 2 +- lib/qmmm/pwqmmm.c | 6 +- lib/scafacos/README | 2 +- 311 files changed, 9176 insertions(+), 9176 deletions(-) diff --git a/lib/README b/lib/README index 75fca5c185..dc25053cec 100644 --- a/lib/README +++ b/lib/README @@ -3,7 +3,7 @@ LAMMPS, if particular packages are included in the LAMMPS build. Most of these directories contain code for the library; some contain a Makefile.lammps file that points to where the library is installed -elsewhere on your system. +elsewhere on your system. In either case, the library itself must be installed and/or built first, so that the appropriate library files exist for LAMMPS to link diff --git a/lib/atc/ATC_Coupling.cpp b/lib/atc/ATC_Coupling.cpp index 552bb9bb37..381e9fee90 100644 --- a/lib/atc/ATC_Coupling.cpp +++ b/lib/atc/ATC_Coupling.cpp @@ -53,7 +53,7 @@ namespace ATC { sourceIntegration_(FULL_DOMAIN) { // size the field mask - fieldMask_.reset(NUM_FIELDS,NUM_FLUX); + fieldMask_.reset(NUM_FIELDS,NUM_FLUX); fieldMask_ = false; // default: no consistent mass matrices useConsistentMassMatrix_.reset(NUM_FIELDS); @@ -67,8 +67,8 @@ namespace ATC { //-------------------------------------------------- ATC_Coupling::~ATC_Coupling() { - interscaleManager_.clear(); - if (feEngine_) { delete feEngine_; feEngine_ = nullptr; } + interscaleManager_.clear(); + if (feEngine_) { delete feEngine_; feEngine_ = nullptr; } if (physicsModel_) delete physicsModel_; if (atomicRegulator_) delete atomicRegulator_; if (prescribedDataMgr_) delete prescribedDataMgr_; @@ -78,7 +78,7 @@ namespace ATC { } //-------------------------------------------------- // Interactions with LAMMPS fix commands - // parse input command and pass on to finite element engine + // parse input command and pass on to finite element engine // or physics specific transfers if necessary // revert to physics-specific transfer if no command matches input // first keyword is unique to particular class @@ -91,8 +91,8 @@ namespace ATC { int thisIndex; int argIdx=0; - bool match = false; - + bool match = false; + // gateways to other modules e.g. extrinsic, control, mesh // pass off to extrinsic if (strcmp(arg[argIdx],"extrinsic")==0) { @@ -106,7 +106,7 @@ namespace ATC { } // parsing handled here else { - /*! \page man_initial fix_modify AtC initial + /*! \page man_initial fix_modify AtC initial \section syntax fix_modify AtC initial - = field name valid for type of physics, temperature | electron_temperature @@ -119,7 +119,7 @@ namespace ATC { Sets the initial values for the specified field at the specified nodes. \section restrictions keyword 'all' reserved in nodeset name - \section default + \section default none */ // set initial conditions @@ -140,7 +140,7 @@ namespace ATC { match = true; } - /*! \page man_fix_nodes fix_modify AtC fix + /*! \page man_fix_nodes fix_modify AtC fix \section syntax fix_modify AtC fix - = field name valid for type of physics @@ -154,9 +154,9 @@ namespace ATC { Creates a constraint on the values of the specified field at specified nodes. \section restrictions keyword 'all' reserved in nodeset name - \section related + \section related see \ref man_unfix_nodes - \section default + \section default none */ // fix and unfix nodes @@ -165,11 +165,11 @@ namespace ATC { parse_field(arg,argIdx,thisField,thisIndex); string nsetName(arg[argIdx++]); XT_Function * f = nullptr; - // fix current value + // fix current value if (narg == argIdx) { set nodeSet = (feEngine_->fe_mesh())->nodeset(nsetName); set::const_iterator iset; - const DENS_MAT & field =(fields_.find(thisField)->second).quantity(); + 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); @@ -184,12 +184,12 @@ namespace ATC { if (is_numeric(a)) { // constant f = XT_Function_Mgr::instance()->constant_function(atof(arg[argIdx])); prescribedDataMgr_->fix_field(nsetName,thisField,thisIndex,f); - } + } else { ATC::LammpsInterface::instance()->print_msg("reading "+field_to_string(thisField)+" on nodeset "+nsetName+" from file "+a); string s = ATC::LammpsInterface::instance()->read_file(a); - stringstream ss; ss << s; - double v; + stringstream ss; ss << s; + double v; set nodeSet = (feEngine_->fe_mesh())->nodeset(nsetName); set::const_iterator iset; for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { @@ -211,20 +211,20 @@ namespace ATC { match = true; } - /*! \page man_unfix_nodes fix_modify AtC unfix + /*! \page man_unfix_nodes fix_modify AtC unfix \section syntax - fix_modify AtC unfix + fix_modify AtC unfix - = field name valid for type of physics - - = name of set of nodes + - = name of set of nodes \section examples fix_modify AtC unfix temperature groupNAME \section description Removes constraint on field values for specified nodes. \section restrictions keyword 'all' reserved in nodeset name - \section related + \section related see \ref man_fix_nodes - \section default + \section default none */ else if (strcmp(arg[argIdx],"unfix")==0) { @@ -239,15 +239,15 @@ namespace ATC { \section syntax fix_modify AtC source - = field name valid for type of physics - - = name of set of elements + - = name of set of elements \section examples fix_modify atc source temperature middle temporal_ramp 10. 0. \section description - Add domain sources to the mesh. The units are consistent with LAMMPS's + Add domain sources to the mesh. The units are consistent with LAMMPS's units for mass, length and time and are defined by the PDE being solved, e.g. for thermal transfer the balance equation is for energy and source is energy per time. - \section restrictions + \section restrictions keyword 'all' reserved in element_set name \section related see \ref man_remove_source @@ -265,14 +265,14 @@ namespace ATC { if (is_numeric(a)) { // constant f = XT_Function_Mgr::instance()->constant_function(atof(arg[argIdx])); prescribedDataMgr_->fix_source(esetName,thisField,thisIndex,f); - } + } else { ATC::LammpsInterface::instance()->print_msg("reading "+field_to_string(thisField)+" source on node set "+esetName+" from file "+a); string s = ATC::LammpsInterface::instance()->read_file(arg[argIdx]); - stringstream ss; ss << s; - double v; + stringstream ss; ss << s; + double v; set nset = (feEngine_->fe_mesh())->nodeset(esetName); - set< pair < int, double > > src; + set< pair < int, double > > src; set::const_iterator iset; double sum = 0.; for (iset = nset.begin(); iset != nset.end(); iset++) { @@ -301,7 +301,7 @@ namespace ATC { \section syntax fix_modify AtC remove_source - = field name valid for type of physics - - = name of set of elements + - = name of set of elements \section examples fix_modify atc remove_source temperature groupNAME \section description @@ -344,7 +344,7 @@ namespace ATC { match = true; } - + /*! \page man_fix_flux fix_modify AtC fix_flux \section syntax fix_modify AtC fix_flux @@ -352,12 +352,12 @@ namespace ATC { - = name of set of element faces \section examples fix_modify atc fix_flux temperature faceSet 10.0 \n - + \section description - Command for fixing normal fluxes e.g. heat_flux. + Command for fixing normal fluxes e.g. heat_flux. This command only prescribes the normal component of the physical flux, e.g. heat (energy) flux. The units are in AtC units, i.e. derived from the LAMMPS length, time, and mass scales. - \section restrictions + \section restrictions Only normal fluxes (Neumann data) can be prescribed. \section related see \ref man_unfix_flux @@ -388,10 +388,10 @@ namespace ATC { - = name of set of element faces \section examples fix_modify atc unfix_flux temperature faceSet \n - + \section description - Command for removing prescribed normal fluxes e.g. heat_flux, stress. - \section restrictions + Command for removing prescribed normal fluxes e.g. heat_flux, stress. + \section restrictions \section related see \ref man_unfix_flux \section default @@ -405,15 +405,15 @@ namespace ATC { match = true; } - - /*! \page man_fe_md_boundary fix_modify AtC fe_md_boundary + + /*! \page man_fe_md_boundary fix_modify AtC fe_md_boundary \section syntax fix_modify AtC fe_md_boundary [args] \section examples fix_modify atc fe_md_boundary interpolate \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 + \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. @@ -427,13 +427,13 @@ namespace ATC { bndyIntType_ = FE_QUADRATURE; string name(arg[argIdx++]); bndyFaceSet_ = & ( (feEngine_->fe_mesh())->faceset(name)); - } + } else if (strcmp(arg[argIdx],"interpolate")==0) { argIdx++; bndyIntType_ = FE_INTERPOLATION; } - else if (strcmp(arg[argIdx],"no_boundary")==0) { - bndyIntType_ = NO_QUADRATURE; + else if (strcmp(arg[argIdx],"no_boundary")==0) { + bndyIntType_ = NO_QUADRATURE; } else { throw ATC_Error("Bad boundary integration type"); @@ -442,7 +442,7 @@ namespace ATC { - /*! \page man_boundary_faceset fix_modify AtC boundary_faceset + /*! \page man_boundary_faceset fix_modify AtC boundary_faceset \section syntax fix_modify AtC boundary_faceset [args] \section examples @@ -472,7 +472,7 @@ namespace ATC { } } - /*! \page man_internal_quadrature fix_modify AtC internal_quadrature + /*! \page man_internal_quadrature fix_modify AtC internal_quadrature \section syntax fix_modify atc internal_quadrature [region] \section examples @@ -487,8 +487,8 @@ namespace ATC { as being within the MD region. This option is only valid with internal_quadrature off. \section restrictions - \section related - \section default + \section related + \section default on */ else if (strcmp(arg[argIdx],"internal_quadrature")==0) { @@ -509,7 +509,7 @@ namespace ATC { match = true; } else { - for (regionID_ = 0; regionID_ < lammpsInterface_->nregion(); regionID_++) + for (regionID_ = 0; regionID_ < lammpsInterface_->nregion(); regionID_++) if (strcmp(arg[argIdx],lammpsInterface_->region_name(regionID_)) == 0) break; if (regionID_ < lammpsInterface_->nregion()) { atomQuadForInternal_ = false; @@ -551,7 +551,7 @@ namespace ATC { match = true; } - + else if (strcmp(arg[argIdx],"fix_open")==0) { argIdx++; parse_field(arg,argIdx,thisField); @@ -655,19 +655,19 @@ namespace ATC { /*! \page man_equilibrium_start fix_modify AtC equilibrium_start \section syntax fix_modify AtC equilibrium_start - + \section examples fix_modify atc equilibrium_start on \n - + \section description Starts filtered calculations assuming they start in equilibrium, i.e. perfect finite element force balance. - + \section restrictions only needed before filtering is begun - + \section related see \ref man_time_filter - + \section default on */ @@ -684,7 +684,7 @@ namespace ATC { } /*! \page man_mass_matrix fix_modify AtC mass_matrix - \section syntax + \section syntax fix_modify AtC mass_matrix - = activiate/deactiviate using the FE mass matrix in the MD region \section examples @@ -720,7 +720,7 @@ namespace ATC { fix_modify AtC material gap_region 2 \section description Sets the material model in elementset_name to be of type material_id. - \section restrictions + \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 @@ -739,7 +739,7 @@ namespace ATC { set::const_iterator iset; for (iset = elemSet.begin(); iset != elemSet.end(); iset++) { int ielem = *iset; - + // and the tag a string elementToMaterialMap_(ielem) = matId; } @@ -747,7 +747,7 @@ namespace ATC { needReset_ = true; } - } // end else + } // end else // no match, call base class parser if (!match) { match = ATC_Method::modify(narg, arg); @@ -760,7 +760,7 @@ namespace ATC { WeakEquation::PDE_Type ATC_Coupling::pde_type(const FieldName fieldName) const { const WeakEquation * weakEq = physicsModel_->weak_equation(fieldName); - if (weakEq == nullptr) return WeakEquation::PROJECTION_PDE; + if (weakEq == nullptr) return WeakEquation::PROJECTION_PDE; return weakEq->type(); } //-------------------------------------------------- @@ -768,7 +768,7 @@ namespace ATC { bool ATC_Coupling::is_dynamic(const FieldName fieldName) const { const WeakEquation * weakEq = physicsModel_->weak_equation(fieldName); - if (weakEq == nullptr) return false; + if (weakEq == nullptr) return false; return (physicsModel_->weak_equation(fieldName)->type() == WeakEquation::DYNAMIC_PDE); } @@ -794,7 +794,7 @@ namespace ATC { //-------------------------------------------------------------- // create_physics_model - // - method to create physics model + // - method to create physics model //-------------------------------------------------------------- void ATC_Coupling::create_physics_model(const PhysicsType & physicsType, string matFileName) @@ -890,7 +890,7 @@ namespace ATC { //-------------------------------------------------------- void ATC_Coupling::set_initial_conditions() { - // set fields + // set fields prescribedDataMgr_->set_initial_conditions(time(), fields_,dot_fields_,ddot_fields_,dddot_fields_); @@ -931,7 +931,7 @@ namespace ATC { atomicSources); } else { - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; FIELDS::const_iterator fieldItr = fields.find(thisFieldName); @@ -941,7 +941,7 @@ namespace ATC { } } //----------------------------------------------------------------- - + void ATC_Coupling::compute_atomic_sources(const RHS_MASK & fieldMask, const FIELDS & fields, FIELDS & atomicSources) @@ -957,7 +957,7 @@ namespace ATC { } if (fieldMask(thisFieldName,PRESCRIBED_SOURCE)) { atomicSources[thisFieldName] -= fluxMask_*(sources_[thisFieldName].quantity()); - } + } // add in sources from extrinsic models @@ -971,7 +971,7 @@ namespace ATC { void ATC_Coupling::masked_atom_domain_rhs_tangent( const pair row_col, const RHS_MASK & rhsMask, - const FIELDS & fields, + const FIELDS & fields, SPAR_MAT & stiffness, const PhysicsModel * physicsModel) { @@ -989,7 +989,7 @@ namespace ATC { void ATC_Coupling::compute_rhs_tangent( const pair row_col, const RHS_MASK & rhsMask, - const FIELDS & fields, + const FIELDS & fields, SPAR_MAT & stiffness, const IntegrationDomainType integrationType, const PhysicsModel * physicsModel) @@ -998,7 +998,7 @@ namespace ATC { if (integrationType == FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE) { RHS_MASK rhsMaskFE = rhsMask; RHS_MASK rhsMaskMD = rhsMask; rhsMaskMD = false; - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; if ( rhsMaskFE(thisFieldName,SOURCE) ) { @@ -1013,14 +1013,14 @@ namespace ATC { fields, stiffnessAtomDomain_, physicsModel); - stiffness += stiffnessAtomDomain_; + stiffness += stiffnessAtomDomain_; } else { feEngine_->compute_tangent_matrix(rhsMask, row_col, fields , physicsModel, elementToMaterialMap_, stiffness); } - ROBIN_SURFACE_SOURCE & robinFcn = *(prescribedDataMgr_->robin_functions()); + ROBIN_SURFACE_SOURCE & robinFcn = *(prescribedDataMgr_->robin_functions()); feEngine_->add_robin_tangent(rhsMask, fields, time(), robinFcn, stiffness); OPEN_SURFACE & openFaces = *(prescribedDataMgr_->open_faces()); feEngine_->add_open_tangent(rhsMask, fields, openFaces, stiffness); @@ -1037,15 +1037,15 @@ namespace ATC { } //----------------------------------------------------------------- void ATC_Coupling::compute_rhs_vector(const RHS_MASK & rhsMask, - const FIELDS & fields, + const FIELDS & fields, FIELDS & rhs, const IntegrationDomainType domain, const PhysicsModel * physicsModel) { if (!physicsModel) physicsModel = physicsModel_; - + // compute FE contributions - + evaluate_rhs_integral(rhsMask,fields,rhs,domain,physicsModel); for (int n = 0; n < rhsMask.nRows(); n++) { @@ -1053,7 +1053,7 @@ namespace ATC { if (rhsMask(thisFieldName,PRESCRIBED_SOURCE)) { if (is_intrinsic(thisFieldName)) { rhs[thisFieldName] += fluxMaskComplement_*(sources_[thisFieldName].quantity()); - } + } else { rhs[thisFieldName] += sources_[thisFieldName].quantity(); } @@ -1068,7 +1068,7 @@ namespace ATC { rhs[thisFieldName] += extrinsicSources_[thisFieldName].quantity(); } } - + } ROBIN_SURFACE_SOURCE & robinFcn = *(prescribedDataMgr_->robin_functions()); feEngine_->add_robin_fluxes(rhsMask, fields, time(), robinFcn, rhs); @@ -1092,7 +1092,7 @@ namespace ATC { rhs); } else { - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; FIELDS::const_iterator fieldItr = fields.find(thisFieldName); @@ -1108,13 +1108,13 @@ namespace ATC { const IntegrationDomainType integrationType, const PhysicsModel * physicsModel) { - + if (!physicsModel) physicsModel = physicsModel_; - + if (integrationType == FE_DOMAIN ) { - feEngine_->compute_rhs_vector(rhsMask, - fields, + feEngine_->compute_rhs_vector(rhsMask, + fields, physicsModel, elementToMaterialMap_, rhs, false, @@ -1123,14 +1123,14 @@ namespace ATC { fields, rhsAtomDomain_, physicsModel); - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; rhs[thisFieldName] -= rhsAtomDomain_[thisFieldName].quantity(); } } else if (integrationType == ATOM_DOMAIN) { - + masked_atom_domain_rhs_integral(rhsMask, fields, rhs, @@ -1139,7 +1139,7 @@ namespace ATC { else if (integrationType == FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE) { RHS_MASK rhsMaskFE = rhsMask; RHS_MASK rhsMaskMD = rhsMask; rhsMaskMD = false; - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; if ( rhsMaskFE(thisFieldName,SOURCE) ) { @@ -1156,7 +1156,7 @@ namespace ATC { fields, rhsAtomDomain_, physicsModel); - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName thisFieldName = field->first; @@ -1180,7 +1180,7 @@ namespace ATC { rhs); } } - + //-------------------------------------------------- bool ATC_Coupling::reset_methods() const { @@ -1192,12 +1192,12 @@ namespace ATC { } //-------------------------------------------------- void ATC_Coupling::initialize() - { + { // initialize physics model if (physicsModel_) physicsModel_->initialize(); ATC_Method::initialize(); - + // initialized_ is set to true by derived class initialize() // STEP 6 - data initialization continued: set initial conditions if (!initialized_) { @@ -1211,7 +1211,7 @@ namespace ATC { throw; } } - + // initialize and fix computational geometry, this can be changed in the future for Eulerian calculations that fill and empty elements which is why it is outside a !initialized_ guard internalElement_->unfix_quantity(); if (ghostElement_) ghostElement_->unfix_quantity(); @@ -1231,7 +1231,7 @@ namespace ATC { map::const_iterator field; for (field = fieldSizes_.begin(); field!=fieldSizes_.end(); field++) { FieldName thisField = field->first; - if (is_intrinsic(thisField) && is_dynamic(thisField)) { + if (is_intrinsic(thisField) && is_dynamic(thisField)) { compute_mass_matrix(thisField); if (!useConsistentMassMatrix_(thisField) && !useFeMdMassMatrix_) { massMatsMd_[thisField] = massMatsMdInstantaneous_[thisField].quantity(); @@ -1242,7 +1242,7 @@ namespace ATC { } } } - + // prepare computes for first timestep lammpsInterface_->computes_addstep(lammpsInterface_->ntimestep()+1); @@ -1283,7 +1283,7 @@ namespace ATC { // set consistent initial conditions, if requested if (!timeFilterManager_.filter_dynamics() && consistentInitialization_) { - + const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); if (fieldSizes_.find(VELOCITY) != fieldSizes_.end()) { @@ -1291,7 +1291,7 @@ namespace ATC { DENS_MAN * nodalAtomicVelocity(interscaleManager_.dense_matrix("NodalAtomicVelocity")); const DENS_MAT & atomicVelocity(nodalAtomicVelocity->quantity()); for (int i = 0; iquantity()); - + for (int i = 0; iquantity()); for (int i = 0; iquantity()); for (int i = 0; iquantity()); for (int i = 0; ifirst; int thisSize = field->second; - + // Allocate fields, initialize to default values, set up initial schedule - + fields_[thisField].reset(nNodes_,thisSize); dot_fields_[thisField].reset(nNodes_,thisSize); ddot_fields_[thisField].reset(nNodes_,thisSize); dddot_fields_[thisField].reset(nNodes_,thisSize); - + // Allocate restricted fields if (is_intrinsic(thisField)) { nodalAtomicFields_[thisField].reset(nNodes_,thisSize); @@ -1383,11 +1383,11 @@ namespace ATC { // Dimension finite element rhs matrix rhs_[thisField].reset(nNodes_,thisSize); rhsAtomDomain_[thisField].reset(nNodes_,thisSize); - + sources_[thisField].reset(nNodes_,thisSize); extrinsicSources_[thisField].reset(nNodes_,thisSize); boundaryFlux_[thisField].reset(nNodes_,thisSize); - + if (is_intrinsic(thisField) && is_dynamic(thisField)) { massMats_[thisField].reset(nNodes_,nNodes_); // PARALLELIZE massMatsFE_[thisField].reset(nNodes_,nNodes_); @@ -1402,7 +1402,7 @@ namespace ATC { // no MD mass matrices needed, regular matrices computed in extrinsic model if (useConsistentMassMatrix_(thisField)) { // compute FE mass matrix in full domain - + consistentMassMats_[thisField].reset(nNodes_,nNodes_); // PARALLELIZE consistentMassMatsInv_[thisField].reset(nNodes_,nNodes_); // PARALLELIZE } @@ -1416,7 +1416,7 @@ namespace ATC { } //-------------------------------------------------------- // create_full_element_mask - // constructs element mask which only masks out + // constructs element mask which only masks out // null elements //-------------------------------------------------------- MatrixDependencyManager * ATC_Coupling::create_full_element_mask() @@ -1424,7 +1424,7 @@ namespace ATC { MatrixDependencyManager * elementMaskMan = new MatrixDependencyManager(feEngine_->num_elements(),1); DenseMatrix & elementMask(elementMaskMan->set_quantity()); elementMask = true; - + const set & nullElements = feEngine_->null_elements(); set::const_iterator iset; for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { @@ -1451,7 +1451,7 @@ namespace ATC { int ielem = *iset; elementMask(ielem,0) = true; } - + const set & nullElements = feEngine_->null_elements(); for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { int ielem = *iset; @@ -1486,13 +1486,13 @@ namespace ATC { 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(); @@ -1562,7 +1562,7 @@ namespace ATC { accumulantWeights_ = new AccumulantWeights(accumulant_); mdMassNormalization_ = false; } - + this->create_atom_volume(); // masked atom weights @@ -1620,7 +1620,7 @@ namespace ATC { //-------------------------------------------------------- void ATC_Coupling::construct_molecule_transfers() { - + map >::const_iterator molecule; PerAtomQuantity * atomProcGhostCoarseGrainingPositions = interscaleManager_.per_atom_quantity("AtomicProcGhostCoarseGrainingPositions"); FundamentalAtomQuantity * mass = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS, @@ -1631,12 +1631,12 @@ namespace ATC { SmallMoleculeSet * smallMoleculeSet = new SmallMoleculeSet(this,groupbit); smallMoleculeSet->initialize(); interscaleManager_.add_small_molecule_set(smallMoleculeSet,moleculeName); - SmallMoleculeCentroid * moleculeCentroid = + SmallMoleculeCentroid * moleculeCentroid = new SmallMoleculeCentroid(this,mass,smallMoleculeSet,atomProcGhostCoarseGrainingPositions); interscaleManager_.add_dense_matrix(moleculeCentroid,"MoleculeCentroid"+moleculeName); // shape function at molecular coordinates - PointToElementMap * elementMapMol = + PointToElementMap * elementMapMol = new PointToElementMap(this,moleculeCentroid); interscaleManager_.add_dense_matrix_int(elementMapMol, "ElementMap"+moleculeName); @@ -1714,16 +1714,16 @@ namespace ATC { meshDataInitialized_ = true; } //-------------------------------------------------------- - + void ATC_Coupling::reset_flux_mask(void) { int i; // this is exact only for uniform meshes and certain types of atomic weights // \int_{\Omega_MD} N_I dV = \sum_\alpha N_I\alpha V_\alpha - fluxMask_.reset((invNodeVolumes_.quantity()) + fluxMask_.reset((invNodeVolumes_.quantity()) * (nodalAtomicVolume_->quantity())); - DIAG_MAT id(fluxMask_.nRows(),fluxMask_.nCols()); + DIAG_MAT id(fluxMask_.nRows(),fluxMask_.nCols()); id = 1.0; fluxMaskComplement_ = id + -1.0*fluxMask_; @@ -1748,10 +1748,10 @@ namespace ATC { if (!physicsModel) physicsModel = physicsModel_; if (useConsistentMassMatrix_(thisField)) { // compute FE mass matrix in full domain - + Array massMask(1); - massMask(0) = thisField; - + massMask(0) = thisField; + feEngine_->compute_mass_matrix(massMask,fields_,physicsModel, elementToMaterialMap_,consistentMassMats_, &(elementMask_->quantity())); @@ -1760,15 +1760,15 @@ namespace ATC { } else if (! is_intrinsic(thisField)) { Array massMask(1); - massMask(0) = thisField; - + massMask(0) = thisField; + feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel, elementToMaterialMap_,massMats_, &(elementMask_->quantity())); const DIAG_MAT & myMassMat(massMats_[thisField].quantity()); DIAG_MAT & myMassMatInv(massMatsInv_[thisField].set_quantity()); for (int iNode = 0; iNode < nNodes_; iNode++) { - + if (fabs(myMassMat(iNode,iNode))>0) myMassMatInv(iNode,iNode) = 1./myMassMat(iNode,iNode); else @@ -1794,7 +1794,7 @@ namespace ATC { const DIAG_MAT & myMassMatMd(massMatsMd_[thisField].quantity()); // compute inverse mass matrices since we're using lumped masses for (int iNode = 0; iNode < nNodes_; iNode++) { - + if (fabs(myMassMat(iNode,iNode))>0) myMassMatInv(iNode,iNode) = 1./myMassMat(iNode,iNode); else @@ -1811,7 +1811,7 @@ namespace ATC { elementToMaterialMap_,massMatsFE_, &(elementMask_->quantity())); // fully remove contributions from internal nodes - + DIAG_MAT & myMassMatFE(massMatsFE_[thisField].set_quantity()); //myMassMatFE.print("MMFE"); if (!atomQuadForInternal_) { @@ -1821,7 +1821,7 @@ namespace ATC { myMassMatFE(iNode,iNode) = 0.; } } - + // atomic quadrature for FE mass matrix in atomic domain if (shpFcnMask_) { feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel,atomMaterialGroupsMask_, @@ -1831,7 +1831,7 @@ namespace ATC { else { (massMatsAqInstantaneous_[thisField].set_quantity()).reset(nNodes_,nNodes_); } - + // set up mass MD matrices compute_md_mass_matrix(thisField,massMatsMdInstantaneous_[thisField].set_quantity()); } @@ -1853,13 +1853,13 @@ namespace ATC { // compute inverse mass matrices since we're using lumped masses for (int iNode = 0; iNode < nNodes_; iNode++) { - - if (fabs(myMassMatMD(iNode,iNode))>0) { + + if (fabs(myMassMatMD(iNode,iNode))>0) { myMassMatMDInv(iNode,iNode) = 1./myMassMatMD(iNode,iNode); } else myMassMatMDInv(iNode,iNode) = 0.; - + if (fabs(myMassMat(iNode,iNode))>0) { myMassMatInv(iNode,iNode) = 1./myMassMat(iNode,iNode); } @@ -1876,18 +1876,18 @@ namespace ATC { void ATC_Coupling::compute_md_mass_matrix(FieldName thisField, DIAG_MAT & massMat) { - + if (thisField == TEMPERATURE) { massMat.shallowreset(nodalAtomicHeatCapacity_->quantity()); } - + else if (thisField == DISPLACEMENT || thisField == VELOCITY) { massMat.shallowreset(nodalAtomicMass_->quantity()); } else if (thisField == MASS_DENSITY || thisField == SPECIES_CONCENTRATION) { massMat.shallowreset(nodalAtomicVolume_->quantity()); } - } + } //-------------------------------------------------- // write_restart_file @@ -1899,7 +1899,7 @@ namespace ATC { atomicRegulator_->pack_fields(data); ATC_Method::write_restart_data(fileName,data); } - + //-------------------------------------------------- // read_restart_file // bundle matrices that need to be saved and call @@ -2006,7 +2006,7 @@ namespace ATC { 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); @@ -2020,7 +2020,7 @@ namespace ATC { // fixed values, non-group bcs handled through FE set_fixed_nodes(); - + update_time(0.5); // ghost update, if needed @@ -2041,7 +2041,7 @@ namespace ATC { } } - + //-------------------------------------------------------- void ATC_Coupling::pre_neighbor() { @@ -2062,7 +2062,7 @@ namespace ATC { void ATC_Coupling::pre_force() { ATC_Method::pre_force(); - atomicRegulator_->pre_force(); + atomicRegulator_->pre_force(); } //-------------------------------------------------------- @@ -2078,7 +2078,7 @@ namespace ATC { for (field = fieldSizes_.begin(); field!=fieldSizes_.end(); field++) { FieldName thisField = field->first; if (is_intrinsic(thisField) && is_dynamic(thisField)) { - compute_mass_matrix(thisField); + compute_mass_matrix(thisField); } } } @@ -2095,7 +2095,7 @@ namespace ATC { massMatsAqInstantaneous_[thisField].quantity(),dt); massMatTimeFilters_[thisField]->apply_post_step1(massMatsMd_[thisField].set_quantity(), massMatsMdInstantaneous_[thisField].quantity(),dt); - update_mass_matrix(thisField); + update_mass_matrix(thisField); } } } @@ -2107,7 +2107,7 @@ namespace ATC { //-------------------------------------------------------- // post_final_integrate - // integration after the second stage lammps atomic + // integration after the second stage lammps atomic // update of Verlet step 2 //-------------------------------------------------------- void ATC_Coupling::post_final_integrate() @@ -2136,7 +2136,7 @@ namespace ATC { compute_atomic_sources(intrinsicMask_,fields_,atomicSources_); } atomicRegulator_->apply_pre_corrector(dt,lammpsInterface_->ntimestep()); - + // Compute atom-integrated rhs // parallel communication happens within FE_Engine compute_rhs_vector(intrinsicMask_,fields_,rhs_,FE_DOMAIN); @@ -2144,7 +2144,7 @@ namespace ATC { (_tiIt_->second)->add_to_rhs(); } atomicRegulator_->add_to_rhs(rhs_); - + // Compute and add atomic contributions to FE equations for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { (_tiIt_->second)->post_final_integrate1(dt); @@ -2152,7 +2152,7 @@ namespace ATC { // fix nodes, non-group bcs applied through FE set_fixed_nodes(); - + // corrector step extrinsic model extrinsicModelManager_.post_final_integrate(); @@ -2174,7 +2174,7 @@ namespace ATC { for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { (_tiIt_->second)->post_final_integrate2(dt); } - + // apply corrector phase of thermostat set_fixed_nodes(); atomicRegulator_->apply_post_corrector(dt,lammpsInterface_->ntimestep()); @@ -2186,9 +2186,9 @@ namespace ATC { // Fix nodes, non-group bcs applied through FE set_fixed_nodes(); - + update_time(0.5); - + output(); lammpsInterface_->computes_addstep(lammpsInterface_->ntimestep()+1); // adds next step to computes //ATC_Method::post_final_integrate(); @@ -2213,13 +2213,13 @@ namespace ATC { // //================================================================= void ATC_Coupling::compute_boundary_flux(const Array2D & rhsMask, - const FIELDS & fields, + const FIELDS & fields, FIELDS & rhs, const Array< set > atomMaterialGroups, const VectorDependencyManager * shpFcnDerivs, const SPAR_MAN * shpFcn, const DIAG_MAN * atomicWeights, - + const MatrixDependencyManager * elementMask, const SetDependencyManager * nodeSet) { @@ -2276,10 +2276,10 @@ if (thisFieldName >= rhsMask.nRows()) break; //----------------------------------------------------------------- void ATC_Coupling::compute_flux(const Array2D & rhsMask, - const FIELDS & fields, + const FIELDS & fields, GRAD_FIELD_MATS & flux, const PhysicsModel * physicsModel, - bool project) + bool project) { if (! physicsModel) { physicsModel = physicsModel_; } feEngine_->compute_flux(rhsMask, @@ -2288,7 +2288,7 @@ if (thisFieldName >= rhsMask.nRows()) break; elementToMaterialMap_, flux); if (project) { - for (FIELDS::const_iterator field = fields.begin(); + for (FIELDS::const_iterator field = fields.begin(); field != fields.end(); field++) { FieldName name = field->first; if ( rhsMask(name,FLUX) ) { @@ -2324,13 +2324,13 @@ if (i==0) f.print("flux_"+field_to_string(name)+"_"+ATC_Utility::to_string(i)); // parses the boundary integration to determine // the type of boundary integration being used //-------------------------------------------------- - - + + BoundaryIntegrationType ATC_Coupling::parse_boundary_integration(int narg, char **arg, const set< pair > * boundaryFaceSet) { - + int argIndex = 0; BoundaryIntegrationType myBoundaryIntegrationType = FE_INTERPOLATION;// default if (narg > 0) { @@ -2340,12 +2340,12 @@ if (i==0) f.print("flux_"+field_to_string(name)+"_"+ATC_Utility::to_string(i)); string name(arg[argIndex]); boundaryFaceSet = & ( (feEngine_->fe_mesh())->faceset(name)); set_boundary_face_set(boundaryFaceSet); - } + } else if (strcmp(arg[argIndex],"interpolate")==0) { myBoundaryIntegrationType = FE_INTERPOLATION; } - else if (strcmp(arg[argIndex],"no_boundary")==0) { - myBoundaryIntegrationType = NO_QUADRATURE; + else if (strcmp(arg[argIndex],"no_boundary")==0) { + myBoundaryIntegrationType = NO_QUADRATURE; } else { throw ATC_Error("Bad boundary integration type"); diff --git a/lib/atc/ATC_Coupling.h b/lib/atc/ATC_Coupling.h index e119b68738..9c9983bf26 100644 --- a/lib/atc/ATC_Coupling.h +++ b/lib/atc/ATC_Coupling.h @@ -20,16 +20,16 @@ namespace ATC { /** * @class ATC_Coupling - * @brief Base class for atom-continuum coupling + * @brief Base class for atom-continuum coupling */ class ATC_Coupling : public ATC_Method { public: /** methods */ - + friend class ExtrinsicModel; // friend is not inherited friend class ExtrinsicModelTwoTemperature; - friend class ExtrinsicModelDriftDiffusion; + friend class ExtrinsicModelDriftDiffusion; friend class ExtrinsicModelDriftDiffusionConvection; friend class ExtrinsicModelElectrostatic; friend class ExtrinsicModelElectrostaticMomentum; @@ -72,13 +72,13 @@ namespace ATC { virtual void pre_init_integrate(); /** Predictor phase, Verlet first step for velocity and position */ - virtual void init_integrate(); + virtual void init_integrate(); /** Predictor phase, executed after Verlet */ virtual void post_init_integrate(); /** Corrector phase, executed after Verlet*/ - + virtual void post_final_integrate(); /** pre/post atomic force calculation in minimize */ @@ -95,9 +95,9 @@ namespace ATC { const std::set & boundary_face_names() {return boundaryFaceNames_;}; /** access to boundary integration method */ int boundary_integration_type() {return bndyIntType_;}; - void set_boundary_integration_type(int boundaryIntegrationType) + void set_boundary_integration_type(int boundaryIntegrationType) {bndyIntType_ = boundaryIntegrationType;}; - void set_boundary_face_set(const std::set< std::pair > * boundaryFaceSet) + void set_boundary_face_set(const std::set< std::pair > * boundaryFaceSet) {bndyFaceSet_ = boundaryFaceSet;}; BoundaryIntegrationType parse_boundary_integration (int narg, char **arg, const std::set< std::pair > * boundaryFaceSet); @@ -107,10 +107,10 @@ namespace ATC { //-------------------------------------------------------- /** access to all boundary fluxes */ - FIELDS &boundary_fluxes() {return boundaryFlux_;}; + FIELDS &boundary_fluxes() {return boundaryFlux_;}; /** wrapper for FE_Engine's compute_boundary_flux functions */ void compute_boundary_flux(const Array2D & rhs_mask, - const FIELDS &fields, + const FIELDS &fields, FIELDS &rhs, const Array< std::set > atomMaterialGroups, const VectorDependencyManager * shpFcnDerivs, @@ -128,12 +128,12 @@ namespace ATC { DENS_MAN &field_rhs(FieldName thisField) { return rhs_[thisField]; }; /** allow FE_Engine to construct ATC structures after mesh is constructed */ - virtual void initialize_mesh_data(void); + virtual void initialize_mesh_data(void); // public for FieldIntegrator - bool source_atomic_quadrature(FieldName /* field */) + bool source_atomic_quadrature(FieldName /* field */) { return (sourceIntegration_ == FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE); } - ATC::IntegrationDomainType source_integration() + ATC::IntegrationDomainType source_integration() { return sourceIntegration_; } /** wrapper for FE_Engine's compute_sources */ @@ -143,25 +143,25 @@ namespace ATC { FIELD_MATS & atomicSources); /** computes tangent matrix using atomic quadrature near FE region */ void masked_atom_domain_rhs_tangent(const std::pair row_col, - const RHS_MASK & rhsMask, - const FIELDS & fields, + 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, + const FIELDS &fields, FIELDS &rhs, const IntegrationDomainType domain, // = FULL_DOMAIN const PhysicsModel * physicsModel=nullptr); /** wrapper for FE_Engine's compute_tangent_matrix */ void compute_rhs_tangent(const std::pair row_col, - const RHS_MASK & rhsMask, - const FIELDS & fields, + const RHS_MASK & rhsMask, + const FIELDS & fields, SPAR_MAT & stiffness, const IntegrationDomainType integrationType, const PhysicsModel * physicsModel=nullptr); void tangent_matrix(const std::pair row_col, - const RHS_MASK & rhsMask, + const RHS_MASK & rhsMask, const PhysicsModel * physicsModel, SPAR_MAT & stiffness); @@ -172,7 +172,7 @@ namespace ATC { // public for ImplicitSolveOperator /** return pointer to PrescribedDataManager */ - PrescribedDataManager * prescribed_data_manager() + PrescribedDataManager * prescribed_data_manager() { return prescribedDataMgr_; } // public for Kinetostat // TODO rename to "mass_matrix" @@ -228,7 +228,7 @@ namespace ATC { void set_mass_mat_time_filter(FieldName thisField,TimeFilterManager::FilterIntegrationType filterIntegrationType); /** return reference to ExtrinsicModelManager */ - ExtrinsicModelManager & extrinsic_model_manager() + ExtrinsicModelManager & extrinsic_model_manager() { return extrinsicModelManager_; } /** access to time integrator */ const TimeIntegrator * time_integrator(const FieldName & field) const { @@ -242,7 +242,7 @@ namespace ATC { //--------------------------------------------------------------- /*@{*/ /** allow FE_Engine to construct data manager after mesh is constructed */ - void construct_prescribed_data_manager (void); + void construct_prescribed_data_manager (void); /** method to create physics model */ void create_physics_model(const PhysicsType & physicsType, std::string matFileName); @@ -289,7 +289,7 @@ namespace ATC { void set_sources(); /** assemble various contributions to the heat flux in the atomic region */ void compute_atomic_sources(const Array2D & rhs_mask, - const FIELDS &fields, + const FIELDS &fields, FIELDS &atomicSources); DENS_MAT &get_source(FieldName thisField){return sources_[thisField].set_quantity();}; @@ -313,25 +313,25 @@ namespace ATC { //--------------------------------------------------------------- /*@{*/ /** access for field mask */ - Array2D &field_mask() {return fieldMask_;}; + Array2D &field_mask() {return fieldMask_;}; /** create field mask */ void reset_flux_mask(); /** field mask for intrinsic integration */ Array2D intrinsicMask_; /** wrapper for FE_Engine's compute_flux functions */ void compute_flux(const Array2D & rhs_mask, - const FIELDS &fields, + const FIELDS &fields, GRAD_FIELD_MATS &flux, const PhysicsModel * physicsModel=nullptr, const bool normalize = false); /** evaluate rhs on the atomic domain which is near the FE region */ void masked_atom_domain_rhs_integral(const Array2D & rhs_mask, - const FIELDS &fields, + 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 & rhs_mask, - const FIELDS &fields, + const FIELDS &fields, FIELDS &rhs, const IntegrationDomainType domain, const PhysicsModel * physicsModel=nullptr); @@ -422,8 +422,8 @@ namespace ATC { /*@{*/ Array elementToMaterialMap_; // ATOMIC_TAG * elementToMaterialMap_; /** atomic ATC material tag */ - - + + Array< std::set > atomMaterialGroups_; // ATOMIC_TAG*atomMaterialGroups_; Array< std::set > atomMaterialGroupsMask_; // ATOMIC_TAG*atomMaterialGroupsMask_; /*@}*/ @@ -432,7 +432,7 @@ namespace ATC { /** computational geometry */ //--------------------------------------------------------------- /*@{*/ - bool atomQuadForInternal_; + bool atomQuadForInternal_; MatrixDependencyManager * elementMask_; MatrixDependencyManager * elementMaskMass_; MatrixDependencyManager * elementMaskMassMd_; @@ -465,7 +465,7 @@ namespace ATC { DIAG_MAN * atomicWeightsMask_; SPAR_MAN * shpFcnMask_; VectorDependencyManager * shpFcnDerivsMask_; - Array atomMask_; + Array atomMask_; SPAR_MAN atomToOverlapMat_; DIAG_MAN nodalMaskMat_; /*@}*/ @@ -475,7 +475,7 @@ namespace ATC { //--------------------------------------------------------------- /*@{*/ /** mask for computation of fluxes */ - Array2D fieldMask_; + Array2D fieldMask_; DIAG_MAT fluxMask_; DIAG_MAT fluxMaskComplement_; /** sources */ diff --git a/lib/atc/ATC_CouplingEnergy.cpp b/lib/atc/ATC_CouplingEnergy.cpp index 8fae1f0703..bed3842bdb 100644 --- a/lib/atc/ATC_CouplingEnergy.cpp +++ b/lib/atc/ATC_CouplingEnergy.cpp @@ -20,7 +20,7 @@ namespace ATC { // Class ATC_CouplingEnergy //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -33,18 +33,18 @@ namespace ATC { nodalAtomicKineticTemperature_(nullptr), nodalAtomicConfigurationalTemperature_(nullptr) { - // Allocate PhysicsModel + // Allocate PhysicsModel create_physics_model(THERMAL, matParamFile); // create extrinsic physics model if (extrinsicModel != NO_MODEL) { - extrinsicModelManager_.create_model(extrinsicModel,matParamFile); + extrinsicModelManager_.create_model(extrinsicModel,matParamFile); } // Defaults set_time(); bndyIntType_ = FE_INTERPOLATION; - + // set up field data based on physicsModel physicsModel_->num_fields(fieldSizes_,fieldMask_); @@ -182,16 +182,16 @@ namespace ATC { // register the per-atom quantity for the temperature definition interscaleManager_.add_per_atom_quantity(atomEnergyForTemperature, "AtomicEnergyForTemperature"); - + // nodal restriction of the atomic energy quantity for the temperature definition AtfShapeFunctionRestriction * nodalAtomicEnergy = new AtfShapeFunctionRestriction(this, atomEnergyForTemperature, shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicEnergy, "NodalAtomicEnergy"); - + // nodal atomic temperature field - + AtfShapeFunctionMdProjection * nodalAtomicTemperature = new AtfShapeFunctionMdProjection(this, nodalAtomicEnergy, TEMPERATURE); @@ -210,18 +210,18 @@ namespace ATC { //--------------------------------------------------------- void ATC_CouplingEnergy::init_filter() { - + TimeIntegrator::TimeIntegrationType timeIntegrationType = timeIntegrators_[TEMPERATURE]->time_integration_type(); - - - - - if (timeFilterManager_.end_equilibrate()) { + + + + + if (timeFilterManager_.end_equilibrate()) { if (timeIntegrationType==TimeIntegrator::GEAR) { if (equilibriumStart_) { - - - + + + if (atomicRegulator_->regulator_target()==AtomicRegulator::DYNAMICS) { // based on FE equation DENS_MAT vdotflamMat(-2.*(nodalAtomicFields_[TEMPERATURE].quantity())); // note 2 is for 1/2 vdotflam addition atomicRegulator_->reset_lambda_contribution(vdotflamMat); @@ -249,7 +249,7 @@ namespace ATC { { bool foundMatch = false; int argIndx = 0; - + // check to see if input is a transfer class command // check derived class before base class @@ -311,19 +311,19 @@ namespace ATC { // output[2] = average temperature double mvv2e = lammpsInterface_->mvv2e(); // convert to lammps energy units - + if (n == 0) { Array mask(1); FIELD_MATS energy; mask(0) = TEMPERATURE; - - feEngine_->compute_energy(mask, + + feEngine_->compute_energy(mask, fields_, physicsModel_, elementToMaterialMap_, energy, &(elementMask_->quantity())); - + double phononEnergy = mvv2e * energy[TEMPERATURE].col_sum(); return phononEnergy; } @@ -353,9 +353,9 @@ namespace ATC { _keTemp_ = nodalAtomicKineticTemperature_->quantity(); if (nodalAtomicConfigurationalTemperature_) _peTemp_ = nodalAtomicConfigurationalTemperature_->quantity(); - + OUTPUT_LIST outputData; - + // base class output ATC_Method::output(); @@ -370,7 +370,7 @@ namespace ATC { } atomicRegulator_->output(outputData); extrinsicModelManager_.output(outputData); - + DENS_MAT & temperature(nodalAtomicFields_[TEMPERATURE].set_quantity()); DENS_MAT & dotTemperature(dot_fields_[TEMPERATURE].set_quantity()); DENS_MAT & ddotTemperature(ddot_fields_[TEMPERATURE].set_quantity()); @@ -384,18 +384,18 @@ namespace ATC { feEngine_->add_global("temperature_std_dev", T_stddev); double Ta_mean = (nodalAtomicFields_[TEMPERATURE].quantity()).col_sum(0)/nNodes_; feEngine_->add_global("atomic_temperature_mean", Ta_mean); - double Ta_stddev = (nodalAtomicFields_[TEMPERATURE].quantity()).col_stdev(0); + double Ta_stddev = (nodalAtomicFields_[TEMPERATURE].quantity()).col_stdev(0); feEngine_->add_global("atomic_temperature_std_dev", Ta_stddev); // different temperature measures, if appropriate if (nodalAtomicKineticTemperature_) outputData["kinetic_temperature"] = & _keTemp_; - + if (nodalAtomicConfigurationalTemperature_) { _peTemp_ *= 2; // account for full temperature outputData["configurational_temperature"] = & _peTemp_; } - + // mesh data outputData["NodalAtomicTemperature"] = &temperature; outputData["dot_temperature"] = &dotTemperature; diff --git a/lib/atc/ATC_CouplingEnergy.h b/lib/atc/ATC_CouplingEnergy.h index fce1a45501..84d195f384 100644 --- a/lib/atc/ATC_CouplingEnergy.h +++ b/lib/atc/ATC_CouplingEnergy.h @@ -25,9 +25,9 @@ namespace ATC { class ATC_CouplingEnergy : public ATC_Coupling { public: - + // constructor - ATC_CouplingEnergy(std::string groupName, + ATC_CouplingEnergy(std::string groupName, double ** & perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile, @@ -64,7 +64,7 @@ namespace ATC { /** physics specific filter initialization */ void init_filter(); - + double compute_lambda_power(int gid); /** kinetic temperature for post-processing */ @@ -77,6 +77,6 @@ namespace ATC { DENS_MAT _keTemp_, _peTemp_; }; - + }; #endif diff --git a/lib/atc/ATC_CouplingMass.cpp b/lib/atc/ATC_CouplingMass.cpp index d36643e590..ecc2fe4a6c 100644 --- a/lib/atc/ATC_CouplingMass.cpp +++ b/lib/atc/ATC_CouplingMass.cpp @@ -31,11 +31,11 @@ namespace ATC { // Class ATC_CouplingMass //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- - ATC_CouplingMass::ATC_CouplingMass(string groupName, + ATC_CouplingMass::ATC_CouplingMass(string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, string matParamFile, @@ -43,19 +43,19 @@ namespace ATC { : ATC_Coupling(groupName,perAtomArray,thisFix), resetNlocal_(false) { - // Allocate PhysicsModel - create_physics_model(SPECIES, matParamFile); + // Allocate PhysicsModel + create_physics_model(SPECIES, matParamFile); // create extrinsic physics model if (extrinsicModel != NO_MODEL) { - extrinsicModelManager_.create_model(extrinsicModel,matParamFile); + extrinsicModelManager_.create_model(extrinsicModel,matParamFile); } // Defaults set_time(); bndyIntType_ = NO_QUADRATURE; - - + + // set up field data based on physicsModel physicsModel_->num_fields(fieldSizes_,fieldMask_); @@ -87,13 +87,13 @@ namespace ATC { //-------------------------------------------------------- // modify - // parses inputs and modifies state + // parses inputs and modifies state //-------------------------------------------------------- bool ATC_CouplingMass::modify(int narg, char **arg) { bool match = false; // check to see if it is a transfer class command - + // check derived class before base class int argIndex = 0; // pass-through to concentration regulator @@ -117,7 +117,7 @@ namespace ATC { //-------------------------------------------------------- void ATC_CouplingMass::initialize() { - + fieldSizes_[SPECIES_CONCENTRATION] = ntracked(); // Base class initalizations @@ -135,9 +135,9 @@ namespace ATC { FieldManager fmgr(this); atomicFields_[MASS_DENSITY] = fmgr.nodal_atomic_field(MASS_DENSITY, field_to_intrinsic_name(MASS_DENSITY)); - if (has_tracked_species()) { + if (has_tracked_species()) { atomicFields_[SPECIES_CONCENTRATION] = fmgr.nodal_atomic_field(SPECIES_CONCENTRATION, field_to_intrinsic_name(SPECIES_CONCENTRATION)); - + //if (atomicRegulator_->needs_temperature()) { atomicFields_[TEMPERATURE] = fmgr.nodal_atomic_field(KINETIC_TEMPERATURE, field_to_intrinsic_name(TEMPERATURE)); @@ -146,7 +146,7 @@ namespace ATC { //} } else { - + throw ATC_Error("ATC_CouplingMass: no tracked species"); } @@ -161,14 +161,14 @@ namespace ATC { const string moleculeName = molecule->first; SmallMoleculeSet * smallMoleculeSet = interscaleManager_.small_molecule_set(moleculeName); SPAR_MAN * shpFcnMol = interscaleManager_.sparse_matrix("ShapeFunction"+moleculeName); - AtomToSmallMoleculeTransfer * moleculeMass = + AtomToSmallMoleculeTransfer * moleculeMass = new AtomToSmallMoleculeTransfer(this,mass,smallMoleculeSet); interscaleManager_.add_dense_matrix(moleculeMass,"MoleculeMass"+moleculeName); - MotfShapeFunctionRestriction * nodalAtomicMoleculeMass = + MotfShapeFunctionRestriction * nodalAtomicMoleculeMass = new MotfShapeFunctionRestriction(moleculeMass,shpFcnMol); interscaleManager_.add_dense_matrix(nodalAtomicMoleculeMass,"NodalMoleculeMass"+moleculeName); - + AtfShapeFunctionMdProjection * nodalAtomicMoleculeMassDensity = new AtfShapeFunctionMdProjection(this,nodalAtomicMoleculeMass,MASS_DENSITY); interscaleManager_.add_dense_matrix(nodalAtomicMoleculeMassDensity,"NodalMoleculeMassDensity"+moleculeName); @@ -180,7 +180,7 @@ namespace ATC { void ATC_CouplingMass::init_filter() { - + ATC_Coupling::init_filter(); } @@ -192,11 +192,11 @@ namespace ATC { void ATC_CouplingMass::pre_exchange() { ATC_Coupling::pre_exchange(); - + //if (atomicRegulator_->needs_temperature()) { - field(TEMPERATURE) = atomicFields_[TEMPERATURE]->quantity(); + field(TEMPERATURE) = atomicFields_[TEMPERATURE]->quantity(); ///} - atomicRegulator_->pre_exchange(); + atomicRegulator_->pre_exchange(); if (resetNlocal_) { this->reset_nlocal(); resetNlocal_ = false; @@ -208,7 +208,7 @@ namespace ATC { // does post-processing steps and outputs data //-------------------------------------------------------- void ATC_CouplingMass::output() - { + { if (output_now()) { feEngine_->departition_mesh(); OUTPUT_LIST outputData; @@ -226,10 +226,10 @@ namespace ATC { (_tiIt_->second)->output(outputData); } extrinsicModelManager_.output(outputData); - atomicRegulator_->output(outputData); + atomicRegulator_->output(outputData); FIELD_POINTERS::iterator itr; - for (itr=atomicFields_.begin(); itr!=atomicFields_.end();itr++) { + for (itr=atomicFields_.begin(); itr!=atomicFields_.end();itr++) { FieldName name = itr->first; const DENS_MAT & data = (itr->second)->quantity(); outputData[field_to_intrinsic_name(name)] = & data; diff --git a/lib/atc/ATC_CouplingMass.h b/lib/atc/ATC_CouplingMass.h index 1589a7a655..8cdb3279ad 100644 --- a/lib/atc/ATC_CouplingMass.h +++ b/lib/atc/ATC_CouplingMass.h @@ -32,20 +32,20 @@ namespace ATC { class ATC_CouplingMass : public ATC_Coupling { public: - + // constructor - ATC_CouplingMass(std::string groupName, + ATC_CouplingMass(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile, ExtrinsicModelType extrinsic = NO_MODEL); - + // destructor virtual ~ATC_CouplingMass(); /** parser/modifier */ virtual bool modify(int narg, char **arg); - + /** pre time integration */ virtual void initialize(); @@ -78,8 +78,8 @@ namespace ATC { bool resetNlocal_; - - + + // i.e. we only need the correct shape function matrix for restriction }; diff --git a/lib/atc/ATC_CouplingMomentum.cpp b/lib/atc/ATC_CouplingMomentum.cpp index 6757245119..9b16efc159 100644 --- a/lib/atc/ATC_CouplingMomentum.cpp +++ b/lib/atc/ATC_CouplingMomentum.cpp @@ -22,11 +22,11 @@ namespace ATC { // Class ATC_CouplingMomentum //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- - ATC_CouplingMomentum::ATC_CouplingMomentum(string groupName, + ATC_CouplingMomentum::ATC_CouplingMomentum(string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, string matParamFile, @@ -35,14 +35,14 @@ namespace ATC { : ATC_Coupling(groupName,perAtomArray,thisFix), refPE_(0) { - // Allocate PhysicsModel + // Allocate PhysicsModel create_physics_model(intrinsicModel, matParamFile); // create extrinsic physics model if (extrinsicModel != NO_MODEL) { - extrinsicModelManager_.create_model(extrinsicModel,matParamFile); + extrinsicModelManager_.create_model(extrinsicModel,matParamFile); } - + // set up field data based on physicsModel physicsModel_->num_fields(fieldSizes_,fieldMask_); @@ -166,14 +166,14 @@ namespace ATC { atomicMassWeightedDisplacement = new AtomicMassWeightedDisplacement(this); interscaleManager_.add_per_atom_quantity(atomicMassWeightedDisplacement, "AtomicMassWeightedDisplacement"); - + // nodal (RHS) mass-weighted displacement AtfShapeFunctionRestriction * nodalAtomicMassWeightedDisplacement = new AtfShapeFunctionRestriction(this, atomicMassWeightedDisplacement, shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicMassWeightedDisplacement, "NodalAtomicMassWeightedDisplacement"); - + // nodal displacement derived only from atoms AtfShapeFunctionMdProjection * nodalAtomicDisplacement = new AtfShapeFunctionMdProjection(this, nodalAtomicMassWeightedDisplacement, @@ -194,7 +194,7 @@ namespace ATC { //--------------------------------------------------------- void ATC_CouplingMomentum::init_filter() { - + ATC_Coupling::init_filter(); if (timeFilterManager_.end_equilibrate() && equilibriumStart_) // set up correct initial lambda forces to enforce initial accerlation @@ -288,35 +288,35 @@ namespace ATC { ATC_Method::min_post_force(); // Set sources - + prescribedDataMgr_->set_sources(time(),sources_); extrinsicModelManager_.set_sources(fields_,extrinsicSources_); extrinsicModelManager_.pre_final_integrate(); - + if (outputNow_) { update_time(1.0); update_step(); output(); outputNow_ = false; } - - + + localStep_ += 1; } - + //-------------------------------------------------------- // output // does post-processing steps and outputs data //-------------------------------------------------------- - void ATC_CouplingMomentum::output() + void ATC_CouplingMomentum::output() { if (output_now()) { feEngine_->departition_mesh(); OUTPUT_LIST outputData; - + // base class output ATC_Method::output(); @@ -331,7 +331,7 @@ namespace ATC { } atomicRegulator_->output(outputData); extrinsicModelManager_.output(outputData); - + DENS_MAT & velocity(nodalAtomicFields_[VELOCITY].set_quantity()); DENS_MAT & rhs(rhs_[VELOCITY].set_quantity()); if (lammpsInterface_->rank_zero()) { @@ -341,7 +341,7 @@ namespace ATC { if (trackDisplacement_) { outputData["NodalAtomicDisplacement"] = & nodalAtomicFields_[DISPLACEMENT].set_quantity(); } - + feEngine_->write_data(output_index(), fields_, & outputData); } // force optional variables to reset to keep in sync @@ -376,7 +376,7 @@ namespace ATC { kineticEnergy += v.dot(M*v); } if (domain == FE_DOMAIN) { - + Array massMask(1); massMask(0) = VELOCITY; feEngine_->compute_lumped_mass_matrix(massMask,fields_,physicsModel_,atomMaterialGroups_, @@ -388,20 +388,20 @@ namespace ATC { kineticEnergy -= v.dot(Ma*v); } } - double mvv2e = lammpsInterface_->mvv2e(); + double mvv2e = lammpsInterface_->mvv2e(); kineticEnergy *= 0.5*mvv2e; // convert to LAMMPS units return kineticEnergy; } //-------------------------------------------------------------------- - // potential/strain energy + // potential/strain energy //-------------------------------------------------------------------- double ATC_CouplingMomentum::potential_energy(const IntegrationDomainType domain) const { Array mask(1); mask(0) = VELOCITY; FIELD_MATS energy; - feEngine_->compute_energy(mask, + feEngine_->compute_energy(mask, fields_, physicsModel_, elementToMaterialMap_, @@ -424,7 +424,7 @@ namespace ATC { // output[3] = total coarse scale energy // output[4] = fe-only coarse scale kinetic energy // output[5] = fe-only coarse scale potential energy - + if (n == 0) { diff --git a/lib/atc/ATC_CouplingMomentum.h b/lib/atc/ATC_CouplingMomentum.h index 66a4b22ca7..8ddb0eabeb 100644 --- a/lib/atc/ATC_CouplingMomentum.h +++ b/lib/atc/ATC_CouplingMomentum.h @@ -26,21 +26,21 @@ namespace ATC { class ATC_CouplingMomentum : public ATC_Coupling { public: - + // constructor - ATC_CouplingMomentum(std::string groupName, + ATC_CouplingMomentum(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile, PhysicsType intrinsicModel, ExtrinsicModelType extrinsicModel = NO_MODEL); - + // destructor virtual ~ATC_CouplingMomentum(); /** parser/modifier */ virtual bool modify(int narg, char **arg); - + /** pre time integration */ virtual void initialize(); diff --git a/lib/atc/ATC_CouplingMomentumEnergy.cpp b/lib/atc/ATC_CouplingMomentumEnergy.cpp index 32df5fd7b9..08206ba6db 100644 --- a/lib/atc/ATC_CouplingMomentumEnergy.cpp +++ b/lib/atc/ATC_CouplingMomentumEnergy.cpp @@ -22,7 +22,7 @@ namespace ATC { // Class ATC_CouplingMomentumEnergy //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -36,12 +36,12 @@ namespace ATC { nodalAtomicConfigurationalTemperature_(nullptr), refPE_(0) { - // Allocate PhysicsModel + // Allocate PhysicsModel create_physics_model(THERMO_ELASTIC, matParamFile); // create extrinsic physics model if (extrinsicModel != NO_MODEL) { - extrinsicModelManager_.create_model(extrinsicModel,matParamFile); + extrinsicModelManager_.create_model(extrinsicModel,matParamFile); } // set up field data based on physicsModel @@ -129,14 +129,14 @@ namespace ATC { AtomicMomentum * atomicMomentum = new AtomicMomentum(this); interscaleManager_.add_per_atom_quantity(atomicMomentum, "AtomicMomentum"); - + // nodal momentum for RHS AtfShapeFunctionRestriction * nodalAtomicMomentum = new AtfShapeFunctionRestriction(this, atomicMomentum, shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicMomentum, "NodalAtomicMomentum"); - + // nodal forces FundamentalAtomQuantity * atomicForce = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE); AtfShapeFunctionRestriction * nodalAtomicForce = new AtfShapeFunctionRestriction(this, @@ -144,14 +144,14 @@ namespace ATC { shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicForce, "NodalAtomicForce"); - + // nodal velocity derived only from atoms AtfShapeFunctionMdProjection * nodalAtomicVelocity = new AtfShapeFunctionMdProjection(this, nodalAtomicMomentum, VELOCITY); interscaleManager_.add_dense_matrix(nodalAtomicVelocity, "NodalAtomicVelocity"); - + if (trackDisplacement_) { // mass-weighted (center-of-mass) displacement of each atom AtomicMassWeightedDisplacement * atomicMassWeightedDisplacement; @@ -166,14 +166,14 @@ namespace ATC { atomicMassWeightedDisplacement = new AtomicMassWeightedDisplacement(this); interscaleManager_.add_per_atom_quantity(atomicMassWeightedDisplacement, "AtomicMassWeightedDisplacement"); - + // nodal (RHS) mass-weighted displacement AtfShapeFunctionRestriction * nodalAtomicMassWeightedDisplacement = new AtfShapeFunctionRestriction(this, atomicMassWeightedDisplacement, shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicMassWeightedDisplacement, "NodalAtomicMassWeightedDisplacement"); - + // nodal displacement derived only from atoms AtfShapeFunctionMdProjection * nodalAtomicDisplacement = new AtfShapeFunctionMdProjection(this, nodalAtomicMassWeightedDisplacement, @@ -183,7 +183,7 @@ namespace ATC { } // always need fluctuating velocity and kinetic energy - + FtaShapeFunctionProlongation * atomicMeanVelocity = new FtaShapeFunctionProlongation(this,&fields_[VELOCITY],shpFcn_); interscaleManager_.add_per_atom_quantity(atomicMeanVelocity, field_to_prolongation_name(VELOCITY)); @@ -267,16 +267,16 @@ namespace ATC { // register the per-atom quantity for the temperature definition interscaleManager_.add_per_atom_quantity(atomEnergyForTemperature, "AtomicEnergyForTemperature"); - + // nodal restriction of the atomic energy quantity for the temperature definition AtfShapeFunctionRestriction * nodalAtomicEnergy = new AtfShapeFunctionRestriction(this, atomEnergyForTemperature, shpFcn_); interscaleManager_.add_dense_matrix(nodalAtomicEnergy, "NodalAtomicEnergy"); - + // nodal atomic temperature field - + AtfShapeFunctionMdProjection * nodalAtomicTemperature = new AtfShapeFunctionMdProjection(this, nodalAtomicEnergy, TEMPERATURE); @@ -299,17 +299,17 @@ namespace ATC { throw ATC_Error("ATC_CouplingMomentumEnergy::initialize - method only valid with fractional step time integration"); } - + ATC_Coupling::init_filter(); - - - - + + + + if (timeFilterManager_.end_equilibrate() && equilibriumStart_) { if (atomicRegulator_->coupling_mode(VELOCITY)==AtomicRegulator::FLUX || atomicRegulator_->coupling_mode(VELOCITY)==AtomicRegulator::GHOST_FLUX) // nothing needed in other cases since kinetostat force is balanced by boundary flux in FE equations atomicRegulator_->reset_lambda_contribution(nodalAtomicFieldsRoc_[VELOCITY].quantity(),VELOCITY); - + DENS_MAT powerMat(-1.*(nodalAtomicFields_[TEMPERATURE].quantity())); atomicRegulator_->reset_lambda_contribution(powerMat,TEMPERATURE); } @@ -360,7 +360,7 @@ namespace ATC { Array mask(1); mask(0) = VELOCITY; FIELD_MATS energy; - feEngine_->compute_energy(mask, + feEngine_->compute_energy(mask, fields_, physicsModel_, elementToMaterialMap_, @@ -371,7 +371,7 @@ namespace ATC { potentialEnergy *= mvv2e; // convert to LAMMPS units return potentialEnergy-refPE_; } - + //-------------------------------------------------------------------- // compute_vector //-------------------------------------------------------------------- @@ -399,14 +399,14 @@ namespace ATC { Array mask(1); FIELD_MATS energy; mask(0) = TEMPERATURE; - - feEngine_->compute_energy(mask, + + feEngine_->compute_energy(mask, fields_, physicsModel_, elementToMaterialMap_, energy, &(elementMask_->quantity())); - + double phononEnergy = mvv2e * energy[TEMPERATURE].col_sum(); return phononEnergy; } @@ -435,9 +435,9 @@ namespace ATC { _keTemp_ = nodalAtomicKineticTemperature_->quantity(); if (nodalAtomicConfigurationalTemperature_) _peTemp_ = nodalAtomicConfigurationalTemperature_->quantity(); - + OUTPUT_LIST outputData; - + // base class output ATC_Method::output(); @@ -447,13 +447,13 @@ namespace ATC { } // auxiliary data - + for (_tiIt_ = timeIntegrators_.begin(); _tiIt_ != timeIntegrators_.end(); ++_tiIt_) { (_tiIt_->second)->output(outputData); } atomicRegulator_->output(outputData); extrinsicModelManager_.output(outputData); - + DENS_MAT & velocity(nodalAtomicFields_[VELOCITY].set_quantity()); DENS_MAT & rhs(rhs_[VELOCITY].set_quantity()); DENS_MAT & temperature(nodalAtomicFields_[TEMPERATURE].set_quantity()); @@ -469,18 +469,18 @@ namespace ATC { feEngine_->add_global("temperature_std_dev", T_stddev); double Ta_mean = (nodalAtomicFields_[TEMPERATURE].quantity()).col_sum(0)/nNodes_; feEngine_->add_global("atomic_temperature_mean", Ta_mean); - double Ta_stddev = (nodalAtomicFields_[TEMPERATURE].quantity()).col_stdev(0); + double Ta_stddev = (nodalAtomicFields_[TEMPERATURE].quantity()).col_stdev(0); feEngine_->add_global("atomic_temperature_std_dev", Ta_stddev); // different temperature measures, if appropriate if (nodalAtomicKineticTemperature_) outputData["kinetic_temperature"] = & _keTemp_; - + if (nodalAtomicConfigurationalTemperature_) { _peTemp_ *= 2; // account for full temperature outputData["configurational_temperature"] = & _peTemp_; } - + // mesh data outputData["NodalAtomicVelocity"] = &velocity; outputData["FE_Force"] = &rhs; @@ -491,10 +491,10 @@ namespace ATC { outputData["ddot_temperature"] = &ddotTemperature; outputData["NodalAtomicPower"] = &rocTemperature; outputData["fePower"] = &fePower; - + feEngine_->write_data(output_index(), fields_, & outputData); } - + // hence propagation is performed on proc 0 but not others. // The real fix is to have const data in the output list // force optional variables to reset to keep in sync diff --git a/lib/atc/ATC_CouplingMomentumEnergy.h b/lib/atc/ATC_CouplingMomentumEnergy.h index 598ee13bd7..2e0f8a8faa 100644 --- a/lib/atc/ATC_CouplingMomentumEnergy.h +++ b/lib/atc/ATC_CouplingMomentumEnergy.h @@ -25,9 +25,9 @@ namespace ATC { class ATC_CouplingMomentumEnergy : public ATC_Coupling { public: - + // constructor - ATC_CouplingMomentumEnergy(std::string groupName, + ATC_CouplingMomentumEnergy(std::string groupName, double ** & perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile, @@ -78,6 +78,6 @@ namespace ATC { // data double refPE_; }; - + }; #endif diff --git a/lib/atc/ATC_Method.cpp b/lib/atc/ATC_Method.cpp index 113d175e26..6fc8d51aa7 100644 --- a/lib/atc/ATC_Method.cpp +++ b/lib/atc/ATC_Method.cpp @@ -78,7 +78,7 @@ namespace ATC { vectorFlag_(0), sizeVector_(0), scalarVectorFreq_(0), - sizePerAtomCols_(4), + sizePerAtomCols_(4), perAtomOutput_(nullptr), perAtomArray_(perAtomArray), extScalar_(0), @@ -121,13 +121,13 @@ namespace ATC { simTime_(0.0), stepCounter_(0) { - lammpsInterface_->print_msg_once("version "+version()); + lammpsInterface_->print_msg_once("version "+version()); lammpsInterface_->set_fix_pointer(thisFix); interscaleManager_.set_lammps_data_prefix(); grow_arrays(lammpsInterface_->nmax()); feEngine_ = new FE_Engine(lammpsInterface_->world()); - + lammpsInterface_->create_compute_pe_peratom(); } @@ -164,7 +164,7 @@ namespace ATC { data[matrixName] = & nodalAtomicFieldsRoc_[thisField].set_quantity(); } } - + //-------------------------------------------------- // write_restart_file // bundle matrices that need to be saved and call @@ -172,7 +172,7 @@ namespace ATC { //-------------------------------------------------- void ATC_Method::write_restart_data(string fileName, RESTART_LIST & data) { - pack_fields(data); + pack_fields(data); feEngine_->write_restart_file(fileName,&data); } @@ -183,13 +183,13 @@ namespace ATC { //-------------------------------------------------- void ATC_Method::read_restart_data(string fileName, RESTART_LIST & data) { - pack_fields(data); + pack_fields(data); feEngine_->read_restart_file(fileName,&data); } //-------------------------------------------------- // Interactions with LAMMPS fix commands - // parse input command and pass on to finite element engine + // parse input command and pass on to finite element engine // or physics specific transfers if necessary // revert to physics-specific transfer if no command matches input // first keyword is unique to particular class @@ -199,21 +199,21 @@ namespace ATC { bool ATC_Method::modify(int narg, char **arg) { int argIdx=0; - bool match = false; - + bool match = false; + // gateways to other modules e.g. extrinsic, control, mesh // pass off to fe engine if (strcmp(arg[argIdx],"mesh")==0) { - match = feEngine_->modify(narg, arg); - if (feEngine_->has_mesh() && !meshDataInitialized_) + match = feEngine_->modify(narg, arg); + if (feEngine_->has_mesh() && !meshDataInitialized_) this->initialize_mesh_data(); } // pass off to time filter - else if (strcmp(arg[argIdx],"filter")==0) { + else if (strcmp(arg[argIdx],"filter")==0) { argIdx++; match = timeFilterManager_.modify(narg-argIdx,&arg[argIdx]); - // consistentInitialization_ = false; + // consistentInitialization_ = false; } // pass off to kernel function manager else if (strcmp(arg[argIdx],"kernel")==0) { @@ -223,11 +223,11 @@ namespace ATC { //delete kernelFunction_; //resetKernelFunction_ = true; } - kernelFunction_ = KernelFunctionMgr::instance()->function(&arg[argIdx],narg-argIdx); + kernelFunction_ = KernelFunctionMgr::instance()->function(&arg[argIdx],narg-argIdx); if (kernelFunction_) match = true; else ATC_Error("no matching kernel found"); feEngine_->set_kernel(kernelFunction_); - + accumulantMol_=&kernelAccumulantMol_; // KKM add accumulantMolGrad_=&kernelAccumulantMolGrad_; // KKM add } @@ -244,27 +244,27 @@ namespace ATC { //if (!kernelFunction_) { throw ATC_Error("on_the_fly requires a kernel function"); } if (strcmp(arg[argIdx],"off")==0) parallelConsistency_ = false; else parallelConsistency_ = true; - match = true; + match = true; } - /*! \page man_hardy_on_the_fly fix_modify AtC on_the_fly + /*! \page man_hardy_on_the_fly fix_modify AtC on_the_fly \section syntax - fix_modify AtC on_the_fly \n - bond | kernel (keyword) = specifies on-the-fly calculation of bond or + fix_modify AtC on_the_fly \n - bond | kernel (keyword) = specifies on-the-fly calculation of bond or kernel matrix elements \n - - on | off (keyword) = activate or discontinue on-the-fly mode \n + - on | off (keyword) = activate or discontinue on-the-fly mode \n \section examples fix_modify AtC on_the_fly bond on \n fix_modify AtC on_the_fly kernel \n fix_modify AtC on_the_fly kernel off \n \section description Overrides normal mode of pre-calculating and storing bond pair-to-node a -nd +nd kernel atom-to-node matrices. If activated, will calculate elements of t hese matrices during repeated calls of field computations (i.e. "on-the-fly") and not store them for future use. \n on flag is optional - if omitted, on_the_fly will be activated for the s -pecified - matrix. Can be deactivated using off flag. \n +pecified + matrix. Can be deactivated using off flag. \n \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default @@ -293,28 +293,28 @@ pecified fix_modify AtC output [text | full_text | binary | vector_components | tensor_components ] fix_modify AtC output index [step | time ] - - filename_prefix (string) = prefix for data files - - frequency (integer) = frequency of output in time-steps + - filename_prefix (string) = prefix for data files + - frequency (integer) = frequency of output in time-steps - options (keyword/s): \n text = creates text output of index, step and nodal variable values for unique nodes \n full_text = creates text output index, nodal id, step, nodal coordinates and nodal variable values for unique and image nodes \n binary = creates binary Ensight output \n vector_components = outputs vectors as scalar components \n - tensor_components = outputs tensor as scalar components + tensor_components = outputs tensor as scalar components (use this for Paraview)\n - + \section examples fix_modify AtC output heatFE 100 \n fix_modify AtC output hardyFE 1 text tensor_components \n fix_modify AtC output hardyFE 10 text binary tensor_components \n fix_modify AtC output index step \n \section description - Creates text and/or binary (Ensight, "gold" format) output of nodal/mesh data + Creates text and/or binary (Ensight, "gold" format) output of nodal/mesh data which is transfer/physics specific. Output indexed by step or time is possible. \section restrictions - \section related + \section related see \ref man_fix_atc - \section default + \section default no default format output indexed by time */ @@ -332,9 +332,9 @@ pecified Performs operation over the nodes belonging to specified nodeset and outputs resulting variable values to GLOBALS file. \section restrictions - \section related + \section related see \ref man_fix_atc - \section default + \section default none */ if (strcmp(arg[argIdx],"nodeset")==0) { @@ -356,7 +356,7 @@ pecified } } - /*! \page man_boundary_integral fix_modify AtC output boundary_integral + /*! \page man_boundary_integral fix_modify AtC output boundary_integral \section syntax fix_modify AtC output boundary_integral [field] faceset [name] - field (string) : name of hardy field @@ -367,7 +367,7 @@ pecified Calculates a surface integral of the given field dotted with the outward normal of the faces and puts output in the "GLOBALS" file \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default @@ -387,17 +387,17 @@ pecified Calculates a surface integral of the given field dotted with the outward normal of the faces and puts output in the "GLOBALS" file \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default none */ - else if ( (strcmp(arg[argIdx],"boundary_integral")==0) + else if ( (strcmp(arg[argIdx],"boundary_integral")==0) || (strcmp(arg[argIdx],"contour_integral")==0) ) { FacesetIntegralType type = BOUNDARY_INTEGRAL; - if (strcmp(arg[argIdx],"contour_integral")==0) + if (strcmp(arg[argIdx],"contour_integral")==0) type = CONTOUR_INTEGRAL; argIdx++; string field(arg[argIdx++]); @@ -412,7 +412,7 @@ pecified /*! \page man_output_elementset fix_modify AtC output elementset \section syntax - fix_modify AtC output volume_integral + fix_modify AtC output volume_integral - set_name (string) = name of elementset to be integrated over - fieldname (string) = name of field to integrate csum = creates nodal sum over nodes in specified nodeset \n @@ -422,9 +422,9 @@ pecified Performs volume integration of specified field over elementset and outputs resulting variable values to GLOBALS file. \section restrictions - \section related + \section related see \ref man_fix_atc - \section default + \section default none */ @@ -434,10 +434,10 @@ pecified string field(arg[argIdx++]); pair pair_name(name,string_to_field(field)); if (++argIdx < narg) { // keyword average - esetData_[pair_name] = ELEMENTSET_AVERAGE; + esetData_[pair_name] = ELEMENTSET_AVERAGE; } else { - esetData_[pair_name] = ELEMENTSET_TOTAL; + esetData_[pair_name] = ELEMENTSET_TOTAL; } match = true; } @@ -455,7 +455,7 @@ pecified outputNow_ = false; match = true; } - else + else if (strcmp(arg[argIdx],"index")==0) { argIdx++; if (strcmp(arg[argIdx],"step")==0) { outputTime_ = false; } @@ -498,10 +498,10 @@ pecified feEngine_->add_field_names(istem,inames); } feEngine_->initialize_output(rank,outputPrefix_,otypes); - if (vect_comp) + if (vect_comp) feEngine_->output_manager() ->set_option(OUTPUT_VECTOR_COMPONENTS,true); - if (tensor_comp) + if (tensor_comp) feEngine_->output_manager() ->set_option(OUTPUT_TENSOR_COMPONENTS,true); } @@ -539,11 +539,11 @@ pecified group GOLDGROUP type 1 \n fix_modify AtC add_species gold group GOLDGROUP \section description - Associates a tag with all atoms of a specified type or within a specified group. \n + Associates a tag with all atoms of a specified type or within a specified group. \n \section restrictions \section related \section default - No defaults for this command. + No defaults for this command. */ else if (strcmp(arg[argIdx],"add_species")==0) { argIdx++; @@ -554,31 +554,31 @@ pecified if (narg-argIdx == 2) { string name = arg[++argIdx]; int id = lammpsInterface_->group_bit(name); - groupList_.push_back(id); - groupNames_.push_back(tag); - } + groupList_.push_back(id); + groupNames_.push_back(tag); + } else { while (++argIdx < narg) { string name = arg[argIdx]; int id = lammpsInterface_->group_bit(name); string tag = speciesTag+"-"+name; - groupList_.push_back(id); - groupNames_.push_back(tag); + groupList_.push_back(id); + groupNames_.push_back(tag); } } } else if (strcmp(arg[argIdx],"type")==0) { if (narg-argIdx == 2) { int id = atoi(arg[++argIdx]); - typeList_.push_back(id); - typeNames_.push_back(tag); - } + typeList_.push_back(id); + typeNames_.push_back(tag); + } else { while (++argIdx < narg) { int id = atoi(arg[argIdx]); string tag = speciesTag+"_"+to_string(id); - typeList_.push_back(id); - typeNames_.push_back(tag); + typeList_.push_back(id); + typeNames_.push_back(tag); } } } @@ -588,20 +588,20 @@ pecified } // remove species from tracking - + /*! \page man_remove_species fix_modify AtC remove_species \section syntax fix_modify_AtC delete_species \n - + - = tag for tracking a species \n \section examples fix_modify AtC remove_species gold \n \section description - Removes tag designated for tracking a specified species. \n + Removes tag designated for tracking a specified species. \n \section restrictions \section related \section default - No defaults for this command. + No defaults for this command. */ else if (strcmp(arg[argIdx],"delete_species")==0) { argIdx++; @@ -609,8 +609,8 @@ pecified 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); + groupList_.erase(groupList_.begin()+j); + groupNames_.erase(groupNames_.begin()+j); break; } } @@ -618,8 +618,8 @@ pecified 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); + typeList_.erase(typeList_.begin()+j); + typeNames_.erase(typeNames_.begin()+j); break; } } @@ -627,26 +627,26 @@ pecified else { throw ATC_Error("ATC_Method: delete_species only handles groups or types"); } match = true; - + } // add a molecule for tracking /*! \page man_add_molecule fix_modify AtC add_molecule \section syntax fix_modify_AtC add_molecule \n - + - small|large = can be small if molecule size < cutoff radius, must be large otherwise \n - = tag for tracking a species \n - - = name of group that tracking will be applied to \n + - = name of group that tracking will be applied to \n \section examples group WATERGROUP type 1 2 \n fix_modify AtC add_molecule small water WATERGROUP \n \section description - Associates a tag with all molecules corresponding to a specified group. \n + Associates a tag with all molecules corresponding to a specified group. \n \section restrictions \section related \section default - No defaults for this command. + No defaults for this command. */ else if (strcmp(arg[argIdx],"add_molecule")==0) { argIdx++; @@ -660,7 +660,7 @@ pecified throw ATC_Error("ATC_CouplingMass: Bad molecule size in add_molecule"); argIdx++; string moleculeTag = arg[argIdx]; - + argIdx++; int groupBit = lammpsInterface_->group_bit(arg[argIdx]); moleculeIds_[moleculeTag] = pair(size,groupBit); @@ -671,26 +671,26 @@ pecified /*! \page man_remove_molecule fix_modify AtC remove_molecule \section syntax fix_modify_AtC remove_molecule \n - + - = tag for tracking a molecule type \n \section examples fix_modify AtC remove_molecule water \n \section description - Removes tag designated for tracking a specified set of molecules. \n + Removes tag designated for tracking a specified set of molecules. \n \section restrictions \section related \section default - No defaults for this command. + No defaults for this command. */ else if (strcmp(arg[argIdx],"remove_molecule")==0) { argIdx++; string moleculeTag = arg[argIdx]; moleculeIds_.erase(moleculeTag); - + taggedDensMan_.erase(moleculeTag); } - - /*! \page man_boundary fix_modify AtC boundary + + /*! \page man_boundary fix_modify AtC boundary \section syntax fix_modify AtC boundary type - = type id for atoms that represent a fictitious @@ -699,11 +699,11 @@ pecified fix_modify AtC boundary type ghost_atoms \section description Command to define the atoms that represent the fictitious - boundary internal to the FE mesh. For fully overlapped MD/FE + boundary internal to the FE mesh. For fully overlapped MD/FE domains with periodic boundary conditions no boundary atoms should be defined. \section restrictions - \section default + \section default none */ else if (strcmp(arg[argIdx],"boundary")==0) { @@ -746,7 +746,7 @@ pecified \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 + 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. @@ -772,11 +772,11 @@ pecified } } - /*! \page man_atom_weight fix_modify AtC atom_weight + /*! \page man_atom_weight fix_modify AtC atom_weight \section syntax fix_modify AtC atom_weight - = \n - value: atoms in specified group assigned constant value given \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: 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 @@ -788,8 +788,8 @@ pecified fix_modify atc atom_weight read-in atm_wt_file.txt \n \section description Command for assigning the value of atomic weights used for atomic integration in - atom-continuum coupled simulations. - \section restrictions + atom-continuum coupled simulations. + \section restrictions Use of lattice option requires a lattice type and parameter is already specified. \section related \section default @@ -797,7 +797,7 @@ pecified */ else if (strcmp(arg[argIdx],"atom_weight")==0) { argIdx++; - if (strcmp(arg[argIdx],"constant")==0) { + if (strcmp(arg[argIdx],"constant")==0) { argIdx++; atomWeightType_ = USER; int groupbit = -1; @@ -850,17 +850,17 @@ pecified } } - /*! \page man_decomposition fix_modify AtC decomposition + /*! \page man_decomposition fix_modify AtC decomposition \section syntax - fix_modify AtC decomposition + fix_modify AtC decomposition - = \n - replicated_memory: nodal information replicated on each processor \n + replicated_memory: nodal information replicated on each processor \n distributed_memory: only owned nodal information on processor \n \section examples fix_modify atc decomposition distributed_memory \n \section description Command for assigning the distribution of work and memory for parallel runs. - \section restrictions + \section restrictions replicated_memory is appropriate for simulations were the number of nodes << number of atoms \section related \section default @@ -868,7 +868,7 @@ pecified */ else if (strcmp(arg[argIdx],"decomposition")==0) { argIdx++; - if (strcmp(arg[argIdx],"replicated_memory")==0) { + if (strcmp(arg[argIdx],"replicated_memory")==0) { domainDecomposition_ = REPLICATED_MEMORY; match = true; } @@ -887,7 +887,7 @@ pecified fix_modify atc write_atom_weights atm_wt_file.txt 10 \n \section description Command for writing the values of atomic weights to a specified file. - \section restrictions + \section restrictions \section related \section default */ @@ -901,13 +901,13 @@ pecified } - /*! \page man_reset_time fix_modify AtC reset_time + /*! \page man_reset_time fix_modify AtC reset_time \section syntax - fix_modify AtC reset_time + fix_modify AtC reset_time \section examples fix_modify atc reset_time 0.0 \n \section description - Resets the simulation time counter. + Resets the simulation time counter. \section restrictions \section related \section default @@ -924,7 +924,7 @@ pecified /*! \page man_reset_time fix_modify AtC kernel_bandwidth \section syntax - fix_modify AtC kernel_bandwidth + fix_modify AtC kernel_bandwidth \section examples fix_modify atc kernel_bandwidth 8 \n \section description @@ -941,7 +941,7 @@ pecified match = true; } - /*! \page man_reset_atomic_reference_positions fix_modify AtC reset_atomic_reference_positions + /*! \page man_reset_atomic_reference_positions fix_modify AtC reset_atomic_reference_positions \section syntax fix_modify AtC reset_atomic_reference_positions \section examples @@ -962,23 +962,23 @@ pecified match = true; } - /*! \page man_set fix_modify AtC set + /*! \page man_set fix_modify AtC set \section syntax fix_modify AtC set reference_potential_energy - 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 + - filename (string) : optional user specified string for file of nodal PE values to be read-in \section examples fix_modify AtC set reference_potential_energy \n fix_modify AtC set reference_potential_energy -0.05 \n fix_modify AtC set reference_potential_energy myPEvalues \n \section description Used to set various quantities for the post-processing algorithms. - 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, or + 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, or values provided within the specified filename. \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default @@ -1000,7 +1000,7 @@ pecified nodalRefPEfile_ = arg[argIdx]; readRefPE_ = true; } - } + } match = true; } } // end "set" @@ -1011,14 +1011,14 @@ pecified \section syntax fix_modify AtC atom_element_map \n - frequency (int) : frequency of updating atom-to-continuum maps based on the - current configuration - only for eulerian + current configuration - only for eulerian \section examples fix_modify atc atom_element_map eulerian 100 \section description Changes frame of reference from eulerian to lagrangian and sets the - frequency for which the map from atoms to elements is reformed and + frequency for which the map from atoms to elements is reformed and all the attendant data is recalculated. - \section restrictions + \section restrictions Cannot change map type after initialization. \section related \section default @@ -1030,11 +1030,11 @@ pecified atomToElementMapType_ = EULERIAN; argIdx++; atomToElementMapFrequency_ = atoi(arg[argIdx]); - } + } else { atomToElementMapType_ = LAGRANGIAN; atomToElementMapFrequency_ = 0; - } + } match = true; needReset_ = true; } @@ -1045,13 +1045,13 @@ pecified \section examples fix_modify AtC read_restart ATC_state \n \section description - Reads the current state of the fields from a named text-based restart + Reads the current state of the fields from a named text-based restart file. - \section restrictions + \section restrictions The restart file only contains fields and their time derivatives. The reference positions of the atoms and the commands that initialize - the fix are not saved e.g. an identical mesh containing the same atoms - will have to be recreated. + the fix are not saved e.g. an identical mesh containing the same atoms + will have to be recreated. \section related see write_restart \ref man_write_restart \section default @@ -1071,13 +1071,13 @@ pecified fix_modify AtC write_restart restart.mydata \n \section description Dumps the current state of the fields to a named text-based restart file. - This done when the command is invoked and not repeated, unlike the + This done when the command is invoked and not repeated, unlike the similar lammps command. - \section restrictions + \section restrictions The restart file only contains fields and their time derivatives. The reference positions of the atoms and the commands that initialize - the fix are not saved e.g. an identical mesh containing the same atoms - will have to be recreated. + the fix are not saved e.g. an identical mesh containing the same atoms + will have to be recreated. \section related see read_restart \ref man_read_restart \section default @@ -1091,10 +1091,10 @@ pecified match = true; } - } // end else + } // end else return match; // return to FixATC - + } //-------------------------------------------------- @@ -1142,10 +1142,10 @@ pecified //------------------------------------------------------------------- // this sets the peratom output - + void ATC_Method::update_peratom_output() { - perAtomArray_ = perAtomOutput_; + perAtomArray_ = perAtomOutput_; // copy values for (int i = 0; i < lammpsInterface_->nlocal(); i++) { for (int j = 0; j < nsd_; j++) { @@ -1170,7 +1170,7 @@ pecified void ATC_Method::adjust_xref_pbc() { - + int nlocal = lammpsInterface_->nlocal(); int xperiodic = lammpsInterface_->xperiodic(); int yperiodic = lammpsInterface_->yperiodic(); @@ -1190,11 +1190,11 @@ pecified xref_[i][0] += Xprd_; // changed = true; } - if (x[i][0] >= boxxhi) { + if (x[i][0] >= boxxhi) { xref_[i][0] -= Xprd_; // changed = true; - } - } + } + } if (yperiodic) { if (x[i][1] < boxylo) { @@ -1204,8 +1204,8 @@ pecified if (x[i][1] >= boxyhi) { xref_[i][1] -= Yprd_; // changed = true; - } - } + } + } if (zperiodic) { if (x[i][2] < boxzlo) { @@ -1215,8 +1215,8 @@ pecified if (x[i][2] >= boxzhi) { xref_[i][2] -= Zprd_; // changed = true; - } - } + } + } } // propagate reset if needed @@ -1232,7 +1232,7 @@ pecified } //------------------------------------------------------------------- void ATC_Method::initialize() - { + { feEngine_->partition_mesh(); // initialized_ is set to true by derived class initialize() // localStep_ is a counter within a run or minimize @@ -1249,7 +1249,7 @@ pecified // 1c) periodicity and box bounds/lengths if (!initialized_) { - + lammpsInterface_->box_periodicity(periodicity[0], periodicity[1], periodicity[2]); @@ -1257,7 +1257,7 @@ pecified box_bounds[0][1],box_bounds[1][1], box_bounds[0][2],box_bounds[1][2]); for (int k = 0; k < nsd_; k++) { - box_length[k] = box_bounds[1][k] - box_bounds[0][k]; + box_length[k] = box_bounds[1][k] - box_bounds[0][k]; } lammpsInterface_->set_reference_box(); @@ -1292,7 +1292,7 @@ pecified xref_[i][j] = x[i][j]; } } - + // re-write non-ghosts' xref with values from a file if (readXref_) { bool success = read_atomic_ref_positions(xRefFile_.c_str()); @@ -1302,7 +1302,7 @@ pecified } // ensure initial configuration is consistent with element set - + if (internalElementSet_.size() && groupbitGhost_) { int *mask = lammpsInterface_->atom_mask(); int nlocal = lammpsInterface_->nlocal(); @@ -1349,7 +1349,7 @@ pecified // STEP 5) construct dependency-managed data // 5b) all other transfer operators // needs to be done before every run in case options have changed or the atoms have been changed by the user - + if (this->reset_methods()) { // construct all the needed data structures this->construct_transfers(); @@ -1359,7 +1359,7 @@ pecified } // reset all computes invoked flags and lammps data interscaleManager_.lammps_force_reset(); - + // STEP 6) initialize data // 6b) size quantities which use pack_comm interscaleManager_.size_comm_quantities(); @@ -1368,12 +1368,12 @@ pecified if (!initialized_) { // FE_Engine allocates all required memory // assume initial atomic position is the reference position for now - + // \int_\Omega N_I dV : static if the mesh is NodeVolumes_.reset(nNodes_,nNodes_); invNodeVolumes_.reset(nNodes_,nNodes_); feEngine_->compute_lumped_mass_matrix(NodeVolumes_); - invNodeVolumes_.set_quantity() = NodeVolumes_.inv(); + invNodeVolumes_.set_quantity() = NodeVolumes_.inv(); } atomVolume_->set_reset(); @@ -1388,7 +1388,7 @@ pecified for (int i = 0; i < nNodes_; ++i) { massMatInv_(i,i) = 1./massMatInv_(i,i); } - + // clear need for resets needReset_ = false; @@ -1410,10 +1410,10 @@ pecified void ATC_Method::set_computational_geometry() { // set positions used for coarse-graining operators - - - - + + + + if (!initialized_) { if (atomToElementMapType_ == EULERIAN) { FundamentalAtomQuantity * atomPositionsAll = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION,ALL); @@ -1444,7 +1444,7 @@ pecified atomProcGhostCoarseGrainingPositions_ = myAtomPositions; interscaleManager_.add_per_atom_quantity(myAtomPositions, "AtomicProcGhostCoarseGrainingPositions"); - } + } } else { XrefWrapper * myAtomPositions = new XrefWrapper(this); @@ -1481,7 +1481,7 @@ pecified //------------------------------------------------------------------- void ATC_Method::construct_methods() { - + if (this->reset_methods()) { if (atomTimeIntegrator_) delete atomTimeIntegrator_; if (integrateInternalAtoms_) { @@ -1672,7 +1672,7 @@ pecified } } } - + //------------------------------------------------------------------- void ATC_Method::set_reference_potential_energy(void) { @@ -1716,7 +1716,7 @@ pecified } } //------------------------------------------------------------------- - + //================================================================= // memory management and processor information exchange @@ -1724,18 +1724,18 @@ pecified //----------------------------------------------------------------- - // number of doubles + // 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 + // memory usage of local atom-based arrays //----------------------------------------------------------------- int ATC_Method::memory_usage() { @@ -1745,20 +1745,20 @@ pecified } //----------------------------------------------------------------- - // allocate local atom-based arrays + // allocate local atom-based arrays //----------------------------------------------------------------- void ATC_Method::grow_arrays(int nmax) { xref_ = lammpsInterface_->grow_2d_double_array(xref_,nmax,3,"fix_atc:xref"); - perAtomOutput_ = + perAtomOutput_ = lammpsInterface_->grow_2d_double_array(perAtomOutput_,nmax,sizePerAtomCols_,"fix_atc:perAtomOutput"); interscaleManager_.grow_arrays(nmax); } //----------------------------------------------------------------- - // copy values within local atom-based arrays + // copy values within local atom-based arrays //----------------------------------------------------------------- void ATC_Method::copy_arrays(int i, int j) { @@ -1773,14 +1773,14 @@ pecified } //----------------------------------------------------------------- - // pack values in local atom-based arrays for exchange with another proc + // pack values in local atom-based arrays for exchange with another proc //----------------------------------------------------------------- int ATC_Method::pack_exchange(int i, double *buf) { - buf[0] = xref_[i][0]; - buf[1] = xref_[i][1]; - buf[2] = xref_[i][2]; - + buf[0] = xref_[i][0]; + buf[1] = xref_[i][1]; + buf[2] = xref_[i][2]; + int j = 4; for (int ii = 0 ; ii < sizePerAtomCols_ ; ii++ ) { buf[j++] = perAtomOutput_[i][ii]; @@ -1790,7 +1790,7 @@ pecified } //----------------------------------------------------------------- - // unpack values in local atom-based arrays from exchange with another proc + // unpack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- int ATC_Method::unpack_exchange(int nlocal, double *buf) { @@ -1807,9 +1807,9 @@ pecified } //----------------------------------------------------------------- - // pack values in local atom-based arrays from exchange with another proc + // pack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- - int ATC_Method::pack_comm(int n, int *list, double *buf, + int ATC_Method::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,m; @@ -1817,7 +1817,7 @@ pecified int * num_bond = lammpsInterface_->num_bond(); int ** bond_atom = lammpsInterface_->bond_atom(); - + m = 0; if (pbc_flag == 0) { for (i = 0; i < n; i++) { @@ -1825,7 +1825,7 @@ pecified buf[m++] = xref_[j][0]; buf[m++] = xref_[j][1]; buf[m++] = xref_[j][2]; - + if (num_bond) { buf[m++] = num_bond[j]; for (int ii = 0; ii < lammpsInterface_->bond_per_atom(); ii++) { @@ -1833,13 +1833,13 @@ pecified } } } - } + } else { if (lammpsInterface_->domain_triclinic() == 0) { dx = pbc[0]*Xprd_; dy = pbc[1]*Yprd_; dz = pbc[2]*Zprd_; - } + } else { dx = pbc[0]*Xprd_ + pbc[5]*XY_ + pbc[4]*XZ_; dy = pbc[1]*Yprd_ + pbc[3]*YZ_; @@ -1864,7 +1864,7 @@ pecified } //----------------------------------------------------------------- - // unpack values in local atom-based arrays from exchange with another proc + // unpack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- void ATC_Method::unpack_comm(int n, int first, double *buf) { @@ -1879,7 +1879,7 @@ pecified xref_[i][0] = buf[m++]; xref_[i][1] = buf[m++]; xref_[i][2] = buf[m++]; - + if (num_bond) { num_bond[i] = static_cast(buf[m++]); for (int ii = 0; ii < lammpsInterface_->bond_per_atom(); ii++) { @@ -1896,7 +1896,7 @@ pecified int ATC_Method::comm_forward() { int size = 3; - if (lammpsInterface_->num_bond()) + if (lammpsInterface_->num_bond()) { size += lammpsInterface_->bond_per_atom()+1; } return size; } @@ -1909,7 +1909,7 @@ pecified nLocalTotal_ = lammpsInterface_->nlocal(); const int * mask = lammpsInterface_->atom_mask(); nLocal_ = 0; - nLocalGhost_ = 0; + nLocalGhost_ = 0; for (int i = 0; i < nLocalTotal_; ++i) { if (mask[i] & groupbit_) nLocal_++; @@ -1917,12 +1917,12 @@ pecified } // set up internal & ghost maps - + if (nLocal_>0) { // set map internalToAtom_.resize(nLocal_); int j = 0; - // construct internalToAtom map + // construct internalToAtom map // : internal index -> local lammps atom index for (int i = 0; i < nLocalTotal_; ++i) { if (mask[i] & groupbit_) internalToAtom_(j++) = i; @@ -1968,7 +1968,7 @@ pecified atomProcGhostCoarseGrainingPositions_->unfix_quantity(); atomProcGhostCoarseGrainingPositions_->quantity(); atomProcGhostCoarseGrainingPositions_->fix_quantity(); - } + } } //----------------------------------------------------------------- @@ -1978,11 +1978,11 @@ pecified { int nlocal = lammpsInterface_->nlocal(); int nlocalmax; - LammpsInterface::instance()->int_allmax(&nlocal,&nlocalmax); + LammpsInterface::instance()->int_allmax(&nlocal,&nlocalmax); int natoms = int(lammpsInterface_->natoms()); ofstream out; const char* fname = &filename[0]; - + // create tag to local id map for this processor map id2tag; map ::const_iterator itr; @@ -2008,7 +2008,7 @@ pecified out << id2tag[i] << " " << atomicVolumeMatrix(i,i) << "\n"; } } - + if (nprocs > 1) { int max_size,send_size; send_size = nlocal; @@ -2022,7 +2022,7 @@ pecified LammpsInterface::instance()->recv(buf,max_size,iproc); for (int i = 0; i < max_size; i++) { out << intbuf[i] << " " << buf[i] << "\n"; - } + } } delete[] intbuf; delete[] buf; @@ -2039,25 +2039,25 @@ pecified delete[] buf; } } - - if (comm_rank == 0) { + + if (comm_rank == 0) { out.close(); - } + } } - + //----------------------------------------------------------------- // //----------------------------------------------------------------- void ATC_Method::compute_consistent_md_mass_matrix(const SPAR_MAT & shapeFunctionMatrix, SPAR_MAT & mdMassMatrix) const { - + int nCols = shapeFunctionMatrix.nCols(); DENS_MAT massMatrixLocal(nCols,nCols); DENS_MAT denseMdMassMatrix(nCols,nCols); if (nLocal_>0) massMatrixLocal = shapeFunctionMatrix.transMat(shapeFunctionMatrix); - + lammpsInterface_->allsum(massMatrixLocal.ptr(), denseMdMassMatrix.ptr(), denseMdMassMatrix.size()); @@ -2068,10 +2068,10 @@ pecified // Interscale operators //================================================================= // in the spirit of the current design of ATC: atoms local, nodes global - - - - + + + + bool ATC_Method::nodal_influence(const int groupbit, set & nset, set & aset, double tol) { @@ -2091,7 +2091,7 @@ pecified DENS_MAT influence(nNodes_,1); DENS_MAT atomInfluence(natoms,1); const int *mask = lammpsInterface_->atom_mask(); - for (int i = 0; i < natoms; i++) { + for (int i = 0; i < natoms; i++) { if (mask[amap(i)] & groupbit) { atomInfluence(i,0) = 1; aset.insert(i); @@ -2102,7 +2102,7 @@ pecified restrict_volumetric_quantity(atomInfluence,influence,(interscaleManager_.per_atom_sparse_matrix("InterpolantGhost"))->quantity()); } else { - restrict_volumetric_quantity(atomInfluence,influence); + restrict_volumetric_quantity(atomInfluence,influence); } DENS_MAT localInfluence = influence; @@ -2110,7 +2110,7 @@ pecified influence.ptr(), influence.size()); - for (int i = 0; i < nNodes_; i++) { + for (int i = 0; i < nNodes_; i++) { if (fabs(influence(i,0)) > tol) { nset.insert(i); } } return aset.size(); @@ -2123,11 +2123,11 @@ pecified const SPAR_MAT & shpFcn) { // computes nodeData = N*DeltaVAtom*atomData where N are the shape functions - DENS_MAT workNodeArray(nodeData.nRows(),nodeData.nCols()); + DENS_MAT workNodeArray(nodeData.nRows(),nodeData.nCols()); //DENS_MAT workNodeArray; - if (atomData.nRows() > 0) { // or shpFcn_??? + if (atomData.nRows() > 0) { // or shpFcn_??? workNodeArray = shpFcn.transMat(atomData); } int count = nodeData.nRows()*nodeData.nCols(); @@ -2170,7 +2170,7 @@ pecified // } } //-------------------------------------------------------- - void ATC_Method::compute_nodeset_output(void) + void ATC_Method::compute_nodeset_output(void) { map< pair , NodesetOperationType >::const_iterator iter; for (iter = nsetData_.begin(); iter != nsetData_.end();iter++){ @@ -2223,7 +2223,7 @@ pecified } } //-------------------------------------------------------- - void ATC_Method::compute_elementset_output(void) + void ATC_Method::compute_elementset_output(void) { map< pair , ElementsetOperationType >::const_iterator iter; for (iter = esetData_.begin(); iter != esetData_.end();iter++){ @@ -2253,7 +2253,7 @@ pecified //================================================================= - // + // //================================================================= //-------------------------------------------------------- bool ATC_Method::read_atomic_ref_positions(const char * filename) @@ -2284,12 +2284,12 @@ pecified in.getline(line,lineSize); // header in.getline(line,lineSize); // blank line in >> natoms; - stringstream ss; + stringstream ss; ss << "found " << natoms << " atoms in reference " << filename ; while(in.good()) { in.getline(line,lineSize); string str(line); - int pos = str.find("Atoms"); + int pos = str.find("Atoms"); if (pos > -1) { in.getline(line,lineSize); // blank line break; @@ -2306,7 +2306,7 @@ pecified ss << " style:atomic"; style = LammpsInterface::ATOMIC_STYLE; break; - // charge: id type q x y z + // charge: id type q x y z // molecule : id molecule-ID type x y z case 6: ss << " style:charge"; @@ -2317,7 +2317,7 @@ pecified ss << " style:full"; style = LammpsInterface::FULL_STYLE; break; - default: + default: throw ATC_Error("cannot determine atom style, columns:"+to_string(ncols)); break; } @@ -2328,11 +2328,11 @@ pecified // read atoms and assign if (LammpsInterface::instance()->rank_zero()) { - in.open(filename); + in.open(filename); while(in.good()) { in.getline(line,lineSize); string str(line); - int pos = str.find("Atoms"); + int pos = str.find("Atoms"); if (pos > -1) { in.getline(line,lineSize); // blank line break; @@ -2345,12 +2345,12 @@ pecified if (LammpsInterface::instance()->rank_zero()) { in.getline(line,lineSize); stringstream ss (line,stringstream::in | stringstream::out); - if (style == LammpsInterface::CHARGE_STYLE) - ss >> tag >> type >> q >> x[0] >> x[1] >> x[2]; - else if (style == LammpsInterface::FULL_STYLE) - ss >> tag >> mId >> type >> q >> x[0] >> x[1] >> x[2]; + if (style == LammpsInterface::CHARGE_STYLE) + ss >> tag >> type >> q >> x[0] >> x[1] >> x[2]; + else if (style == LammpsInterface::FULL_STYLE) + ss >> tag >> mId >> type >> q >> x[0] >> x[1] >> x[2]; else - ss >> tag >> type >> x[0] >> x[1] >> x[2]; + ss >> tag >> type >> x[0] >> x[1] >> x[2]; nread++; } LammpsInterface::instance()->int_broadcast(&nread); @@ -2367,21 +2367,21 @@ pecified } if (LammpsInterface::instance()->rank_zero()) { in.close(); - stringstream ss; + stringstream ss; ss << "read " << natoms << " reference positions"; LammpsInterface::instance()->print_msg(ss.str()); } - if (count != nlocal) + if (count != nlocal) throw ATC_Error("reset "+to_string(count)+" atoms vs "+to_string(nlocal)); return true; - } + } //-------------------------------------------------------- void ATC_Method::remap_ghost_ref_positions(void) { - + int nlocal = lammpsInterface_->nlocal(); int nghost = lammpsInterface_->nghost(); @@ -2406,26 +2406,26 @@ pecified for (int i = 0; i < nlocal; ++i) { tag2id[atom_tag[i]] = i; } - + // loop over ghosts double ** x = lammpsInterface_->xatom(); for (int j = nlocal; j < nlocal + nghost; j++) { int tag = atom_tag[j]; int i = tag2id[tag]; //itr = tag2id.find(tag); - //if (itr != tag2id.end()) + //if (itr != tag2id.end()) double* xj = x[j]; double* Xj = xref_[j]; //double Xj[3]; double* Xi = xref_[i]; - // the assumption is that xref_[j] has been shuffled + // the assumption is that xref_[j] has been shuffled // so make an image of xref_[i] that is close to x[j] - if (xj[0] <= xlo) Xj[0] = Xi[0] -Lx; - if (xj[0] >= xhi) Xj[0] = Xi[0] +Lx; - if (xj[1] <= ylo) Xj[1] = Xi[1] -Ly; - if (xj[1] >= yhi) Xj[1] = Xi[1] +Ly; + if (xj[0] <= xlo) Xj[0] = Xi[0] -Lx; + if (xj[0] >= xhi) Xj[0] = Xi[0] +Lx; + if (xj[1] <= ylo) Xj[1] = Xi[1] -Ly; + if (xj[1] >= yhi) Xj[1] = Xi[1] +Ly; if (xj[2] <= zlo) Xj[2] = Xi[2] -Lz; - if (xj[2] >= zhi) Xj[2] = Xi[2] +Lz; + if (xj[2] >= zhi) Xj[2] = Xi[2] +Lz; } } }; diff --git a/lib/atc/ATC_Method.h b/lib/atc/ATC_Method.h index 0779990a99..f070258e5d 100644 --- a/lib/atc/ATC_Method.h +++ b/lib/atc/ATC_Method.h @@ -66,12 +66,12 @@ namespace ATC { /** Predictor phase, executed before Verlet */ virtual void pre_init_integrate() { - feEngine_->partition_mesh(); + feEngine_->partition_mesh(); update_step(); }; /** Predictor phase, Verlet first step for velocity and position */ - virtual void init_integrate(); + virtual void init_integrate(); /** Predictor phase, executed after Verlet */ virtual void post_init_integrate(); @@ -127,7 +127,7 @@ namespace ATC { /** access to interscale manager */ InterscaleManager & interscale_manager() {return interscaleManager_;}; /** access to lammps interface */ - + LammpsInterface const * lammps_interface() const {return lammpsInterface_;}; /** access to time filter */ TimeFilterManager * time_filter_manager() {return &timeFilterManager_;}; @@ -142,7 +142,7 @@ namespace ATC { /** compute vector for output */ virtual double compute_vector(int /* n */) {return 0.;} /** compute vector for output */ - virtual double compute_array(int /* irow */, int /* icol */) {return 0.;}; + virtual double compute_array(int /* irow */, int /* icol */) {return 0.;}; int scalar_flag() const {return scalarFlag_;} int vector_flag() const {return vectorFlag_;} int size_vector() const {return sizeVector_;} @@ -164,16 +164,16 @@ namespace ATC { /** time/step functions */ bool sample_now(void) const - { + { int s = step(); bool now = ( (sampleFrequency_ > 0) && (s % sampleFrequency_ == 0)); return now; } bool output_now(void) const - { + { int s = step(); - bool now = ( (outputFrequency_ > 0) && (s == 1 || s % outputFrequency_ == 0) ); + bool now = ( (outputFrequency_ > 0) && (s == 1 || s % outputFrequency_ == 0) ); now = now || outputNow_; return now; } @@ -328,7 +328,7 @@ namespace ATC { const std::map > & molecule_ids() const {return moleculeIds_;}; /** access to internal element set */ const std::string & internal_element_set() {return internalElementSet_;}; - + //---------------------------------------------------------------- /** \name mass matrix operations */ @@ -339,7 +339,7 @@ namespace ATC { // inverted using GMRES void apply_inverse_mass_matrix(MATRIX & data, FieldName thisField) { - + if (useConsistentMassMatrix_(thisField)) { //data = consistentMassInverse_*data; data = (consistentMassMatsInv_[thisField].quantity())*data; @@ -351,7 +351,7 @@ namespace ATC { void apply_inverse_mass_matrix(const MATRIX & data_in, MATRIX & data_out, FieldName thisField) { - if (useConsistentMassMatrix_(thisField)) { + if (useConsistentMassMatrix_(thisField)) { //data_out = consistentMassInverse_*data_in; data_out = (consistentMassMatsInv_[thisField].quantity())*data_in; return; @@ -365,7 +365,7 @@ namespace ATC { DIAG_MAN &mass_mat(FieldName thisField) { return massMats_[thisField];}; - + //--------------------------------------------------------------- /** \name mass matrices */ @@ -383,13 +383,13 @@ namespace ATC { void register_mass_matrix_dependency(DependencyManager * dependent, FieldName thisField) { - if (useConsistentMassMatrix_(thisField)) { + if (useConsistentMassMatrix_(thisField)) { consistentMassMatsInv_[thisField].register_dependence(dependent); return; } massMatsInv_[thisField].register_dependence(dependent); }; - + void apply_inverse_md_mass_matrix(MATRIX & data, FieldName thisField) { data = (massMatsMdInv_[thisField].quantity())*data; }; void register_md_mass_matrix_dependency(DependencyManager * dependent, @@ -416,11 +416,11 @@ namespace ATC { return man->second; }; /*@}*/ - + //---------------------------------------------------------------- /** \name Interscale operators */ //---------------------------------------------------------------- - bool use_md_mass_normalization() const { return mdMassNormalization_;} + bool use_md_mass_normalization() const { return mdMassNormalization_;} bool kernel_based() { return kernelBased_; } bool kernel_on_the_fly() const { return kernelOnTheFly_;} bool has_kernel_function() { return kernelFunction_ != nullptr; } @@ -439,20 +439,20 @@ namespace ATC { double ke_scale() { return keScale_; } double pe_scale() { return peScale_; } - + /** from a atom group, find the nodes that have non-zero shape function contributions */ bool nodal_influence(const int groupbit, std::set& nset, std::set& aset, double tol =1.e-8); - int nodal_influence(const int groupbit, std::set& nset, std::set& aset, + int nodal_influence(const int groupbit, std::set& nset, std::set& aset, bool ghost, double tol =1.e-8); /*@{*/ - + /** Restrict based on atomic volume integration for volumetric quantities : given w_\alpha, w_I = \sum_\alpha N_{I\alpha} w_\alpha */ void restrict_volumetric_quantity(const MATRIX &atomData, - MATRIX &nodeData); + MATRIX &nodeData); void restrict_volumetric_quantity(const MATRIX &atomData, MATRIX &nodeData, const SPAR_MAT & shpFcn); @@ -474,7 +474,7 @@ namespace ATC { protected: /** methods */ /** time functions */ void set_time(double t=0) {simTime_=t;}; - void update_time(double alpha = 1.0) + void update_time(double alpha = 1.0) { double dt = lammpsInterface_->dt(); simTime_ += alpha*dt; @@ -506,7 +506,7 @@ namespace ATC { 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); + void pack_fields(RESTART_LIST & data); /** mass matrices */ DIAG_MAT massMatInv_; @@ -564,11 +564,11 @@ namespace ATC { void reset_fields(); - private: /** methods */ + private: /** methods */ ATC_Method(); // do not define protected: /** data */ - + /* parsed input requires changes */ bool needReset_; @@ -609,7 +609,7 @@ namespace ATC { PerAtomQuantity * atomProcGhostCoarseGrainingPositions_; PerAtomQuantity * atomReferencePositions_; - + /** number of unique FE nodes */ int nNodes_; @@ -631,17 +631,17 @@ namespace ATC { bool trackDisplacement_; /** map from reference positions to element id, pointer is to internal only */ - + bool needsAtomToElementMap_; PerAtomQuantity * atomElement_; PerAtomQuantity * atomGhostElement_; /* use element sets to define internal and/or ghost regions */ std::string internalElementSet_; - + /** atomic ATC material tag */ - - + + double Xprd_,Yprd_,Zprd_; // lengths of periodic box in reference frame double XY_,YZ_,XZ_; double boxXlo_,boxXhi_; // lo/hi bounds of periodic box in reference frame @@ -671,22 +671,22 @@ namespace ATC { /** base name for output files */ std::string outputPrefix_; - /** output flag */ - + /** output flag */ + bool outputNow_; /** output time or step (for lammps compatibility) */ bool outputTime_; - + /** output frequency */ int outputFrequency_; - + /** sample frequency */ int sampleFrequency_; - + /** sample counter */ int sampleCounter_; - TAG_FIELDS filteredData_; + TAG_FIELDS filteredData_; double peScale_,keScale_; @@ -702,7 +702,7 @@ namespace ATC { int sizeVector_; // N = size of global vector int scalarVectorFreq_; // frequency compute s/v data is available at int sizePerAtomCols_; // N = size of per atom vector to dump - + double **perAtomOutput_; // per atom data double **&perAtomArray_; // per atom data int extScalar_; // 0/1 if scalar is intensive/extensive @@ -724,15 +724,15 @@ namespace ATC { /** \name time integration and filtering fields */ //--------------------------------------------------------------- /*@{*/ - - FIELDS dot_fields_; + + FIELDS dot_fields_; FIELDS ddot_fields_; FIELDS dddot_fields_; /** Restricted Fields */ FIELDS nodalAtomicFields_; // replaces fieldNdFiltered_ - FIELDS nodalAtomicFieldsRoc_; + FIELDS nodalAtomicFieldsRoc_; /*@}*/ @@ -740,9 +740,9 @@ namespace ATC { /** \name quadrature weights */ //--------------------------------------------------------------- /*@{*/ - - DIAG_MAT NodeVolumes_; - DIAG_MAN invNodeVolumes_; + + DIAG_MAT NodeVolumes_; + DIAG_MAN invNodeVolumes_; /** atomic quadrature integration weights (V_\alpha) */ ProtectedAtomDiagonalMatrix * atomVolume_; std::string atomicWeightsFile_; @@ -770,7 +770,7 @@ namespace ATC { bool needProcGhost_; std::string groupTag_; std::string groupTagGhost_; - + /** number of atoms of correct type, ghosts are atoms outside our domain of interest boundary are atoms contributing to boundary flux terms */ @@ -824,7 +824,7 @@ namespace ATC { SPAR_MAN kernelAccumulantMol_; // KKM add SPAR_MAN kernelAccumulantMolGrad_; // KKM add DIAG_MAN* accumulantWeights_; - DIAG_MAN* accumulantInverseVolumes_; + DIAG_MAN* accumulantInverseVolumes_; int accumulantBandwidth_; /*@}*/ @@ -845,7 +845,7 @@ namespace ATC { //--------------------------------------------------------------- - /** \name reference data */ + /** \name reference data */ //--------------------------------------------------------------- bool hasRefPE_; bool setRefPE_; diff --git a/lib/atc/ATC_Transfer.cpp b/lib/atc/ATC_Transfer.cpp index a9e87e3ff9..5ea7f1233a 100644 --- a/lib/atc/ATC_Transfer.cpp +++ b/lib/atc/ATC_Transfer.cpp @@ -68,7 +68,7 @@ namespace ATC { LAMMPS_NS::Fix * thisFix, string matParamFile) : ATC_Method(groupName,perAtomArray,thisFix), - xPointer_(nullptr), + xPointer_(nullptr), outputStepZero_(true), neighborReset_(false), pairMap_(nullptr), @@ -95,7 +95,7 @@ namespace ATC { lmp->lattice(cb.cell_vectors, cb.basis_vectors); cb.inv_atom_volume = 1.0 / lmp->volume_per_atom(); cb.e2mvv = 1.0 / lmp->mvv2e(); - cb.atom_mass = lmp->atom_mass(1); + cb.atom_mass = lmp->atom_mass(1); cb.boltzmann = lmp->boltz(); cb.hbar = lmp->hbar(); cauchyBornStress_ = new StressCauchyBorn(fileId, cb); @@ -103,7 +103,7 @@ namespace ATC { // Defaults set_time(); - + outputFlags_.reset(NUM_TOTAL_FIELDS); outputFlags_ = false; fieldFlags_.reset(NUM_TOTAL_FIELDS); @@ -117,20 +117,20 @@ namespace ATC { for (int i = 0; i < NUM_TOTAL_FIELDS; i++) { outputFields_[i] = nullptr; } // Hardy requires ref positions for processor ghosts for bond list - + //needXrefProcessorGhosts_ = true; } //------------------------------------------------------------------- ATC_Transfer::~ATC_Transfer() { - interscaleManager_.clear(); - if (cauchyBornStress_) delete cauchyBornStress_; + interscaleManager_.clear(); + if (cauchyBornStress_) delete cauchyBornStress_; } //------------------------------------------------------------------- // called before the beginning of a "run" - void ATC_Transfer::initialize() + void ATC_Transfer::initialize() { if (kernelOnTheFly_ && !readRefPE_ && !setRefPEvalue_) { if (setRefPE_) { @@ -143,7 +143,7 @@ namespace ATC { ATC_Method::initialize(); - if (!initialized_) { + if (!initialized_) { if (cauchyBornStress_) cauchyBornStress_->initialize(); } @@ -164,16 +164,16 @@ namespace ATC { ghostManager_.initialize(); // initialize bond matrix B_Iab - if ((! bondOnTheFly_) - && ( ( fieldFlags_(STRESS) - || fieldFlags_(ESHELBY_STRESS) + if ((! bondOnTheFly_) + && ( ( fieldFlags_(STRESS) + || fieldFlags_(ESHELBY_STRESS) || fieldFlags_(HEAT_FLUX) ) ) ) { try { - compute_bond_matrix(); - } - catch(bad_alloc&) { + compute_bond_matrix(); + } + catch(bad_alloc&) { ATC::LammpsInterface::instance()->print_msg("stress/heat_flux will be computed on-the-fly"); - + bondOnTheFly_ = true; } } @@ -181,7 +181,7 @@ namespace ATC { // set sample frequency to output if sample has not be specified if (sampleFrequency_ == 0) sampleFrequency_ = outputFrequency_; - // output for step 0 + // output for step 0 if (!initialized_) { if (outputFrequency_ > 0) { // initialize filtered data @@ -224,9 +224,9 @@ namespace ATC { lammpsInterface_->computes_addstep(lammpsInterface_->ntimestep()+sampleFrequency_); - + //remap_ghost_ref_positions(); - update_peratom_output(); + update_peratom_output(); } //------------------------------------------------------------------- @@ -242,7 +242,7 @@ namespace ATC { void ATC_Transfer::construct_time_integration_data() { if (!initialized_) { - + // size arrays for requested/required fields for(int index=0; index < NUM_TOTAL_FIELDS; ++index) { if (fieldFlags_(index)) { @@ -298,13 +298,13 @@ namespace ATC { { // interpolant if (!(kernelOnTheFly_)) { - // finite element shape functions for interpolants + // 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_) { @@ -312,7 +312,7 @@ namespace ATC { if (kernelOnTheFly_) { ConstantQuantity * atomCount = new ConstantQuantity(this,1.); interscaleManager_.add_per_atom_quantity(atomCount,"AtomCount"); - OnTheFlyKernelAccumulation * myWeights + OnTheFlyKernelAccumulation * myWeights = new OnTheFlyKernelAccumulation(this, atomCount, kernelFunction_, atomCoarseGrainingPositions_); interscaleManager_.add_dense_matrix(myWeights, @@ -337,7 +337,7 @@ namespace ATC { if (kernelOnTheFly_) { ConstantQuantity * atomCount = new ConstantQuantity(this,1.); interscaleManager_.add_per_atom_quantity(atomCount,"AtomCount"); - OnTheFlyMeshAccumulation * myWeights + OnTheFlyMeshAccumulation * myWeights = new OnTheFlyMeshAccumulation(this, atomCount, atomCoarseGrainingPositions_); interscaleManager_.add_dense_matrix(myWeights, @@ -363,13 +363,13 @@ namespace ATC { // molecule centroid, molecule charge, dipole moment and quadrupole moment calculations KKM add if (!moleculeIds_.empty()) { map >::const_iterator molecule; - InterscaleManager & interscaleManager = this->interscale_manager(); // KKM add, may be we do not need this as interscaleManager_ already exists. + InterscaleManager & interscaleManager = this->interscale_manager(); // KKM add, may be we do not need this as interscaleManager_ already exists. PerAtomQuantity * atomProcGhostCoarseGrainingPositions_ = interscaleManager.per_atom_quantity("AtomicProcGhostCoarseGrainingPositions"); FundamentalAtomQuantity * mass = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,PROC_GHOST); molecule = moleculeIds_.begin(); int groupbit = (molecule->second).second; smallMoleculeSet_ = new SmallMoleculeSet(this,groupbit); - smallMoleculeSet_->initialize(); // KKM add, why should we? + smallMoleculeSet_->initialize(); // KKM add, why should we? interscaleManager_.add_small_molecule_set(smallMoleculeSet_,"MoleculeSet"); moleculeCentroid_ = new SmallMoleculeCentroid(this,mass,smallMoleculeSet_,atomProcGhostCoarseGrainingPositions_); interscaleManager_.add_dense_matrix(moleculeCentroid_,"MoleculeCentroid"); @@ -393,7 +393,7 @@ namespace ATC { // set pointer to positions // REFACTOR use method's handling of xref/xpointer - set_xPointer(); + set_xPointer(); ATC_Method::construct_transfers(); @@ -412,7 +412,7 @@ namespace ATC { } // for hardy-based fluxes - + bool needsBondMatrix = (! bondOnTheFly_ ) && (fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) @@ -434,7 +434,7 @@ namespace ATC { const FE_Mesh * fe_mesh = feEngine_->fe_mesh(); if (!kernelBased_) { - bondMatrix_ = new BondMatrixPartitionOfUnity(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,accumulantInverseVolumes_); + bondMatrix_ = new BondMatrixPartitionOfUnity(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,accumulantInverseVolumes_); } else { bondMatrix_ = new BondMatrixKernel(lammpsInterface_,*pairMap_,xPointer_,fe_mesh,kernelFunction_); @@ -470,7 +470,7 @@ namespace ATC { FieldManager fmgr(this); -// for(int index=0; index < NUM_TOTAL_FIELDS; ++index) +// for(int index=0; index < NUM_TOTAL_FIELDS; ++index) for(int i=0; i < numFields_; ++i) { FieldName index = indices_[i]; if (fieldFlags_(index)) { @@ -492,9 +492,9 @@ namespace ATC { interscaleManager_.add_per_atom_quantity(c,tag); int projection = iter->second; DIAG_MAN * w = nullptr; - if (projection == VOLUME_NORMALIZATION ) + if (projection == VOLUME_NORMALIZATION ) { w = accumulantInverseVolumes_; } - else if (projection == NUMBER_NORMALIZATION ) + else if (projection == NUMBER_NORMALIZATION ) { w = accumulantWeights_; } if (kernelFunction_ && kernelOnTheFly_) { OnTheFlyKernelAccumulationNormalized * C = new OnTheFlyKernelAccumulationNormalized(this, c, kernelFunction_, atomCoarseGrainingPositions_, w); @@ -507,7 +507,7 @@ namespace ATC { outputFieldsTagged_[tag] = C; } } - + } //------------------------------------------------------------------- @@ -519,18 +519,18 @@ namespace ATC { if ((!initialized_) || timeFilterManager_.need_reset()) { timeFilters_.reset(NUM_TOTAL_FIELDS+nComputes_); sampleCounter_ = 0; - + // for filtered fields for(int index=0; index < NUM_TOTAL_FIELDS; ++index) { if (fieldFlags_(index)) { string name = field_to_string((FieldName) index); filteredData_[name] = 0.0; - timeFilters_(index) = timeFilterManager_.construct(); + timeFilters_(index) = timeFilterManager_.construct(); } } - + // for filtered projected computes - + // lists/accessing of fields ( & computes) map ::const_iterator iter; int index = NUM_TOTAL_FIELDS; @@ -546,7 +546,7 @@ namespace ATC { //------------------------------------------------------------------- // called after the end of a "run" - void ATC_Transfer::finish() + void ATC_Transfer::finish() { // base class ATC_Method::finish(); @@ -560,7 +560,7 @@ namespace ATC { int argIdx = 0; // check to see if it is a transfer class command - /*! \page man_hardy_fields fix_modify AtC fields + /*! \page man_hardy_fields fix_modify AtC fields \section syntax fix_modify AtC fields \n fix_modify AtC fields \n @@ -575,13 +575,13 @@ namespace ATC { temperature : temperature derived from the relative atomic kinetic energy (as done by ) \n kinetic_temperature : temperature derived from the full kinetic energy \n number_density : simple kernel estimation of number of atoms per unit volume \n - stress : + stress : Cauchy stress tensor for eulerian analysis (atom_element_map), or 1st Piola-Kirchhoff stress tensor for lagrangian analysis \n - transformed_stress : - 1st Piola-Kirchhoff stress tensor for eulerian analysis (atom_element_map), or + transformed_stress : + 1st Piola-Kirchhoff stress tensor for eulerian analysis (atom_element_map), or Cauchy stress tensor for lagrangian analysis \n - heat_flux : spatial heat flux vector for eulerian, + heat_flux : spatial heat flux vector for eulerian, or referential heat flux vector for lagrangian \n potential_energy : potential energy per unit volume \n kinetic_energy : kinetic energy per unit volume \n @@ -590,23 +590,23 @@ namespace ATC { energy : total energy (potential + kinetic) per unit volume \n number_density : number of atoms per unit volume \n eshelby_stress: configurational stress (energy-momentum) tensor defined by Eshelby - [References: Philos. Trans. Royal Soc. London A, Math. Phys. Sci., Vol. 244, + [References: Philos. Trans. Royal Soc. London A, Math. Phys. Sci., Vol. 244, No. 877 (1951) pp. 87-112; J. Elasticity, Vol. 5, Nos. 3-4 (1975) pp. 321-335] \n vacancy_concentration: volume fraction of vacancy content \n type_concentration: volume fraction of a specific atom type \n \section examples fix_modify AtC fields add velocity temperature \section description - Allows modification of the fields calculated and output by the + Allows modification of the fields calculated and output by the transfer class. The commands are cumulative, e.g.\n - fix_modify AtC fields none \n - followed by \n + fix_modify AtC fields none \n + followed by \n fix_modify AtC fields add velocity temperature \n will only output the velocity and temperature fields. \section restrictions Must be used with the hardy/field type of AtC fix, see \ref man_fix_atc. - Currently, the stress and heat flux formulas are only correct for - central force potentials, e.g. Lennard-Jones and EAM + Currently, the stress and heat flux formulas are only correct for + central force potentials, e.g. Lennard-Jones and EAM but not Stillinger-Weber. \section related See \ref man_hardy_gradients , \ref man_hardy_rates and \ref man_hardy_computes @@ -615,30 +615,30 @@ namespace ATC { */ if (strcmp(arg[argIdx],"fields")==0) { argIdx++; - if (strcmp(arg[argIdx],"all")==0) { + if (strcmp(arg[argIdx],"all")==0) { outputFlags_ = true; match = true; - } - else if (strcmp(arg[argIdx],"none")==0) { + } + else if (strcmp(arg[argIdx],"none")==0) { outputFlags_ = false; match = true; - } - else if (strcmp(arg[argIdx],"add")==0) { + } + else if (strcmp(arg[argIdx],"add")==0) { argIdx++; for (int i = argIdx; i < narg; ++i) { FieldName field_name = string_to_field(arg[i]); - outputFlags_(field_name) = true; + outputFlags_(field_name) = true; } match = true; - } - else if (strcmp(arg[argIdx],"delete")==0) { + } + else if (strcmp(arg[argIdx],"delete")==0) { argIdx++; for (int i = argIdx; i < narg; ++i) { FieldName field_name = string_to_field(arg[i]); - outputFlags_(field_name) = false; + outputFlags_(field_name) = false; } match = true; - } + } check_field_dependencies(); if (fieldFlags_(DISPLACEMENT)) { trackDisplacement_ = true; } } @@ -649,17 +649,17 @@ namespace ATC { - add | delete (keyword) = add or delete the calculation of gradients for the listed output fields \n - fields (keyword) = \n gradients can be calculated for all fields listed in \ref man_hardy_fields - + \section examples fix_modify AtC gradients add temperature velocity stress \n fix_modify AtC gradients delete velocity \n \section description Requests calculation and output of gradients of the fields from the transfer class. These gradients will be with regard to spatial or material - coordinate for eulerian or lagrangian analysis, respectively, as specified by + coordinate for eulerian or lagrangian analysis, respectively, as specified by atom_element_map (see \ref man_atom_element_map ) \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default @@ -667,33 +667,33 @@ namespace ATC { */ else if (strcmp(arg[argIdx],"gradients")==0) { argIdx++; - if (strcmp(arg[argIdx],"add")==0) { + if (strcmp(arg[argIdx],"add")==0) { argIdx++; FieldName field_name; for (int i = argIdx; i < narg; ++i) { field_name = string_to_field(arg[i]); - gradFlags_(field_name) = true; + gradFlags_(field_name) = true; } match = true; - } - else if (strcmp(arg[argIdx],"delete")==0) { + } + else if (strcmp(arg[argIdx],"delete")==0) { argIdx++; FieldName field_name; for (int i = argIdx; i < narg; ++i) { field_name = string_to_field(arg[i]); - gradFlags_(field_name) = false; + gradFlags_(field_name) = false; } match = true; - } + } } - /*! \page man_hardy_rates fix_modify AtC rates + /*! \page man_hardy_rates fix_modify AtC rates \section syntax fix_modify AtC rates \n - add | delete (keyword) = add or delete the calculation of rates (time derivatives) for the listed output fields \n - fields (keyword) = \n rates can be calculated for all fields listed in \ref man_hardy_fields - + \section examples fix_modify AtC rates add temperature velocity stress \n fix_modify AtC rates delete stress \n @@ -703,7 +703,7 @@ namespace ATC { are the partial time derivatives of the nodal fields, not the full (material) time derivatives. \n \section restrictions - Must be used with the hardy/field type of AtC fix + Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \section related \section default @@ -711,16 +711,16 @@ namespace ATC { */ else if (strcmp(arg[argIdx],"rates")==0) { argIdx++; - if (strcmp(arg[argIdx],"add")==0) { + if (strcmp(arg[argIdx],"add")==0) { argIdx++; FieldName field_name; for (int i = argIdx; i < narg; ++i) { field_name = string_to_field(arg[i]); - rateFlags_(field_name) = true; + rateFlags_(field_name) = true; } match = true; - } - else if (strcmp(arg[argIdx],"delete")==0) { + } + else if (strcmp(arg[argIdx],"delete")==0) { argIdx++; FieldName field_name; for (int i = argIdx; i < narg; ++i) { @@ -728,7 +728,7 @@ namespace ATC { rateFlags_(field_name) = false; } match = true; - } + } } @@ -736,7 +736,7 @@ namespace ATC { \section syntax fix_modify AtC pair_interactions \n fix_modify AtC bond_interactions \n - + \section examples fix_modify AtC bond_interactions on \n \section description @@ -748,27 +748,27 @@ namespace ATC { */ if (strcmp(arg[argIdx],"pair_interactions")==0) { // default true argIdx++; - if (strcmp(arg[argIdx],"on")==0) { hasPairs_ = true; } + if (strcmp(arg[argIdx],"on")==0) { hasPairs_ = true; } else { hasPairs_ = false;} match = true; - } + } if (strcmp(arg[argIdx],"bond_interactions")==0) { // default false argIdx++; - if (strcmp(arg[argIdx],"on")==0) { hasBonds_ = true; } + if (strcmp(arg[argIdx],"on")==0) { hasBonds_ = true; } else { hasBonds_ = false;} match = true; - } - - /*! \page man_hardy_computes fix_modify AtC computes + } + + /*! \page man_hardy_computes fix_modify AtC computes \section syntax fix_modify AtC computes [per-atom compute id] \n - add | delete (keyword) = add or delete the calculation of an equivalent continuum field for the specified per-atom compute as volume or number density quantity \n - - per-atom compute id = name/id for per-atom compute, + - per-atom compute id = name/id for per-atom compute, fields can be calculated for all per-atom computes available from LAMMPS \n - volume | number (keyword) = field created is a per-unit-volume quantity - or a per-atom quantity as weighted by kernel functions \n - + or a per-atom quantity as weighted by kernel functions \n + \section examples compute virial all stress/atom \n fix_modify AtC computes add virial volume \n @@ -782,24 +782,24 @@ namespace ATC { Must be used with the hardy/field type of AtC fix ( see \ref man_fix_atc ) \n Per-atom compute must be specified before corresponding continuum field can be requested \n \section related - See manual page for compute + See manual page for compute \section default No defaults exist for this command */ else if (strcmp(arg[argIdx],"computes")==0) { argIdx++; - if (strcmp(arg[argIdx],"add")==0) { + if (strcmp(arg[argIdx],"add")==0) { argIdx++; string tag(arg[argIdx++]); int normalization = NO_NORMALIZATION; if (narg > argIdx) { - if (strcmp(arg[argIdx],"volume")==0) { + if (strcmp(arg[argIdx],"volume")==0) { normalization = VOLUME_NORMALIZATION; } - else if (strcmp(arg[argIdx],"number")==0) { + else if (strcmp(arg[argIdx],"number")==0) { normalization = NUMBER_NORMALIZATION; } - else if (strcmp(arg[argIdx],"mass")==0) { + else if (strcmp(arg[argIdx],"mass")==0) { normalization = MASS_NORMALIZATION; throw ATC_Error("mass normalized not implemented"); } @@ -807,8 +807,8 @@ namespace ATC { computes_[tag] = normalization; nComputes_++; match = true; - } - else if (strcmp(arg[argIdx],"delete")==0) { + } + else if (strcmp(arg[argIdx],"delete")==0) { argIdx++; string tag(arg[argIdx]); if (computes_.find(tag) != computes_.end()) { @@ -816,10 +816,10 @@ namespace ATC { nComputes_--; } else { - throw ATC_Error(tag+" compute is not in list"); + throw ATC_Error(tag+" compute is not in list"); } match = true; - } + } } @@ -833,7 +833,7 @@ namespace ATC { 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 ) + Must be used with the hardy/field AtC fix ( see \ref man_fix_atc ) and is only relevant when time filters are being used. \section related \section default @@ -869,11 +869,11 @@ namespace ATC { // REFACTOR move this to post_neighbor void ATC_Transfer::pre_final_integrate() { - // update time + // update time update_time(); // time uses step if dt = 0 - + if ( neighborReset_ && sample_now() ) { if (! kernelOnTheFly_ ) { if (!moleculeIds_.empty()) compute_kernel_matrix_molecule(); //KKM add @@ -889,7 +889,7 @@ namespace ATC { // compute spatially smoothed quantities double dt = lammpsInterface_->dt(); if ( sample_now() ) { - + bool needsBond = (! bondOnTheFly_ ) && (fieldFlags_(STRESS) || fieldFlags_(ESHELBY_STRESS) @@ -898,7 +898,7 @@ namespace ATC { if ( needsBond ) { if (pairMap_->need_reset()) { // ATC::LammpsInterface::instance()->print_msg("Recomputing bond matrix due to atomReset_ value"); - compute_bond_matrix(); + compute_bond_matrix(); } } time_filter_pre (dt); @@ -923,8 +923,8 @@ namespace ATC { //------------------------------------------------------------------- void ATC_Transfer::compute_fields(void) { - - // keep per-atom computes fresh. JAZ and REJ not sure why; + + // keep per-atom computes fresh. JAZ and REJ not sure why; // need to confer with JAT. (JAZ, 4/5/12) interscaleManager_.lammps_force_reset(); @@ -937,16 +937,16 @@ namespace ATC { } } - if (fieldFlags_(STRESS)) + if (fieldFlags_(STRESS)) compute_stress(hardyData_["stress"].set_quantity()); - if (fieldFlags_(HEAT_FLUX)) + if (fieldFlags_(HEAT_FLUX)) compute_heatflux(hardyData_["heat_flux"].set_quantity()); // molecule data if (fieldFlags_(DIPOLE_MOMENT)) - compute_dipole_moment(hardyData_["dipole_moment"].set_quantity()); + compute_dipole_moment(hardyData_["dipole_moment"].set_quantity()); if (fieldFlags_(QUADRUPOLE_MOMENT)) compute_quadrupole_moment(hardyData_["quadrupole_moment"].set_quantity()); - if (fieldFlags_(DISLOCATION_DENSITY)) + if (fieldFlags_(DISLOCATION_DENSITY)) compute_dislocation_density(hardyData_["dislocation_density"].set_quantity()); // (2) derived quantities @@ -963,7 +963,7 @@ namespace ATC { } } } - // compute: eshelby stress + // compute: eshelby stress if (fieldFlags_(ESHELBY_STRESS)) { { compute_eshelby_stress(hardyData_["eshelby_stress"].set_quantity(), @@ -985,18 +985,18 @@ namespace ATC { E,hardyData_["stress"].quantity(), hardyData_["displacement_gradient"].quantity()); } - // compute: cauchy born stress + // compute: cauchy born stress if (fieldFlags_(CAUCHY_BORN_STRESS)) { ATOMIC_DATA::const_iterator tfield = hardyData_.find("temperature"); const DENS_MAT *temp = tfield==hardyData_.end() ? nullptr : &((tfield->second).quantity()); cauchy_born_stress(hardyData_["displacement_gradient"].quantity(), hardyData_["cauchy_born_stress"].set_quantity(), temp); } - // compute: cauchy born energy + // compute: cauchy born energy if (fieldFlags_(CAUCHY_BORN_ENERGY)) { ATOMIC_DATA::const_iterator tfield = hardyData_.find("temperature"); const DENS_MAT *temp = tfield==hardyData_.end() ? nullptr : &((tfield->second).quantity()); - cauchy_born_energy(hardyData_["displacement_gradient"].quantity(), + cauchy_born_energy(hardyData_["displacement_gradient"].quantity(), hardyData_["cauchy_born_energy"].set_quantity(), temp); } // 1st PK transformed to cauchy (lag) or cauchy transformed to 1st PK (eul) @@ -1014,13 +1014,13 @@ namespace ATC { compute_electric_potential( hardyData_[field_to_string(ELECTRIC_POTENTIAL)].set_quantity()); } - // compute: rotation and/or stretch from deformation gradient + // compute: rotation and/or stretch from deformation gradient if (fieldFlags_(ROTATION) || fieldFlags_(STRETCH)) { compute_polar_decomposition(hardyData_["rotation"].set_quantity(), hardyData_["stretch"].set_quantity(), hardyData_["displacement_gradient"].quantity()); } - // compute: rotation and/or stretch from deformation gradient + // compute: rotation and/or stretch from deformation gradient if (fieldFlags_(CAUCHY_BORN_ELASTIC_DEFORMATION_GRADIENT)) { compute_elastic_deformation_gradient2(hardyData_["elastic_deformation_gradient"].set_quantity(), hardyData_["stress"].quantity(), @@ -1082,9 +1082,9 @@ namespace ATC { F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; FT = F.transpose(); FTINV = inv(FT); - + // volumes are already reference volumes. - PK1 = CAUCHY*FTINV; + PK1 = CAUCHY*FTINV; matrix_to_vector(k,PK1,myData); } } @@ -1094,7 +1094,7 @@ namespace ATC { } #endif } - + }// end of compute_fields routine //------------------------------------------------------------------- @@ -1156,7 +1156,7 @@ namespace ATC { filteredData_[grad_field] = hardyData_[grad_field]; } } - + // lists/accessing of fields ( & computes) map ::const_iterator iter; int index = NUM_TOTAL_FIELDS; @@ -1177,7 +1177,7 @@ namespace ATC { void ATC_Transfer::output() { feEngine_->departition_mesh(); - + for(int index=0; index < NUM_TOTAL_FIELDS; ++index) { if (outputFlags_(index)) { FieldName fName = (FieldName) index; @@ -1185,7 +1185,7 @@ namespace ATC { fields_[fName] = filteredData_[name]; } } - + ATC_Method::output(); if (lammpsInterface_->comm_rank() == 0) { // data @@ -1209,7 +1209,7 @@ namespace ATC { output_data[grad_name] = & ( filteredData_[grad_name].set_quantity()); } } - + // lists/accessing of fields ( & computes) map ::const_iterator iter; for (iter = computes_.begin(); iter != computes_.end(); iter++) { @@ -1226,7 +1226,7 @@ namespace ATC { output_data["NodalInverseVolumes"] = &nodalInverseVolumes; // output - feEngine_->write_data(output_index(), & output_data); + feEngine_->write_data(output_index(), & output_data); } feEngine_->partition_mesh(); } @@ -1235,7 +1235,7 @@ namespace ATC { /////// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //------------------------------------------------------------------- - // computes nodeData = N*atomData + // computes nodeData = N*atomData void ATC_Transfer::project(const DENS_MAT & atomData, DENS_MAT & nodeData) { @@ -1290,8 +1290,8 @@ namespace ATC { void ATC_Transfer::project_count_normalized(const DENS_MAT & atomData, DENS_MAT & nodeData) { - DENS_MAT tmp; - project(atomData,tmp); + DENS_MAT tmp; + project(atomData,tmp); nodeData = (accumulantWeights_->quantity())*tmp; } @@ -1301,7 +1301,7 @@ namespace ATC { DENS_MAT & nodeData) { DENS_MAT tmp; - project(atomData,tmp); + project(atomData,tmp); nodeData = (accumulantInverseVolumes_->quantity())*tmp; } @@ -1310,8 +1310,8 @@ namespace ATC { void ATC_Transfer::project_volume_normalized_molecule(const DENS_MAT & molData, DENS_MAT & nodeData) { - DENS_MAT tmp; - project_molecule(molData,tmp); + DENS_MAT tmp; + project_molecule(molData,tmp); nodeData = (accumulantInverseVolumes_->quantity())*tmp; } @@ -1320,8 +1320,8 @@ namespace ATC { void ATC_Transfer::project_volume_normalized_molecule_gradient(const DENS_MAT & molData, DENS_MAT & nodeData) { - DENS_MAT tmp; - project_molecule_gradient(molData,tmp); + DENS_MAT tmp; + project_molecule_gradient(molData,tmp); nodeData = (accumulantInverseVolumes_->quantity())*tmp; } @@ -1354,14 +1354,14 @@ namespace ATC { //------------------------------------------------------------------- // computes "virial" part of heat flux - // This is correct ONLY for pair potentials. + // This is correct ONLY for pair potentials. void ATC_Transfer::compute_heat_matrix() { atomicHeatMatrix_ = pairHeatFlux_->quantity(); } //------------------------------------------------------------------- - // set xPointer_ to xref or xatom depending on Lagrangian/Eulerian analysis + // set xPointer_ to xref or xatom depending on Lagrangian/Eulerian analysis void ATC_Transfer::set_xPointer() { xPointer_ = xref_; @@ -1386,7 +1386,7 @@ namespace ATC { fieldFlags_(DISPLACEMENT) = true; } if (fieldFlags_(CAUCHY_BORN_STRESS) - || fieldFlags_(CAUCHY_BORN_ENERGY) + || fieldFlags_(CAUCHY_BORN_ENERGY) || fieldFlags_(CAUCHY_BORN_ESHELBY_STRESS) || fieldFlags_(CAUCHY_BORN_ELASTIC_DEFORMATION_GRADIENT)) { if (! (cauchyBornStress_) ) { @@ -1419,7 +1419,7 @@ namespace ATC { fieldFlags_(KINETIC_ENERGY) = true; } if (fieldFlags_(TEMPERATURE) || fieldFlags_(HEAT_FLUX) || - fieldFlags_(KINETIC_ENERGY) || fieldFlags_(THERMAL_ENERGY) || + fieldFlags_(KINETIC_ENERGY) || fieldFlags_(THERMAL_ENERGY) || fieldFlags_(ENERGY) || fieldFlags_(INTERNAL_ENERGY) || fieldFlags_(KINETIC_ENERGY) || (fieldFlags_(STRESS) && atomToElementMapType_ == EULERIAN) ) { @@ -1438,15 +1438,15 @@ namespace ATC { fieldFlags_(NUMBER_DENSITY) = true; } - if (fieldFlags_(ROTATION) || + if (fieldFlags_(ROTATION) || fieldFlags_(STRETCH)) { fieldFlags_(DISPLACEMENT) = true; } if (fieldFlags_(ESHELBY_STRESS) - || fieldFlags_(CAUCHY_BORN_STRESS) - || fieldFlags_(CAUCHY_BORN_ENERGY) - || fieldFlags_(CAUCHY_BORN_ESHELBY_STRESS) - || fieldFlags_(CAUCHY_BORN_ELASTIC_DEFORMATION_GRADIENT) + || fieldFlags_(CAUCHY_BORN_STRESS) + || fieldFlags_(CAUCHY_BORN_ENERGY) + || fieldFlags_(CAUCHY_BORN_ESHELBY_STRESS) + || fieldFlags_(CAUCHY_BORN_ELASTIC_DEFORMATION_GRADIENT) || fieldFlags_(VACANCY_CONCENTRATION) || fieldFlags_(ROTATION) || fieldFlags_(STRETCH) ) { @@ -1459,8 +1459,8 @@ namespace ATC { throw ATC_Error("Calculation of stress field not possible with selected pair type."); } } - - } + + } //============== THIN WRAPPERS ==================================== // OBSOLETE @@ -1492,7 +1492,7 @@ namespace ATC { // calculate kinetic energy tensor part of stress for Eulerian analysis if (atomToElementMapType_ == EULERIAN && nLocal_>0) { - compute_kinetic_stress(stress); + compute_kinetic_stress(stress); } else { // zero stress table for Lagrangian analysis or if nLocal_ = 0 @@ -1511,7 +1511,7 @@ namespace ATC { compute_force_matrix(); // calculate force part of stress tensor local_potential_hardy_stress = atomicBondMatrix_*atomicForceMatrix_; - local_potential_hardy_stress *= 0.5; + local_potential_hardy_stress *= 0.5; } } // global summation of potential part of stress tensor @@ -1570,7 +1570,7 @@ namespace ATC { compute_kinetic_heatflux(flux); } else { - flux.zero(); // zero stress table for Lagrangian analysis + flux.zero(); // zero stress table for Lagrangian analysis } // add potential part of heat flux vector int nrows = flux.nRows(); @@ -1628,11 +1628,11 @@ namespace ATC { // - e^0_I v_I + \sigma^T_I v_I for (int i = 0; i < nNodes_; i++) { double e_i = energy(i,0); - flux(i,0) += (e_i + stress(i,0))*velocity(i,0) + flux(i,0) += (e_i + stress(i,0))*velocity(i,0) + stress(i,3)*velocity(i,1)+ stress(i,4)*velocity(i,2); - flux(i,1) += (e_i + stress(i,1))*velocity(i,1) + flux(i,1) += (e_i + stress(i,1))*velocity(i,1) + stress(i,3)*velocity(i,0)+ stress(i,5)*velocity(i,2); - flux(i,2) += (e_i + stress(i,2))*velocity(i,2) + flux(i,2) += (e_i + stress(i,2))*velocity(i,2) + stress(i,4)*velocity(i,0)+ stress(i,5)*velocity(i,1); } } @@ -1643,7 +1643,7 @@ namespace ATC { const DENS_MAT & rho = (restrictedCharge_->quantity()); SPAR_MAT K; feEngine_->stiffness_matrix(K); - double permittivity = lammpsInterface_->dielectric(); + double permittivity = lammpsInterface_->dielectric(); permittivity *= LammpsInterface::instance()->epsilon0(); K *= permittivity; BC_SET bcs; @@ -1670,7 +1670,7 @@ namespace ATC { for (int i = 0; i < nLocal_; i++) { int atomIdx = internalToAtom_(i); - if (type[atomIdx] != 13) { + if (type[atomIdx] != 13) { atomCnt(i,0) = myAtomicWeights(i,i); atomic_weight_sum += myAtomicWeights(i,i); number_atoms++; @@ -1725,7 +1725,7 @@ namespace ATC { #ifndef H_BASED F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; #endif - FT = F.transpose(); + FT = F.transpose(); } else if (atomToElementMapType_ == EULERIAN) { vector_to_symm_matrix(i,S,P); @@ -1741,9 +1741,9 @@ namespace ATC { // Q stores (1-H) Q -= FT.transpose(); DENS_MAT F(3,3); - F = inv(Q); + F = inv(Q); FT = F.transpose(); - ESH = FT*ESH; + ESH = FT*ESH; } // copy to global matrix_to_vector(i,ESH,M); @@ -1761,7 +1761,7 @@ namespace ATC { DENS_MAT_VEC &h = hField[DISPLACEMENT]; h.assign(nsd_, DENS_MAT(nNodes_,nsd_)); tField.assign(nsd_, DENS_MAT(nNodes_,nsd_)); - // each row is the CB stress at a node stored in voigt form + // each row is the CB stress at a node stored in voigt form T.reset(nNodes_,FieldSizes[CAUCHY_BORN_STRESS]); const double nktv2p = lammpsInterface_->nktv2p(); const double fact = -lammpsInterface_->mvv2e()*nktv2p; @@ -1779,7 +1779,7 @@ namespace ATC { DENS_MAT S(nNodes_,6); symm_dens_mat_vec_to_vector(tField,S); S *= fact; - + // tField/S holds the 2nd P-K stress tensor. Transform to // Cauchy for EULERIAN analysis, transform to 1st P-K // for LAGRANGIAN analysis. @@ -1799,7 +1799,7 @@ namespace ATC { FT = transpose(F); double J = det(F); STRESS = F*PK2*FT; - STRESS *= 1/J; + STRESS *= 1/J; symm_matrix_to_vector(i,STRESS,T); } else{ @@ -1810,7 +1810,7 @@ namespace ATC { STRESS = F*PK2; matrix_to_vector(i,STRESS,T); } - + } } //--------------------------------------------------------------------------- @@ -1861,7 +1861,7 @@ namespace ATC { void ATC_Transfer::cauchy_born_entropic_energy(const DENS_MAT &H, DENS_MAT &E, const DENS_MAT &T) { FIELD_MATS uField; // uField should contain temperature. - uField[TEMPERATURE] = T; + uField[TEMPERATURE] = T; GRAD_FIELD_MATS hField; DENS_MAT_VEC &h = hField[DISPLACEMENT]; h.assign(nsd_, DENS_MAT(nNodes_,nsd_)); @@ -1916,13 +1916,13 @@ namespace ATC { vector_to_matrix(i,H,F); F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; - FT = F.transpose(); + FT = F.transpose(); } // double J = det(FT); FT *= 1/J; if (atomToElementMapType_ == EULERIAN) { - FT = inv(FT); + FT = inv(FT); } S = P*FT; matrix_to_vector(i,S,stress); @@ -1933,10 +1933,10 @@ namespace ATC { DENS_MAT & stretch, const DENS_MAT & H) { DENS_MAT F(3,3),R(3,3),U(3,3); - for (int i = 0; i < nNodes_; i++) { + for (int i = 0; i < nNodes_; i++) { vector_to_matrix(i,H,F); F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; - if (atomToElementMapType_ == EULERIAN) { + if (atomToElementMapType_ == EULERIAN) { polar_decomposition(F,R,U,false); } // F = V R else { polar_decomposition(F,R,U); } // F = R U @@ -1953,12 +1953,12 @@ namespace ATC { //-------------------------------------------------------------------- void ATC_Transfer::compute_elastic_deformation_gradient(DENS_MAT & Fe, const DENS_MAT & P, const DENS_MAT & H) - + { // calculate Fe for every node const double nktv2p = lammpsInterface_->nktv2p(); const double fact = 1.0/ ( lammpsInterface_->mvv2e()*nktv2p ); - for (int i = 0; i < nNodes_; i++) { + for (int i = 0; i < nNodes_; i++) { DENS_VEC Pv = global_vector_to_vector(i,P); Pv *= fact; CBElasticTangentOperator tangent(cauchyBornStress_, Pv); @@ -1977,11 +1977,11 @@ namespace ATC { const double nktv2p = lammpsInterface_->nktv2p(); const double fact = 1.0/ ( lammpsInterface_->mvv2e()*nktv2p ); DENS_MAT F(3,3),R(3,3),U(3,3),PP(3,3),S(3,3); - for (int i = 0; i < nNodes_; i++) { + for (int i = 0; i < nNodes_; i++) { // get F = RU vector_to_matrix(i,H,F); F(0,0) += 1.0; F(1,1) += 1.0; F(2,2) += 1.0; - if (atomToElementMapType_ == EULERIAN) { + if (atomToElementMapType_ == EULERIAN) { polar_decomposition(F,R,U,false); } // F = V R else { polar_decomposition(F,R,U); } // F = R U @@ -1989,7 +1989,7 @@ namespace ATC { vector_to_matrix(i,P,PP); //S = PP*transpose(F); S = inv(F)*PP; - + S += S.transpose(); S *= 0.5; // symmetrize DENS_VEC Sv = to_voigt(S); Sv *= fact; diff --git a/lib/atc/ATC_Transfer.h b/lib/atc/ATC_Transfer.h index 9e05b8b84b..021b549fb6 100644 --- a/lib/atc/ATC_Transfer.h +++ b/lib/atc/ATC_Transfer.h @@ -22,9 +22,9 @@ class TimeFilter; class ATC_Transfer : public ATC_Method { public: - + // constructor - ATC_Transfer(std::string groupName, + ATC_Transfer(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile = "none"); @@ -52,7 +52,7 @@ class ATC_Transfer : public ATC_Method { virtual void pre_neighbor() {ATC_Method::pre_neighbor(); neighborReset_ = true;}; /** output function */ - virtual void output(); + virtual void output(); /** external access to hardy data and other information*/ const DENS_MAT * hardy_data(std::string field) { return &hardyData_[field].quantity(); } @@ -63,25 +63,25 @@ class ATC_Transfer : public ATC_Method { double ** xPointer_; /** data */ - TAG_FIELDS hardyData_; + TAG_FIELDS hardyData_; SmallMoleculeSet * smallMoleculeSet_; // KKM add SmallMoleculeCentroid * moleculeCentroid_; // KKM add SmallMoleculeDipoleMoment * dipoleMoment_; // KKM add SmallMoleculeQuadrupoleMoment * quadrupoleMoment_; // KKM add /** container for dependency managed data */ std::vector < DENS_MAN * > outputFields_; - + std::map < std::string, DENS_MAN * > outputFieldsTagged_; DENS_MAN * restrictedCharge_; // WIP/TEMP - /** work space */ + /** work space */ DENS_MAT atomicScalar_; DENS_MAT atomicVector_; DENS_MAT atomicTensor_; /** calculation flags */ - Array fieldFlags_; + Array fieldFlags_; Array outputFlags_; Array gradFlags_; Array rateFlags_; @@ -117,7 +117,7 @@ class ATC_Transfer : public ATC_Method { void compute_heatflux(DENS_MAT & flux); /** derived quantities: compute nodal to nodal quantities */ void compute_eshelby_stress(DENS_MAT & eshebly_stress, - const DENS_MAT & energy, const DENS_MAT & stress, + const DENS_MAT & energy, const DENS_MAT & stress, const DENS_MAT & displacement_gradient); void cauchy_born_stress(const DENS_MAT &dudx, DENS_MAT &T, const DENS_MAT *temp=0); void cauchy_born_energy(const DENS_MAT &dudx, DENS_MAT &T, const DENS_MAT *temp=0); @@ -151,15 +151,15 @@ class ATC_Transfer : public ATC_Method { virtual void compute_dislocation_density(DENS_MAT & dislocation_density) = 0; /** compute smooth fields */ - void compute_fields(void); - void time_filter_pre (double dt); - void time_filter_post(double dt); + void compute_fields(void); + void time_filter_pre (double dt); + void time_filter_post(double dt); /** mapping of atomic pairs to pair index value */ - class PairMap * pairMap_; - class BondMatrix * bondMatrix_; - class PairVirial * pairVirial_; - class PairPotentialHeatFlux * pairHeatFlux_; + class PairMap * pairMap_; + class BondMatrix * bondMatrix_; + class PairVirial * pairVirial_; + class PairPotentialHeatFlux * pairHeatFlux_; /** routine to calculate matrix of force & position dyads */ void compute_force_matrix(); @@ -176,7 +176,7 @@ class ATC_Transfer : public ATC_Method { DENS_MAT & nodeData) = 0; /** routine to calculate matrix of bond functions */ - virtual void compute_bond_matrix(); + virtual void compute_bond_matrix(); /** routine to set xPointer to xref or xatom */ void set_xPointer(); @@ -200,21 +200,21 @@ class ATC_Transfer : public ATC_Method { void project_count_normalized(const DENS_MAT & atomData, DENS_MAT & nodeData); - /** hardy_project (volume density): given w_\alpha, - w_I = 1/\Omega_I \sum_\alpha N_{I\alpha} w_\alpha + /** hardy_project (volume density): given w_\alpha, + w_I = 1/\Omega_I \sum_\alpha N_{I\alpha} w_\alpha where \Omega_I = \int_{support region of node I} N_{I} dV */ // REFACTOR AtfNodeWeightedShapeFunctionRestriction void project_volume_normalized(const DENS_MAT & atomData, DENS_MAT & nodeData); void project_volume_normalized_molecule(const DENS_MAT & molData, - DENS_MAT & nodeData); // KKM add + DENS_MAT & nodeData); // KKM add void project_volume_normalized_molecule_gradient(const DENS_MAT & molData, - DENS_MAT & nodeData); // KKM add - - - /** gradient_compute: given w_I, - w_J = \sum_I N_I'{xJ} \dyad w_I - where N_I'{xJ} is the gradient of the normalized + DENS_MAT & nodeData); // KKM add + + + /** gradient_compute: given w_I, + w_J = \sum_I N_I'{xJ} \dyad w_I + where N_I'{xJ} is the gradient of the normalized shape function of node I evaluated at node J */ // REFACTOR MatToGradBySparse void gradient_compute(const DENS_MAT & inNodeData, @@ -226,7 +226,7 @@ class ATC_Transfer : public ATC_Method { /** workset data */ VectorDependencyManager * gradientMatrix_; - + SPAR_MAT atomicBondMatrix_; DENS_MAT atomicForceMatrix_; DENS_MAT atomicHeatMatrix_; @@ -247,7 +247,7 @@ class ATC_Transfer : public ATC_Method { Array timeFilters_; /** check consistency of fieldFlags_ */ - void check_field_dependencies(); + void check_field_dependencies(); }; diff --git a/lib/atc/ATC_TransferKernel.cpp b/lib/atc/ATC_TransferKernel.cpp index a4d592ba64..e09139f92c 100644 --- a/lib/atc/ATC_TransferKernel.cpp +++ b/lib/atc/ATC_TransferKernel.cpp @@ -1,4 +1,4 @@ -// ATC headers +// ATC headers #include "ATC_TransferKernel.h" #include "ATC_Error.h" #include "FE_Engine.h" @@ -44,10 +44,10 @@ using ATC_Utility::to_string; { bool match = false; - /*! \page man_hardy_kernel fix_modify AtC kernel + /*! \page man_hardy_kernel fix_modify AtC kernel \section syntax fix_modify AtC kernel - - type (keyword) = step, cell, cubic_bar, cubic_cylinder, cubic_sphere, + - type (keyword) = step, cell, cubic_bar, cubic_cylinder, cubic_sphere, quartic_bar, quartic_cylinder, quartic_sphere \n - parameters :\n step = radius (double) \n @@ -62,7 +62,7 @@ using ATC_Utility::to_string; fix_modify AtC kernel cell 1.0 1.0 1.0 \n fix_modify AtC kernel quartic_sphere 10.0 \section description - + \section restrictions Must be used with the hardy AtC fix \n For bar kernel types, half-width oriented along x-direction \n @@ -92,28 +92,28 @@ using ATC_Utility::to_string; SPAR_MAT & dN(kernelAccumulantMolGrad_.set_quantity()); dN.reset(nLocalMol,nNodes_); DENS_VEC derivKer(nsd_); - DENS_VEC xI(nsd_),xm(nsd_),xmI(nsd_); + DENS_VEC xI(nsd_),xm(nsd_),xmI(nsd_); const DENS_MAT & centroidMolMatrix(moleculeCentroid_->quantity()); - ATC::LammpsInterface::instance()->stream_msg_once("computing kernel matrix molecule ",true,false); - int heartbeatFreq = (nNodes_ <= 10 ? 1 : (int) nNodes_ / 10); + ATC::LammpsInterface::instance()->stream_msg_once("computing kernel matrix molecule ",true,false); + int heartbeatFreq = (nNodes_ <= 10 ? 1 : (int) nNodes_ / 10); for (int i = 0; i < nNodes_; i++) { - if (i % heartbeatFreq == 0 ) { + if (i % heartbeatFreq == 0 ) { ATC::LammpsInterface::instance()->stream_msg_once(".",false,false); - } + } xI = (feEngine_->fe_mesh())->nodal_coordinates(i); for (int j = 0; j < nLocalMol; j++) { for (int k = 0; k < nsd_; k++) { xm(k) = centroidMolMatrix(j,k); } - xmI = xm - xI; + xmI = xm - xI; lammpsInterface_->periodicity_correction(xmI.ptr()); double val = kernelFunction_->value(xmI); if (val > 0) N.add(j,i,val); kernelFunction_->derivative(xmI,derivKer); double val_grad = derivKer(2); if (val_grad!= 0) dN.add(j,i,val_grad); - } - } + } + } // reset kernelShpFunctions with the weights of molecules on processors DENS_VEC fractions(N.nRows()); DENS_VEC fractions_deriv(dN.nRows()); @@ -126,10 +126,10 @@ using ATC_Utility::to_string; dN.compress(); if (lammpsInterface_->rank_zero()) { ATC::LammpsInterface::instance()->stream_msg_once("done",false,true); - } - } + } + } } - + //------------------------------------------------------------------- void ATC_TransferKernel::compute_projection(const DENS_MAT & atomData, DENS_MAT & nodeData) @@ -183,7 +183,7 @@ using ATC_Utility::to_string; int **firstneigh = lammpsInterface_->neighbor_list_firstneigh(); double ** xatom = lammpsInterface_->xatom(); double lam1,lam2; - double bond_value; + double bond_value; // process differently for mesh vs translation-invariant kernels ATC::LammpsInterface::instance()->stream_msg_once("computing potential stress: ",true,false); int heartbeatFreq = (nNodes_ <= 10 ? 1 : (int) nNodes_ / 10); @@ -202,7 +202,7 @@ using ATC_Utility::to_string; int inode = i; for (int j = 0; j < nLocal_; j++) { // second (neighbor) atom location - int lammps_j = internalToAtom_(j); + int lammps_j = internalToAtom_(j); xa.copy(xPointer_[lammps_j],3); // difference vector xaI = xa - xI; @@ -217,8 +217,8 @@ using ATC_Utility::to_string; kernelFunction_->bond_intercepts(xaI,xbI,lam1,lam2); // compute virial if (lam1 < lam2) { - bond_value - = kernel_inv_vol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); + bond_value + = kernel_inv_vol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); double delx = xatom[lammps_j][0] - xatom[lammps_k][0]; double dely = xatom[lammps_j][1] - xatom[lammps_k][1]; double delz = xatom[lammps_j][2] - xatom[lammps_k][2]; @@ -227,9 +227,9 @@ using ATC_Utility::to_string; lammpsInterface_->pair_force(lammps_j,lammps_k,rsq,fforce); fforce *= 0.5; // dbl count if (atomToElementMapType_ == LAGRANGIAN) { - double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; - double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; - double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; + double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; + double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; + double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; stress(inode,0) +=-delx*fforce*delX*bond_value; stress(inode,1) +=-delx*fforce*delY*bond_value; stress(inode,2) +=-delx*fforce*delZ*bond_value; @@ -266,9 +266,9 @@ using ATC_Utility::to_string; int **firstneigh = lammpsInterface_->neighbor_list_firstneigh(); double ** xatom = lammpsInterface_->xatom(); double ** vatom = lammpsInterface_->vatom(); - + double lam1,lam2; - double bond_value; + double bond_value; // process differently for mesh vs translation-invariant kernels // "normal" kernel functions DENS_VEC xa(nsd_),xI(nsd_),xaI(nsd_),xb(nsd_),xbI(nsd_),xba(nsd_); @@ -281,7 +281,7 @@ using ATC_Utility::to_string; continue; } for (int j = 0; j < nLocal_; j++) { - int lammps_j = internalToAtom_(j); + int lammps_j = internalToAtom_(j); xa.copy(xPointer_[lammps_j],3); // difference vector xaI = xa - xI; @@ -296,8 +296,8 @@ using ATC_Utility::to_string; kernelFunction_->bond_intercepts(xaI,xbI,lam1,lam2); // compute virial if (lam1 < lam2) { - bond_value - = kernel_inv_vol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); + bond_value + = kernel_inv_vol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); double delx = xatom[lammps_j][0] - xatom[lammps_k][0]; double dely = xatom[lammps_j][1] - xatom[lammps_k][1]; double delz = xatom[lammps_j][2] - xatom[lammps_k][2]; @@ -308,9 +308,9 @@ using ATC_Utility::to_string; double * v = vatom[lammps_j]; fforce *= (delx*v[0] + dely*v[1] + delz*v[2]); if (atomToElementMapType_ == LAGRANGIAN) { - double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; - double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; - double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; + double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; + double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; + double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; flux(inode,0) +=fforce*delX*bond_value; flux(inode,1) +=fforce*delY*bond_value; flux(inode,2) +=fforce*delZ*bond_value; @@ -327,7 +327,7 @@ using ATC_Utility::to_string; } //------------------------------------------------------------------- - // calculation of the dislocation density tensor + // calculation of the dislocation density tensor void ATC_TransferKernel::compute_dislocation_density(DENS_MAT & A) { A.reset(nNodes_,9); @@ -348,7 +348,7 @@ using ATC_Utility::to_string; lammpsInterface_->int_allsum(&localNumberLines,&totalNumberLines,1); if (totalNumberLines == 0) { ATC::LammpsInterface::instance()->print_msg_once("no dislocation lines found"); - return; + return; } // for output @@ -366,7 +366,7 @@ using ATC_Utility::to_string; DENS_MAT local_A(nNodes_,9); - local_A.zero(); + local_A.zero(); DENS_VEC xa(nsd_),xI(nsd_),xaI(nsd_),xb(nsd_),xbI(nsd_),xba(nsd_); double kernel_inv_vol = kernelFunction_->inv_vol(); int iPt = 0, iSeg= 0; @@ -393,7 +393,7 @@ using ATC_Utility::to_string; xa(k) = x1[k]; xb(k) = x2[k]; xba(k) = delta[k]; - } + } for (int I = 0; I < nNodes_; I++) { xI = (feEngine_->fe_mesh())->nodal_coordinates(I); if (!kernelFunction_->node_contributes(xI)) { @@ -405,7 +405,7 @@ using ATC_Utility::to_string; double lam1=0,lam2=0; kernelFunction_->bond_intercepts(xaI,xbI,lam1,lam2); if (lam1 < lam2) { - double bond_value + double bond_value = kernel_inv_vol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); local_A(I,0) += xba(0)*burgers[0]*bond_value; local_A(I,1) += xba(0)*burgers[1]*bond_value; @@ -449,7 +449,7 @@ using ATC_Utility::to_string; lammpsInterface_->int_allsum(&nSeg,&totalNumberSegments,1); // output - double volume = lammpsInterface_->domain_volume(); + double volume = lammpsInterface_->domain_volume(); stringstream ss; ss << "total dislocation line length = " << totalDislocationDensity; ss << " lines = " << totalNumberLines << " segments = " << totalNumberSegments; @@ -474,10 +474,10 @@ using ATC_Utility::to_string; segOutput.write_geometry(&segCoor,&segConn); OUTPUT_LIST segOut; segOut["burgers_vector"] = &segBurg; - segOutput.write_data(0,&segOut); + segOutput.write_data(0,&segOut); } #else - throw ATC_Error("unimplemented function compute_dislocation_density (DXA support not included"); + throw ATC_Error("unimplemented function compute_dislocation_density (DXA support not included"); #endif } diff --git a/lib/atc/ATC_TransferKernel.h b/lib/atc/ATC_TransferKernel.h index 2443940e7e..5ad350bc68 100644 --- a/lib/atc/ATC_TransferKernel.h +++ b/lib/atc/ATC_TransferKernel.h @@ -12,9 +12,9 @@ class KernelFunction; class ATC_TransferKernel : public ATC_Transfer { public: - + // constructor - ATC_TransferKernel(std::string groupName, + ATC_TransferKernel(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile = "none"); @@ -27,7 +27,7 @@ class ATC_TransferKernel : public ATC_Transfer { protected: /** routine to calculate matrix of kernel functions */ - + virtual void compute_kernel_matrix_molecule(); /** calculate projection on the fly*/ diff --git a/lib/atc/ATC_TransferPartitionOfUnity.cpp b/lib/atc/ATC_TransferPartitionOfUnity.cpp index 5d83fd8fd7..be3dae77dd 100644 --- a/lib/atc/ATC_TransferPartitionOfUnity.cpp +++ b/lib/atc/ATC_TransferPartitionOfUnity.cpp @@ -1,4 +1,4 @@ -// ATC headers +// ATC headers #include "ATC_TransferPartitionOfUnity.h" #include "ATC_Error.h" #include "FE_Engine.h" @@ -27,7 +27,7 @@ static double line_xg[line_ngauss], line_wg[line_ngauss]; namespace ATC { ATC_TransferPartitionOfUnity::ATC_TransferPartitionOfUnity( - string groupName, + string groupName, double ** & perAtomArray, LAMMPS_NS::Fix * thisFix, string matParamFile) @@ -67,7 +67,7 @@ namespace ATC { //------------------------------------------------------------------- // kinetic energy portion of stress - + /** * @class KineticTensor * @brief Class for computing the quantity - m v' (x) v' @@ -83,7 +83,7 @@ namespace ATC { double mvv2e = lammpsInterface_->mvv2e(); // [MV^2]-->[Energy] DENS_MAT & v = variationVelocity_; - + atomicTensor_.reset(nLocal_,6); for (int i = 0; i < nLocal_; i++) { int atomIdx = internalToAtom_(i); @@ -132,7 +132,7 @@ namespace ATC { ATC::LammpsInterface::instance()->stream_msg_once(".",false,false); } // first atom location - int lammps_j = internalToAtom_(j); + int lammps_j = internalToAtom_(j); xa.copy(xPointer_[lammps_j],3); for (int k = 0; k < numneigh[lammps_j]; ++k) { int lammps_k = firstneigh[lammps_j][k]; @@ -147,9 +147,9 @@ namespace ATC { lammpsInterface_->pair_force(lammps_j,lammps_k,rsq,fforce); fforce *= 0.5; // 1/2 sum_ab = sum_(ab) if (atomToElementMapType_ == LAGRANGIAN) { - double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; - double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; - double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; + double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; + double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; + double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; virial[0] =-delx*fforce*delX; virial[1] =-delx*fforce*delY; virial[2] =-delx*fforce*delZ; @@ -172,7 +172,7 @@ namespace ATC { for (int i = 0; i < line_ngauss; i++) { double lambda = line_xg[i]; xlambda = lambda*xab + xb; - + lammpsInterface_->periodicity_correction(xlambda.ptr()); feEngine_->shape_functions(xlambda,shp,node_list); // accumulate to nodes whose support overlaps the integration point @@ -242,7 +242,7 @@ namespace ATC { DENS_VEC xa(nsd_),xb(nsd_),xab(nsd_),xlambda(nsd_); for (int j = 0; j < nLocal_; j++) { // first atom location - int lammps_j = internalToAtom_(j); + int lammps_j = internalToAtom_(j); xa.copy(xPointer_[lammps_j],3); for (int k = 0; k < numneigh[lammps_j]; ++k) { int lammps_k = firstneigh[lammps_j][k]; @@ -260,9 +260,9 @@ namespace ATC { delz*variationVelocity_(j,2)); double flux_vec[3]; if (atomToElementMapType_ == LAGRANGIAN) { - double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; - double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; - double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; + double delX = xref_[lammps_j][0] - xref_[lammps_k][0]; + double delY = xref_[lammps_j][1] - xref_[lammps_k][1]; + double delZ = xref_[lammps_j][2] - xref_[lammps_k][2]; flux_vec[0] =fforce*delX; flux_vec[1] =fforce*delY; flux_vec[2] =fforce*delZ; @@ -276,7 +276,7 @@ namespace ATC { for (int i = 0; i < line_ngauss; i++) { double lambda = line_xg[i]; xlambda = lambda*xab + xb; - + lammpsInterface_->periodicity_correction(xlambda.ptr()); feEngine_->shape_functions(xlambda,shp,node_list); // accumulate to nodes whose support overlaps the integration point @@ -316,7 +316,7 @@ namespace ATC { field_to_prolongation_name(VELOCITY)); } // use of prolong assumes atom system contained within mesh - vbar_ = vbar->quantity(); + vbar_ = vbar->quantity(); // compute and store variation velocities of atoms for (int i = 0; i < nLocal_; i++) { int atomIdx = internalToAtom_(i); @@ -328,10 +328,10 @@ namespace ATC { } //------------------------------------------------------------------- - // calculation of the dislocation density tensor + // calculation of the dislocation density tensor void ATC_TransferPartitionOfUnity::compute_dislocation_density(DENS_MAT & A) { - + A.reset(nNodes_,9); #ifdef HAS_DXA double cnaCutoff = lammpsInterface_->near_neighbor_cutoff(); @@ -368,7 +368,7 @@ namespace ATC { DENS_MAT local_A(nNodes_,9); - local_A.zero(); + local_A.zero(); Array latticePeriodicity(3); latticePeriodicity(0) = (bool) periodicity[0]; latticePeriodicity(1) = (bool) periodicity[1]; @@ -406,7 +406,7 @@ namespace ATC { for (int i = 0; i < line_ngauss; i++) { double lambda = line_xg[i]; xlambda = lambda*xba + xa; - + lammpsInterface_->periodicity_correction(xlambda.ptr()); feEngine_->shape_functions(xlambda,shp,node_list); // accumulate to nodes whose support overlaps the integration point @@ -472,7 +472,7 @@ namespace ATC { } ATC::LammpsInterface::instance()->print_msg_once(ss.str()); ss.str(""); - DENS_VEC A_avg(9); + DENS_VEC A_avg(9); for (int i = 0; i < nNodes_; i++) { for (int j = 0; j < 9; j++) { A_avg(j) += A(i,j); @@ -480,9 +480,9 @@ namespace ATC { } A_avg /= nNodes_; ss << "average nodal dislocation density tensor = \n"; - ss << A_avg(0) << " " << A_avg(1) << " " << A_avg(2) << "\n"; - ss << A_avg(3) << " " << A_avg(4) << " " << A_avg(5) << "\n"; - ss << A_avg(6) << " " << A_avg(7) << " " << A_avg(8) << "\n"; + ss << A_avg(0) << " " << A_avg(1) << " " << A_avg(2) << "\n"; + ss << A_avg(3) << " " << A_avg(4) << " " << A_avg(5) << "\n"; + ss << A_avg(6) << " " << A_avg(7) << " " << A_avg(8) << "\n"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); if (nSeg > 0) { @@ -495,7 +495,7 @@ namespace ATC { segOutput.write_geometry(&segCoor,&segConn); OUTPUT_LIST segOut; segOut["burgers_vector"] = &segBurg; - segOutput.write_data(0,&segOut); + segOutput.write_data(0,&segOut); } #else throw ATC_Error("TransferParititionOfUnity::compute_dislocaton_density - unimplemented function"); diff --git a/lib/atc/ATC_TransferPartitionOfUnity.h b/lib/atc/ATC_TransferPartitionOfUnity.h index 5c224d7c8e..4d919cc9ef 100644 --- a/lib/atc/ATC_TransferPartitionOfUnity.h +++ b/lib/atc/ATC_TransferPartitionOfUnity.h @@ -9,9 +9,9 @@ namespace ATC { class ATC_TransferPartitionOfUnity : public ATC_Transfer { public: - + // constructor - ATC_TransferPartitionOfUnity(std::string groupName, + ATC_TransferPartitionOfUnity(std::string groupName, double **& perAtomArray, LAMMPS_NS::Fix * thisFix, std::string matParamFile = "none"); @@ -49,7 +49,7 @@ class ATC_TransferPartitionOfUnity : public ATC_Transfer { virtual void compute_dislocation_density(DENS_MAT & dislocation_density); private: - + DENS_MAT variationVelocity_; DENS_MAT vbar_; }; diff --git a/lib/atc/ATC_TypeDefs.h b/lib/atc/ATC_TypeDefs.h index 590cf15980..71f351494a 100644 --- a/lib/atc/ATC_TypeDefs.h +++ b/lib/atc/ATC_TypeDefs.h @@ -23,7 +23,7 @@ namespace ATC static const double kBeV_ = 8.617343e-5;// [eV/K] /** unsigned ints, when needed */ - typedef int INDEX; + typedef int INDEX; /** elementset integral */ enum ElementsetOperationType { @@ -53,13 +53,13 @@ namespace ATC FULL_DOMAIN=0, ATOM_DOMAIN, FE_DOMAIN, - FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE, + FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE, FULL_DOMAIN_FREE_ONLY }; /** domain decomposition */ enum DomainDecompositionType { REPLICATED_MEMORY=0, - DISTRIBUTED_MEMORY + DISTRIBUTED_MEMORY }; /** atomic weight specification */ enum AtomicWeightType { @@ -100,7 +100,7 @@ namespace ATC NUM_ATOM_TYPES }; /** field types */ - enum FieldName { + enum FieldName { TIME=-2, POSITION=-1, TEMPERATURE=0, // Intrinsic Fields @@ -114,9 +114,9 @@ namespace ATC ELECTRON_TEMPERATURE, ELECTRIC_POTENTIAL, ELECTRON_WAVEFUNCTION, - ELECTRON_WAVEFUNCTIONS, - ELECTRON_WAVEFUNCTION_ENERGIES, - FERMI_ENERGY, + ELECTRON_WAVEFUNCTIONS, + ELECTRON_WAVEFUNCTION_ENERGIES, + FERMI_ENERGY, MOMENTUM, PROJECTED_VELOCITY, KINETIC_TEMPERATURE, @@ -144,9 +144,9 @@ namespace ATC QUADRUPOLE_MOMENT, CAUCHY_BORN_ELASTIC_DEFORMATION_GRADIENT, DISLOCATION_DENSITY, - NUM_TOTAL_FIELDS + NUM_TOTAL_FIELDS }; - const int NUM_FIELDS = ELECTRON_WAVEFUNCTION+1; + const int NUM_FIELDS = ELECTRON_WAVEFUNCTION+1; #define NDIM 3 static const int FieldSizes[NUM_TOTAL_FIELDS] = { @@ -193,7 +193,7 @@ namespace ATC NDIM*NDIM // DISLOCATION_DENSITY }; - enum NodalAtomicFieldNormalization { + enum NodalAtomicFieldNormalization { NO_NORMALIZATION=0, VOLUME_NORMALIZATION, NUMBER_NORMALIZATION, MASS_NORMALIZATION, MASS_MATRIX @@ -209,7 +209,7 @@ namespace ATC enum FeIntQuadrature {NODAL, GAUSS1, GAUSS2, GAUSS3, FACE}; /** field name enum to string */ - inline FeIntQuadrature string_to_FIQ(const std::string &str) + inline FeIntQuadrature string_to_FIQ(const std::string &str) { if (str == "nodal") return NODAL; @@ -226,7 +226,7 @@ namespace ATC } /** field name enum to string */ - inline std::string field_to_string(const FieldName index) + inline std::string field_to_string(const FieldName index) { switch (index) { case TEMPERATURE: @@ -313,7 +313,7 @@ namespace ATC } /** string to field enum */ - inline FieldName string_to_field(const std::string & name) + inline FieldName string_to_field(const std::string & name) { if (name=="temperature") return TEMPERATURE; @@ -397,7 +397,7 @@ namespace ATC throw ATC_Error(name + " is not a valid field"); } - inline bool is_intrinsic(const FieldName & field_enum) + inline bool is_intrinsic(const FieldName & field_enum) { if (field_enum==TEMPERATURE || field_enum==DISPLACEMENT @@ -412,7 +412,7 @@ namespace ATC else return false; } - inline std::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)); @@ -421,7 +421,7 @@ namespace ATC throw ATC_Error("field "+field_to_string(index)+" is not an intrinsic field"); } } - inline std::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)); @@ -430,7 +430,7 @@ namespace ATC throw ATC_Error("field "+field_to_string(index)+" is not an intrinsic field"); } } - inline std::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)); } @@ -473,9 +473,9 @@ namespace ATC THERMO_ELASTIC, SPECIES // aka Mass }; - + /** rhs types */ - enum FluxType + enum FluxType { FLUX = 0, // has a source weighted by gradient of shape function SOURCE, // has a source term weighted by the shape function @@ -487,12 +487,12 @@ namespace ATC }; /** stiffness/ derivative of rhs types */ - enum StiffnessType + enum StiffnessType { - BB_STIFFNESS = 0, - NN_STIFFNESS, - BN_STIFFNESS, - NB_STIFFNESS, + BB_STIFFNESS = 0, + NN_STIFFNESS, + BN_STIFFNESS, + NB_STIFFNESS, NUM_STIFFNESS }; @@ -519,8 +519,8 @@ namespace ATC typedef std::set ESET; // elementset /** typedefs for N and B integrand functions */ - typedef std::set ARG_NAMES; - typedef std::map > ARGS; + typedef std::set ARG_NAMES; + typedef std::map > ARGS; typedef ATC::MatrixDependencyManager FIELD; typedef std::vector > GRAD_FIELD; typedef std::map > FIELDS; @@ -555,7 +555,7 @@ namespace ATC typedef std::map > OPEN_SURFACE; typedef std::map > VOLUME_SOURCE; typedef std::map > ATOMIC_DATA; - + /** typedefs for FE_Mesh */ typedef std::map > NODE_SET_MAP; typedef std::map > ELEMENT_SET_MAP; @@ -603,14 +603,14 @@ namespace ATC return true; } - inline std::string print_mask(const Array2D & rhsMask) + inline std::string print_mask(const Array2D & rhsMask) { std::string msg; - for (int i = 0; i < NUM_FIELDS; i++) { + for (int i = 0; i < NUM_FIELDS; i++) { FieldName field = (FieldName) i; std::string name = field_to_string(field); if (rhsMask(field,FLUX) - || rhsMask(field,SOURCE) + || rhsMask(field,SOURCE) || rhsMask(field,PRESCRIBED_SOURCE) || rhsMask(field,ROBIN_SOURCE) || rhsMask(field,OPEN_SOURCE) diff --git a/lib/atc/Array.h b/lib/atc/Array.h index c29729d320..1c3f56a35a 100644 --- a/lib/atc/Array.h +++ b/lib/atc/Array.h @@ -12,8 +12,8 @@ namespace ATC_matrix { /** - * @class Array - * @brief Base class for creating, sizing and operating on 1-D arrays of data + * @class Array + * @brief Base class for creating, sizing and operating on 1-D arrays of data */ template @@ -24,7 +24,7 @@ public: Array(const Array& A); virtual ~Array(); - // Resize and reinitialize the array + // Resize and reinitialize the array virtual void reset(int len); //* resizes the matrix, copy what fits default to OFF virtual void resize(int len, bool copy=false); @@ -38,17 +38,17 @@ public: int size() const; // Do I have this element? bool has_member(T val) const; - // range + // range bool check_range(T min, T max) const; void range(T & min, T & max) const; // search an ordered array int index(T& val) const; // Return pointer to internal data - const T* data() const; + const T* data() const; T* ptr() const; // print void print(std::string name = "") const; - // Dump templated type to disk; operation not safe for all types + // Dump templated type to disk; operation not safe for all types void write_restart(FILE *f) const; protected: @@ -66,7 +66,7 @@ public: virtual ~AliasArray(); virtual AliasArray& operator= (const Array &other); virtual AliasArray& operator= (const T &value); - + const T& operator() (int i) const; int size() const; T* ptr() const; @@ -135,8 +135,8 @@ void Array::resize(int len, bool copy) { delete[] data_; data_ = new T[len_]; for (int i = 0 ; i < len_; i++) { - if (i < temp.size()) - data_[i] = temp.data_[i]; + if (i < temp.size()) + data_[i] = temp.data_[i]; } } else { @@ -269,7 +269,7 @@ AliasArray::AliasArray(const AliasArray & other) { // for a mem continguous slice template -AliasArray::AliasArray(int len, T * ptr) { +AliasArray::AliasArray(int len, T * ptr) { len_ = len; data_ = ptr; } @@ -281,8 +281,8 @@ AliasArray::AliasArray(const Array& A) { } template -AliasArray::~AliasArray(void) { - len_ = 0; +AliasArray::~AliasArray(void) { + len_ = 0; data_ = nullptr; // trick base class into not deleting parent data } diff --git a/lib/atc/Array2D.h b/lib/atc/Array2D.h index 37b7dcb3c9..de255563e3 100644 --- a/lib/atc/Array2D.h +++ b/lib/atc/Array2D.h @@ -20,20 +20,20 @@ namespace ATC_matrix { template class Array2D { -public: +public: Array2D(); Array2D(int nrows, int ncols); Array2D(const Array2D& A); // copy constructor ~Array2D(); - + // Resize and reinitalize matrix void reset(int nrows, int ncols); // Access method to get the (i,j) element: - T& operator() (int i, int j); - // Access method to get the i-th col - AliasArray column(int i) const; + T& operator() (int i, int j); + // Access method to get the i-th col + AliasArray column(int i) const; // Access method to get the (i,j) element: - const T& operator() (int i, int j) const; + const T& operator() (int i, int j) const; // Copy operator Array2D& operator= (const Array2D& other); // assignment operator @@ -48,10 +48,10 @@ public: // Dump templated type to disk; operation not safe for all types void write_restart(FILE *f) const; -private: +private: int nrows_, ncols_; - T *data_; -}; + T *data_; +}; template Array2D::Array2D() { @@ -172,7 +172,7 @@ template Array2D::~Array2D() { if (data_ != nullptr) delete[] data_; -} +} template void Array2D::print(std::string name) const { diff --git a/lib/atc/AtomToMoleculeTransfer.cpp b/lib/atc/AtomToMoleculeTransfer.cpp index 21293967bd..e6c84fb6bc 100644 --- a/lib/atc/AtomToMoleculeTransfer.cpp +++ b/lib/atc/AtomToMoleculeTransfer.cpp @@ -1,4 +1,4 @@ -// ATC headers +// ATC headers #include "AtomToMoleculeTransfer.h" #include "ATC_Method.h" @@ -19,15 +19,15 @@ namespace ATC { { atomPositions_->register_dependence(this); } - + //-------------------------------------------------------- - // Destructor + // Destructor //-------------------------------------------------------- SmallMoleculeCentroid::~SmallMoleculeCentroid() { atomPositions_->remove_dependence(this); } - + //-------------------------------------------------------- // Quantity //-------------------------------------------------------- @@ -42,7 +42,7 @@ namespace ATC { for (int i = 0; i < nLocalMol; i++) { const set & atomsLocalMolArray = smallMoleculeSet_->atoms_by_local_molecule(i); set::const_iterator atomsLocalMolID; - double totalSourceMol = 0.0; // for total source + double totalSourceMol = 0.0; // for total source for (atomsLocalMolID = atomsLocalMolArray.begin(); atomsLocalMolID != atomsLocalMolArray.end(); atomsLocalMolID++) { totalSourceMol += sourceMatrix(*atomsLocalMolID,0); } // compute total source @@ -62,11 +62,11 @@ namespace ATC { } } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class SmallMoleculeDipoleMoment - //-------------------------------------------------------- + //-------------------------------------------------------- //-------------------------------------------------------- //-------------------------------------------------------- @@ -100,8 +100,8 @@ namespace ATC { quantity_.reset(nLocalMol,nsd); double dx[3]; - //call the SmallMoleculeCentroid here to find Centroid .... - const DENS_MAT & centroidMolMatrix(centroid_->quantity()); + //call the SmallMoleculeCentroid here to find Centroid .... + const DENS_MAT & centroidMolMatrix(centroid_->quantity()); for (int i = 0; i < nLocalMol; i++) { const set & atomsLocalMolArray = smallMoleculeSet_->atoms_by_local_molecule(i); set::const_iterator atomsLocalMolID;; @@ -111,15 +111,15 @@ namespace ATC { } lammps->minimum_image(dx[0], dx[1], dx[2]); for(int j = 0; j < nsd; j++) { - quantity_(i,j) += sourceMatrix(*atomsLocalMolID,0) * dx[j]; - } + quantity_(i,j) += sourceMatrix(*atomsLocalMolID,0) * dx[j]; + } } } } //-------------------------------------------------------- // Class SmallMoleculeQuadrupoleMoment - //-------------------------------------------------------- + //-------------------------------------------------------- //-------------------------------------------------------- //-------------------------------------------------------- @@ -202,9 +202,9 @@ namespace ATC { // reallocate memory only if sizing has changed const SPAR_MAT & shapeFunctionMatrix(shapeFunction_->quantity()); quantity_.resize(shapeFunctionMatrix.nCols(),sourceMatrix.nCols()); - + local_restriction(sourceMatrix,shapeFunctionMatrix); - + // communicate for total restriction int count = quantity_.nRows()*quantity_.nCols(); lammpsInterface_->allsum(_workspace_.ptr(),quantity_.ptr(),count); @@ -222,4 +222,4 @@ namespace ATC { _workspace_.reset(quantity_.nRows(),quantity_.nCols()); } -} // end namespace +} // end namespace diff --git a/lib/atc/AtomToMoleculeTransfer.h b/lib/atc/AtomToMoleculeTransfer.h index c628ee356f..6ebfa2f9a2 100644 --- a/lib/atc/AtomToMoleculeTransfer.h +++ b/lib/atc/AtomToMoleculeTransfer.h @@ -1,4 +1,4 @@ -// A class for defining transfer operations molecular centers of mass (centroid), dipole moments, quadrupole moments +// A class for defining transfer operations molecular centers of mass (centroid), dipole moments, quadrupole moments #ifndef ATOM_TO_MOLECULE_TRANSFER_H #define ATOM_TO_MOLECULE_TRANSFER_H @@ -15,18 +15,18 @@ namespace ATC { // forward declarations class ATC_Method; - /** + /** * @class PerMoleculeQuantity * */ - + template class PerMoleculeQuantity : public DenseMatrixTransfer { - + public: PerMoleculeQuantity(ATC_Method * atc):DenseMatrixTransfer(), atc_(atc) {}; - + virtual ~PerMoleculeQuantity() {}; protected: @@ -34,8 +34,8 @@ namespace ATC { /** utility object for atc information */ ATC_Method * atc_; - private: - + private: + //do not define PerMoleculeQuantity(); @@ -48,7 +48,7 @@ namespace ATC { */ template class AtomToSmallMoleculeTransfer : public PerMoleculeQuantity { - + public: //constructor @@ -61,20 +61,20 @@ namespace ATC { source_->register_dependence(this); smallMoleculeSet_->register_dependence(this); }; - - //destructor + + //destructor virtual ~AtomToSmallMoleculeTransfer() { source_->remove_dependence(this); smallMoleculeSet_->remove_dependence(this); }; - // apply transfer operator + // apply transfer operator void reset_quantity() const { const DenseMatrix & sourceMatrix(source_->quantity()); int nLocalMol = smallMoleculeSet_->local_molecule_count(); - (this->quantity_).reset(nLocalMol,sourceMatrix.nCols()); + (this->quantity_).reset(nLocalMol,sourceMatrix.nCols()); for (int i = 0; i < nLocalMol ; i++) { const std::set & atomsLocalMolArray = smallMoleculeSet_->atoms_by_local_molecule(i); std::set::const_iterator atomsLocalMolID; @@ -86,29 +86,29 @@ namespace ATC { } }; - protected: + protected: - // pointer to source atomic quantity data + // pointer to source atomic quantity data PerAtomQuantity * source_; - // pointer to molecule data + // pointer to molecule data SmallMoleculeSet * smallMoleculeSet_; private: // do not define AtomToSmallMoleculeTransfer(); - + }; /** - * @class SmallMoleculeCentroid + * @class SmallMoleculeCentroid * @brief Class for defining objects to transfer molecular centroid (center of mass) */ class SmallMoleculeCentroid : public AtomToSmallMoleculeTransfer { - public: + public: //constructor SmallMoleculeCentroid(ATC_Method * atc, PerAtomQuantity * source, SmallMoleculeSet * smallMoleculeSet, PerAtomQuantity * atomPositions); @@ -116,15 +116,15 @@ namespace ATC { //destructor virtual ~SmallMoleculeCentroid(); - // apply transfer operator + // apply transfer operator virtual void reset_quantity() const; - - protected: - + + protected: + // pointer to source atomic quantity date : positions of atoms in a molecule PerAtomQuantity * atomPositions_; - private: + private: //do not define SmallMoleculeCentroid(); @@ -133,28 +133,28 @@ namespace ATC { /** * @class SmallMoleculeDipoleMoment - * @brief Class for defining objects to transfer molecular dipole moments + * @brief Class for defining objects to transfer molecular dipole moments */ class SmallMoleculeDipoleMoment : public SmallMoleculeCentroid { - public: - + public: + //constructor SmallMoleculeDipoleMoment(ATC_Method * atc, PerAtomQuantity * source, SmallMoleculeSet * smallMoleculeSet, PerAtomQuantity * atomPositions, SmallMoleculeCentroid * centroid); - + //destructor virtual ~SmallMoleculeDipoleMoment(); - // apply transfer operator + // apply transfer operator virtual void reset_quantity() const; - protected: + protected: - //pointer to the centroid data + //pointer to the centroid data SmallMoleculeCentroid * centroid_; - private: + private: //do not define SmallMoleculeDipoleMoment(); @@ -162,14 +162,14 @@ namespace ATC { }; /** - * @class AtomToFeTransfer + * @class AtomToFeTransfer * @brief Class for defining objects to transfer molecular quadrupole moments */ class SmallMoleculeQuadrupoleMoment : public SmallMoleculeCentroid { - public: + public: //constructor SmallMoleculeQuadrupoleMoment(ATC_Method * atc, PerAtomQuantity * source, SmallMoleculeSet * smallMoleculeSet, PerAtomQuantity * atomPositions, SmallMoleculeCentroid * centroid); @@ -179,10 +179,10 @@ namespace ATC { //apply transfer operator virtual void reset_quantity() const; - + protected: - //pointer to the centroid data + //pointer to the centroid data SmallMoleculeCentroid * centroid_; private: @@ -190,7 +190,7 @@ namespace ATC { //do not define SmallMoleculeQuadrupoleMoment(); - }; + }; /** * @class MotfShapeFunctionRestriction @@ -201,11 +201,11 @@ namespace ATC { class MotfShapeFunctionRestriction : public MatToMatTransfer { public: - + // constructor MotfShapeFunctionRestriction(PerMoleculeQuantity * source, SPAR_MAN * shapeFunction); - + // destructor virtual ~MotfShapeFunctionRestriction(); @@ -218,8 +218,8 @@ namespace ATC { SPAR_MAN * shapeFunction_; /** persistent workspace */ - - + + mutable DENS_MAT _workspace_; /** applies restriction operation on this processor */ @@ -236,4 +236,4 @@ namespace ATC { } #endif - + diff --git a/lib/atc/AtomicRegulator.cpp b/lib/atc/AtomicRegulator.cpp index 9dfcdaab51..1d2b5d1d85 100644 --- a/lib/atc/AtomicRegulator.cpp +++ b/lib/atc/AtomicRegulator.cpp @@ -13,7 +13,7 @@ using std::pair; namespace ATC { - + // only one regulator method at time, i.e. fixed & flux, thermo & elastic // regulator manages lambda variables, creates new ones when requested with dimensions and zero ics (map of tag to lambda) // regulator keeps track of which lambda are being used, unused lambdas deleted (map of tag to bool), all tags set to unused on start of initialization @@ -168,7 +168,7 @@ namespace ATC { fix_modify AtC control \n - physics_type (string) = thermal | momentum\n - solution_parameter (string) = max_iterations | tolerance\n - + fix_modify AtC transfer control max_iterations \n - max_iterations (int) = maximum number of iterations that will be used by iterative matrix solvers\n @@ -209,14 +209,14 @@ namespace ATC { foundMatch = true; } - /*! \page man_localized_lambda fix_modify AtC control localized_lambda + /*! \page man_localized_lambda fix_modify AtC control localized_lambda \section syntax - fix_modify AtC control localized_lambda + fix_modify AtC control localized_lambda \section examples fix_modify atc control localized_lambda on \n \section description Turns on localization algorithms for control algorithms to restrict the influence of FE coupling or boundary conditions to a region near the boundary of the MD region. Control algorithms will not affect atoms in elements not possessing faces on the boundary of the region. Flux-based control is localized via row-sum lumping while quantity control is done by solving a truncated matrix equation. - \section restrictions + \section restrictions \section related \section default Default is off. @@ -233,16 +233,16 @@ namespace ATC { } } - - - /*! \page man_lumped_lambda_solve fix_modify AtC control lumped_lambda_solve + + + /*! \page man_lumped_lambda_solve fix_modify AtC control lumped_lambda_solve \section syntax - fix_modify AtC control lumped_lambda_solve + fix_modify AtC control lumped_lambda_solve \section examples fix_modify atc control lumped_lambda_solve on \n \section description Command to use or not use lumped matrix for lambda solve - \section restrictions + \section restrictions \section related \section default */ @@ -260,12 +260,12 @@ namespace ATC { /*! \page man_mask_direction fix_modify AtC control mask_direction \section syntax - fix_modify AtC control mask_direction + fix_modify AtC control mask_direction \section examples fix_modify atc control mask_direction 0 on \n \section description Command to mask out certain dimensions from the atomic regulator - \section restrictions + \section restrictions \section related \section default */ @@ -404,7 +404,7 @@ namespace ATC { //-------------------------------------------------------- // apply_pre_predictor: // applies the controller in the pre-predictor - // phase of the time integrator + // phase of the time integrator //-------------------------------------------------------- void AtomicRegulator::apply_pre_predictor(double dt, int timeStep) { @@ -415,7 +415,7 @@ namespace ATC { //-------------------------------------------------------- // apply_mid_predictor: // applies the controller in the mid-predictor - // phase of the time integrator + // phase of the time integrator //-------------------------------------------------------- void AtomicRegulator::apply_mid_predictor(double dt, int timeStep) { @@ -426,14 +426,14 @@ namespace ATC { //-------------------------------------------------------- // apply_post_predictor: // applies the controller in the post-predictor - // phase of the time integrator + // phase of the time integrator //-------------------------------------------------------- void AtomicRegulator::apply_post_predictor(double dt, int timeStep) { if (timeStep % howOften_==0) // apply full integration scheme, including filter regulatorMethod_->apply_post_predictor(dt); } - + //-------------------------------------------------------- // apply_pre_corrector: // applies the controller in the pre-corrector phase @@ -441,7 +441,7 @@ namespace ATC { //-------------------------------------------------------- void AtomicRegulator::apply_pre_corrector(double dt, int timeStep) { - if (timeStep % howOften_==0) // apply full integration scheme, including filter + if (timeStep % howOften_==0) // apply full integration scheme, including filter regulatorMethod_->apply_pre_corrector(dt); } @@ -497,7 +497,7 @@ namespace ATC { //-------------------------------------------------------- // add_to_rhs: - // adds any controller contributions to the FE rhs + // adds any controller contributions to the FE rhs //-------------------------------------------------------- void AtomicRegulator::add_to_rhs(FIELDS & rhs) { @@ -509,7 +509,7 @@ namespace ATC { // Class RegulatorMethod //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -545,7 +545,7 @@ namespace ATC { // Class RegulatorShapeFunction //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -604,7 +604,7 @@ namespace ATC { interscaleManager.add_dense_matrix_int(overlapToNodeMap_, regulatorPrefix_+"OverlapToNodeMap"); } - + } //-------------------------------------------------------- @@ -690,7 +690,7 @@ namespace ATC { //-------------------------------------------------------- void RegulatorShapeFunction::compute_sparsity(void) { - + // first get local pattern from N N^T int nNodeOverlap = nodeToOverlapMap_->size(); DENS_MAT tmpLocal(nNodeOverlap,nNodeOverlap); @@ -699,7 +699,7 @@ namespace ATC { if (myShapeFunctionMatrix.nRows() > 0) { tmpLocal = myShapeFunctionMatrix.transMat(myShapeFunctionMatrix); } - + // second accumulate total pattern across processors LammpsInterface::instance()->allsum(tmpLocal.ptr(), tmp.ptr(), tmp.size()); // third extract non-zero entries & construct sparse template @@ -724,13 +724,13 @@ namespace ATC { { // assemble N^T W N with appropriate weighting matrix - + DIAG_MAT weights; if (shapeFunctionMatrix_->nRows() > 0) { weights.reset(weights_->quantity()); } matrixSolver_->assemble_matrix(weights); - + // solve on overlap nodes int nNodeOverlap = nodeToOverlapMap_->size(); DENS_MAT rhsOverlap(nNodeOverlap,rhs.nCols()); @@ -747,7 +747,7 @@ namespace ATC { tempLambda = 0.; } } - + // map solution back to all nodes map_overlap_to_unique(lambdaOverlap,lambda); } @@ -761,8 +761,8 @@ namespace ATC { RegulatorMethod::reset_nlocal(); nLocal_ = atomicRegulator_->nlocal(); - - + + //compute_sparsity(); } @@ -903,7 +903,7 @@ namespace ATC { void LambdaMatrixSolver::assemble_matrix(DIAG_MAT & weights) { // form matrix : sum_a N_Ia * W_a * N_Ja - + SPAR_MAT lambdaMatrixLocal(matrixTemplate_.quantity()); if (weights.nRows()>0) lambdaMatrixLocal.weighted_least_squares(shapeFunctionMatrix_->quantity(),weights); @@ -941,13 +941,13 @@ namespace ATC { void LambdaMatrixSolverLumped::assemble_matrix(DIAG_MAT & weights) { LambdaMatrixSolver::assemble_matrix(weights); - + lumpedMatrix_ = lambdaMatrix_.row_sum_lump(); } - void LambdaMatrixSolverLumped::execute(VECTOR & rhs, VECTOR & lambda) + void LambdaMatrixSolverLumped::execute(VECTOR & rhs, VECTOR & lambda) { - + // solve lumped equation const set & applicationNodes(applicationNodes_->quantity()); const INT_ARRAY & nodeToOverlapMap(nodeToOverlapMap_->quantity()); diff --git a/lib/atc/AtomicRegulator.h b/lib/atc/AtomicRegulator.h index 360af3a4f6..24a5517dc2 100644 --- a/lib/atc/AtomicRegulator.h +++ b/lib/atc/AtomicRegulator.h @@ -44,7 +44,7 @@ namespace ATC { //-------------------------------------------------------- class AtomicRegulator { - + public: /** linear solver types */ @@ -68,14 +68,14 @@ namespace ATC { GHOST_FLUX, FIXED }; - + // constructor AtomicRegulator(ATC_Coupling * atc, const std::string & regulatorPrefix = ""); - + // destructor virtual ~AtomicRegulator(); - + /** parser/modifier */ virtual bool modify(int narg, char **arg); @@ -87,11 +87,11 @@ namespace ATC { /** initialization of method data */ virtual void initialize(); - + /** add output information */ virtual void output(OUTPUT_LIST & outputData) const; virtual double compute_vector(int /* n */) const {return 0;} - + /** final work at the end of a run */ virtual void finish(); @@ -101,7 +101,7 @@ namespace ATC { /** set up atom to material identification */ virtual void reset_atom_materials(const Array & elementToMaterialMap, const MatrixDependencyManager * atomElement); - + // application steps /** apply the regulator in the pre-predictor phase */ virtual void apply_pre_predictor(double dt, int timeStep); @@ -136,7 +136,7 @@ namespace ATC { virtual void compute_boundary_flux(FIELDS & fields); /** add contributions (if any) to the finite element right-hand side */ virtual void add_to_rhs(FIELDS & rhs); - + // 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 std::string tag, int nCols); @@ -158,7 +158,7 @@ namespace ATC { /** access for number of spatial dimensions */ int nsd() {return nsd_;}; /** access for number of local atoms */ - int nlocal() {return nLocal_;}; + int nlocal() {return nLocal_;}; /** access for boundary integration methods */ BoundaryIntegrationType boundary_integration_type() {return boundaryIntegrationType_;}; @@ -176,7 +176,7 @@ namespace ATC { /** check to see if this direction is being used */ bool apply_in_direction(int i) const {return applyInDirection_[i];}; - + /** checks if there are any fixed nodes in the MD region */ bool md_fixed_nodes(FieldName fieldName = NUM_TOTAL_FIELDS) const; @@ -185,7 +185,7 @@ namespace ATC { /** returns prefix tag for regulator */ const std::string & regulator_prefix() const {return regulatorPrefix_;}; - + protected: // methods @@ -200,11 +200,11 @@ namespace ATC { /** sets all data to be used */ void set_all_data_to_used(); - + // data /** point to atc_transfer object */ ATC_Coupling * atc_; - + /** how often in number of time steps regulator is applied */ int howOften_; @@ -227,7 +227,7 @@ namespace ATC { RegulatorTargetType regulatorTarget_; /** regulator fe coupling type flag */ RegulatorCouplingType couplingMode_; - + /** number of nodes */ int nNodes_; /** number of spatial dimensions */ @@ -241,7 +241,7 @@ namespace ATC { /** restrict application in certain directions */ std::vector applyInDirection_; - + // method pointers /** time filtering object */ TimeFilter * timeFilter_; @@ -256,30 +256,30 @@ namespace ATC { const std::string regulatorPrefix_; private: - + // DO NOT define this AtomicRegulator(); - + }; /** * @class RegulatorMethod * @brief Base class for implementation of control algorithms */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class RegulatorMethod //-------------------------------------------------------- //-------------------------------------------------------- - + class RegulatorMethod { - + public: - + RegulatorMethod(AtomicRegulator * atomicRegulator, const std::string & regulatorPrefix = ""); - + virtual ~RegulatorMethod(){}; /** instantiate all needed data */ @@ -294,7 +294,7 @@ namespace ATC { /** set up atom to material identification */ virtual void reset_atom_materials(const Array & /* elementToMaterialMap */, const MatrixDependencyManager * /* atomElement */){}; - + /** applies regulator to atoms in the pre-predictor phase */ virtual void apply_pre_predictor(double /* dt */){}; @@ -340,7 +340,7 @@ namespace ATC { /** pack fields for restart */ virtual void pack_fields(RESTART_LIST & /* data */){}; - + protected: //data @@ -372,7 +372,7 @@ namespace ATC { // DO NOT define this RegulatorMethod(); - + }; /** @@ -389,14 +389,14 @@ namespace ATC { // of N^T w N lambda = rhs //-------------------------------------------------------- //-------------------------------------------------------- - + class RegulatorShapeFunction : public RegulatorMethod { - + public: - + RegulatorShapeFunction(AtomicRegulator * atomicRegulator, const std::string & regulatorPrefix = ""); - + virtual ~RegulatorShapeFunction(); /** instantiate all needed data */ @@ -524,18 +524,18 @@ namespace ATC { // Class LambdaMatrixSolver //-------------------------------------------------------- //-------------------------------------------------------- - + class LambdaMatrixSolver { - + public: - + LambdaMatrixSolver(SPAR_MAN & matrixTemplate, SPAR_MAN * shapeFunctionMatrix, int maxIterations, double tolerance); - + virtual ~LambdaMatrixSolver(){}; /** assemble the matrix */ virtual void assemble_matrix(DIAG_MAT & weights); - + /** execute the solver */ virtual void execute(VECTOR & rhs, VECTOR & lambda)=0; @@ -549,7 +549,7 @@ namespace ATC { /** matrix used to solve for lambda */ SPAR_MAT lambdaMatrix_; - + /** maximum number of iterations */ int maxIterations_; @@ -560,7 +560,7 @@ namespace ATC { // DO NOT define this LambdaMatrixSolver(); - + }; //-------------------------------------------------------- @@ -568,21 +568,21 @@ namespace ATC { // Class LambdaMatrixSolverLumped //-------------------------------------------------------- //-------------------------------------------------------- - + class LambdaMatrixSolverLumped : public LambdaMatrixSolver { - + public: - + LambdaMatrixSolverLumped(SPAR_MAN & matrixTemplate, SPAR_MAN * shapeFunctionMatrix, int maxIterations, double tolerance, const SetDependencyManager * applicationNodes, const NodeToSubset * nodeToOverlapMap); - + virtual ~LambdaMatrixSolverLumped(){}; /** assemble the matrix */ virtual void assemble_matrix(DIAG_MAT & weights); - + /** execute the solver */ - virtual void execute(VECTOR & rhs, VECTOR & lambda); - + virtual void execute(VECTOR & rhs, VECTOR & lambda); + protected: /** lumped version of the matrix governing lambda */ @@ -598,7 +598,7 @@ namespace ATC { // DO NOT define this LambdaMatrixSolverLumped(); - + }; //-------------------------------------------------------- @@ -606,18 +606,18 @@ namespace ATC { // Class LambdaMatrixSolverCg //-------------------------------------------------------- //-------------------------------------------------------- - + class LambdaMatrixSolverCg : public LambdaMatrixSolver { - + public: - + LambdaMatrixSolverCg(SPAR_MAN & matrixTemplate, SPAR_MAN * shapeFunctionMatrix, int maxIterations, double tolerance); - + virtual ~LambdaMatrixSolverCg(){}; - + /** execute the solver */ - virtual void execute(VECTOR & rhs, VECTOR & lambda); - + virtual void execute(VECTOR & rhs, VECTOR & lambda); + protected: @@ -625,7 +625,7 @@ namespace ATC { // DO NOT define this LambdaMatrixSolverCg(); - + }; }; diff --git a/lib/atc/BodyForce.cpp b/lib/atc/BodyForce.cpp index ecef3749b7..30b87f90a3 100644 --- a/lib/atc/BodyForce.cpp +++ b/lib/atc/BodyForce.cpp @@ -16,14 +16,14 @@ using std::vector; namespace ATC { BodyForceViscous::BodyForceViscous( - fstream &fileId, std::map & parameters) + fstream &fileId, std::map & parameters) : BodyForce(), gamma_(0) { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); std::vector line; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; double value = str2dbl(line[1]); if (line[0] == "gamma") { diff --git a/lib/atc/BodyForce.h b/lib/atc/BodyForce.h index 10d7cf66c1..bdf7c991db 100644 --- a/lib/atc/BodyForce.h +++ b/lib/atc/BodyForce.h @@ -9,7 +9,7 @@ namespace ATC { /** - * @class BodyForce + * @class BodyForce * @brief Base class for models of body forces in the momentum eqn */ @@ -32,7 +32,7 @@ namespace ATC { BodyForceViscous(std::fstream &matfile,std::map & parameters); virtual ~BodyForceViscous() {}; virtual bool body_force(const FIELD_MATS &fields, - DENS_MAT &flux) const + DENS_MAT &flux) const { FIELD_MATS::const_iterator v_field = fields.find(VELOCITY); const DENS_MAT & v = v_field->second; @@ -49,20 +49,20 @@ namespace ATC { class BodyForceElectricField : public BodyForce { public: - BodyForceElectricField(std::fstream & /* matfile */,std::map & /* parameters */) + BodyForceElectricField(std::fstream & /* matfile */,std::map & /* parameters */) { throw ATC_Error("unimplemented due to issues with accessing electric field"); } virtual ~BodyForceElectricField() {}; virtual bool body_force(const FIELD_MATS &fields, - DENS_MAT &flux) const + DENS_MAT &flux) const { FIELD_MATS::const_iterator v_field = fields.find(VELOCITY); const DENS_MAT & v = v_field->second; int nNodes = v.nRows(); - flux.reset(nNodes,1); + flux.reset(nNodes,1); return true; } }; } -#endif +#endif diff --git a/lib/atc/CBLattice.cpp b/lib/atc/CBLattice.cpp index c50b8eb3d5..a7d8d750b9 100644 --- a/lib/atc/CBLattice.cpp +++ b/lib/atc/CBLattice.cpp @@ -12,7 +12,7 @@ namespace ATC { std::vector::iterator R(ref_coords_.begin()), Rp; const double TOL = 1.0e-6 * R->dot(*R); - for (; R!=ref_coords_.end(); R++, r++) { + for (; R!=ref_coords_.end(); R++, r++) { for (Rp=R+1; Rp!=ref_coords_.end(); Rp++) { if (sum_difference_squared(*Rp, *R) < TOL) { ref_coords_.erase(R--); @@ -59,13 +59,13 @@ namespace ATC { fid << ((i+1)%3==0 ? "\n" : " "); } fid << "\nCELLS "< cur_bond_len_; //*> Bond lengths (current) std::vector ref_coords_; //*> Atom coordinates (ref) DENS_MAT F_; //*> Deformation gradient }; /** - * @class CBLattice - * @brief Base class that generates a virtual atom clusters given a lattice and + * @class CBLattice + * @brief Base class that generates a virtual atom clusters given a lattice and * a deformation gradient. */ - + class CBLattice { protected: @@ -76,7 +76,7 @@ namespace ATC public: //* Operator that outputs the lattice and basis to a stream. friend std::ostream& operator<<(std::ostream& o, const CBLattice& lattice); - CBLattice(const MATRIX &N, const MATRIX &B); + CBLattice(const MATRIX &N, const MATRIX &B); //* generates the virtual atom cluster void atom_cluster(const MATRIX &F, double cutoff, AtomCluster &v); @@ -87,7 +87,7 @@ namespace ATC }; // hash functions: a, b, c must in range [-128, 127] inline int hash(int a,int b,int c) {return(a+128)|((b+128)<<8)|((c+128)<<16);} - inline void unhash(int r, int &a, int &b, int &c) + inline void unhash(int r, int &a, int &b, int &c) { a = (r&0xFF) - 128; b = ((r>>8)&0xFF) - 128; diff --git a/lib/atc/CG.h b/lib/atc/CG.h index 7821a495b9..975861f9c3 100644 --- a/lib/atc/CG.h +++ b/lib/atc/CG.h @@ -4,28 +4,28 @@ // CG solves the symmetric positive definite linear // system Ax=b using the Conjugate Gradient method. // -// CG follows the algorithm described on p. 15 in the +// CG follows the algorithm described on p. 15 in the // SIAM Templates book. // // The return value indicates convergence within max_iter (input) // iterations (0), or no convergence within max_iter iterations (1). // // Upon successful return, output arguments have the following values: -// +// // x -- approximate solution to Ax = b // max_iter -- the number of iterations performed before the // tolerance was reached // tol -- the residual after the final iteration -// +// //***************************************************************** /** - * @class CG - * @brief Base class for solving the linear system Ax=b using the Conjugate Gradient method + * @class CG + * @brief Base class for solving the linear system Ax=b using the Conjugate Gradient method */ template < class Matrix, class Vector, class DataVector, class Preconditioner, class Real > -int +int CG(const Matrix &A, Vector &x, const DataVector &b, const Preconditioner &M, int &max_iter, Real &tol) { Real resid; DenseVector p, z, q; @@ -44,9 +44,9 @@ CG(const Matrix &A, Vector &x, const DataVector &b, const Preconditioner &M, int // Implicit assumption that only diagonal matrices are being used for preconditioning Preconditioner Minv = M.inv(); - if (normb == 0.0) + if (normb == 0.0) normb = 1; - + if ((resid = r.norm() / normb) <= tol) { tol = resid; max_iter = 0; @@ -56,7 +56,7 @@ CG(const Matrix &A, Vector &x, const DataVector &b, const Preconditioner &M, int for (int i = 0; i < max_iter; i++) { z = Minv*r; rho = r.dot(z); - + if (i == 0) p = z; else { @@ -64,18 +64,18 @@ CG(const Matrix &A, Vector &x, const DataVector &b, const Preconditioner &M, int tmp = p*beta; p = z + tmp; } - + q = A*p; alpha = rho / p.dot(q); x += p*alpha; r -= q*alpha; - - if ((resid = r.norm() / normb) <= tol) + + if ((resid = r.norm() / normb) <= tol) { tol = resid; max_iter = i+1; - return 0; + return 0; } rho_1 = rho; } diff --git a/lib/atc/CauchyBorn.cpp b/lib/atc/CauchyBorn.cpp index 81f7b4e1a8..f00912786d 100644 --- a/lib/atc/CauchyBorn.cpp +++ b/lib/atc/CauchyBorn.cpp @@ -32,7 +32,7 @@ namespace ATC { DENS_MAT L0; DENS_MAT_VEC M0; - // If temperature is nonzero then allocate space for + // If temperature is nonzero then allocate space for // dynamical matrix and its derivative with respect to F. if (finite_temp) { D.reset(3,3); @@ -42,11 +42,11 @@ namespace ATC { l0.reset(3); } - if (F) *F = 0.0; + if (F) *F = 0.0; // if using EAM potential, calculate embedding function and derivatives if (args.potential->terms.embedding) { - + for (INDEX a=0; arho(pair.d); @@ -58,7 +58,7 @@ namespace ATC { DENS_MAT rR = tensor_product(pair.r, pair.R); L0.add_scaled(rR, pair.di*pair.rho_r); DENS_MAT rr = tensor_product(pair.r, pair.r); - rr *= pair.di*pair.di*(pair.rho_rr - pair.di*pair.rho_r); + rr *= pair.di*pair.di*(pair.rho_rr - pair.di*pair.rho_r); diagonal(rr) += pair.di*pair.rho_r; for (int i = 0; i < 3; i++) { for (int k = 0; k < 3; k++) { @@ -96,7 +96,7 @@ namespace ATC { // Loop on all cluster atoms (origin atom not included). for (INDEX a=0; aterms.pairwise) { + if (args.potential->terms.pairwise) { if (F) *F += 0.5*args.potential->phi(pair.d); pair.phi_r = args.potential->phi_r(pair.d); pairwise_stress(pair, s); @@ -104,7 +104,7 @@ namespace ATC { if (args.potential->terms.embedding) { pair.F_p = embed_p; pair.rho_r = args.potential->rho_r(pair.d); - embedding_stress(pair, s); + embedding_stress(pair, s); } if (finite_temp) { // Compute finite T terms. @@ -177,7 +177,7 @@ namespace ATC { for (INDEX a=0; aterms.pairwise) { + if (args.potential->terms.pairwise) { F += 0.5*args.potential->phi(pair.d); } @@ -185,11 +185,11 @@ namespace ATC { pair.r = args.vac.r(a); if (args.potential->terms.pairwise) { pair.phi_r = args.potential->phi_r(pair.d); - pair.phi_rr = args.potential->phi_rr(pair.d); - pair.phi_rrr = args.potential->phi_rrr(pair.d); + pair.phi_rr = args.potential->phi_rr(pair.d); + pair.phi_rrr = args.potential->phi_rrr(pair.d); pairwise_thermal(pair, D); } - if (args.potential->terms.embedding) { + if (args.potential->terms.embedding) { pair.rho_r = args.potential->rho_r(pair.d); pair.rho_rr = args.potential->rho_rr(pair.d); pair.rho_rrr = args.potential->rho_rrr(pair.d); @@ -200,7 +200,7 @@ namespace ATC { } } // if has three-body terms ... TODO compute three-body terms - } + } // Finish finite temperature Cauchy-Born. const double kB = args.boltzmann_constant; const double hbar = args.planck_constant; @@ -209,7 +209,7 @@ namespace ATC { } //if (finite_temp) F += 0.5*args.boltzmann_constant*T*log(det(D)); return F; - } + } //=========================================================================== // Computes the entropic energy TS (minus c_v T) //=========================================================================== @@ -268,7 +268,7 @@ namespace ATC { const double hbar = args.planck_constant;; double F = kB*T*log(pow(hbar/(kB*T),3.0)*sqrt(det(D))); return F; - } + } //=========================================================================== // Computes the stress contribution given the pairwise parameters. //=========================================================================== @@ -295,26 +295,26 @@ namespace ATC { void pairwise_thermal(const PairParam &p, DENS_MAT &D, DENS_MAT_VEC *dDdF) { const double di2 = p.di*p.di; - const double g = p.di*p.phi_r; + const double g = p.di*p.phi_r; const double g_d = p.di*p.phi_rr - p.di*g; // units (energy / length^3) const double f = di2 * (p.phi_rr - g); // units (energy / length^4) const double f_d = di2*(p.phi_rrr-g_d) - 2.0*p.di*f; - // compute needed tensor products of r and R + // compute needed tensor products of r and R const DENS_MAT rr = tensor_product(p.r, p.r); - // compute the dynamical matrix + // compute the dynamical matrix D.add_scaled(rr, f); diagonal(D) += g; - + if (!dDdF) return; // skip derivative const double gp_r = g_d*p.di; const double fp_r = f_d*p.di; - const double fr[] = {f*p.r(0), f*p.r(1), f*p.r(2)}; + const double fr[] = {f*p.r(0), f*p.r(1), f*p.r(2)}; const DENS_MAT rR = tensor_product(p.r, p.R); DENS_MAT_VEC &dD = *dDdF; - + // compute first term in A.13 dD[0].add_scaled(rR, fp_r*rr(0,0) + gp_r); dD[1].add_scaled(rR, fp_r*rr(1,1) + gp_r); @@ -349,13 +349,13 @@ namespace ATC { const double z = di*(2*p.F_p*p.rho_r); const double y = di2*(x-z); - // compute needed tensor products of r and R + // compute needed tensor products of r and R const DENS_MAT rr = tensor_product(p.r, p.r); - // compute the dynamical matrix + // compute the dynamical matrix D.add_scaled(rr, y); diagonal(D) += z; - + if (!dDdF) return; // skip derivative DENS_MAT_VEC &dD = *dDdF; const DENS_MAT rR = tensor_product(p.r, p.R); @@ -382,10 +382,10 @@ namespace ATC { dD[3].add_scaled(L0, b*rr(1,2)); dD[4].add_scaled(L0, b*rr(0,2)); dD[5].add_scaled(L0, b*rr(0,1)); - - //add remaining term + + //add remaining term const double aw = a + w; - const double awr[] = {aw*p.r(0), aw*p.r(1), aw*p.r(2)}; + const double awr[] = {aw*p.r(0), aw*p.r(1), aw*p.r(2)}; for (INDEX L=0; L(6,6),Iu*Iu-IIu); da -= voigt3::derivative_of_square(C); - + dU = tensor_product(U, dfct); dU.add_scaled(da, fct); - U *= fct; + U *= fct; } //============================================================================ // Computes the dynamical matrix (TESTING FUNCTION) @@ -526,11 +526,11 @@ namespace ATC { { DENS_MAT D(3,3); for (INDEX a=0; aphi_r(pair.d); pair.r = args.vac.r(a); - pair.phi_rr = args.potential->phi_rr(pair.d); - pair.phi_rrr = args.potential->phi_rrr(pair.d); + pair.phi_rr = args.potential->phi_rr(pair.d); + pair.phi_rrr = args.potential->phi_rrr(pair.d); pairwise_thermal(pair, D); } return D; @@ -558,7 +558,7 @@ namespace ATC { args.vac.F_(i,j) = Fij - EPS; DENS_MAT Db = compute_dynamical_matrix(args); args.vac.F_(i,j) = Fij; - + dDdF[0](i,j) = (Da(0,0)-Db(0,0))*(0.5/EPS); dDdF[1](i,j) = (Da(1,1)-Db(1,1))*(0.5/EPS); dDdF[2](i,j) = (Da(2,2)-Db(2,2))*(0.5/EPS); diff --git a/lib/atc/CauchyBorn.h b/lib/atc/CauchyBorn.h index fb63afa39b..7770486c14 100644 --- a/lib/atc/CauchyBorn.h +++ b/lib/atc/CauchyBorn.h @@ -13,9 +13,9 @@ namespace ATC { class AtomCluster; /** - * @class StressAtIP - * @brief Class for passing the vector of stresses at quadrature points - * Done by storing the quadrature point and providing indexing + * @class StressAtIP + * @brief Class for passing the vector of stresses at quadrature points + * Done by storing the quadrature point and providing indexing */ class StressAtIP { @@ -30,7 +30,7 @@ namespace ATC { void set_quadrature_point(INDEX qp) { q = qp; } //* Operator that outputs the stress friend std::ostream& operator<<(std::ostream& o, const StressAtIP& s) - { o << "stress\n"; + { o << "stress\n"; o << s(0,0) << " " << s(0,1) << " " << s(0,2) << "\n"; o << s(1,0) << " " << s(1,1) << " " << s(1,2) << "\n"; o << s(2,0) << " " << s(2,1) << " " << s(2,2) << "\n"; @@ -56,7 +56,7 @@ namespace ATC { }; /** - * @class PairParam + * @class PairParam * @brief Class for storing parameters used in pairwise stress computations */ struct PairParam { @@ -82,7 +82,7 @@ namespace ATC { void cb_stress(const StressArgs &args, StressAtIP &s, double *F=0); //* Computes the elastic energy (free or potential if T=0). double cb_energy(const StressArgs &args); - //* Computes the entropic energy + //* Computes the entropic energy double cb_entropic_energy(const StressArgs &args); //* Auxiliary functions for cb_stress //@{ @@ -96,8 +96,8 @@ namespace ATC { void embedding_thermal(const PairParam &p, DENS_MAT &D, DENS_MAT &L0, DENS_MAT_VEC *dDdF=0); //* Last stage of the pairwise finite-T Cauchy-Born stress computation. void thermal_end(const DENS_MAT_VEC &DF, const DENS_MAT &D, const DENS_MAT &F, - const double &T, const double &kb, StressAtIP &s, double *F_w=0); - //* Returns the stretch tensor and its derivative with respect to C (R C-G). + const double &T, const double &kb, StressAtIP &s, double *F_w=0); + //* Returns the stretch tensor and its derivative with respect to C (R C-G). void stretch_tensor_derivative(const DENS_VEC &C, DENS_VEC &U, DENS_MAT &dU); //@} diff --git a/lib/atc/CbEam.h b/lib/atc/CbEam.h index 7b7df175e8..b7740c88ff 100644 --- a/lib/atc/CbEam.h +++ b/lib/atc/CbEam.h @@ -11,75 +11,75 @@ namespace ATC { /** - * @class CbEam - * @brief Class for computing Cauchy-Born quantities for an Embeded-Atom Method material - * (A factor of one-half is already included to split the + * @class CbEam + * @brief Class for computing Cauchy-Born quantities for an Embeded-Atom Method material + * (A factor of one-half is already included to split the * bond energy between atoms) */ class CbEam : public CbPotential { public: - //! Constructor - CbEam(void) : CbPotential(Interactions(PAIRWISE,EAM)) { + //! Constructor + CbEam(void) : CbPotential(Interactions(PAIRWISE,EAM)) { // get pointer to lammps' pair_eam object - lammps_eam = ATC::LammpsInterface::instance()->pair_eam(); - nrho = &lammps_eam->nrho; - nr = &lammps_eam->nr; - nfrho = &lammps_eam->nfrho; - nrhor = &lammps_eam->nrhor; - nz2r = &lammps_eam->nz2r; + lammps_eam = ATC::LammpsInterface::instance()->pair_eam(); + nrho = &lammps_eam->nrho; + nr = &lammps_eam->nr; + nfrho = &lammps_eam->nfrho; + nrhor = &lammps_eam->nrhor; + nz2r = &lammps_eam->nz2r; type2frho = lammps_eam->type2frho; type2rhor = lammps_eam->type2rhor; type2z2r = lammps_eam->type2z2r; - dr = &lammps_eam->dr; - rdr = &lammps_eam->rdr; - drho = &lammps_eam->drho; - rdrho = &lammps_eam->rdrho; + dr = &lammps_eam->dr; + rdr = &lammps_eam->rdr; + drho = &lammps_eam->drho; + rdrho = &lammps_eam->rdrho; rhor_spline = &lammps_eam->rhor_spline; frho_spline = &lammps_eam->frho_spline; z2r_spline = &lammps_eam->z2r_spline; cutmax = &lammps_eam->cutmax; } - + //! Returns the cutoff readius of the EAM potential functions rho and z2r. double cutoff_radius() const { return *cutmax; } - //! Returns the EAM pair energy - double phi(const double &r) const + //! Returns the EAM pair energy + double phi(const double &r) const { double p = r*(*rdr) + 1.0; int m = static_cast (p); m = MIN(m,(*nr)-1); p -= m; p = MIN(p,1.0); - // for now, assume itype = jtype = 1 + // for now, assume itype = jtype = 1 double *coeff = (*z2r_spline)[type2z2r[1][1]][m]; double z2 = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6]; return z2/r; } //! Returns the first derivative of the pair energy. - double phi_r(const double &r) const + double phi_r(const double &r) const { double p = r*(*rdr) + 1.0; int m = static_cast (p); m = MIN(m,(*nr)-1); p -= m; p = MIN(p,1.0); - // for now, assume itype = jtype = 1 + // for now, assume itype = jtype = 1 double *coeff = (*z2r_spline)[type2z2r[1][1]][m]; double z2 = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6]; double z2p = (coeff[0]*p + coeff[1])*p + coeff[2]; return (1.0/r)*(z2p-z2/r); } //! Returns the second derivative of the pair energy. - double phi_rr(const double &r) const + double phi_rr(const double &r) const { double p = r*(*rdr) + 1.0; int m = static_cast (p); m = MIN(m,(*nr)-1); p -= m; p = MIN(p,1.0); - // for now, assume itype = jtype = 1 + // for now, assume itype = jtype = 1 double *coeff = (*z2r_spline)[type2z2r[1][1]][m]; double z2 = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6]; double z2p = (coeff[0]*p + coeff[1])*p + coeff[2]; @@ -94,7 +94,7 @@ namespace ATC m = MIN(m,(*nr)-1); p -= m; p = MIN(p,1.0); - // for now, assume itype = jtype = 1 + // for now, assume itype = jtype = 1 double *coeff = (*z2r_spline)[type2z2r[1][1]][m]; double z2 = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6]; double z2p = (coeff[0]*p + coeff[1])*p + coeff[2]; @@ -102,7 +102,7 @@ namespace ATC double z2ppp = (*rdr)*(*rdr)*2.0*coeff[0]; return (1.0/r)*(z2ppp-3.0*z2pp/r+6.0*z2p/(r*r)-6.0*z2/(r*r*r)); } - //! Returns the EAM atomic charge density. + //! Returns the EAM atomic charge density. double rho(const double &r) const { double p = r*(*rdr) + 1.0; @@ -150,7 +150,7 @@ namespace ATC double *coeff = (*rhor_spline)[type2rhor[1][1]][m]; return ((*rdr)*(*rdr)*2.0*coeff[0]); } - //! Returns the EAM embedding energy. + //! Returns the EAM embedding energy. double F(const double &p) const { double q = p*(*rdrho) + 1.0; @@ -202,7 +202,7 @@ namespace ATC int *type2frho,**type2rhor,**type2z2r; double *cutmax; double *dr,*rdr,*drho,*rdrho; - double ****rhor_spline,****frho_spline,****z2r_spline; + double ****rhor_spline,****frho_spline,****z2r_spline; LAMMPS_NS::PairEAM* lammps_eam; }; } diff --git a/lib/atc/CbLjCut.h b/lib/atc/CbLjCut.h index 53402f281c..1158a8ff37 100644 --- a/lib/atc/CbLjCut.h +++ b/lib/atc/CbLjCut.h @@ -24,24 +24,24 @@ namespace ATC B (4.0*eps*pow(sig, 6)), rcut(cutoff_radius) { } - + //! Returns the cutoff readius of the LJ potential. double cutoff_radius() const { return rcut; } //! Returns the LJ energy between two interacting atoms (6,12). - double phi(const double &r) const + double phi(const double &r) const { const double r6i = 1.0/((r*r*r)*(r*r*r)); return r6i*(A*r6i - B); } //! Returns the first derivative of the LJ energy (7,13). - double phi_r(const double &r) const + double phi_r(const double &r) const { const double ri = 1.0/r; const double r6i = (ri*ri*ri)*(ri*ri*ri); return r6i*ri*(6.0*B - 12.0*A*r6i); } //! Returns the second derivative of the LJ energy (8,14). - double phi_rr(const double &r) const + double phi_rr(const double &r) const { const double r2i = 1.0/(r*r); const double r6i = r2i*r2i*r2i; diff --git a/lib/atc/CbLjSmoothLinear.h b/lib/atc/CbLjSmoothLinear.h index d74b2b5df9..f4708de4f7 100644 --- a/lib/atc/CbLjSmoothLinear.h +++ b/lib/atc/CbLjSmoothLinear.h @@ -23,20 +23,20 @@ namespace ATC A (4.0*eps*pow(sig, 12)), B (4.0*eps*pow(sig, 6)), rcut(cutoff_radius) - { + { ricut = 1.0/rcut; - r6icut = (ricut*ricut*ricut)*(ricut*ricut*ricut); + r6icut = (ricut*ricut*ricut)*(ricut*ricut*ricut); phicut = r6icut*(A*r6icut - B); - dphicut = r6icut*ricut*(6.0*B - 12.0*A*r6icut); + dphicut = r6icut*ricut*(6.0*B - 12.0*A*r6icut); } - + //! Returns the cutoff readius of the LJ potential. double cutoff_radius() const { return rcut; } //! Returns the LJ energy between two interacting atoms (6,12). - double phi(const double &r) const + double phi(const double &r) const { const double r6i = 1.0/((r*r*r)*(r*r*r)); - if (r < rcut) { + if (r < rcut) { return (r6i*(A*r6i - B) - phicut - (r-rcut)*dphicut); } else { @@ -44,11 +44,11 @@ namespace ATC } } //! Returns the first derivative of the LJ energy (7,13). - double phi_r(const double &r) const + double phi_r(const double &r) const { const double ri = 1.0/r; const double r6i = (ri*ri*ri)*(ri*ri*ri); - if (r < rcut) { + if (r < rcut) { return (r6i*ri*(6.0*B - 12.0*A*r6i) - dphicut); } else { @@ -56,7 +56,7 @@ namespace ATC } } //! Returns the second derivative of the LJ energy (8,14). - double phi_rr(const double &r) const + double phi_rr(const double &r) const { const double r2i = 1.0/(r*r); const double r6i = r2i*r2i*r2i; diff --git a/lib/atc/CbPotential.cpp b/lib/atc/CbPotential.cpp index 741e75eb73..0886eec642 100644 --- a/lib/atc/CbPotential.cpp +++ b/lib/atc/CbPotential.cpp @@ -17,7 +17,7 @@ namespace ATC return (phi_r(r+dr)-phi_r(r)) / dr; } // Approximates the third derivative of phi - double CbPotential::phi_rrr(const double &r) const + double CbPotential::phi_rrr(const double &r) const { const double dr = r*EPS; return (phi_rr(r+dr)-phi_rr(r)) / dr; @@ -34,8 +34,8 @@ namespace ATC const double dr = r*EPS; return (rho_r(r+dr)-rho_r(r)) / dr; } - // Approximates the third derivative of rho - double CbPotential::rho_rrr(const double &r) const + // Approximates the third derivative of rho + double CbPotential::rho_rrr(const double &r) const { const double dr = r*EPS; return (rho_rr(r+dr)-rho_rr(r)) / dr; @@ -44,7 +44,7 @@ namespace ATC double CbPotential::F_p(const double &p) const { const double dp = p*EPS; - return (F(p+dp)-F(p)) / dp; + return (F(p+dp)-F(p)) / dp; } // Approximates the second derivative of the embedding function double CbPotential::F_pp(const double &p) const @@ -79,7 +79,7 @@ namespace ATC Interactions::Interactions(int a, int b, int c) { // bitwise OR combines the terms that are listed - const int abc = a|b|c; + const int abc = a|b|c; pairwise = (abc&PAIRWISE)>0; embedding = (abc&EAM)>0; three_body = (abc&THREE_BDY)>0; diff --git a/lib/atc/CbPotential.h b/lib/atc/CbPotential.h index 1d5386fcd5..e0f651852b 100644 --- a/lib/atc/CbPotential.h +++ b/lib/atc/CbPotential.h @@ -29,10 +29,10 @@ namespace ATC protected: //! CbPotential base constructor: //! Initializes which terms are included in energy computation. - //@param potential_terms Switches for atomic interaction terms. + //@param potential_terms Switches for atomic interaction terms. CbPotential(Interactions interaction_terms) : terms(interaction_terms) {} public: - virtual ~CbPotential() {} + virtual ~CbPotential() {} const Interactions terms; //!< switches for types of potential terms. //! Returns the minimum distance that all interactions get neglected. diff --git a/lib/atc/ChargeRegulator.cpp b/lib/atc/ChargeRegulator.cpp index 972530829c..f0f0423e9a 100644 --- a/lib/atc/ChargeRegulator.cpp +++ b/lib/atc/ChargeRegulator.cpp @@ -20,7 +20,7 @@ using std::vector; using std::set; using std::pair; using std::string; - + namespace ATC { @@ -47,7 +47,7 @@ namespace ATC { } } - + //-------------------------------------------------------- // modify: // parses and adjusts charge regulator state based on @@ -97,7 +97,7 @@ namespace ATC { regulators_[tag] = new ChargeRegulatorMethodEffectiveCharge(this,p); break; } - default: + default: throw ATC_Error("ChargeRegulator::construct_method unknown charge regulator type"); } } @@ -110,12 +110,12 @@ namespace ATC { void ChargeRegulator::initialize() { - + map::iterator itr; for (itr = regulators_.begin(); itr != regulators_.end(); itr++) { itr->second->initialize(); } - atc_->set_boundary_integration_type(boundaryIntegrationType_); + atc_->set_boundary_integration_type(boundaryIntegrationType_); AtomicRegulator::reset_nlocal(); AtomicRegulator::delete_unused_data(); needReset_ = false; @@ -152,23 +152,23 @@ namespace ATC { //======================================================== // Class ChargeRegulatorMethod //======================================================== - + //-------------------------------------------------------- // Constructor - // Grab references to ATC and ChargeRegulator + // Grab references to ATC and ChargeRegulator //-------------------------------------------------------- ChargeRegulatorMethod::ChargeRegulatorMethod - (ChargeRegulator *chargeRegulator, + (ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & p) - : RegulatorShapeFunction(chargeRegulator), + : RegulatorShapeFunction(chargeRegulator), chargeRegulator_(chargeRegulator), lammpsInterface_(LammpsInterface::instance()), rC_(0), rCsq_(0), - targetValue_(nullptr), - targetPhi_(p.value), + targetValue_(nullptr), + targetPhi_(p.value), surface_(p.faceset), - atomGroupBit_(p.groupBit), - boundary_(false), + atomGroupBit_(p.groupBit), + boundary_(false), depth_(p.depth), surfaceType_(p.surfaceType), permittivity_(p.permittivity), @@ -185,7 +185,7 @@ namespace ATC { point_.reset(nsd_); for (int i=0; i < nsd_; i++) { point_(i) = faceCoords(i,0); } #ifdef ATC_VERBOSE - stringstream ss; ss << "point: (" << point_(0) << "," << point_(1) << "," << point_(2) << ") normal: (" << normal_(0) << "," << normal_(1) << "," << normal_(2) << ") depth: " << depth_; + stringstream ss; ss << "point: (" << point_(0) << "," << point_(1) << "," << point_(2) << ") normal: (" << normal_(0) << "," << normal_(1) << "," << normal_(2) << ") depth: " << depth_; lammpsInterface_->print_msg_once(ss.str()); #endif sum_.reset(nsd_); @@ -193,7 +193,7 @@ namespace ATC { //-------------------------------------------------------- // Initialize - + //-------------------------------------------------------- @@ -217,7 +217,7 @@ namespace ATC { // note derived method set initialized to true } - + int ChargeRegulatorMethod::nlocal() { return atc_->nlocal(); } void ChargeRegulatorMethod::set_greens_functions(void) @@ -260,14 +260,14 @@ namespace ATC { // Constructor //-------------------------------------------------------- ChargeRegulatorMethodFeedback::ChargeRegulatorMethodFeedback - (ChargeRegulator *chargeRegulator, + (ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & p) : ChargeRegulatorMethod (chargeRegulator, p), controlNodes_(nodes_), influenceGroupBit_(p.groupBit) { - nControlNodes_ = controlNodes_.size(); - sum_.resize(1); + nControlNodes_ = controlNodes_.size(); + sum_.resize(1); } //-------------------------------------------------------- // Initialize @@ -275,10 +275,10 @@ namespace ATC { void ChargeRegulatorMethodFeedback::initialize(void) { ChargeRegulatorMethod::initialize(); - if (surfaceType_ != ChargeRegulator::CONDUCTOR) + if (surfaceType_ != ChargeRegulator::CONDUCTOR) throw ATC_Error("currently charge feedback can only mimic a conductor"); - set_influence(); - set_influence_matrix(); + set_influence(); + set_influence_matrix(); initialized_ = true; } //-------------------------------------------------------- @@ -299,13 +299,13 @@ namespace ATC { } } //-------------------------------------------------------- - // find measurement atoms and nodes + // find measurement atoms and nodes //-------------------------------------------------------- void ChargeRegulatorMethodFeedback::set_influence(void) { // get nodes that overlap influence atoms & compact list of influence atoms - boundary_ = + boundary_ = atc_->nodal_influence(influenceGroupBit_,influenceNodes_,influenceAtoms_); nInfluenceAtoms_ = influenceAtoms_.size(); // local nInfluenceNodes_ = influenceNodes_.size(); // global @@ -313,13 +313,13 @@ namespace ATC { lammpsInterface_->print_msg(ss.str()); if (nInfluenceNodes_ == 0) throw ATC_Error("no influence nodes"); - const Array & map = (boundary_) ? atc_->ghost_to_atom_map() : atc_->internal_to_atom_map(); + const Array & map = (boundary_) ? atc_->ghost_to_atom_map() : atc_->internal_to_atom_map(); for (set::const_iterator itr = influenceAtoms_.begin(); itr != influenceAtoms_.end(); itr++) { influenceAtomsIds_.insert(map(*itr)); } } //-------------------------------------------------------- - // constuct a Green's submatrix + // constuct a Green's submatrix //-------------------------------------------------------- void ChargeRegulatorMethodFeedback::set_influence_matrix(void) { @@ -329,7 +329,7 @@ namespace ATC { // if (nInfluenceNodes_ < nControlNodes_) throw ATC_Error(" least square not implemented "); if (nInfluenceNodes_ > nControlNodes_) throw ATC_Error(" solve not possible "); - DENS_MAT G(nInfluenceNodes_,nControlNodes_); + DENS_MAT G(nInfluenceNodes_,nControlNodes_); DENS_VEC G_I; set::const_iterator itr,itr2,itr3; const Array & nmap = atc_->fe_engine()->fe_mesh()->global_to_unique_map(); @@ -339,7 +339,7 @@ namespace ATC { int j = 0; for (itr2 = controlNodes_.begin(); itr2 != controlNodes_.end(); itr2++) { int jnode = nmap(*itr2); - G(i,j++) = G_I(jnode); + G(i,j++) = G_I(jnode); } i++; } @@ -371,33 +371,33 @@ namespace ATC { } // swap contributions across processors DENS_MAT localNNT = NNT; - int count = NNT.nRows()*NNT.nCols(); + int count = NNT.nRows()*NNT.nCols(); lammpsInterface_->allsum(localNNT.ptr(),NNT.ptr(),count); invNNT_ = inv(NNT); - + // total influence matrix if (nInfluenceAtoms_ > 0) { NTinvNNTinvG_ = NT_*invNNT_*invG_; } } - + //-------------------------------------------------------- // change potential/charge pre-force calculation //-------------------------------------------------------- void ChargeRegulatorMethodFeedback::apply_pre_force(double /* dt */) { - sum_ = 0; + sum_ = 0; if (nInfluenceAtoms_ == 0) return; // nothing to do apply_feedback_charges(); } //-------------------------------------------------------- - // apply feedback charges to atoms + // apply feedback charges to atoms //-------------------------------------------------------- void ChargeRegulatorMethodFeedback::apply_feedback_charges() { double * q = lammpsInterface_->atom_charge(); // calculate error in potential on the control nodes - + const DENS_MAT & phiField = (atc_->field(ELECTRIC_POTENTIAL)).quantity(); DENS_MAT dphi(nControlNodes_,1); int i = 0; @@ -410,10 +410,10 @@ namespace ATC { DENS_MAT dq = NTinvNNTinvG_*dphi; i = 0; for (itr = influenceAtomsIds_.begin(); itr != influenceAtomsIds_.end(); itr++) { - sum_(0) += dq(i,0); - q[*itr] += dq(i++,0); + sum_(0) += dq(i,0); + q[*itr] += dq(i++,0); } - + (interscaleManager_->fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE))->force_reset(); (interscaleManager_->fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE, GHOST))->force_reset(); } @@ -425,7 +425,7 @@ namespace ATC { // Constructor //-------------------------------------------------------- ChargeRegulatorMethodImageCharge::ChargeRegulatorMethodImageCharge - (ChargeRegulator *chargeRegulator, + (ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & p) : ChargeRegulatorMethod (chargeRegulator, p), imageNodes_(nodes_) @@ -459,12 +459,12 @@ namespace ATC { { sum_ = 0; apply_local_forces(); - + //correct_forces(); } - + //-------------------------------------------------------- - // apply local coulomb forces + // apply local coulomb forces // -- due to image charges //-------------------------------------------------------- void ChargeRegulatorMethodImageCharge::apply_local_forces() @@ -477,8 +477,8 @@ namespace ATC { const int *mask = lammpsInterface_->atom_mask(); ///.............................................. - double ** x = lammpsInterface_->xatom(); - double ** f = lammpsInterface_->fatom(); + double ** x = lammpsInterface_->xatom(); + double ** f = lammpsInterface_->fatom(); double * q = lammpsInterface_->atom_charge(); // loop over neighbor list @@ -487,13 +487,13 @@ namespace ATC { double qi = q[i]; if ((mask[i] & atomGroupBit_) && qi != 0.) { double* fi = f[i]; - DENS_VEC xi(x[i],nsd_); + DENS_VEC xi(x[i],nsd_); // distance to surface double dn = reflect(xi); // all ions near the interface/wall // (a) self image if (dn < rC_) { // close enough to wall to have explicit image charges - double factor_coul = 1; + double factor_coul = 1; double dx = 2.*dn; // distance to image charge double fn = factor_coul*qi*qi*permittivityRatio_/dx; fi[0] += fn*normal_[0]; @@ -513,8 +513,8 @@ namespace ATC { dn = reflect(xj); DENS_VEC dx = xi-xj; double r2 = dx.norm_sq(); - // neighbor image j' inside cutoff from i - if (r2 < rCsq_) { + // neighbor image j' inside cutoff from i + if (r2 < rCsq_) { double fm = factor_coul*qi*qj*permittivityRatio_/r2; fi[0] += fm*dx(0); fi[1] += fm*dx(1); @@ -532,7 +532,7 @@ namespace ATC { //-------------------------------------------------------- // correct charge densities - // - to reflect image charges + // - to reflect image charges //-------------------------------------------------------- void ChargeRegulatorMethodImageCharge::correct_charge_densities() { @@ -554,19 +554,19 @@ namespace ATC { //-------------------------------------------------------- // Constructor //-------------------------------------------------------- - - ChargeRegulatorMethodEffectiveCharge::ChargeRegulatorMethodEffectiveCharge( - ChargeRegulator *chargeRegulator, + + ChargeRegulatorMethodEffectiveCharge::ChargeRegulatorMethodEffectiveCharge( + ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & p) : ChargeRegulatorMethod (chargeRegulator, p), chargeDensity_(p.value), - useSlab_(false) + useSlab_(false) { } //-------------------------------------------------------- // add_charged_surface //-------------------------------------------------------- - void ChargeRegulatorMethodEffectiveCharge::initialize( ) + void ChargeRegulatorMethodEffectiveCharge::initialize( ) { ChargeRegulatorMethod::initialize(); boundary_ = atc_->is_ghost_group(atomGroupBit_); @@ -644,7 +644,7 @@ namespace ATC { //-------------------------------------------------------- // add effective forces post LAMMPS force call //-------------------------------------------------------- - void ChargeRegulatorMethodEffectiveCharge::apply_post_force(double /* dt */) + void ChargeRegulatorMethodEffectiveCharge::apply_post_force(double /* dt */) { apply_local_forces(); } @@ -664,7 +664,7 @@ namespace ATC { const DENS_MAT & xa((interscaleManager_->per_atom_quantity("AtomicCoarseGrainingPositions"))->quantity()); // WORKSPACE - most are static - SparseVector dv(nNodes_); + SparseVector dv(nNodes_); vector > derivativeVectors; derivativeVectors.reserve(nsd_); const SPAR_MAT_VEC & shapeFunctionDerivatives((interscaleManager_->vector_sparse_matrix("InterpolateGradient"))->quantity()); @@ -674,7 +674,7 @@ namespace ATC { NODE_TO_XF_MAP::const_iterator inode; for (inode = nodeXFMap_.begin(); inode != nodeXFMap_.end(); inode++) { - + int node = inode->first; DENS_VEC xI = (inode->second).first; double qI = (inode->second).second; @@ -682,46 +682,46 @@ namespace ATC { for (int i = 0; i < nlocal(); i++) { int atom = (atc_->internal_to_atom_map())(i); double qa = q[atom]; - if (qa != 0) { + if (qa != 0) { double dxSq = 0.; for (int j = 0; j < nsd_; j++) { dx[j] = xa(i,j) - xI(j); dxSq += dx[j]*dx[j]; } - if (dxSq < rCsq_) { + if (dxSq < rCsq_) { // first apply pairwise coulombic interaction - if (!useSlab_) { + if (!useSlab_) { double coulForce = qqrd2e_*qI*qa/(dxSq*sqrtf(dxSq)); for (int j = 0; j < nsd_; j++) { _atomElectricalForce_(i,j) += dx[j]*coulForce; } } - + // second correct for FE potential induced by BCs // determine shape function derivatives at atomic location // and construct sparse vectors to store derivative data - - + + for (int j = 0; j < nsd_; j++) { shapeFunctionDerivatives[j]->row(i,nodeValues,nodeIndices); derivativeVectors.push_back(dv); for (int k = 0; k < nodeIndices.size(); k++) { derivativeVectors[j](nodeIndices(k)) = nodeValues(k); } } - + // compute greens function from charge quadrature - - SparseVector shortFePotential(nNodes_); + + SparseVector shortFePotential(nNodes_); shortFePotential.add_scaled(greensFunctions_[node],penalty*phiI); - + // compute electric field induced by charge DENS_VEC efield(nsd_); for (int j = 0; j < nsd_; j++) { efield(j) = -.1*dot(derivativeVectors[j],shortFePotential); } - + // apply correction in atomic forces double c = qV2e_*qa; for (int j = 0; j < nsd_; j++) { - if ((!useSlab_) || (j==nsd_)) { + if ((!useSlab_) || (j==nsd_)) { _atomElectricalForce_(i,j) -= c*efield(j); } } @@ -729,7 +729,7 @@ namespace ATC { } } } - + } }; // end namespace diff --git a/lib/atc/ChargeRegulator.h b/lib/atc/ChargeRegulator.h index f250a955e8..d076f5a315 100644 --- a/lib/atc/ChargeRegulator.h +++ b/lib/atc/ChargeRegulator.h @@ -17,7 +17,7 @@ namespace ATC { class ChargeRegulatorMethod; class ChargeRegulator : public AtomicRegulator { - + public: /** charge regulator types */ @@ -43,21 +43,21 @@ namespace ATC { permittivity(0), surfaceType(INSULATOR) { }; ChargeRegulatorType method; - double value; + double value; int groupBit; std::string groupTag; double depth; - double permittivity; + double permittivity; ChargedSurfaceType surfaceType; - FSET faceset; + FSET faceset; }; /** constructor */ ChargeRegulator(ATC_Coupling *atc); - + /** destructor */ ~ChargeRegulator(); - + /** parser/modifier */ virtual bool modify(int narg, char **arg); virtual void construct_methods(); @@ -67,8 +67,8 @@ namespace ATC { virtual void output(OUTPUT_LIST & outputData) const; virtual double compute_vector(int /* n */) const {return 0;} // TODO - void assign_poisson_solver(PoissonSolver * solver) { poissonSolver_ = solver;} - PoissonSolver * poisson_solver(void) { return poissonSolver_;} + void assign_poisson_solver(PoissonSolver * solver) { poissonSolver_ = solver;} + PoissonSolver * poisson_solver(void) { return poissonSolver_;} protected: @@ -86,19 +86,19 @@ namespace ATC { /** * @class ChargeRegulatorMethod - * @brief Base class for implementation of ChargeRegulator algorithms + * @brief Base class for implementation of ChargeRegulator algorithms */ class ChargeRegulatorMethod : public RegulatorShapeFunction { - + public: ChargeRegulatorMethod(ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & parameters); ~ChargeRegulatorMethod(){}; - virtual void initialize(void); + virtual void initialize(void); void set_greens_functions(); - virtual void apply_pre_force(double /* dt */){}; - virtual void apply_post_force(double /* dt */){}; + virtual void apply_pre_force(double /* dt */){}; + virtual void apply_post_force(double /* dt */){}; virtual void set_weights() {}; const DENS_VEC & total_influence() const { return sum_;} virtual void output(OUTPUT_LIST & outputData); @@ -120,13 +120,13 @@ namespace ATC { /** conversion constants */ double qV2e_, qqrd2e_; /** member data */ - XT_Function * targetValue_; - double targetPhi_; - // controlling + XT_Function * targetValue_; + double targetPhi_; + // controlling FSET surface_; NSET nodes_; int atomGroupBit_; - bool boundary_; // atoms on boundary + bool boundary_; // atoms on boundary DENS_VEC point_; DENS_VEC normal_; double depth_; @@ -147,13 +147,13 @@ namespace ATC { */ class ChargeRegulatorMethodFeedback : public ChargeRegulatorMethod { - + public: - + /** constructor */ ChargeRegulatorMethodFeedback(ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & parameters); - + /** destructor */ ~ChargeRegulatorMethodFeedback(){}; @@ -161,30 +161,30 @@ namespace ATC { virtual void construct_transfers(); /** initialize */ - virtual void initialize(void); + virtual void initialize(void); - /** set influence nodes and atoms */ + /** set influence nodes and atoms */ void set_influence(); - void set_influence_matrix(void); + void set_influence_matrix(void); /** post first verlet step */ - virtual void apply_pre_force(double dt); + virtual void apply_pre_force(double dt); void apply_feedback_charges(); protected: - int nControlNodes_; + int nControlNodes_; NSET & controlNodes_; // measurement/controlled int influenceGroupBit_; int nInfluenceAtoms_; - NSET influenceAtoms_, influenceAtomsIds_; + NSET influenceAtoms_, influenceAtomsIds_; int nInfluenceNodes_; NSET influenceNodes_; - - + + DENS_MAT invG_; DENS_MAT invNNT_; DENS_MAT NT_; @@ -200,26 +200,26 @@ namespace ATC { */ class ChargeRegulatorMethodImageCharge : public ChargeRegulatorMethod { - + public: - + /** constructor */ ChargeRegulatorMethodImageCharge(ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & parameters); - + /** destructor */ ~ChargeRegulatorMethodImageCharge(){}; /** initialize */ - virtual void initialize(void); + virtual void initialize(void); /** post first verlet step */ - virtual void apply_post_force(double dt); + virtual void apply_post_force(double dt); protected: - double reflect(DENS_VEC & x) const { + double reflect(DENS_VEC & x) const { double dn = (x-point_).dot(normal_); - x -= 2*dn*normal_; + x -= 2*dn*normal_; return dn; } // internal functions @@ -229,8 +229,8 @@ namespace ATC { double layerDepth_; double permittivityRatio_; - NSET & imageNodes_; - DENS_MAT imageTransferOp_; + NSET & imageNodes_; + DENS_MAT imageTransferOp_; private: ChargeRegulatorMethodImageCharge(); // DO NOT define this @@ -244,21 +244,21 @@ namespace ATC { class ChargeRegulatorMethodEffectiveCharge : public ChargeRegulatorMethod { typedef std::map > NODE_TO_XF_MAP; - + public: - + /** constructor */ ChargeRegulatorMethodEffectiveCharge(ChargeRegulator *chargeRegulator, ChargeRegulator::ChargeRegulatorParameters & parameters); - + /** destructor */ ~ChargeRegulatorMethodEffectiveCharge(){}; /** initialize */ - virtual void initialize(void); + virtual void initialize(void); /** post first verlet step */ - virtual void apply_post_force(double dt); + virtual void apply_post_force(double dt); protected: // internal functions @@ -268,7 +268,7 @@ namespace ATC { double chargeDensity_; std::map nodalChargePotential_; - NODE_TO_XF_MAP nodeXFMap_; + NODE_TO_XF_MAP nodeXFMap_; bool useSlab_; @@ -276,7 +276,7 @@ namespace ATC { private: ChargeRegulatorMethodEffectiveCharge(); // DO NOT define this }; - + }; #endif diff --git a/lib/atc/CloneVector.h b/lib/atc/CloneVector.h index 63d11636b3..0b80b57628 100644 --- a/lib/atc/CloneVector.h +++ b/lib/atc/CloneVector.h @@ -7,7 +7,7 @@ namespace ATC_matrix { /** - * @class CloneVector + * @class CloneVector * @brief Class for creating objects that wrap matrix data for manipulation through vector operations */ @@ -39,7 +39,7 @@ public: private: void _resize(INDEX nRows, INDEX nCols, bool copy, bool zero); - + Vector * const _baseV; // ptr to a base vector Matrix * const _baseM; // ptr to a base matrix int _clone_type; // what to clone (see enum CLONE_TYPE) @@ -52,7 +52,7 @@ private: //----------------------------------------------------------------------------- template CloneVector::CloneVector(const Vector &c) - : Vector(), _baseV(const_cast*>(&c)), _baseM(nullptr) + : Vector(), _baseV(const_cast*>(&c)), _baseM(nullptr) {} //----------------------------------------------------------------------------- // Construct from a matrix, the const_cast isn't pretty @@ -64,7 +64,7 @@ CloneVector::CloneVector(const Vector &c) */ //----------------------------------------------------------------------------- template -CloneVector::CloneVector(const Matrix &c, int dim, INDEX idx) +CloneVector::CloneVector(const Matrix &c, int dim, INDEX idx) : Vector(), _baseV(nullptr), _baseM(const_cast*>(&c)) , _clone_type(dim), _idx(idx) {} @@ -72,7 +72,7 @@ CloneVector::CloneVector(const Matrix &c, int dim, INDEX idx) // Construct from a DiagonalMatrix //----------------------------------------------------------------------------- template -CloneVector::CloneVector(const DiagonalMatrix &c, INDEX /* idx */) +CloneVector::CloneVector(const DiagonalMatrix &c, INDEX /* idx */) : Vector(), _baseV(nullptr), _baseM(const_cast*>(&c)) , _clone_type(CLONE_DIAG), _idx(0) {} @@ -80,7 +80,7 @@ CloneVector::CloneVector(const DiagonalMatrix &c, INDEX /* idx */) // value (const) indexing operator //----------------------------------------------------------------------------- template - T CloneVector::operator()(INDEX i, INDEX /* j */) const + T CloneVector::operator()(INDEX i, INDEX /* j */) const { return (*this)[i]; } @@ -134,7 +134,7 @@ INDEX CloneVector::nRows() const template CloneVector& CloneVector::operator=(const T &v) { - this->set_all_elements_to(v); + this->set_all_elements_to(v); return *this; } //----------------------------------------------------------------------------- @@ -144,7 +144,7 @@ template CloneVector& CloneVector::operator=(const CloneVector &C) { GCK(*this, C, this->size()!=C.size(), "Error in CloneVector:operator="); - int sz = this->size(); + int sz = this->size(); for (INDEX i = 0; i < sz; i++) (*this)[i] = C[i]; return *this; } @@ -155,7 +155,7 @@ template CloneVector& CloneVector::operator=(const Matrix &C) { GCK(*this, C, this->size()!=C.size(), "Error in CloneVector:operator="); - int sz = this->size(); + int sz = this->size(); for (INDEX i = 0; i < sz; i++) (*this)[i] = C[i]; return *this; } @@ -168,7 +168,7 @@ bool CloneVector::memory_contiguous() const // drill down through clone of clones if (_baseV) return _baseV->memory_contiguous(); // could be okay if DiagonalMatrix, but can't guarantee this - if (_clone_type == CLONE_DIAG) return false; + if (_clone_type == CLONE_DIAG) return false; #ifdef ROW_STORAGE return _clone_type == CLONE_ROW; #else @@ -199,7 +199,7 @@ T* CloneVector::ptr() const template void CloneVector::_resize(INDEX nRows, INDEX nCols, bool copy, bool zero) { - if (_baseV) + if (_baseV) { if (copy) _baseV->resize(nRows, nCols, copy); else _baseV->reset (nRows, nCols, zero); @@ -232,7 +232,7 @@ void CloneVector::resize(INDEX nRows, INDEX nCols, bool copy) _resize(nRows, nCols, copy, false); } //----------------------------------------------------------------------------- -// resizes the matrix and optionally zeros it out +// resizes the matrix and optionally zeros it out //----------------------------------------------------------------------------- template void CloneVector::reset(INDEX nRows, INDEX nCols, bool zero) diff --git a/lib/atc/ConcentrationRegulator.cpp b/lib/atc/ConcentrationRegulator.cpp index 499a5501c1..b6aa6c5265 100644 --- a/lib/atc/ConcentrationRegulator.cpp +++ b/lib/atc/ConcentrationRegulator.cpp @@ -41,7 +41,7 @@ const double kMinScale_ = 10000.; } if (parameters_.size()) parameters_.clear(); } - + //-------------------------------------------------------- // modify: // parses and adjusts charge regulator state based on @@ -66,7 +66,7 @@ const double kMinScale_ = 10000.; // consruct new ones map::iterator itr; for (itr = parameters_.begin(); - itr != parameters_.end(); itr++) { + itr != parameters_.end(); itr++) { string tag = itr->first; if (regulators_.find(tag) != regulators_.end()) delete regulators_[tag]; ConcentrationRegulatorParameters & p = itr->second; @@ -82,7 +82,7 @@ const double kMinScale_ = 10000.; regulators_[tag] = new ConcentrationRegulatorMethodTransition(this,p); break; } - default: + default: throw ATC_Error("ConcentrationRegulator::initialize unknown concentration regulator type"); } } @@ -93,12 +93,12 @@ const double kMinScale_ = 10000.; //-------------------------------------------------------- void ConcentrationRegulator::initialize() { - + map::iterator itr; for (itr = regulators_.begin(); itr != regulators_.end(); itr++) { itr->second->initialize(); } - atc_->set_boundary_integration_type(boundaryIntegrationType_); + atc_->set_boundary_integration_type(boundaryIntegrationType_); AtomicRegulator::reset_nlocal(); AtomicRegulator::delete_unused_data(); needReset_ = false; @@ -157,7 +157,7 @@ const double kMinScale_ = 10000.; map::const_iterator itr; for (itr = regulators_.begin(); - itr != regulators_.end(); itr++) { + itr != regulators_.end(); itr++) { if (c++ == n) { return itr->second->compute_vector(m); } } return 0.; @@ -168,34 +168,34 @@ const double kMinScale_ = 10000.; //-------------------------------------------------------- int ConcentrationRegulator::size_vector(int /* i */) const { - int n = (regulators_.size())*5; - if (n==0) n = 20; - return n; + int n = (regulators_.size())*5; + if (n==0) n = 20; + return n; } //======================================================== // Class ConcentrationRegulatorMethodTransition //======================================================== - + //-------------------------------------------------------- // Constructor - // Grab references to ATC and ConcentrationRegulator + // Grab references to ATC and ConcentrationRegulator //-------------------------------------------------------- ConcentrationRegulatorMethodTransition::ConcentrationRegulatorMethodTransition - (ConcentrationRegulator *concReg, + (ConcentrationRegulator *concReg, ConcentrationRegulator::ConcentrationRegulatorParameters & p) - : ConcentrationRegulatorMethod(concReg), + : ConcentrationRegulatorMethod(concReg), concentrationRegulator_(concReg), interscaleManager_(nullptr), lammpsInterface_(LammpsInterface::instance()), list_(nullptr), - targetConcentration_(p.value), - targetCount_(0), + targetConcentration_(p.value), + targetCount_(0), elemset_(p.elemset), p_(nullptr), - randomNumberGenerator_(nullptr), + randomNumberGenerator_(nullptr), q0_(0), - controlType_(p.type), + controlType_(p.type), controlIndex_(0), transitionType_(p.transitionType), transitionInterval_(p.transitionInterval), @@ -241,7 +241,7 @@ const double kMinScale_ = 10000.; PerAtomQuantity * a2el = atc_->atom_to_element_map(); list_ = new AtomInElementSet(atc_,a2el,elemset_,controlType_); - + nNodes_ = atc_->num_nodes(); DENS_MAT conc(nNodes_,1); conc = targetConcentration_; DENS_VEC integral = atc_->fe_engine()->integrate(conc,elemset_); @@ -250,7 +250,7 @@ const double kMinScale_ = 10000.; volumes_.resize(elemset_.size()); ESET::const_iterator itr; int i = 0; - DENS_MAT c(nNodes_,1); c = 1; + DENS_MAT c(nNodes_,1); c = 1; V_ = 0.; for (itr = elemset_.begin(); itr != elemset_.end(); itr++, i++) { ESET e; e.insert(*itr); @@ -261,14 +261,14 @@ const double kMinScale_ = 10000.; volumes_ *= 1./V_; for (int i = 1; i < volumes_.size(); i++) { volumes_(i) += volumes_(i-1); - } + } // record original energetic properties int ntypes = lammpsInterface_->ntypes(); epsilon0_.reset(ntypes); p_ = lammpsInterface_->potential(); lammpsInterface_->epsilons(controlType_,p_,epsilon0_.ptr()); - + #ifdef ATC_VERBOSE string msg = "type "+to_string(controlType_)+" target count " + to_string(targetCount_); msg += " volume " + to_string(V_); @@ -280,11 +280,11 @@ const double kMinScale_ = 10000.; } double ConcentrationRegulatorMethodTransition::uniform() const { _rngUniformCounter_++; - return lammpsInterface_->random_uniform(randomNumberGenerator_); + return lammpsInterface_->random_uniform(randomNumberGenerator_); } double ConcentrationRegulatorMethodTransition::normal() const { _rngNormalCounter_++; - return lammpsInterface_->random_normal(randomNumberGenerator_); + return lammpsInterface_->random_normal(randomNumberGenerator_); } //-------------------------------------------------------- // pre exchange @@ -294,7 +294,7 @@ const double kMinScale_ = 10000.; // return if should not be called on this timestep if ( ! lammpsInterface_->now(frequency_)) return; nexchanges_ = excess(); - int n = abs(nexchanges_); + int n = abs(nexchanges_); bool success = false; if (nexchanges_ > 0) { success = delete_atoms(n); } else if (nexchanges_ < 0) { success = insert_atoms(n); } @@ -308,7 +308,7 @@ const double kMinScale_ = 10000.; } transitionCounter_=0; transition(); - } + } //-------------------------------------------------------- // pre force //-------------------------------------------------------- @@ -319,28 +319,28 @@ const double kMinScale_ = 10000.; //-------------------------------------------------------- // accept //-------------------------------------------------------- - bool ConcentrationRegulatorMethodTransition::accept(double energy, double /* T */) const - { + bool ConcentrationRegulatorMethodTransition::accept(double energy, double /* T */) const + { #ifdef ATC_VERBOSE2 if (energy < maxEnergy_) lammpsInterface_->print_msg(" energy "+to_string(energy)+" "+to_string(rngCounter_)); #endif return (energy < maxEnergy_); - } + } //-------------------------------------------------------- // energy //-------------------------------------------------------- - double ConcentrationRegulatorMethodTransition::energy(int id) const + double ConcentrationRegulatorMethodTransition::energy(int id) const { double e = lammpsInterface_->shortrange_energy(id,maxEnergy_); #ifdef ATC_VERBOSE -{ +{ int * tag = lammpsInterface_->atom_tag(); lammpsInterface_->print_msg(to_string(controlType_)+" deletion energy "+to_string(e)+" id "+to_string(tag[id])+" "+to_string(_rngUniformCounter_)+":"+to_string(_rngNormalCounter_)); } #endif return e; } - double ConcentrationRegulatorMethodTransition::energy(double * x) const + double ConcentrationRegulatorMethodTransition::energy(double * x) const { double e = lammpsInterface_->shortrange_energy(x,controlType_,maxEnergy_); #ifdef ATC_VERBOSE @@ -375,8 +375,8 @@ const double kMinScale_ = 10000.; bool ConcentrationRegulatorMethodTransition::delete_atoms(int n) { ID_PAIR idPair; - - deletionIds_.clear(); + + deletionIds_.clear(); int deletions = 0; int attempts = 0; while(deletions < n && attempts < maxAttempts_){ @@ -406,7 +406,7 @@ const double kMinScale_ = 10000.; //-------------------------------------------------------- double ConcentrationRegulatorMethodTransition::deletion_id(ID_PAIR & id) const { - if (atc_->parallel_consistency()) return deletion_id_consistent(id); + if (atc_->parallel_consistency()) return deletion_id_consistent(id); else return deletion_id_free(id); } double ConcentrationRegulatorMethodTransition::deletion_id_consistent(ID_PAIR & id) const @@ -422,12 +422,12 @@ const double kMinScale_ = 10000.; double min = ntotal; int * tag = lammpsInterface_->atom_tag(); for (itr = list.begin(); itr != list.end(); itr++) { - int atag = tag[itr->second]; + int atag = tag[itr->second]; double d = fabs(atag-r); if (d < min) { min = d; idx = i; - } + } i++; } int imin = kMinScale_*min; @@ -455,7 +455,7 @@ const double kMinScale_ = 10000.; r *= ntotal; if ( (r >= nrank-n) && (r < nrank)) { // pick processor - r = uniform(); + r = uniform(); int idx = rnd(r*(n-1)); id = list_->item(idx); // avoid repeats @@ -463,7 +463,7 @@ const double kMinScale_ = 10000.; l.erase(l.begin()+idx); return energy(id.second); } - else { + else { return maxEnergy_; } } @@ -474,7 +474,7 @@ const double kMinScale_ = 10000.; { insertionIds_.clear(); - DENS_VEC x(3); x = 0; + DENS_VEC x(3); x = 0; DENS_VEC v(3); v = 0; const DENS_MAN & T = atc_->field(TEMPERATURE); int additions = 0; @@ -482,7 +482,7 @@ const double kMinScale_ = 10000.; while(additions < n && attempts < maxAttempts_){ if(accept(insertion_location(x))) { DENS_VEC Tv = atc_->fe_engine()->interpolate_field(x,T); -Tv(0) = 300.; +Tv(0) = 300.; pick_velocity(v,Tv(0)); // 3 normal int nlocal = lammpsInterface_->insert_atom(transitionType_,controlMask_,x.ptr(),v.ptr()); // no charge insertionIds_.push_back(pair(-1,nlocal)); // atc id unknown @@ -540,7 +540,7 @@ Tv(0) = 300.; //-------------------------------------------------------- double ConcentrationRegulatorMethodTransition::insertion_location(DENS_VEC & x) const { - // pick random element + // pick random element int elem = pick_element(); // 1 uniform // pick random local coordinate DENS_VEC xi(3); @@ -552,8 +552,8 @@ Tv(0) = 300.; #endif return energy(x.ptr()); } - else { - return maxEnergy_; + else { + return maxEnergy_; } } //-------------------------------------------------------- @@ -573,7 +573,7 @@ Tv(0) = 300.; // pick coordinates //-------------------------------------------------------- void ConcentrationRegulatorMethodTransition::pick_coordinates(const int elem, - DENS_VEC & xi, + DENS_VEC & xi, DENS_VEC & x) const { xi.reset(3); @@ -600,9 +600,9 @@ Tv(0) = 300.; void ConcentrationRegulatorMethodTransition::transition() { transitionCounter_++; - //if (insertionIds_.size() == 0) return; // - if (transitionCounter_> transitionInterval_) { - nInTransition_ = 0; + //if (insertionIds_.size() == 0) return; // + if (transitionCounter_> transitionInterval_) { + nInTransition_ = 0; return; } else if (transitionCounter_==transitionInterval_) { @@ -611,10 +611,10 @@ Tv(0) = 300.; else { transitionFactor_ = insertion_factor(transitionCounter_); if (nInTransition_ < 0) transitionFactor_ = 1-transitionFactor_; - double q = 0; + double q = 0; lammpsInterface_->set_charge(transitionType_,q); DENS_VEC eps = epsilon0_; - + lammpsInterface_->set_epsilons(transitionType_,p_,eps.ptr()); lammpsInterface_->pair_reinit(); // epsilon } @@ -624,7 +624,7 @@ Tv(0) = 300.; //-------------------------------------------------------- double ConcentrationRegulatorMethodTransition::compute_vector(int n) const { - if (n==0) return count() - targetCount_; + if (n==0) return count() - targetCount_; else if (n==1) return count()/V_; else if (n==2) return (1.-transitionFactor_)*nInTransition_; else if (n==3) return _rngUniformCounter_; diff --git a/lib/atc/ConcentrationRegulator.h b/lib/atc/ConcentrationRegulator.h index 952cf88339..89810f4e49 100644 --- a/lib/atc/ConcentrationRegulator.h +++ b/lib/atc/ConcentrationRegulator.h @@ -16,13 +16,13 @@ namespace ATC { class ConcentrationRegulatorMethod; class ConcentrationRegulator : public AtomicRegulator { - + public: enum ConcentrationRegulatorType {NONE=0,TRANSITION}; /** parser data */ struct ConcentrationRegulatorParameters { ConcentrationRegulatorParameters(): - method(NONE), + method(NONE), type(0), groupbit(0), transitionType(0), @@ -36,14 +36,14 @@ namespace ATC { int type; int groupbit; int transitionType; - double value; + double value; int frequency; int transitionInterval; double maxEnergy; int maxExchanges; int maxAttempts; std::string transitionTag; - ESET elemset; + ESET elemset; }; /** constructor */ @@ -96,22 +96,22 @@ namespace ATC { private: ConcentrationRegulator(); // DO NOT define this }; - + /** * @class ConcentrationRegulatorMethod - * @brief Base class for ConcentrationRegulator algorithms + * @brief Base class for ConcentrationRegulator algorithms */ class ConcentrationRegulatorMethod : public RegulatorShapeFunction { - + public: ConcentrationRegulatorMethod(ConcentrationRegulator *c) : RegulatorShapeFunction(c) {}; ~ConcentrationRegulatorMethod() {}; void initialize(void) {}; - virtual void pre_force() {}; - virtual void pre_exchange() {}; - virtual void finish() {}; + virtual void pre_force() {}; + virtual void pre_exchange() {}; + virtual void finish() {}; virtual void set_weights() {}; virtual double compute_vector(int /* n */) const { return 0;} virtual void output(OUTPUT_LIST & /* outputData */){}; @@ -124,7 +124,7 @@ namespace ATC { * @brief GCMC + thermodynamic integration */ class ConcentrationRegulatorMethodTransition : public ConcentrationRegulatorMethod { - + public: /** constructor */ ConcentrationRegulatorMethodTransition( @@ -135,11 +135,11 @@ namespace ATC { if (randomNumberGenerator_) delete randomNumberGenerator_; } /** initialize */ - void initialize(void); + void initialize(void); /** prior to force evaluation */ - virtual void pre_force(); + virtual void pre_force(); /** prior to exchanges */ - virtual void pre_exchange(); + virtual void pre_exchange(); /** "thermo" output */ virtual double compute_vector(int n) const; protected: @@ -155,13 +155,13 @@ namespace ATC { double deletion_id_free(ID_PAIR & id) const ; double insertion_factor(int c) const // a ramp { - if (c < transitionInterval_) return ((double) c)/transitionInterval_; + if (c < transitionInterval_) return ((double) c)/transitionInterval_; else return 1.0; } void transition(); bool accept(double energy, double T = 0) const; bool delete_atoms(int n); - bool insert_atoms(int n); + bool insert_atoms(int n); int pick_element() const; void pick_coordinates(const int elem, DENS_VEC & xi, DENS_VEC& x ) const; void pick_velocity(DENS_VEC & v, const double T ) const; @@ -179,9 +179,9 @@ namespace ATC { /** member data */ class AtomInElementSet * list_; - double targetConcentration_; - double targetCount_; - ESET elemset_; + double targetConcentration_; + double targetCount_; + ESET elemset_; POTENTIAL p_; RNG_POINTER randomNumberGenerator_; DENS_VEC volumes_; diff --git a/lib/atc/DenseMatrix.h b/lib/atc/DenseMatrix.h index e4759f02d4..0143b7cc52 100644 --- a/lib/atc/DenseMatrix.h +++ b/lib/atc/DenseMatrix.h @@ -8,8 +8,8 @@ namespace ATC_matrix { /** - * @class DenseMatrix - * @brief Class for storing data in a "dense" matrix form + * @class DenseMatrix + * @brief Class for storing data in a "dense" matrix form */ template @@ -36,7 +36,7 @@ public: DenseMatrix mult_by_element(const DenseMatrix& B) const; /** returns by element multiply A_ij = this_ij / B_ij */ DenseMatrix div_by_element(const DenseMatrix& B) const; - + /** overloaded virtual functions */ //T& operator()(INDEX i, INDEX j) { MICK(i,j) return DATA(i,j); } T& operator()(INDEX i, INDEX j) { MICK(i,j) return DATA(i,j); } @@ -50,7 +50,7 @@ public: void from_file(std::string & name); void set_all_elements_to(const T &v); DiagonalMatrix diag() const; - + DenseMatrix& operator=(const T &v); DenseMatrix& operator=(const Matrix &c); DenseMatrix& operator=(const DenseMatrix &c); @@ -120,8 +120,8 @@ void DenseMatrix::resize(INDEX rows, INDEX cols, bool copy) _delete(); _create(rows, cols); int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) for (INDEX j = 0; j < szj; j++) (*this)(i,j) = temp.in_range(i,j) ? temp(i,j) : T(0); } @@ -153,22 +153,22 @@ DenseMatrix DenseMatrix::mult_by_element(const DenseMatrix& B) const DenseMatrix C; C.reset(_nRows,_nCols); if (B.nCols() == _nCols) { - int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + int szi = this->nRows(); + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) + for (INDEX j = 0; j < szj; j++) C(i,j) = (*this)(i,j)*B(i,j); } else if (B.nCols() == 1) { std::cout << "MULTIPLYING\n"; - int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + int szi = this->nRows(); + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) + for (INDEX j = 0; j < szj; j++) C(i,j) = (*this)(i,j)*B(i,0); } - else { - SSCK(B, *this, "DenseMatrix::mult_by_element"); + else { + SSCK(B, *this, "DenseMatrix::mult_by_element"); } return C; } @@ -182,21 +182,21 @@ DenseMatrix DenseMatrix::div_by_element(const DenseMatrix& B) const C.reset(_nRows,_nCols); if (B.nCols() == _nCols) { - int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + int szi = this->nRows(); + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) + for (INDEX j = 0; j < szj; j++) C(i,j) = (*this)(i,j)/B(i,j); } else if (B.nCols() == 1) { - int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + int szi = this->nRows(); + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) + for (INDEX j = 0; j < szj; j++) C(i,j) = (*this)(i,j)/B(i,0); } - else { - SSCK(B, *this, "DenseMatrix::div_by_element"); + else { + SSCK(B, *this, "DenseMatrix::div_by_element"); } return C; } @@ -214,7 +214,7 @@ void DenseMatrix::write_restart(FILE *f) const // reads matrix from text file (matrix needs to be sized) //---------------------------------------------------------------------------- template -void DenseMatrix::from_file(std::string & name) +void DenseMatrix::from_file(std::string & name) { GCHK(_nRows == 0,"from_file needs nRows > 0"); GCHK(_nCols == 0,"from_file needs nCols > 0"); @@ -223,10 +223,10 @@ void DenseMatrix::from_file(std::string & name) char line[lineSize]; if (! in.good()) gerror(name+" is not available"); in.getline(line,lineSize); // header - int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + int szi = this->nRows(); + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) + for (INDEX j = 0; j < szj; j++) in >> (*this)(i,j); } //---------------------------------------------------------------------------- @@ -239,15 +239,15 @@ inline void DenseMatrix::set_all_elements_to(const T &v) for (INDEX i = 0; i < sz; i++) _data[i] = v; } //----------------------------------------------------------------------------- -// Return a diagonal matrix containing the diagonal entries of this matrix +// Return a diagonal matrix containing the diagonal entries of this matrix //----------------------------------------------------------------------------- template -DiagonalMatrix DenseMatrix::diag() const +DiagonalMatrix DenseMatrix::diag() const { DiagonalMatrix D(nRows(), true); // initialized to zero INDEX i; for (i=0; i void DenseMatrix::_delete() { _nRows = _nCols = 0; - if (_data){ + if (_data){ delete [] _data; _data = nullptr; } @@ -271,7 +271,7 @@ template void DenseMatrix::_create(INDEX rows, INDEX cols, bool zero) { - _nRows=rows; + _nRows=rows; _nCols=cols; _data = (this->size() ? new T [_nCols*_nRows] : nullptr); if (zero) this->zero(); @@ -280,14 +280,14 @@ void DenseMatrix::_create(INDEX rows, INDEX cols, bool zero) // creates a deep memory copy from a general matrix //---------------------------------------------------------------------------- template -void DenseMatrix::_copy(const Matrix &c) +void DenseMatrix::_copy(const Matrix &c) { if (!_data || this->size()!=c.size()) { - _delete(); + _delete(); _create(c.nRows(), c.nCols()); } - else + else { _nRows = c.nRows(); _nCols = c.nCols(); @@ -295,7 +295,7 @@ void DenseMatrix::_copy(const Matrix &c) memcpy(_data, c.ptr(), c.size()*sizeof(T)); } //---------------------------------------------------------------------------- -// sets all elements to a constant +// sets all elements to a constant //---------------------------------------------------------------------------- template DenseMatrix& DenseMatrix::operator=(const T &v) @@ -355,9 +355,9 @@ void DenseMatrix::_set_equal(const Matrix &r) } } //* Returns the transpose of the cofactor matrix of A. -//* see http://en.wikipedia.org/wiki/Adjugate_matrix -//* symmetric flag only affects cases N>3 -template +//* see http://en.wikipedia.org/wiki/Adjugate_matrix +//* symmetric flag only affects cases N>3 +template DenseMatrix adjugate(const Matrix &A, bool symmetric) { if (!A.is_square()) gerror("adjugate can only be computed for square matrices."); @@ -365,7 +365,7 @@ DenseMatrix adjugate(const Matrix &A, bool symmetric) switch (A.nRows()) { case 1: gerror("adjugate must be computed for matrixes of size greater than 1"); - case 2: + case 2: C(0,0) = A(1,1); C(0,1) =-A(0,1); C(1,0) =-A(1,0); C(1,1) = A(0,0); break; @@ -377,18 +377,18 @@ DenseMatrix adjugate(const Matrix &A, bool symmetric) C(1,1) = A(0,0)*A(2,2)-A(0,2)*A(2,0); C(2,1) =-A(0,0)*A(2,1)+A(0,1)*A(2,0); // i+j is odd C(0,2) = A(0,1)*A(1,2)-A(0,2)*A(1,1); - C(1,2) =-A(0,0)*A(1,2)+A(0,2)*A(1,0); // i+j is odd + C(1,2) =-A(0,0)*A(1,2)+A(0,2)*A(1,0); // i+j is odd C(2,2) = A(0,0)*A(1,1)-A(0,1)*A(1,0); break; - default: - + default: + // this feature is neither tested nor optimal - use at your own risk!!! DenseMatrix m(A.nRows()-1, A.nRows()-1); double sign[] = {1.0, -1.0}; for (INDEX j=0; j=i), mj+(mj>=j)); // skip row i and col j } } diff --git a/lib/atc/DenseVector.h b/lib/atc/DenseVector.h index bab90bf3ff..1108d02451 100644 --- a/lib/atc/DenseVector.h +++ b/lib/atc/DenseVector.h @@ -9,7 +9,7 @@ template /** * @class DenseVector - * @brief Class for storing data in a "dense" vector form + * @brief Class for storing data in a "dense" vector form */ class DenseVector : public Vector @@ -20,7 +20,7 @@ public: DenseVector(const Vector &c) : Vector(), _data(nullptr) { _copy(c); } DenseVector(const T * ptr, INDEX nrows) : Vector(), _data(nullptr) { copy(ptr,nrows); } virtual ~DenseVector() { _delete(); } - + //* resizes the Vector, ignores nCols, optionally copys what fits void resize(INDEX rows, INDEX cols=1, bool copy=false); //* resizes the Vector, ignores nCols, optionally zeros it out @@ -35,7 +35,7 @@ public: T& operator()(INDEX i, INDEX /* j */) { VICK(i) return _data[i]; } T operator()(INDEX i) const { VICK(i) return _data[i]; } T& operator()(INDEX i) { VICK(i) return _data[i]; } - void set_all_elements_to(const T &v) { + void set_all_elements_to(const T &v) { int sz = this->size(); for (INDEX i = 0; i < sz; i++) _data[i] = v; } @@ -129,8 +129,8 @@ inline void DenseVector::_create(INDEX n, bool zero) /////////////////////////////////////////////////////////////////////////////// //* creates a deep memory copy from a general matrix template -inline void DenseVector::_copy(const Vector &c) -{ +inline void DenseVector::_copy(const Vector &c) +{ if (!_data || _size!=c.size()) { _delete(); diff --git a/lib/atc/DependencyManager.h b/lib/atc/DependencyManager.h index c797406240..fe8ed036ff 100644 --- a/lib/atc/DependencyManager.h +++ b/lib/atc/DependencyManager.h @@ -20,7 +20,7 @@ namespace ATC { }; /** - * @class DependencyManager + * @class DependencyManager * @brief Base class for defining objects that manage the dependencies of various objects */ @@ -30,13 +30,13 @@ namespace ATC { // used as a friend so it can perform a depth-first search to have safe deletions of managed dependencies friend class InterscaleManager; - + // constructor DependencyManager() : needReset_(true), isFixed_(false), memoryType_(TEMPORARY), dfsFound_(false) {}; - + // destructor virtual ~DependencyManager() {}; - + /** registration by other PerAtomQuantity objects */ void register_dependence(DependencyManager * dependentQuantity) {dependentQuantities_.insert(dependentQuantity);}; @@ -47,7 +47,7 @@ namespace ATC { /** check if a reset is required */ bool need_reset() const {return needReset_ && !isFixed_;}; - + /** propagate need to reset to to dependencies */ void propagate_reset() { @@ -91,10 +91,10 @@ namespace ATC { protected: - + /** list of dependent atomic quantities */ std::set dependentQuantities_; - + /** flag for needing a recent */ // mutable is applied because there can be internal updates because we update when needed rather than when pushed mutable bool needReset_; @@ -107,9 +107,9 @@ namespace ATC { /** flag for if the node has been found in depth-first search */ bool dfsFound_; - + }; - + /** * @class MatrixDependencyManager * @brief Class for defining objects that manage the dependencies of matrices @@ -127,7 +127,7 @@ namespace ATC { /** returns a non-const version for manipulations and changes, resets dependent quantities */ virtual T & set_quantity() {propagate_reset(); return get_quantity();}; - + /** access to a constant dense matrix of the quantity, indexed by AtC atom counts */ virtual const T & quantity() const {return get_quantity();}; @@ -210,12 +210,12 @@ namespace ATC { { public: - MatrixDependencyManager(MPI_Comm comm) : + MatrixDependencyManager(MPI_Comm comm) : MatrixDependencyManager(), quantity_(comm) {}; - + MatrixDependencyManager(MPI_Comm comm, int nRows, int nCols) : MatrixDependencyManager(), quantity_(comm, nRows, nCols) {}; - + virtual ~MatrixDependencyManager() {}; protected: @@ -238,12 +238,12 @@ namespace ATC { { public: - MatrixDependencyManager(MPI_Comm comm) : + MatrixDependencyManager(MPI_Comm comm) : MatrixDependencyManager(), quantity_(comm) {}; - + MatrixDependencyManager(MPI_Comm comm, int nRows, int nCols) : MatrixDependencyManager(), quantity_(comm, nRows, nCols) {}; - + virtual ~MatrixDependencyManager() {}; protected: @@ -267,13 +267,13 @@ namespace ATC { // constructor SetDependencyManager() : DependencyManager(), quantity_() {}; - + // destructor virtual ~SetDependencyManager() {}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ virtual std::set & set_quantity() {propagate_reset(); return quantity_;}; - + /** access to a constant dense matrix of the quantity, indexed by AtC atom counts */ virtual const std::set & quantity() const {return quantity_;}; @@ -300,13 +300,13 @@ namespace ATC { // constructor VectorDependencyManager() : DependencyManager(), quantity_() {}; - + // destructor virtual ~VectorDependencyManager() {}; /** returns a non-const version for manipulations and changes, resets dependent quantities */ virtual std::vector & set_quantity() {propagate_reset(); return quantity_;}; - + /** access to a constant dense matrix of the quantity, indexed by AtC atom counts */ virtual const std::vector & quantity() const {return quantity_;}; diff --git a/lib/atc/DiagonalMatrix.h b/lib/atc/DiagonalMatrix.h index b24e19dd4e..49256975e9 100644 --- a/lib/atc/DiagonalMatrix.h +++ b/lib/atc/DiagonalMatrix.h @@ -7,19 +7,19 @@ namespace ATC_matrix { /** * @class DiagonalMatrix - * @brief Class for storing data as a diagonal matrix + * @brief Class for storing data as a diagonal matrix */ template class DiagonalMatrix : public Matrix { - public: + public: explicit DiagonalMatrix(INDEX nRows=0, bool zero=0); DiagonalMatrix(const DiagonalMatrix& c); DiagonalMatrix(const Vector& v); virtual ~DiagonalMatrix(); - - //* resizes the matrix, ignores nCols, optionally zeros + + //* resizes the matrix, ignores nCols, optionally zeros void reset(INDEX rows, INDEX cols=0, bool zero=true); //* resizes the matrix, ignores nCols, optionally copies what fits void resize(INDEX rows, INDEX cols=0, bool copy=false); @@ -62,7 +62,7 @@ class DiagonalMatrix : public Matrix INDEX size() const { return _data->size(); } //* computes the inverse of this matrix - DiagonalMatrix& inv_this(); + DiagonalMatrix& inv_this(); //* returns a copy of the inverse of this matrix DiagonalMatrix inv() const; @@ -82,19 +82,19 @@ protected: DiagonalMatrix& operator=(const Vector & /* c */) {} DiagonalMatrix& operator=(const Matrix & /* c */) {} -private: +private: void _delete(); Vector *_data; -}; +}; //----------------------------------------------------------------------------- // DiagonalMatrix-DiagonalMatrix multiplication //----------------------------------------------------------------------------- template -DiagonalMatrix operator*(const DiagonalMatrix& A, const DiagonalMatrix& B) +DiagonalMatrix operator*(const DiagonalMatrix& A, const DiagonalMatrix& B) { SSCK(A, B, "DiagonalMatrix-DiagonalMatrix multiplication"); - DiagonalMatrix R(A); + DiagonalMatrix R(A); for (INDEX i=0; i operator*(const Vector &b, const DiagonalMatrix& A) // DiagonalMatrix-SparseMatrix multiplication //----------------------------------------------------------------------------- template -SparseMatrix operator*(const DiagonalMatrix &A, const SparseMatrix& B) +SparseMatrix operator*(const DiagonalMatrix &A, const SparseMatrix& B) { GCK(A, B, A.nCols()!=B.nRows() ,"DiagonalMatrix-SparseMatrix multiplication"); SparseMatrix R(B); @@ -171,7 +171,7 @@ DiagonalMatrix operator*(DiagonalMatrix &A, const T s) // Commute with DiagonalMatrix * double //----------------------------------------------------------------------------- template -DiagonalMatrix operator*(const T s, const DiagonalMatrix& A) +DiagonalMatrix operator*(const T s, const DiagonalMatrix& A) { DiagonalMatrix R(A); R *= s; @@ -231,10 +231,10 @@ DiagonalMatrix::DiagonalMatrix(const Vector& v) // destructor //----------------------------------------------------------------------------- template -DiagonalMatrix::~DiagonalMatrix() +DiagonalMatrix::~DiagonalMatrix() { _delete(); -} +} //----------------------------------------------------------------------------- // deletes the data stored by this matrix //----------------------------------------------------------------------------- @@ -244,7 +244,7 @@ void DiagonalMatrix::_delete() if (_data) delete _data; } //----------------------------------------------------------------------------- -// resizes the matrix, ignores nCols, optionally zeros +// resizes the matrix, ignores nCols, optionally zeros //----------------------------------------------------------------------------- template void DiagonalMatrix::reset(INDEX rows, INDEX /* cols */, bool zero) @@ -258,13 +258,13 @@ void DiagonalMatrix::reset(INDEX rows, INDEX /* cols */, bool zero) template void DiagonalMatrix::resize(INDEX rows, INDEX /* cols */, bool copy) { - _data->resize(rows, copy); + _data->resize(rows, copy); } //----------------------------------------------------------------------------- // changes the diagonal of the matrix to a vector v (makes a copy) //----------------------------------------------------------------------------- template -void DiagonalMatrix::reset(const Vector& v) +void DiagonalMatrix::reset(const Vector& v) { if (&v == _data) return; // check for self-reset _delete(); @@ -274,7 +274,7 @@ void DiagonalMatrix::reset(const Vector& v) // copys from another DiagonalMatrix //----------------------------------------------------------------------------- template -void DiagonalMatrix::reset(const DiagonalMatrix& c) +void DiagonalMatrix::reset(const DiagonalMatrix& c) { reset(*(c._data)); } @@ -337,41 +337,41 @@ T& DiagonalMatrix::operator()(INDEX i, INDEX /* j */) // value indexing operator - returns 0 if i!=j //----------------------------------------------------------------------------- template -T DiagonalMatrix::operator()(INDEX i, INDEX j) const +T DiagonalMatrix::operator()(INDEX i, INDEX j) const { - return (i==j) ? (*_data)(i) : (T)0; + return (i==j) ? (*_data)(i) : (T)0; } //----------------------------------------------------------------------------- // flat reference indexing operator //----------------------------------------------------------------------------- template -T& DiagonalMatrix::operator[](INDEX i) +T& DiagonalMatrix::operator[](INDEX i) { - return (*_data)(i); + return (*_data)(i); } //----------------------------------------------------------------------------- // flat value indexing operator //----------------------------------------------------------------------------- template -T DiagonalMatrix::operator[](INDEX i) const -{ - return (*_data)(i); +T DiagonalMatrix::operator[](INDEX i) const +{ + return (*_data)(i); } //----------------------------------------------------------------------------- // returns the number of rows //----------------------------------------------------------------------------- template -INDEX DiagonalMatrix::nRows() const -{ - return _data->size(); +INDEX DiagonalMatrix::nRows() const +{ + return _data->size(); } //----------------------------------------------------------------------------- // returns the number of columns (same as nCols()) //----------------------------------------------------------------------------- template -INDEX DiagonalMatrix::nCols() const +INDEX DiagonalMatrix::nCols() const { - return _data->size(); + return _data->size(); } //----------------------------------------------------------------------------- // returns a pointer to the diagonal values, dangerous! @@ -379,13 +379,13 @@ INDEX DiagonalMatrix::nCols() const template T* DiagonalMatrix::ptr() const { - return _data->ptr(); -} + return _data->ptr(); +} //----------------------------------------------------------------------------- // writes the diagonal to a binary data restart file //----------------------------------------------------------------------------- template -void DiagonalMatrix::write_restart(FILE *f) const +void DiagonalMatrix::write_restart(FILE *f) const { _data->write_restart(f); } @@ -393,7 +393,7 @@ void DiagonalMatrix::write_restart(FILE *f) const // sets the diagonal to a constant //----------------------------------------------------------------------------- template -DiagonalMatrix& DiagonalMatrix::operator=(const T v) +DiagonalMatrix& DiagonalMatrix::operator=(const T v) { this->set_all_elements_to(v); return *this; @@ -402,7 +402,7 @@ DiagonalMatrix& DiagonalMatrix::operator=(const T v) // assignment operator with another diagonal matrix //----------------------------------------------------------------------------- template -DiagonalMatrix& DiagonalMatrix::operator=(const DiagonalMatrix& C) +DiagonalMatrix& DiagonalMatrix::operator=(const DiagonalMatrix& C) { reset(C); return *this; @@ -411,7 +411,7 @@ DiagonalMatrix& DiagonalMatrix::operator=(const DiagonalMatrix& C) // writes a matlab command to duplicate this sparse matrix //----------------------------------------------------------------------------- template -void DiagonalMatrix::matlab(std::ostream &o, const std::string &s) const +void DiagonalMatrix::matlab(std::ostream &o, const std::string &s) const { _data->matlab(o, s); o << s <<"=diag("<::matlab(std::ostream &o, const std::string &s) template DiagonalMatrix& DiagonalMatrix::inv_this() { - for(INDEX i=0; iminabs() / _data->maxabs(); if (min_max > 1e-14) return *this; @@ -447,10 +447,10 @@ DiagonalMatrix DiagonalMatrix::inv() const { DiagonalMatrix invA(*this); // Make copy of A to invert - for(INDEX i=0; i::_set_equal(const Matrix &r) } } //----------------------------------------------------------------------------- -// casts a generic matrix pointer into a DiagonalMatrix pointer - null if fail +// casts a generic matrix pointer into a DiagonalMatrix pointer - null if fail //----------------------------------------------------------------------------- template const DiagonalMatrix *diag_cast(const Matrix *m) diff --git a/lib/atc/ElasticTimeIntegrator.cpp b/lib/atc/ElasticTimeIntegrator.cpp index 785568cbb2..3d4cb83774 100644 --- a/lib/atc/ElasticTimeIntegrator.cpp +++ b/lib/atc/ElasticTimeIntegrator.cpp @@ -15,7 +15,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- MomentumTimeIntegrator::MomentumTimeIntegrator(ATC_Coupling * atc, TimeIntegrationType timeIntegrationType) : TimeIntegrator(atc, timeIntegrationType) @@ -36,7 +36,7 @@ namespace ATC { \section syntax fix_modify AtC time_integration \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, nodal temperature update with 2nd order Verlet, kinetostats based on controlling force \n @@ -49,7 +49,7 @@ namespace ATC { \section related see \ref man_fix_atc \section default - none + none */ if (strcmp(arg[argIndex],"verlet")==0) { timeIntegrationType_ = VERLET; @@ -78,7 +78,7 @@ namespace ATC { if (atc_->reset_methods()) { if (timeIntegrationMethod_) delete timeIntegrationMethod_; - + if (timeFilterManager_->need_reset()) { switch (timeIntegrationType_) { case VERLET: @@ -122,7 +122,7 @@ namespace ATC { default: throw ATC_Error("Unknown time integration type in MomentumTimeIntegrator::Initialize()"); } - } + } } } @@ -146,7 +146,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor // Grab data from ATC - //-------------------------------------------------------- + //-------------------------------------------------------- MomentumIntegrationMethod::MomentumIntegrationMethod(MomentumTimeIntegrator * momentumTimeIntegrator) : TimeIntegrationMethod(momentumTimeIntegrator), timeFilter_(timeIntegrator_->time_filter()), @@ -178,7 +178,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- ElasticTimeIntegratorVerlet::ElasticTimeIntegratorVerlet(MomentumTimeIntegrator * momentumTimeIntegrator) : MomentumIntegrationMethod(momentumTimeIntegrator), displacement_(atc_->field(DISPLACEMENT)), @@ -217,7 +217,7 @@ namespace ATC { if (timeFilterManager->need_reset()) { timeFilter_->initialize(nodalAtomicForce_->quantity()); } - + if (!(timeFilterManager->end_equilibrate())) { nodalAtomicForceFiltered_.reset(atc_->num_nodes(),atc_->nsd()); } @@ -238,14 +238,14 @@ namespace ATC { explicit_1(velocity_.set_quantity(),acceleration_.quantity(),.5*dt); } - + //-------------------------------------------------------- // post_initial_integrate1 // time integration after Verlet step 1 //-------------------------------------------------------- void ElasticTimeIntegratorVerlet::post_initial_integrate1(double dt) { - + // for improved accuracy, but this would be inconsistent with // the atomic integration scheme explicit_1(displacement_.set_quantity(),velocity_.quantity(),dt); @@ -253,7 +253,7 @@ namespace ATC { //-------------------------------------------------------- // pre_final_integrate1 - // first time integration computations + // first time integration computations // before Verlet step 2 //-------------------------------------------------------- void ElasticTimeIntegratorVerlet::pre_final_integrate1(double dt) @@ -325,7 +325,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- ElasticTimeIntegratorVerletFiltered::ElasticTimeIntegratorVerletFiltered(MomentumTimeIntegrator * momentumTimeIntegrator) : ElasticTimeIntegratorVerlet(momentumTimeIntegrator), nodalAtomicAcceleration_(atc_->nodal_atomic_field_roc(VELOCITY)) @@ -349,7 +349,7 @@ namespace ATC { //-------------------------------------------------------- void ElasticTimeIntegratorVerletFiltered::post_initial_integrate1(double dt) { - + // for improved accuracy, but this would be inconsistent with // the atomic integration scheme explicit_1(displacement_.set_quantity(),velocity_.quantity(),dt); @@ -367,7 +367,7 @@ namespace ATC { acceleration_.set_quantity(), VELOCITY); explicit_1(velocity_.set_quantity(),acceleration_.quantity(),.5*dt); - + atc_->apply_inverse_md_mass_matrix(nodalAtomicForceFiltered_.quantity(), nodalAtomicAcceleration_.set_quantity(), VELOCITY); @@ -404,7 +404,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- ElasticTimeIntegratorFractionalStep::ElasticTimeIntegratorFractionalStep(MomentumTimeIntegrator * momentumTimeIntegrator) : MomentumIntegrationMethod(momentumTimeIntegrator), displacement_(atc_->field(DISPLACEMENT)), @@ -413,7 +413,7 @@ namespace ATC { nodalAtomicMomentum_(nullptr), nodalAtomicMomentumFiltered_(momentumTimeIntegrator->nodal_atomic_momentum_filtered()), nodalAtomicDisplacement_(nullptr), - nodalAtomicMomentumOld_(atc_->num_nodes(),atc_->nsd()), + nodalAtomicMomentumOld_(atc_->num_nodes(),atc_->nsd()), nodalAtomicVelocityOld_(atc_->num_nodes(),atc_->nsd()) { // do nothing @@ -450,7 +450,7 @@ namespace ATC { // the form of this integrator implies no time filters that require history data can be used timeFilter_->initialize(); } - + // sets up time filter for post-processing the filtered power // this time integrator should use an explicit-implicit filter // to mirror the 2nd order Verlet integration scheme @@ -513,7 +513,7 @@ namespace ATC { atomicVelocityDelta, VELOCITY); velocity_ += atomicVelocityDelta; - + // approximation to force for output nodalAtomicForce_ /= 0.5*dt; timeFilter_->apply_post_step1(nodalAtomicForceFiltered_.set_quantity(), @@ -549,16 +549,16 @@ namespace ATC { // atomic contributions to change in momentum // compute change in restricted atomic momentum nodalAtomicForce_ += nodalAtomicMomentum_->quantity(); - + // update FE temperature with change in temperature from MD compute_velocity_delta(nodalAtomicForce_,dt); velocity_ += atomicVelocityDelta_.quantity(); - + // approximation to power for output nodalAtomicForce_ /= 0.5*dt; timeFilter_->apply_post_step1(nodalAtomicForceFiltered_.set_quantity(), nodalAtomicForce_,dt); - + // change to velocity from FE dynamics atc_->apply_inverse_mass_matrix(velocityRhs_.quantity(), acceleration_.set_quantity(), @@ -681,7 +681,7 @@ namespace ATC { if (!timeFilterManager->end_equilibrate()) { // implies an initial condition of the instantaneous atomic energy // for the corresponding filtered variable, consistent with the temperature - nodalAtomicMomentumFiltered_ = nodalAtomicMomentum_->quantity(); + nodalAtomicMomentumFiltered_ = nodalAtomicMomentum_->quantity(); nodalAtomicForceFiltered_.reset(atc_->num_nodes(),atc_->nsd()); } } @@ -709,7 +709,7 @@ namespace ATC { apply_gear_predictor(dt); // update filtered nodal atomic force - + // that way kinetostat and integrator can be consistent timeFilter_->apply_pre_step1(nodalAtomicForceFiltered_.set_quantity(), nodalAtomicForce_,dt); @@ -724,15 +724,15 @@ namespace ATC { //-------------------------------------------------------- void FluidsTimeIntegratorGear::pre_final_integrate1(double dt) { - + // before the new rhs is computed but after atomic velocity is updated. // compute change in restricted atomic momentum nodalAtomicForce_ += nodalAtomicMomentum_->quantity(); - + // update FE velocity with change in velocity from MD compute_velocity_delta(nodalAtomicForce_,dt); velocity_ += atomicVelocityDelta_.quantity(); - + // approximation to force for output nodalAtomicForce_ /= dt; timeFilter_->apply_post_step1(nodalAtomicForceFiltered_.set_quantity(), diff --git a/lib/atc/ElasticTimeIntegrator.h b/lib/atc/ElasticTimeIntegrator.h index 02e6b5c3c8..70d1eb8b54 100644 --- a/lib/atc/ElasticTimeIntegrator.h +++ b/lib/atc/ElasticTimeIntegrator.h @@ -16,19 +16,19 @@ namespace ATC { */ class MomentumTimeIntegrator : public TimeIntegrator { - + public: - + // constructor MomentumTimeIntegrator(ATC_Coupling * atc, TimeIntegrationType timeIntegrationType); - + // destructor virtual ~MomentumTimeIntegrator(){}; /** parser/modifier */ virtual bool modify(int narg, char **arg); - + /** create objects to implement requested numerical method */ virtual void construct_methods(); @@ -47,7 +47,7 @@ namespace ATC { protected: /** filtered atomic force */ - + DENS_MAN nodalAtomicForceFiltered_; /** filtered atomic momentum due initial conditions and MD updates */ @@ -58,7 +58,7 @@ namespace ATC { // DO NOT define this MomentumTimeIntegrator(); - + }; /** @@ -67,12 +67,12 @@ namespace ATC { */ class MomentumIntegrationMethod : public TimeIntegrationMethod { - + public: - + // constructor MomentumIntegrationMethod(MomentumTimeIntegrator * momentumTimeIntegrator); - + // destructor virtual ~MomentumIntegrationMethod(){}; @@ -81,17 +81,17 @@ namespace ATC { /** checks to see if first RHS computation is needed */ virtual bool has_final_predictor() {return true;}; - + protected: - + /** time filtering object */ TimeFilter * timeFilter_; - + /** finite element velocity field */ DENS_MAN & velocity_; /** finite element acceleration field */ DENS_MAN & acceleration_; - + /** atomic nodal velocity field */ DENS_MAN & nodalAtomicVelocityOut_; /** right-hand side of velocity equation */ @@ -106,7 +106,7 @@ namespace ATC { // DO NOT define this MomentumIntegrationMethod(); - + }; /** @@ -115,21 +115,21 @@ namespace ATC { */ class ElasticTimeIntegratorVerlet : public MomentumIntegrationMethod { - + public: - + // constructor ElasticTimeIntegratorVerlet(MomentumTimeIntegrator * momentumTimeIntegrator); - + // destructor virtual ~ElasticTimeIntegratorVerlet(){}; /** create and get necessary transfer operators */ virtual void construct_transfers(); - + /** pre time integration initialization of data */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -143,52 +143,52 @@ namespace ATC { virtual void add_to_rhs(); /** post processing step before output */ virtual void post_process(); - + /** add output data */ virtual void output(OUTPUT_LIST & outputData); - + /** operations at end of a run */ virtual void finish(); - + protected: - + /** finite element displacement field */ DENS_MAN & displacement_; - + /** atomic nodal displacement field */ DENS_MAN & nodalAtomicDisplacementOut_; - + /** filtered atomic force */ DENS_MAN & nodalAtomicForceFiltered_; - + /** transfer for computing atomic displacement */ DENS_MAN * nodalAtomicDisplacement_; /** transfer for computing nodal atomic force */ DENS_MAN * nodalAtomicForce_; - + private: - + // DO NOT define this ElasticTimeIntegratorVerlet(); - + }; - + /** * @class ElasticTimeIntegratorVerlet * @brief Verlet integration for FE elastic quantities with time filtering */ class ElasticTimeIntegratorVerletFiltered : public ElasticTimeIntegratorVerlet { - + public: - + // constructor ElasticTimeIntegratorVerletFiltered(MomentumTimeIntegrator * momentumTimeIntegrator); - + // destructor virtual ~ElasticTimeIntegratorVerletFiltered(){}; - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -203,7 +203,7 @@ namespace ATC { /** add output data */ virtual void output(OUTPUT_LIST & outputData); - + protected: /** atomic nodal acceleration field */ @@ -213,16 +213,16 @@ namespace ATC { // DO NOT define this ElasticTimeIntegratorVerletFiltered(); - + }; /** - * @class ElasticTimeIntegratorFractionalStep + * @class ElasticTimeIntegratorFractionalStep * @brief Class for using 2nd order Verlet integration to update FE contributions to momentum field - * (Uses same update for the atomic contributions to the finite - * elements as are used by the LAMMPS integration scheme + * (Uses same update for the atomic contributions to the finite + * elements as are used by the LAMMPS integration scheme * for the atomic velocities and positions, i.e. Verlet.) - */ + */ class ElasticTimeIntegratorFractionalStep : public MomentumIntegrationMethod { @@ -230,16 +230,16 @@ namespace ATC { // constructor ElasticTimeIntegratorFractionalStep(MomentumTimeIntegrator * momentumTimeIntegrator); - + // destructor virtual ~ElasticTimeIntegratorFractionalStep() {}; - + /** create and get necessary transfer operators */ virtual void construct_transfers(); /** pre time integration initialization of data */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -272,13 +272,13 @@ namespace ATC { // data /** finite element displacement field */ DENS_MAN & displacement_; - + /** atomic nodal displacement field */ DENS_MAN & nodalAtomicDisplacementOut_; /** equivalent nodal force due to atomic momentum change */ DENS_MAT nodalAtomicForce_; - + /** filtered atomic force */ DENS_MAN & nodalAtomicForceFiltered_; @@ -287,7 +287,7 @@ namespace ATC { /** filtered atomic momentum */ DENS_MAN & nodalAtomicMomentumFiltered_; - + /** transfer for computing atomic displacement */ DENS_MAN * nodalAtomicDisplacement_; @@ -312,7 +312,7 @@ namespace ATC { * @class FluidsTimeIntegratorGear * @brief Class for using 3rd order Gear integration to update FE contributions to momentum field * and fractional step method for atomic contributions - */ + */ class FluidsTimeIntegratorGear : public MomentumIntegrationMethod { @@ -320,16 +320,16 @@ namespace ATC { // constructor FluidsTimeIntegratorGear(MomentumTimeIntegrator * MomentumTimeIntegrator); - + // destructor virtual ~FluidsTimeIntegratorGear() {}; - + /** create and get necessary transfer operators */ virtual void construct_transfers(); /** pre time integration initialization of data */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -371,7 +371,7 @@ namespace ATC { // data /** equivalent nodal force due to atomic momentum change */ DENS_MAT nodalAtomicForce_; - + /** filtered atomic force */ DENS_MAN & nodalAtomicForceFiltered_; diff --git a/lib/atc/ElectronChargeDensity.cpp b/lib/atc/ElectronChargeDensity.cpp index 14c764e46e..5f4d04af0d 100644 --- a/lib/atc/ElectronChargeDensity.cpp +++ b/lib/atc/ElectronChargeDensity.cpp @@ -14,7 +14,7 @@ using std::vector; namespace ATC { ElectronChargeDensityInterpolation::ElectronChargeDensityInterpolation( - fstream &fileId, map & /* parameters */) + fstream &fileId, map & /* parameters */) : ElectronChargeDensity(), n_() { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); @@ -23,7 +23,7 @@ ElectronChargeDensityInterpolation::ElectronChargeDensityInterpolation( double coef = 1.; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; else if (line[0] == "scale") coef = str2dbl(line[1]); else if (line[0] == "number_of_points") { @@ -34,14 +34,14 @@ ElectronChargeDensityInterpolation::ElectronChargeDensityInterpolation( } ElectronChargeDensityLinear::ElectronChargeDensityLinear( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronChargeDensity() { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); vector line; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; double value = str2dbl(line[1]); if (line[0] == "coefficient") { @@ -52,7 +52,7 @@ ElectronChargeDensityLinear::ElectronChargeDensityLinear( } ElectronChargeDensityExponential::ElectronChargeDensityExponential( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronChargeDensity(), intrinsicConcentration_(0), intrinsicEnergy_(0), @@ -62,7 +62,7 @@ ElectronChargeDensityExponential::ElectronChargeDensityExponential( vector line; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; double value = str2dbl(line[1]); if (line[0] == "intrinsic_concentration") { @@ -84,7 +84,7 @@ ElectronChargeDensityExponential::ElectronChargeDensityExponential( } ElectronChargeDensityFermiDirac::ElectronChargeDensityFermiDirac( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronChargeDensity(), Ef_(0), referenceTemperature_(0), @@ -96,7 +96,7 @@ ElectronChargeDensityFermiDirac::ElectronChargeDensityFermiDirac( vector line; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; double value = str2dbl(line[1]); if (line[0] == "fermi_energy") { @@ -120,7 +120,7 @@ ElectronChargeDensityFermiDirac::ElectronChargeDensityFermiDirac( else if (line[0] == "donor_concentration") { donorIonization_ = true; Nd_ = value; - parameters["donor_concentration"] = Nd_; + parameters["donor_concentration"] = Nd_; } else { throw ATC_Error( "unrecognized material function "+line[0]); diff --git a/lib/atc/ElectronChargeDensity.h b/lib/atc/ElectronChargeDensity.h index ac6052a9ef..53671d5df9 100644 --- a/lib/atc/ElectronChargeDensity.h +++ b/lib/atc/ElectronChargeDensity.h @@ -12,8 +12,8 @@ const double tol = 1.e-8; namespace ATC { /** - * @class ElectronChargeDensity - * @brief Base class for models of extrinsic electric charges + * @class ElectronChargeDensity + * @brief Base class for models of extrinsic electric charges */ class ElectronChargeDensity @@ -24,10 +24,10 @@ namespace ATC { virtual bool electron_charge_density(const FIELD_MATS & /* fields */, DENS_MAT & /* flux */) const { return false; }; - - virtual void D_electron_charge_density(const FieldName /* fieldName */, + + virtual void D_electron_charge_density(const FieldName /* fieldName */, const FIELD_MATS & /* fields */, - DENS_MAT & /* flux */) const + DENS_MAT & /* flux */) const { throw ATC_Error("Charge density D_electron_charge_density unimplemented function");} virtual void band_edge_potential(const FIELD_MATS & /* fields */, @@ -51,13 +51,13 @@ namespace ATC { FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL); const DENS_MAT & phi = phi_field->second; int nNodes = phi.nRows(); - flux.reset(nNodes,1,false); + flux.reset(nNodes,1,false); for (int i = 0; i < nNodes; i++) { // a mapping of a vector - flux(i,0) = n_.f(phi(i,0)); + flux(i,0) = n_.f(phi(i,0)); } flux *= -1.; return true; - }; + }; virtual void D_electron_charge_density(const FieldName /* field */, const FIELD_MATS &fields, DENS_MAT &coef) const @@ -65,10 +65,10 @@ namespace ATC { FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL); const DENS_MAT & phi = phi_field->second; int nNodes = phi.nRows(); - coef.reset(nNodes,1,false); - for (int i = 0; i < nNodes; i++) { - coef(i,0) = n_.dfdt(phi(i,0)); - coef(i,0) = n_.dfdt(phi(i,0)); + coef.reset(nNodes,1,false); + for (int i = 0; i < nNodes; i++) { + coef(i,0) = n_.dfdt(phi(i,0)); + coef(i,0) = n_.dfdt(phi(i,0)); } coef *= -1.; } @@ -93,7 +93,7 @@ namespace ATC { flux = phi_field->second; flux *= -C_; return true; - }; + }; virtual void D_electron_charge_density(const FieldName /* field */, const FIELD_MATS &fields, DENS_MAT &coef) const @@ -111,7 +111,7 @@ namespace ATC { /** * @class ElectronChargeDensityExponential * @brief Class for models of electron charge density dependent on difference between electric potential and the Fermi level n = n_i exp ( (phi-E_i) / kB T) - */ + */ class ElectronChargeDensityExponential : public ElectronChargeDensity { @@ -121,13 +121,13 @@ namespace ATC { double n(const double phi, double T) const { - return -intrinsicConcentration_*exp((phi-intrinsicEnergy_)/(kBeV_*T)); + return -intrinsicConcentration_*exp((phi-intrinsicEnergy_)/(kBeV_*T)); } double dndphi(const double phi, double T) const { return n(phi,T)/(kBeV_*T); } - virtual bool electron_charge_density(const FIELD_MATS &fields, + virtual bool electron_charge_density(const FIELD_MATS &fields, DENS_MAT &density) const { FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL); @@ -139,17 +139,17 @@ namespace ATC { density.resize(nNodes,1); if (hasTref) { T = referenceTemperature_; - for (int i = 0; i < nNodes; i++) { + for (int i = 0; i < nNodes; i++) { density(i,0) = n(phi(i,0),T); } } else { const DENS_MAT & temp = T_field->second; - for (int i = 0; i < nNodes; i++) { + for (int i = 0; i < nNodes; i++) { density(i,0) = n(phi(i,0),temp(i,0)); } } density *= -1.; return true; - }; + }; virtual void D_electron_charge_density(const FieldName /* field */, const FIELD_MATS &fields, DENS_MAT &coef) const @@ -163,16 +163,16 @@ namespace ATC { coef.resize(nNodes,1); if (hasTref) { T = referenceTemperature_; - for (int i = 0; i < nNodes; i++) { + for (int i = 0; i < nNodes; i++) { coef(i,0) = dndphi(phi(i,0),T); } } else { const DENS_MAT & temp = T_field->second; - for (int i = 0; i < nNodes; i++) { + for (int i = 0; i < nNodes; i++) { coef(i,0) = dndphi(phi(i,0),temp(i,0)); } } coef *= -1.; - }; + }; protected: double intrinsicConcentration_,intrinsicEnergy_; double referenceTemperature_; @@ -181,8 +181,8 @@ namespace ATC { //----------------------------------------------------------------------- /** * @class ElectronChargeDensityFermiDirac - * @brief Class for models of electron charge density based on Fermi-Dirac statistics - */ + * @brief Class for models of electron charge density based on Fermi-Dirac statistics + */ class ElectronChargeDensityFermiDirac : public ElectronChargeDensity { @@ -195,7 +195,7 @@ namespace ATC { if (T > 0) f = 1.0 / ( exp((E-Ef_)/kBeV_/T)+1.0 ); else if (E > Ef_) f = 0; return f; - }; + }; virtual bool electron_charge_density(const FIELD_MATS &fields, DENS_MAT &density) const { @@ -215,34 +215,34 @@ namespace ATC { const DENS_MAT & phi = phi_field->second; int nNodes = psi.nRows(); - density.reset(nNodes,1); + density.reset(nNodes,1); double T = referenceTemperature_; int count = 0; for (int i = 0; i < nNodes; i++) { if (!hasReferenceTemperature_) { T = Ts(i,0); } int j = 0; for (j = 0; j < psis.nCols(); j++) { - double E = Es(j,0); // Eigenvalue + double E = Es(j,0); // Eigenvalue double f = fermi_dirac(E,T); if (f < tol) break; else count++; density(i,0) -= psis(i,j)*psis(i,j)*f; // < 0 } - if (donorIonization_) { + if (donorIonization_) { double E = -1.0* phi(i,0);// units [eV] E = - |e| phi if ( E + Eb_ > Ef_+Ed_) density(i,0) += Nd_; // > 0 } } return true; - }; - virtual void D_electron_charge_density(const FieldName /* fieldName */, + }; + virtual void D_electron_charge_density(const FieldName /* fieldName */, const FIELD_MATS &fields, DENS_MAT &coef) const { FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL); const DENS_MAT & phi = phi_field->second; int nNodes = phi.nRows(); - coef.reset(nNodes,1,false); + coef.reset(nNodes,1,false); } virtual void band_edge_potential(const FIELD_MATS &fields, @@ -251,7 +251,7 @@ namespace ATC { FIELD_MATS::const_iterator p_field = fields.find(ELECTRIC_POTENTIAL); const DENS_MAT & phi = p_field->second; int nNodes = phi.nRows(); - density.reset(nNodes,1,false); + density.reset(nNodes,1,false); density = Eb_; }; @@ -264,6 +264,6 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/ElectronDragPower.cpp b/lib/atc/ElectronDragPower.cpp index 7fe31f0120..f1b69a8611 100644 --- a/lib/atc/ElectronDragPower.cpp +++ b/lib/atc/ElectronDragPower.cpp @@ -16,7 +16,7 @@ namespace ATC { ElectronDragPowerLinear::ElectronDragPowerLinear(fstream &fileId, map & parameters, - Material * material) + Material * material) : ElectronDragPower(), electronDragInvTau_(0), material_(material) @@ -42,7 +42,7 @@ ElectronDragPowerLinear::ElectronDragPowerLinear(fstream &fileId, const GRAD_FIELD_MATS & /* gradFields */, DENS_MAT & flux) { - + FIELD_MATS::const_iterator evField = fields.find(ELECTRON_VELOCITY); const DENS_MAT & v = evField->second; @@ -57,7 +57,7 @@ ElectronDragPowerLinear::ElectronDragPowerLinear(fstream &fileId, return true; } - + void ElectronDragPowerLinear::electron_drag_velocity_coefficient(const FIELD_MATS &fields, DENS_MAT & dragCoef) { diff --git a/lib/atc/ElectronDragPower.h b/lib/atc/ElectronDragPower.h index 12c1472e37..063e0df648 100644 --- a/lib/atc/ElectronDragPower.h +++ b/lib/atc/ElectronDragPower.h @@ -11,7 +11,7 @@ namespace ATC { /** - * @class ElectronDragPower + * @class ElectronDragPower * @brief Base class for defining the lattice drag power from electrons */ @@ -35,12 +35,12 @@ namespace ATC { }; }; //------------------------------------------------------------------- - + /** * @class ElectronDragPowerLinear * @brief Class for electron drag that linearly depends on the difference between the electron and lattice velocities - */ - + */ + class ElectronDragPowerLinear : public ElectronDragPower { public: @@ -66,6 +66,6 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/ElectronFlux.cpp b/lib/atc/ElectronFlux.cpp index 4894a32dae..a5a6b36469 100644 --- a/lib/atc/ElectronFlux.cpp +++ b/lib/atc/ElectronFlux.cpp @@ -22,8 +22,8 @@ ElectronFlux::ElectronFlux() : ElectronFluxLinear::ElectronFluxLinear( - fstream &fileId, map & parameters) - : ElectronFlux(), + fstream &fileId, map & parameters) + : ElectronFlux(), electronMobility_(0), electronDiffusivity_(0) { @@ -52,7 +52,7 @@ ElectronFluxLinear::ElectronFluxLinear( } ElectronFluxThermopower::ElectronFluxThermopower( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronFlux(), electronMobility_(0), seebeckCoef_(0) @@ -61,7 +61,7 @@ ElectronFluxThermopower::ElectronFluxThermopower( vector line; while(fileId.good()) { command_line(fileId, line); - if (line.size() == 0) continue; + if (line.size() == 0) continue; if (line[0] == "end") return; double value = str2dbl(line[1]); if (line[0] == "mobility") { @@ -79,7 +79,7 @@ ElectronFluxThermopower::ElectronFluxThermopower( } ElectronFluxConvection::ElectronFluxConvection( - fstream &fileId, map & /* parameters */) + fstream &fileId, map & /* parameters */) : ElectronFlux() { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); diff --git a/lib/atc/ElectronFlux.h b/lib/atc/ElectronFlux.h index b9cfd2305c..f58bc29dbf 100644 --- a/lib/atc/ElectronFlux.h +++ b/lib/atc/ElectronFlux.h @@ -20,12 +20,12 @@ namespace ATC { /** computes flux */ virtual void electron_flux(const FIELD_MATS &fields, const GRAD_FIELD_MATS & /* gradFields */, - DENS_MAT_VEC &flux) + DENS_MAT_VEC &flux) { - - - - + + + + FIELD_MATS::const_iterator etField = fields.find(ELECTRON_TEMPERATURE); const DENS_MAT & etMat = etField->second; zeroWorkspace_.reset(etMat.nRows(),etMat.nCols()); @@ -75,12 +75,12 @@ namespace ATC { DENS_MAT zeroWorkspace_; }; //----------------------------------------------------------------------- - + /** * @class ElectronFluxLinear * @brief Class for drift-diffusion electron flux with linear dependency on the electron density gradient - */ - + */ + class ElectronFluxLinear : public ElectronFlux { public: @@ -98,7 +98,7 @@ namespace ATC { const DENS_MAT & n = edField->second; const DENS_MAT_VEC & dn = dEdField->second; const DENS_MAT_VEC & dphi = dPhiField->second; - + //n.print("DENSITY"); //for (int i = 0; i < 3; i++) { // dn[i].print("GRAD N"); @@ -131,17 +131,17 @@ namespace ATC { flux[2] += -electronDiffusivity_* dn[2]; } - }; + }; protected: double electronMobility_, electronDiffusivity_; }; //----------------------------------------------------------------------- - + /** * @class ElectronFluxThermopower * @brief Class for defining the electron flux (i.e., current) to include the elctron velocity or have a electron temperature-dependent mobility - */ - + */ + class ElectronFluxThermopower : public ElectronFlux { public: @@ -165,13 +165,13 @@ namespace ATC { GRAD_FIELD_MATS::const_iterator dPhiField = gradFields.find(ELECTRIC_POTENTIAL); GRAD_FIELD_MATS::const_iterator dEtField = gradFields.find(ELECTRON_TEMPERATURE); - // J_n = - \mu n grad \phi - \mu kB/e T_e grad n + // J_n = - \mu n grad \phi - \mu kB/e T_e grad n // - \mu S n grad T_e - \mu kB/e n grad T_e const DENS_MAT & n = edField->second; const DENS_MAT_VEC & dn = dEdField->second; const DENS_MAT_VEC & dphi = dPhiField->second; const DENS_MAT_VEC & dT = dEtField->second; - + flux[0] = -electronMobility_*dphi[0]; flux[1] = -electronMobility_*dphi[1]; flux[2] = -electronMobility_*dphi[2]; @@ -179,7 +179,7 @@ namespace ATC { flux[0] += coef* dT[0]; flux[1] += coef* dT[1]; flux[2] += coef* dT[2]; - flux[0] *= n; // scale by n + flux[0] *= n; // scale by n flux[1] *= n; flux[2] *= n; @@ -188,23 +188,23 @@ namespace ATC { //tmp[0] *= Te; //tmp[1] *= Te; //tmp[2] *= Te; - coef = -electronMobility_*kBeV_; + coef = -electronMobility_*kBeV_; //flux[0] += tmp[0]; flux[0] += dn[0].mult_by_element(Te); flux[1] += dn[1].mult_by_element(Te); flux[2] += dn[2].mult_by_element(Te); } - }; + }; protected: double electronMobility_, seebeckCoef_; }; //----------------------------------------------------------------------- - + /** * @class ElectronFluxConvection * @brief Class for electron flux based on the standard convection term - */ - + */ + class ElectronFluxConvection : public ElectronFlux { public: @@ -220,6 +220,6 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/ElectronHeatCapacity.cpp b/lib/atc/ElectronHeatCapacity.cpp index aafaa3c37d..38515d4659 100644 --- a/lib/atc/ElectronHeatCapacity.cpp +++ b/lib/atc/ElectronHeatCapacity.cpp @@ -15,7 +15,7 @@ using std::vector; namespace ATC { ElectronHeatCapacityConstant::ElectronHeatCapacityConstant( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronHeatCapacity(), electronHeatCapacity_(0) { @@ -36,7 +36,7 @@ ElectronHeatCapacityConstant::ElectronHeatCapacityConstant( } ElectronHeatCapacityLinear::ElectronHeatCapacityLinear( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronHeatCapacity(), electronHeatCapacity_(0) { @@ -58,7 +58,7 @@ ElectronHeatCapacityLinear::ElectronHeatCapacityLinear( ElectronHeatCapacityConstantAddDensity::ElectronHeatCapacityConstantAddDensity(fstream &fileId, map & parameters, - Material * material) + Material * material) : ElectronHeatCapacityConstant(fileId, parameters), material_(material) { @@ -67,7 +67,7 @@ ElectronHeatCapacityConstantAddDensity::ElectronHeatCapacityConstantAddDensity(f ElectronHeatCapacityLinearAddDensity::ElectronHeatCapacityLinearAddDensity(fstream &fileId, map & parameters, - Material * material) + Material * material) : ElectronHeatCapacityLinear(fileId, parameters), material_(material) { diff --git a/lib/atc/ElectronHeatCapacity.h b/lib/atc/ElectronHeatCapacity.h index f27d8193a0..eb4e970fee 100644 --- a/lib/atc/ElectronHeatCapacity.h +++ b/lib/atc/ElectronHeatCapacity.h @@ -27,19 +27,19 @@ namespace ATC { DENS_MAT_VEC & Dcapacity)=0; /** computes thermal energy */ virtual void electron_thermal_energy(const FIELD_MATS &fields, - DENS_MAT &energy)=0; + DENS_MAT &energy)=0; }; //------------------------------------------------------------------- - + /** * @class ElectronHeatCapacityConstant * @brief Class for a constant electron heat capacity - */ - + */ + class ElectronHeatCapacityConstant : public ElectronHeatCapacity { public: - ElectronHeatCapacityConstant(std::fstream &matfile, + ElectronHeatCapacityConstant(std::fstream &matfile, std::map & parameters); virtual ~ElectronHeatCapacityConstant() {}; virtual void electron_heat_capacity(const FIELD_MATS &fields, @@ -59,25 +59,25 @@ namespace ATC { Dcapacity[0] = zeroWorkspace_; Dcapacity[1] = zeroWorkspace_; Dcapacity[2] = zeroWorkspace_; - } + } virtual void electron_thermal_energy(const FIELD_MATS &fields, DENS_MAT &energy) { FIELD_MATS::const_iterator etField = fields.find(ELECTRON_TEMPERATURE); const DENS_MAT & T = etField->second; energy = electronHeatCapacity_ * T; - }; + }; protected: double electronHeatCapacity_; DENS_MAT zeroWorkspace_; }; //------------------------------------------------------------------- - + /** * @class ElectronHeatCapacityLinear * @brief Class for an electron capacity that is directly proportional to the electron temperature - */ - + */ + class ElectronHeatCapacityLinear : public ElectronHeatCapacity { public: @@ -108,21 +108,21 @@ namespace ATC { const DENS_MAT & T = etField->second; energy = electronHeatCapacity_ * T; energy *= T; - }; + }; protected: double electronHeatCapacity_; }; //------------------------------------------------------------------- - + /** * @class ElectronHeatCapacityConstantAddDensity * @brief Class for a constant electron specific heat capacity (i.e, does not include the electron density) - */ - + */ + class ElectronHeatCapacityConstantAddDensity : public ElectronHeatCapacityConstant { public: - ElectronHeatCapacityConstantAddDensity(std::fstream &matfile, + ElectronHeatCapacityConstantAddDensity(std::fstream &matfile, std::map & parameters, Material * material); virtual ~ElectronHeatCapacityConstantAddDensity() {}; @@ -165,12 +165,12 @@ namespace ATC { DENS_MAT capacityMat_; // avoid resizing if possible }; //------------------------------------------------------------------- - + /** * @class ElectronHeatCapacityLinearAddDensity * @brief Class for a electron specific heat capacity that is proportional to the temperature (i.e., does not include density) - */ - + */ + class ElectronHeatCapacityLinearAddDensity : public ElectronHeatCapacityLinear { public: @@ -199,7 +199,7 @@ namespace ATC { GRAD_FIELD_MATS::const_iterator dEdField = gradFields.find(ELECTRON_DENSITY); const DENS_MAT_VEC & Ddensity = dEdField->second; - ElectronHeatCapacityLinear::electron_heat_capacity(fields,capacityWorkspace_); + ElectronHeatCapacityLinear::electron_heat_capacity(fields,capacityWorkspace_); Dcapacity[0] += Ddensity[0].mult_by_element(capacityWorkspace_); Dcapacity[1] += Ddensity[1].mult_by_element(capacityWorkspace_); Dcapacity[2] += Ddensity[2].mult_by_element(capacityWorkspace_); @@ -208,7 +208,7 @@ namespace ATC { DENS_MAT &energy) { ElectronHeatCapacityLinear::electron_thermal_energy(fields,energy); - + FIELD_MATS::const_iterator edField = fields.find(ELECTRON_DENSITY); const DENS_MAT & density = edField->second; @@ -220,6 +220,6 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/ElectronHeatFlux.cpp b/lib/atc/ElectronHeatFlux.cpp index fbe3d0d512..6515efc3cd 100644 --- a/lib/atc/ElectronHeatFlux.cpp +++ b/lib/atc/ElectronHeatFlux.cpp @@ -22,7 +22,7 @@ ElectronHeatFlux::ElectronHeatFlux(ElectronHeatCapacity * electronHeatCapacity) } ElectronHeatFluxLinear::ElectronHeatFluxLinear(fstream &fileId, map & parameters, - ElectronHeatCapacity * electronHeatCapacity) + ElectronHeatCapacity * electronHeatCapacity) : ElectronHeatFlux(electronHeatCapacity), conductivity_(0) { @@ -43,7 +43,7 @@ ElectronHeatFluxLinear::ElectronHeatFluxLinear(fstream &fileId, map & parameters, - ElectronHeatCapacity * electronHeatCapacity) + ElectronHeatCapacity * electronHeatCapacity) : ElectronHeatFlux(electronHeatCapacity), conductivity_(0) { @@ -66,7 +66,7 @@ ElectronHeatFluxPowerLaw::ElectronHeatFluxPowerLaw(fstream &fileId, map & parameters, /*const*/ ElectronFlux * electronFlux, - ElectronHeatCapacity * electronHeatCapacity) + ElectronHeatCapacity * electronHeatCapacity) : ElectronHeatFlux(electronHeatCapacity), conductivity_(0), seebeckCoef_(0), @@ -86,7 +86,7 @@ ElectronHeatFluxThermopower::ElectronHeatFluxThermopower( else { throw ATC_Error( "unrecognized material function "+line[0]); } - + seebeckCoef_ = parameters["seebeck_coefficient"]; } } diff --git a/lib/atc/ElectronHeatFlux.h b/lib/atc/ElectronHeatFlux.h index 4c5b6200d3..ae1d420009 100644 --- a/lib/atc/ElectronHeatFlux.h +++ b/lib/atc/ElectronHeatFlux.h @@ -24,7 +24,7 @@ namespace ATC { const GRAD_FIELD_MATS & /* gradFields */, DENS_MAT_VEC &flux) { - + FIELD_MATS::const_iterator etField = fields.find(ELECTRON_TEMPERATURE); const DENS_MAT & Te = etField->second; zeroWorkspace_.reset(Te.nRows(),Te.nCols()); @@ -47,7 +47,7 @@ namespace ATC { flux[0] = vx; flux[1] = vy; flux[2] = vz; - // scale by thermal energy + // scale by thermal energy flux[0] *= cpTeWorkspace_; flux[1] *= cpTeWorkspace_; flux[2] *= cpTeWorkspace_; @@ -58,12 +58,12 @@ namespace ATC { DENS_MAT cpTeWorkspace_; // hopefully avoid resizing }; //----------------------------------------------------------------------- - + /** * @class ElectronHeatFluxLinear * @brief Class for an electron heat flux proportional to the temperature gradient with constant conductivity - */ - + */ + class ElectronHeatFluxLinear : public ElectronHeatFlux { public: @@ -80,17 +80,17 @@ namespace ATC { flux[0] = -conductivity_ * dT[0]; flux[1] = -conductivity_ * dT[1]; flux[2] = -conductivity_ * dT[2]; - }; + }; protected: double conductivity_; }; //----------------------------------------------------------------------- - + /** * @class ElectronHeatFluxPowerLaw * @brief Class for an electron heat flux proportional to the temperature gradient but with a conductivity proportional to the ratio of the electron and phonon temperatures - */ - + */ + class ElectronHeatFluxPowerLaw : public ElectronHeatFlux { public: @@ -116,23 +116,23 @@ namespace ATC { flux[0] *= electronConductivity_; flux[1] *= electronConductivity_; flux[2] *= electronConductivity_; - }; + }; protected: double conductivity_; DENS_MAT electronConductivity_; // hopefully avoid resizing }; //----------------------------------------------------------------------- - + /** * @class ElectronHeatFluxThermopower * @brief Class for an electron heat flux proportional to the temperature gradient but with a condu ctivity proportional to the ratio of the electron and phonon temperatures with the thermopower from the electric current included - */ - + */ + class ElectronHeatFluxThermopower : public ElectronHeatFlux { public: - ElectronHeatFluxThermopower(std::fstream &matfile, + ElectronHeatFluxThermopower(std::fstream &matfile, std::map & parameters, /*const*/ ElectronFlux * electronFlux = nullptr, /*const*/ ElectronHeatCapacity * electronHeatCapacity = nullptr); @@ -147,7 +147,7 @@ ctivity proportional to the ratio of the electron and phonon temperatures with t const DENS_MAT_VEC & dT = dEtField->second; const DENS_MAT & T = tField->second; const DENS_MAT & Te = etField->second; - + // flux = -ke * ( Te / T ) dT + pi J_e; flux[0] = dT[0]; flux[1] = dT[1]; @@ -163,16 +163,16 @@ ctivity proportional to the ratio of the electron and phonon temperatures with t tmp_[2] *= Te; flux[0] += seebeckCoef_*tmp_[0]; flux[1] += seebeckCoef_*tmp_[1]; - flux[2] += seebeckCoef_*tmp_[2]; - }; + flux[2] += seebeckCoef_*tmp_[2]; + }; protected: double conductivity_,seebeckCoef_; ElectronFlux * electronFlux_; DENS_MAT elecCondWorkspace_; // hopefully avoid resizing - DENS_MAT_VEC tmp_; + DENS_MAT_VEC tmp_; }; } -#endif +#endif diff --git a/lib/atc/ElectronPhononExchange.cpp b/lib/atc/ElectronPhononExchange.cpp index 0ccc8ec67e..40ae720445 100644 --- a/lib/atc/ElectronPhononExchange.cpp +++ b/lib/atc/ElectronPhononExchange.cpp @@ -18,7 +18,7 @@ using std::vector; namespace ATC { ElectronPhononExchangeLinear::ElectronPhononExchangeLinear( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronPhononExchange(), exchangeCoef_(0) { @@ -39,7 +39,7 @@ ElectronPhononExchangeLinear::ElectronPhononExchangeLinear( } ElectronPhononExchangePowerLaw::ElectronPhononExchangePowerLaw( - fstream &fileId, map & parameters) + fstream &fileId, map & parameters) : ElectronPhononExchange(), exchangeCoef_(0), exponent_(1) @@ -65,7 +65,7 @@ ElectronPhononExchangePowerLaw::ElectronPhononExchangePowerLaw( ElectronPhononExchangeHertel::ElectronPhononExchangeHertel(fstream &fileId, map & parameters, - Material * material) + Material * material) : ElectronPhononExchange(), exchangeCoef_(0), debeyeTemperature_(1), @@ -93,7 +93,7 @@ ElectronPhononExchangeHertel::ElectronPhononExchangeHertel(fstream &fileId, // coupling coefficient, eqn. 15 of Hertel 2002 double kb = LammpsInterface::instance()->kBoltzmann(); double hbar = LammpsInterface::instance()->hbar(); - double PI = 3.141592653589793238; + double PI = 3.141592653589793238; exchangeCoef_ = 144.*1.0369*kb/(PI*hbar); exchangeCoef_ *= massEnhancement_/pow(debeyeTemperature_,2); } diff --git a/lib/atc/ElectronPhononExchange.h b/lib/atc/ElectronPhononExchange.h index 3037451513..13d7ac2d76 100644 --- a/lib/atc/ElectronPhononExchange.h +++ b/lib/atc/ElectronPhononExchange.h @@ -7,7 +7,7 @@ #include "ATC_TypeDefs.h" namespace ATC { - + class Material; /** @@ -54,16 +54,16 @@ namespace ATC { double exchangeCoef_; }; //------------------------------------------------------------------- - + /** * @class ElectronPhononExchangePowerLaw * @brief Class for electron-phonon exchange proportional to the temperature difference raised to a constant power - */ - + */ + class ElectronPhononExchangePowerLaw : public ElectronPhononExchange { public: - ElectronPhononExchangePowerLaw(std::fstream &matfile, + ElectronPhononExchangePowerLaw(std::fstream &matfile, std::map & parameters); virtual ~ElectronPhononExchangePowerLaw() {}; virtual bool electron_phonon_exchange(const FIELD_MATS &fields, @@ -78,22 +78,22 @@ namespace ATC { flux = (Te - T).pow(exponent_); flux *= exchangeCoef_; return true; - }; + }; protected: double exchangeCoef_; int exponent_; }; //------------------------------------------------------------------- - + /** * @class ElectronPhononExchangeHertel * @brief Class for electron-phonon exchange based on the formulation of Hertel for Cu - */ - + */ + class ElectronPhononExchangeHertel : public ElectronPhononExchange { public: - ElectronPhononExchangeHertel(std::fstream &matfile, + ElectronPhononExchangeHertel(std::fstream &matfile, std::map & parameters, Material * material); virtual ~ElectronPhononExchangeHertel() {}; @@ -104,13 +104,13 @@ namespace ATC { double debeyeTemperature_; double massEnhancement_; Material * material_; - + private: ElectronPhononExchangeHertel() {}; DENS_MAT capacityWorkspace_; }; } -#endif +#endif diff --git a/lib/atc/ExtrinsicModel.cpp b/lib/atc/ExtrinsicModel.cpp index 8e0079d965..8dc8b71539 100644 --- a/lib/atc/ExtrinsicModel.cpp +++ b/lib/atc/ExtrinsicModel.cpp @@ -32,7 +32,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -48,16 +48,16 @@ namespace ATC { //-------------------------------------------------------- bool ExtrinsicModelManager::modify(int narg, char **arg) { - bool foundMatch = false; - + bool foundMatch = false; + // loop over models with command vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { foundMatch = (*imodel)->modify(narg,arg); if (foundMatch) break; } - + return foundMatch; } @@ -81,10 +81,10 @@ namespace ATC { myModel = new ExtrinsicModelTwoTemperature (this,modelType,matFileName); } - else if (modelType==DRIFT_DIFFUSION + else if (modelType==DRIFT_DIFFUSION || modelType==DRIFT_DIFFUSION_EQUILIBRIUM || modelType==DRIFT_DIFFUSION_SCHRODINGER - || modelType==DRIFT_DIFFUSION_SCHRODINGER_SLICE) + || modelType==DRIFT_DIFFUSION_SCHRODINGER_SLICE) { stringstream ss; ss << "creating drift_diffusion extrinsic model"; @@ -92,7 +92,7 @@ namespace ATC { myModel = new ExtrinsicModelDriftDiffusion (this,modelType,matFileName); } - else if (modelType==CONVECTIVE_DRIFT_DIFFUSION + else if (modelType==CONVECTIVE_DRIFT_DIFFUSION || modelType==CONVECTIVE_DRIFT_DIFFUSION_EQUILIBRIUM || modelType==CONVECTIVE_DRIFT_DIFFUSION_SCHRODINGER) { stringstream ss; @@ -129,7 +129,7 @@ namespace ATC { void ExtrinsicModelManager::construct_transfers() { vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { // initialize models (*imodel)->construct_transfers(); @@ -142,7 +142,7 @@ namespace ATC { void ExtrinsicModelManager::initialize() { vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { // initialize models (*imodel)->initialize(); @@ -168,13 +168,13 @@ namespace ATC { { int extrinsicSize = 0; vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { // query all models for LAMMPS display int currentSize = intrinsicSize + extrinsicSize; extrinsicSize += (*imodel)->size_vector(currentSize); } - + return extrinsicSize; } @@ -185,7 +185,7 @@ namespace ATC { { double value = 0.; vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { value += (*imodel)->compute_scalar(); // sum } @@ -199,7 +199,7 @@ namespace ATC { { double value = 0.; vector::iterator imodel; - for(imodel=extrinsicModels_.begin(); + for(imodel=extrinsicModels_.begin(); imodel!=extrinsicModels_.end(); imodel++) { // query all models for LAMMPS display if ((*imodel)->compute_vector(n,value)) @@ -348,7 +348,7 @@ namespace ATC { rhsMaskIntrinsic_.reset(NUM_FIELDS,NUM_FLUX); rhsMaskIntrinsic_ = false; } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -371,7 +371,7 @@ namespace ATC { //-------------------------------------------------------- void ExtrinsicModel::num_fields(map & fieldSizes) { - physicsModel_->num_fields(fieldSizes,atc_->fieldMask_); + physicsModel_->num_fields(fieldSizes,atc_->fieldMask_); } }; diff --git a/lib/atc/ExtrinsicModel.h b/lib/atc/ExtrinsicModel.h index 66282fb505..77f38d109c 100644 --- a/lib/atc/ExtrinsicModel.h +++ b/lib/atc/ExtrinsicModel.h @@ -42,7 +42,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelManager { - + public: // constructor @@ -98,7 +98,7 @@ namespace ATC { /** model name enum to string */ - static bool model_to_string(const ExtrinsicModelType index, std::string & name) + static bool model_to_string(const ExtrinsicModelType index, std::string & name) { switch (index) { case NO_MODEL: @@ -141,11 +141,11 @@ namespace ATC { return false; break; } - return true; + return true; }; /** string to model enum */ - static bool string_to_model(const std::string & name, ExtrinsicModelType & index) + static bool string_to_model(const std::string & name, ExtrinsicModelType & index) { if (name=="no_model") index = NO_MODEL; @@ -174,7 +174,7 @@ namespace ATC { else return false; - + return true; }; @@ -209,7 +209,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModel { - + public: // constructor @@ -295,8 +295,8 @@ namespace ATC { /** rhs mask for coupling with MD */ Array2D rhsMaskIntrinsic_; - - + + GRAD_FIELD_MATS fluxes_; /** number of nodes */ diff --git a/lib/atc/ExtrinsicModelDriftDiffusion.cpp b/lib/atc/ExtrinsicModelDriftDiffusion.cpp index a9d8f27604..0288197da8 100644 --- a/lib/atc/ExtrinsicModelDriftDiffusion.cpp +++ b/lib/atc/ExtrinsicModelDriftDiffusion.cpp @@ -39,7 +39,7 @@ namespace ATC { string matFileName) : ExtrinsicModelTwoTemperature(modelManager,modelType,matFileName), continuityIntegrator_(nullptr), - + poissonSolverType_(DIRECT), // ITERATIVE | DIRECT poissonSolver_(nullptr), baseSize_(0), @@ -49,34 +49,34 @@ namespace ATC { schrodingerSolver_(nullptr), schrodingerPoissonMgr_(), schrodingerPoissonSolver_(nullptr), - maxConsistencyIter_(0), maxConstraintIter_(1), + maxConsistencyIter_(0), maxConstraintIter_(1), safe_dEf_(0.1), Ef_shift_(0.0), oneD_(false), oneDcoor_(0), oneDconserve_(0) { // delete base class's version of the physics model - if (physicsModel_) delete physicsModel_; + if (physicsModel_) delete physicsModel_; if (modelType == DRIFT_DIFFUSION_EQUILIBRIUM) { - physicsModel_ = new PhysicsModelDriftDiffusionEquilibrium(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusionEquilibrium(matFileName); electronDensityEqn_ = ELECTRON_EQUILIBRIUM; } else if (modelType == DRIFT_DIFFUSION_SCHRODINGER) { - physicsModel_ = new PhysicsModelDriftDiffusionSchrodinger(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusionSchrodinger(matFileName); electronDensityEqn_ = ELECTRON_SCHRODINGER; maxConsistencyIter_ = 1; } else if (modelType == DRIFT_DIFFUSION_SCHRODINGER_SLICE) { - physicsModel_ = new PhysicsModelDriftDiffusionSchrodingerSlice(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusionSchrodingerSlice(matFileName); electronDensityEqn_ = ELECTRON_SCHRODINGER; maxConsistencyIter_ = 1; } else { - physicsModel_ = new PhysicsModelDriftDiffusion(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusion(matFileName); } atc_->useConsistentMassMatrix_(ELECTRON_DENSITY) = true; rhsMaskIntrinsic_(ELECTRON_TEMPERATURE,SOURCE) = true; //atc_->fieldMask_(ELECTRON_TEMPERATURE,EXTRINSIC_SOURCE) = true; } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -89,7 +89,7 @@ namespace ATC { } //-------------------------------------------------------- - // modify + // modify //-------------------------------------------------------- bool ExtrinsicModelDriftDiffusion::modify(int narg, char **arg) { @@ -110,9 +110,9 @@ namespace ATC { nNodes_ = atc_->num_nodes(); rhs_[ELECTRON_DENSITY].reset(nNodes_,1); rhs_[ELECTRIC_POTENTIAL].reset(nNodes_,1); - + // set up electron continuity integrator - Array2D rhsMask(NUM_TOTAL_FIELDS,NUM_FLUX); + Array2D rhsMask(NUM_TOTAL_FIELDS,NUM_FLUX); rhsMask = false; for (int i = 0; i < NUM_FLUX; i++) { rhsMask(ELECTRON_DENSITY,i) = atc_->fieldMask_(ELECTRON_DENSITY,i); @@ -121,7 +121,7 @@ namespace ATC { atc_->set_fixed_nodes(); if (continuityIntegrator_) delete continuityIntegrator_; - if (electronTimeIntegration_ == TimeIntegrator::IMPLICIT) { + if (electronTimeIntegration_ == TimeIntegrator::IMPLICIT) { continuityIntegrator_ = new FieldImplicitEulerIntegrator(ELECTRON_DENSITY, physicsModel_, atc_->feEngine_, atc_, rhsMask); } @@ -142,7 +142,7 @@ namespace ATC { rhsMask(ELECTRIC_POTENTIAL,i) = atc_->fieldMask_(ELECTRIC_POTENTIAL,i); } int type = ATC::LinearSolver::ITERATIVE_SOLVE_SYMMETRIC; - if (poissonSolverType_ == DIRECT) { + if (poissonSolverType_ == DIRECT) { type = ATC::LinearSolver::DIRECT_SOLVE; } if (poissonSolver_) delete poissonSolver_; @@ -154,12 +154,12 @@ namespace ATC { // set up schrodinger solver if ( electronDensityEqn_ == ELECTRON_SCHRODINGER ) { if ( schrodingerSolver_ ) delete schrodingerSolver_; - if ( oneD_ ) { + if ( oneD_ ) { EfHistory_.reset(oneDslices_.size(),2); schrodingerSolver_ = new SliceSchrodingerSolver(ELECTRON_DENSITY, physicsModel_, atc_->feEngine_, atc_->prescribedDataMgr_, atc_, oneDslices_,oneDdxs_); - } + } else { schrodingerSolver_ = new SchrodingerSolver(ELECTRON_DENSITY, physicsModel_, atc_->feEngine_, atc_->prescribedDataMgr_, atc_); @@ -192,7 +192,7 @@ namespace ATC { double dt = atc_->lammpsInterface_->dt(); double time = atc_->time(); int step = atc_->step(); - if (step % fluxUpdateFreq_ != 0) return; + if (step % fluxUpdateFreq_ != 0) return; // set Dirchlet data atc_->set_fixed_nodes(); @@ -201,25 +201,25 @@ namespace ATC { atc_->set_sources(); // subcyle integration of fast electron variable/s - + double idt = dt/nsubcycle_; for (int i = 0; i < nsubcycle_ ; ++i) { if (electronDensityEqn_ == ELECTRON_CONTINUITY) { // update continuity eqn - if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) + if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) continuityIntegrator_->update(idt,time,atc_->fields_,rhs_); - atc_->set_fixed_nodes(); + atc_->set_fixed_nodes(); // solve poisson eqn for electric potential if (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) poissonSolver_->solve(atc_->fields(),rhs_); - } + } else if (electronDensityEqn_ == ELECTRON_SCHRODINGER) { - if ( (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) + if ( (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) || (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) ) schrodingerPoissonSolver_->solve(rhs_,fluxes_); } // update electron temperature - if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_TEMPERATURE) + if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_TEMPERATURE) && temperatureIntegrator_ ) { #ifdef ATC_VERBOSE ATC::LammpsInterface::instance()->stream_msg_once("start temperature integration...",true,false); @@ -229,10 +229,10 @@ namespace ATC { ATC::LammpsInterface::instance()->stream_msg_once(" done",false,true); #endif } - atc_->set_fixed_nodes(); + atc_->set_fixed_nodes(); } - + } //-------------------------------------------------------- // set coupling source terms @@ -249,7 +249,7 @@ namespace ATC { // output //-------------------------------------------------------- void ExtrinsicModelDriftDiffusion::output(OUTPUT_LIST & outputData) - { + { #ifdef ATC_VERBOSE // ATC::LammpsInterface::instance()->print_msg_once("start output",true,false); #endif @@ -355,13 +355,13 @@ namespace ATC { baseSize_(0) { // delete base class's version of the physics model - if (physicsModel_) delete physicsModel_; + if (physicsModel_) delete physicsModel_; if (modelType == CONVECTIVE_DRIFT_DIFFUSION_SCHRODINGER) { - physicsModel_ = new PhysicsModelDriftDiffusionConvectionSchrodinger(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusionConvectionSchrodinger(matFileName); electronDensityEqn_ = ELECTRON_SCHRODINGER; } else { - physicsModel_ = new PhysicsModelDriftDiffusionConvection(matFileName); + physicsModel_ = new PhysicsModelDriftDiffusionConvection(matFileName); } atc_->useConsistentMassMatrix_(ELECTRON_VELOCITY) = false; atc_->useConsistentMassMatrix_(ELECTRON_TEMPERATURE) = false; @@ -388,7 +388,7 @@ namespace ATC { nsd_ = atc_->nsd(); rhs_[ELECTRON_VELOCITY].reset(nNodes_,nsd_); - + atc_->set_fixed_nodes(); // needed to correctly set BC data // initialize Poisson solver if (cddmPoissonSolver_) delete cddmPoissonSolver_; @@ -397,9 +397,9 @@ namespace ATC { rhsMask(ELECTRIC_POTENTIAL,FLUX) = true; pair row_col(ELECTRIC_POTENTIAL,ELECTRIC_POTENTIAL); SPAR_MAT stiffness; - (atc_->feEngine_)->compute_tangent_matrix(rhsMask,row_col, atc_->fields(), physicsModel_, + (atc_->feEngine_)->compute_tangent_matrix(rhsMask,row_col, atc_->fields(), physicsModel_, atc_->element_to_material_map(), stiffness); - + const BC_SET & bcs = (atc_->prescribedDataMgr_->bcs(ELECTRIC_POTENTIAL))[0]; cddmPoissonSolver_ = new LinearSolver(stiffness, bcs, poissonSolverType_, @@ -427,7 +427,7 @@ namespace ATC { double dt = atc_->lammpsInterface_->dt(); double time = atc_->time(); int step = atc_->step(); - if (step % fluxUpdateFreq_ != 0) return; + if (step % fluxUpdateFreq_ != 0) return; // set Dirchlet data atc_->set_fixed_nodes(); @@ -436,16 +436,16 @@ namespace ATC { atc_->set_sources(); // subcyle integration of fast electron variable/s - + double idt = dt/nsubcycle_; for (int i = 0; i < nsubcycle_ ; ++i) { // update electron temperature mass matrix atc_->compute_mass_matrix(ELECTRON_VELOCITY,physicsModel_); // update electron velocity if (!(atc_->prescribedDataMgr_)->all_fixed(ELECTRON_VELOCITY)) { - //const BCS & bcs + //const BCS & bcs // = atc_->prescribedDataMgr_->bcs(ELECTRON_VELOCITY); - Array2D rhsMask(NUM_FIELDS,NUM_FLUX); + Array2D rhsMask(NUM_FIELDS,NUM_FLUX); rhsMask = false; rhsMask(ELECTRON_VELOCITY,SOURCE) = atc_->fieldMask_(ELECTRON_VELOCITY,SOURCE); rhsMask(ELECTRON_VELOCITY,FLUX) = atc_->fieldMask_(ELECTRON_VELOCITY,FLUX); @@ -455,7 +455,7 @@ namespace ATC { atc_->compute_rhs_vector(rhsMask, atc_->fields_, rhs, atc_->source_integration(), physicsModel_); const DENS_MAT & velocityRhs = rhs[ELECTRON_VELOCITY].quantity(); - // add a solver for electron momentum + // add a solver for electron momentum DENS_MAT & velocity = (atc_->field(ELECTRON_VELOCITY)).set_quantity(); for (int j = 0; j < nsd_; ++j) { if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_VELOCITY,j) ) { @@ -477,12 +477,12 @@ namespace ATC { } } } - + //atc_->set_fixed_nodes(); - + if (electronDensityEqn_ == ELECTRON_CONTINUITY) { // update continuity eqn - Array2D rhsMask(NUM_FIELDS,NUM_FLUX); + Array2D rhsMask(NUM_FIELDS,NUM_FLUX); rhsMask = false; rhsMask(ELECTRON_DENSITY,FLUX) = atc_->fieldMask_(ELECTRON_DENSITY,FLUX); rhsMask(ELECTRON_DENSITY,SOURCE) = atc_->fieldMask_(ELECTRON_DENSITY,SOURCE); @@ -490,11 +490,11 @@ namespace ATC { FIELDS rhs; rhs[ELECTRON_DENSITY].reset(nNodes_,1); atc_->compute_rhs_vector(rhsMask, atc_->fields_, rhs, atc_->source_integration(), physicsModel_); - if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) + if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) continuityIntegrator_->update(idt,time,atc_->fields_,rhs); - atc_->set_fixed_nodes(); + atc_->set_fixed_nodes(); // solve poisson eqn for electric potential - + if (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) { //poissonSolver_->solve(atc_->fields_,rhs_); rhsMask = false; @@ -507,12 +507,12 @@ namespace ATC { const CLON_VEC r =column(rhs[ELECTRIC_POTENTIAL].quantity(),0); cddmPoissonSolver_->solve(x,r); } - } + } else if (electronDensityEqn_ == ELECTRON_SCHRODINGER) { schrodingerPoissonSolver_->solve(rhs_,fluxes_); } - - atc_->set_fixed_nodes(); + + atc_->set_fixed_nodes(); // update electron temperature mass matrix atc_->compute_mass_matrix(ELECTRON_TEMPERATURE,physicsModel_); // update electron temperature @@ -521,11 +521,11 @@ namespace ATC { temperatureIntegrator_->update(idt,time,atc_->fields_,rhs_); //} //else { // lumped mass matrix - + //} } - atc_->set_fixed_nodes(); - + atc_->set_fixed_nodes(); + } } @@ -536,8 +536,8 @@ namespace ATC { void ExtrinsicModelDriftDiffusionConvection::output(OUTPUT_LIST & outputData) { ExtrinsicModelDriftDiffusion::output(outputData); - - + + //FIELD jouleHeating(atc_->num_nodes(),1); //set_kinetic_energy_source(atc_->fields(),jouleHeating); outputData["joule_heating"] = & (atc_->extrinsic_source(TEMPERATURE)).set_quantity(); @@ -587,7 +587,7 @@ namespace ATC { DENS_MAT & velocity((atc_->field(ELECTRON_VELOCITY)).set_quantity()); SPAR_MAT & velocityMassMat = (atc_->consistentMassMats_[ELECTRON_VELOCITY]).set_quantity(); kineticEnergy.reset(nNodes_,1); - + for (int j = 0; j < nsd_; j++) { CLON_VEC myVelocity(velocity,CLONE_COL,j); DENS_MAT velocityMat(nNodes_,1); diff --git a/lib/atc/ExtrinsicModelDriftDiffusion.h b/lib/atc/ExtrinsicModelDriftDiffusion.h index abc40e84d2..1547eb16aa 100644 --- a/lib/atc/ExtrinsicModelDriftDiffusion.h +++ b/lib/atc/ExtrinsicModelDriftDiffusion.h @@ -32,7 +32,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelDriftDiffusion : public ExtrinsicModelTwoTemperature { - + public: // constructor @@ -63,7 +63,7 @@ namespace ATC { /** get LAMMPS display variables */ virtual bool compute_vector(int n, double & value); - + protected: /** Poisson solve */ void poisson_solve(); @@ -91,7 +91,7 @@ namespace ATC { enum electronDensityEqnType { ELECTRON_CONTINUITY, ELECTRON_EQUILIBRIUM, ELECTRON_SCHRODINGER}; - + /** frequency for updating the electron state */ int fluxUpdateFreq_; @@ -139,7 +139,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelDriftDiffusionConvection : public ExtrinsicModelDriftDiffusion { - + public: // constructor @@ -167,7 +167,7 @@ namespace ATC { /** get LAMMPS display variables */ virtual bool compute_vector(int n, double & value); - + protected: /** compute the total kinetic energy of the electrons */ @@ -176,7 +176,7 @@ namespace ATC { /** Linear solver for velocity */ std::vector velocitySolvers_; - + /** Linear solver for solving the poisson equations */ LinearSolver * cddmPoissonSolver_; diff --git a/lib/atc/ExtrinsicModelElectrostatic.cpp b/lib/atc/ExtrinsicModelElectrostatic.cpp index d0aa56d67d..73a94b8192 100644 --- a/lib/atc/ExtrinsicModelElectrostatic.cpp +++ b/lib/atc/ExtrinsicModelElectrostatic.cpp @@ -53,11 +53,11 @@ namespace ATC { rhsMaskIntrinsic_.reset(NUM_FIELDS,NUM_FLUX); rhsMaskIntrinsic_ = false; if (atc_->track_charge()) { - + if (! chargeRegulator_) chargeRegulator_ = new ChargeRegulator(atc_); } } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -68,7 +68,7 @@ namespace ATC { } //-------------------------------------------------------- - // modify + // modify //-------------------------------------------------------- bool ExtrinsicModelElectrostatic::modify(int narg, char **arg) { @@ -82,7 +82,7 @@ namespace ATC { if (strcmp(arg[argIndx],"max_solves")==0) { argIndx++; maxSolves_ = atoi(arg[argIndx]) ; } - + else if (strcmp(arg[argIndx],"tolerance")==0) { argIndx++; poissonSolverTol_ = atof(arg[argIndx]); @@ -97,7 +97,7 @@ namespace ATC { poissonSolverType_ = DIRECT; } match = true; } // end "poisson_solver" - + /** creates fixed charge on faceset @@ -177,9 +177,9 @@ namespace ATC { "InterpolantGradient"); } - FundamentalAtomQuantity * atomicCharge = + FundamentalAtomQuantity * atomicCharge = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE); - AtfShapeFunctionRestriction * nodalAtomicCharge = + AtfShapeFunctionRestriction * nodalAtomicCharge = new AtfShapeFunctionRestriction(atc_,atomicCharge,atc_->accumulant()); interscaleManager.add_dense_matrix(nodalAtomicCharge,"NodalAtomicCharge"); AtfShapeFunctionMdProjection * nodalAtomicChargeDensity = @@ -198,10 +198,10 @@ namespace ATC { const string moleculeName = molecule->first; SmallMoleculeSet * smallMoleculeSet = interscaleManager.small_molecule_set(moleculeName); // calculate nodal charge from the molecules - AtomToSmallMoleculeTransfer * moleculeCharge = + AtomToSmallMoleculeTransfer * moleculeCharge = new AtomToSmallMoleculeTransfer(atc_,charge,smallMoleculeSet); interscaleManager.add_dense_matrix(moleculeCharge,"MoleculeCharge"+moleculeName); - MotfShapeFunctionRestriction * nodalAtomicMoleculeCharge = + MotfShapeFunctionRestriction * nodalAtomicMoleculeCharge = new MotfShapeFunctionRestriction(moleculeCharge, interscaleManager.sparse_matrix("ShapeFunction"+moleculeName)); interscaleManager.add_dense_matrix(nodalAtomicMoleculeCharge,"NodalMoleculeCharge"+moleculeName); @@ -212,10 +212,10 @@ namespace ATC { // dipole moment density // calculate the dipole moment of the molecules SmallMoleculeCentroid * moleculeCentroid = static_cast(interscaleManager.dense_matrix("MoleculeCentroid"+moleculeName)); - SmallMoleculeDipoleMoment * dipoleMoment = + SmallMoleculeDipoleMoment * dipoleMoment = new SmallMoleculeDipoleMoment(atc_,charge,smallMoleculeSet,atomProcGhostCoarseGrainingPositions,moleculeCentroid); interscaleManager.add_dense_matrix(dipoleMoment,"DipoleMoment"+moleculeName); - MotfShapeFunctionRestriction * nodalAtomicMoleculeDipole = + MotfShapeFunctionRestriction * nodalAtomicMoleculeDipole = new MotfShapeFunctionRestriction(dipoleMoment, interscaleManager.sparse_matrix("ShapeFunction"+moleculeName)); interscaleManager.add_dense_matrix(nodalAtomicMoleculeDipole,"NodalMoleculeDipole"+moleculeName); @@ -224,7 +224,7 @@ namespace ATC { interscaleManager.add_dense_matrix(nodalAtomicMoleculeDipoleDensity,"NodalMoleculeDipoleDensity"+moleculeName); } } - + } //-------------------------------------------------------- @@ -255,7 +255,7 @@ namespace ATC { } rhsMask_(ELECTRIC_POTENTIAL,FLUX) = false;// for poisson solve & rhs compute // need to create the bcs for the solver to configure properly - atc_->set_fixed_nodes(); + atc_->set_fixed_nodes(); if (poissonSolver_) delete poissonSolver_; @@ -278,14 +278,14 @@ namespace ATC { // set up Green's function per node for (int i = 0; i < nNodes; i++) { set localNodes; - + for (int j = 0; j < nNodes; j++) localNodes.insert(j); // call Poisson solver to get Green's function for node i DENS_VEC globalGreensFunction; poissonSolver_->greens_function(i,globalGreensFunction); - + // store green's functions as sparse vectors only on local nodes set::const_iterator thisNode; SparseVector sparseGreensFunction(nNodes); @@ -311,7 +311,7 @@ namespace ATC { nodalAtomicGhostCharge_ = interscaleManager.dense_matrix("NodalAtomicGhostCharge"); if (! nodalAtomicGhostCharge_) { FundamentalAtomQuantity * ghostCharge = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_CHARGE, GHOST); - + PerAtomSparseMatrix * ghostShapeFunctions = interscaleManager.per_atom_sparse_matrix("InterpolantGhost"); if (!ghostShapeFunctions) { ghostShapeFunctions = new PerAtomShapeFunction(atc_, @@ -353,10 +353,10 @@ namespace ATC { { if (chargeRegulator_) chargeRegulator_->apply_post_force(atc_->dt()); - // add in correction accounting for lumped mass matrix in charge density + // add in correction accounting for lumped mass matrix in charge density // in atomistic part of domain & account for physics model fluxes,resets rhs - - + + // set Dirchlet data atc_->set_fixed_nodes(); @@ -365,7 +365,7 @@ namespace ATC { // compute Poisson equation RHS sources atc_->compute_rhs_vector(rhsMask_, atc_->fields_, rhs_, atc_->source_integration(), physicsModel_); - + // add atomic charges to rhs DENS_MAT & rhs = rhs_[ELECTRIC_POTENTIAL].set_quantity(); if (atc_->track_charge()) { @@ -376,9 +376,9 @@ namespace ATC { } } - - + + // solve poisson eqn for electric potential // electron charge density added to Poisson RHS in solver @@ -391,7 +391,7 @@ namespace ATC { } // do this for intrinsic charges or effective electron charges at atoms - if (atc_->track_charge() + if (atc_->track_charge() || ( LammpsInterface::instance()->atom_charge() && atc_->source_atomic_quadrature(ELECTRIC_POTENTIAL) ) ) { _atomElectricalForce_.resize(atc_->nlocal(),atc_->nsd()); add_electrostatic_forces(potential); @@ -400,8 +400,8 @@ namespace ATC { apply_charged_surfaces(potential); #endif - InterscaleManager & interscaleManager_ = atc_->interscale_manager(); - atomForces_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE); + InterscaleManager & interscaleManager_ = atc_->interscale_manager(); + atomForces_ = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_FORCE); (*atomForces_) += _atomElectricalForce_; // f_E in ours, f in lammps ultimately } } @@ -421,7 +421,7 @@ namespace ATC { else { localF[0] = 0.;localF[1] = 0.; localF[2] = 0.; } - LammpsInterface::instance()->allsum(localF,totalElectricalForce_,3); + LammpsInterface::instance()->allsum(localF,totalElectricalForce_,3); if (LammpsInterface::instance()->rank_zero()) { atc_->feEngine_->add_global("electrostatic_force_x", totalElectricalForce_[0]); atc_->feEngine_->add_global("electrostatic_force_y", totalElectricalForce_[1]); @@ -435,9 +435,9 @@ namespace ATC { InterscaleManager & interscaleManager(atc_->interscale_manager()); const DENS_MAN * atomicChargeDensity(interscaleManager.dense_matrix("NodalAtomicChargeDensity")); atc_->nodal_atomic_field(CHARGE_DENSITY) = atomicChargeDensity->quantity(); - + fields[CHARGE_DENSITY] = atomicChargeDensity->quantity(); - + DENS_MAT & chargeDensity(fields[CHARGE_DENSITY].set_quantity()); DENS_MAT & nodalAtomicChargeDensity((atc_->nodal_atomic_field(CHARGE_DENSITY)).set_quantity()); if ((atc_->lammps_interface())->rank_zero()) { @@ -446,7 +446,7 @@ namespace ATC { } } - + if (fields.find(ELECTRON_DENSITY)==fields.end()) { fields[ELECTRON_DENSITY].reset(fields[CHARGE_DENSITY].nRows(),1); DENS_MAT & electronDensity(fields[ELECTRON_DENSITY].set_quantity()); @@ -454,7 +454,7 @@ namespace ATC { outputData["electron_density"] = &electronDensity; } } - + const map > & moleculeIds(atc_->molecule_ids()); map >::const_iterator molecule; for (molecule = moleculeIds.begin(); molecule != moleculeIds.end(); molecule++) { @@ -488,7 +488,7 @@ namespace ATC { //((atc_->interscale_manager()).fundamental_atom_quantity(LammpsInterface::ATOM_POSITION))->force_reset(); const DENS_MAT & atomPosition = ((atc_->interscale_manager()).fundamental_atom_quantity(LammpsInterface::ATOM_POSITION))->quantity(); double local_fdotx = 0, fdotx; - + for (int i = 0; i < _atomElectricalForce_.nRows() ; i++) { for (int j = 0; j < _atomElectricalForce_.nCols() ; j++) { local_fdotx -= _atomElectricalForce_(i,j)*atomPosition(i,j); @@ -505,7 +505,7 @@ namespace ATC { bool ExtrinsicModelElectrostatic::compute_vector(int n, double & value) { if (n == baseSize_) { - + double nSum = ((atc_->field(ELECTRON_DENSITY)).quantity()).col_sum(); value = nSum; return true; @@ -532,7 +532,7 @@ namespace ATC { void ExtrinsicModelElectrostatic::add_electrostatic_forces (MATRIX & potential) { - + //double qE2f = LammpsInterface::instance()->qe2f(); double qV2e = LammpsInterface::instance()->qv2e(); // charge volts to our energy units //double ** f = LammpsInterface::instance()->fatom(); @@ -548,7 +548,7 @@ namespace ATC { Ei = -1.*(*(shapeFucntionDerivatives[i])*potential); } } - + int dimOffset = 0; if (useSlab_) dimOffset = nsd - 1; for (int i = 0; i < nLocal; i++) { @@ -559,7 +559,7 @@ namespace ATC { for (int j = dimOffset; j < nsd; j ++) _atomElectricalForce_(i,j) = c*E(i,j); } - + // correct field for short range interactions if (includeShortRange_) correct_electrostatic_forces(); @@ -577,7 +577,7 @@ namespace ATC { double * q = LammpsInterface::instance()->atom_charge(); vector > atomicFePotential; int nLocal = atc_->nlocal(); - + int nGhostLammps = LammpsInterface::instance()->nghost(); int nLocalLammps = LammpsInterface::instance()->nlocal(); int nLocalTotal = nLocalLammps + nGhostLammps; // total number of atoms on this processor @@ -593,18 +593,18 @@ namespace ATC { DenseVector nodeIndices; DENS_VEC nodeValues; myShpFcn.row(i,nodeValues,nodeIndices); - + int atomIdx = atc_->internalToAtom_(i); //double c = qE2f*q[atomIdx]; //double c = qV2e*q[atomIdx]; //nodeValues *= c; nodeValues *= q[atomIdx]; - + for (int j = 0; j < nodeIndices.size(); j++) atomicFePotential[atomIdx].add_scaled(greensFunctions_[nodeIndices(j)],nodeValues(j)); } - // compute local potential contribtutions for lammps ghost atoms + // compute local potential contribtutions for lammps ghost atoms // which are known to ATC, // this will grab both processor and periodic neighbors, // so we need to add in neighbor contributions using lammps indices @@ -621,7 +621,7 @@ namespace ATC { Array nodeIndices(nodesPerElement); DENS_VEC nodeValues(nodesPerElement); (atc_->feEngine_)->shape_functions(coords,nodeValues,nodeIndices); - + //double c = qV2e*q[i]; //nodeValues *= c; nodeValues *= q[i]; @@ -633,7 +633,7 @@ namespace ATC { } // Get sparse vectors of derivatives at each atom - + // to compute this only when the shape functions change vector > > atomicDerivatives; atomicDerivatives.reserve(nLocal); @@ -657,9 +657,9 @@ namespace ATC { } } - // loop over all atoms and correct their efield based on all their + // loop over all atoms and correct their efield based on all their // neighbor's local efield response - + // need to use specific coulombic cutoff from different pairs // see pair_coul_cut for an example of the data structures // unfortunately don't know how to get at this data in general @@ -670,12 +670,12 @@ namespace ATC { double cutoffRadius = LammpsInterface::instance()->pair_cutoff(); double cutoffSq = cutoffRadius*cutoffRadius; - + int inum = LammpsInterface::instance()->neighbor_list_inum(); int * ilist = LammpsInterface::instance()->neighbor_list_ilist(); int * numneigh = LammpsInterface::instance()->neighbor_list_numneigh(); int ** firstneigh = LammpsInterface::instance()->neighbor_list_firstneigh(); - + // loop over neighbors of my atoms for (int ii = 0; ii < inum; ii++) { int i = ilist[ii]; @@ -683,10 +683,10 @@ namespace ATC { double xtmp = xatom[i][0]; double ytmp = xatom[i][1]; double ztmp = xatom[i][2]; - + int * jlist = firstneigh[i]; int jnum = numneigh[i]; - + for (int jj = 0; jj < jnum; jj++) { int j = jlist[jj]; if (mask[j] & atc_->groupbit_) { @@ -696,7 +696,7 @@ namespace ATC { double delx = xtmp - xatom[j][0]; double dely = ytmp - xatom[j][1]; double delz = ztmp - xatom[j][2]; - double rsq = delx*delx + dely*dely + delz*delz; + double rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutoffSq) { DENS_VEC efield(nsd); efield = 0.; @@ -732,7 +732,7 @@ namespace ATC { // get faceset information int nNodes = atc_->num_nodes(); const FE_Mesh * feMesh = (atc_->feEngine_)->fe_mesh(); - const set< pair > * faceset + const set< pair > * faceset = & ( feMesh->faceset(facesetName)); // set face sources to all point at one function for use in integration @@ -765,7 +765,7 @@ namespace ATC { nodalFaceWeights[ELECTRIC_POTENTIAL].reset(nNodes,1); Array fieldMask(NUM_FIELDS); fieldMask(ELECTRIC_POTENTIAL) = true; - + (atc_->feEngine_)->add_fluxes(fieldMask,0.,faceSources,nodalFaceWeights); // set up data structure holding charged faceset information FIELDS sources; @@ -774,7 +774,7 @@ namespace ATC { for (myNodeData = myFaceset.begin(); myNodeData != myFaceset.end(); myNodeData++) { // evaluate voltage at each node I // set up X_T function for integration: k*chargeDensity/||x_I - x_s|| - + // integral is approximated in two parts: // 1) near part with all faces within r < rcrit evaluated as 2 * pi * rcrit * k sigma A/A0, A is area of this region and A0 = pi * rcrit^2, so 2 k sigma A / rcrit // 2) far part evaluated using Gaussian quadrature on faceset @@ -790,7 +790,7 @@ namespace ATC { string radialPower = "radial_power"; f = XT_Function_Mgr::instance()->function(radialPower,8,xtArgs); - + for (iset = faceset->begin(); iset != faceset->end(); iset++) { pair face = *iset; // allocate @@ -850,7 +850,7 @@ namespace ATC { string facesetName = isurface->first; map >::const_iterator inode; for (inode = (isurface->second).begin(); inode != (isurface->second).end(); inode++) { - + int nodeId = inode->first; DENS_VEC nodalCoords = (inode->second).first; double nodalCharge = (inode->second).second; @@ -858,26 +858,26 @@ namespace ATC { PerAtomQuantity * atomicCoords = (atc_->interscale_manager()).per_atom_quantity("AtomicCoarseGrainingPositions"); const DENS_MAT & myAtomicCoords(atomicCoords->quantity()); for (int i = 0; i < nLocal; i++) { - if (abs(qatom(i,0)) > 0) { + if (abs(qatom(i,0)) > 0) { double distanceSq = 0.; double deltaX[3]; for (int j = 0; j < nsd; j++) { deltaX[j] = myAtomicCoords(i,j) - nodalCoords(j); distanceSq += deltaX[j]*deltaX[j]; } - if (distanceSq < cutoffSq) { + if (distanceSq < cutoffSq) { // first apply pairwise coulombic interaction - if (!useSlab_) { + if (!useSlab_) { double coulForce = qqrd2e*nodalCharge*qatom(i,0)/(distanceSq*sqrtf(distanceSq)); for (int j = 0; j < nsd; j++) //fatom[atomIdx][j] += deltaX[j]*coulForce; _atomElectricalForce_(i,j) += deltaX[j]*coulForce; } - + // second correct for FE potential induced by BCs // determine shape function derivatives at atomic location // and construct sparse vectors to store derivative data - + vector > derivativeVectors; derivativeVectors.reserve(nsd); const SPAR_MAT_VEC & shapeFunctionDerivatives((interscaleManager.vector_sparse_matrix("InterpolantGradient"))->quantity()); @@ -889,23 +889,23 @@ namespace ATC { for (int k = 0; k < nodeIndices.size(); k++) derivativeVectors[j](nodeIndices(k)) = nodeValues(k); } - + // compute greens function from charge quadrature - + SparseVector shortFePotential(nNodes); shortFePotential.add_scaled(greensFunctions_[nodeId],penalty*nodalPotential); - + // compute electric field induced by charge DENS_VEC efield(nsd); efield = 0.; for (int j = 0; j < nsd; j++) efield(j) = -.1*dot(derivativeVectors[j],shortFePotential); - + // apply correction in atomic forces //double c = qE2f*qatom[atomIdx]; double c = qV2e*qatom(i,0); for (int j = 0; j < nsd; j++) - if ((!useSlab_) || (j==nsd)) { + if ((!useSlab_) || (j==nsd)) { //fatom[atomIdx][j] -= c*efield(j); _atomElectricalForce_(i,j) -= c*efield(j); } @@ -932,7 +932,7 @@ namespace ATC { string matFileName) : ExtrinsicModelElectrostatic(modelManager,modelType,matFileName) { - if (physicsModel_) delete physicsModel_; + if (physicsModel_) delete physicsModel_; if (modelType == ELECTROSTATIC) { physicsModel_ = new PhysicsModelElectrostatic(matFileName); } @@ -943,7 +943,7 @@ namespace ATC { rhsMaskIntrinsic_(VELOCITY,SOURCE) = true; atc_->fieldMask_(VELOCITY,EXTRINSIC_SOURCE) = true; } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -953,7 +953,7 @@ namespace ATC { } //-------------------------------------------------------- - // modify + // modify //-------------------------------------------------------- bool ExtrinsicModelElectrostaticMomentum::modify(int narg, char **arg) { @@ -983,7 +983,7 @@ namespace ATC { void ExtrinsicModelElectrostaticMomentum::set_sources(FIELDS & fields, FIELDS & sources) { // compute charge density - if (modelType_ == ELECTROSTATIC_EQUILIBRIUM) { + if (modelType_ == ELECTROSTATIC_EQUILIBRIUM) { DENS_MAN & n = atc_->field(ELECTRON_DENSITY); atc_->nodal_projection(ELECTRON_DENSITY,physicsModel_,n); } @@ -997,7 +997,7 @@ namespace ATC { // compute source term with appropriate masking and physics model atc_->evaluate_rhs_integral(rhsMaskIntrinsic_, fields, sources, - atc_->source_integration(), physicsModel_); + atc_->source_integration(), physicsModel_); //(sources[VELOCITY].quantity()).print("V SRC"); } diff --git a/lib/atc/ExtrinsicModelElectrostatic.h b/lib/atc/ExtrinsicModelElectrostatic.h index 86cba31471..4e80f20b9b 100644 --- a/lib/atc/ExtrinsicModelElectrostatic.h +++ b/lib/atc/ExtrinsicModelElectrostatic.h @@ -25,7 +25,7 @@ namespace ATC { /** * @class ExtrinsicModelElectrostatic * @brief add self-consistent electrostatic forces - * owned field: ELECTRIC_POTENTIAL + * owned field: ELECTRIC_POTENTIAL */ //-------------------------------------------------------- @@ -35,7 +35,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelElectrostatic : public ExtrinsicModel { - + public: // constructor @@ -71,9 +71,9 @@ namespace ATC { virtual double compute_scalar(void); virtual bool compute_vector(int n, double & value); - PoissonSolver * poisson_solver(void) const { return poissonSolver_;} + PoissonSolver * poisson_solver(void) const { return poissonSolver_;} + - protected: /** poisson solver type */ SolverType poissonSolverType_; @@ -91,7 +91,7 @@ namespace ATC { /** rhs mask for Poisson solver */ Array2D rhsMask_; - + /** estimate intrinsic charge density */ void add_electrostatic_forces(MATRIX & nodalPotential); @@ -107,7 +107,7 @@ namespace ATC { const double chargeDensity); #endif /** charge regulator */ - ChargeRegulator * chargeRegulator_; + ChargeRegulator * chargeRegulator_; /** local electric potential Green's function for each node */ std::vector > greensFunctions_; @@ -123,11 +123,11 @@ namespace ATC { /** data structure storing potential induced only by charges under the nodal shape function support */ std::map > nodalChargePotential_; - + /** allows electric force only applied only in z direction to complement LAMMPS slab command */ bool useSlab_; - + /** enables method when short range interactions are off */ bool includeShortRange_; @@ -158,7 +158,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelElectrostaticMomentum : public ExtrinsicModelElectrostatic { - + public: // constructor @@ -180,7 +180,7 @@ namespace ATC { /** Add model-specific output data */ virtual void output(OUTPUT_LIST & outputData); - + }; }; diff --git a/lib/atc/ExtrinsicModelTwoTemperature.cpp b/lib/atc/ExtrinsicModelTwoTemperature.cpp index 35846fe496..43c68577bb 100644 --- a/lib/atc/ExtrinsicModelTwoTemperature.cpp +++ b/lib/atc/ExtrinsicModelTwoTemperature.cpp @@ -28,7 +28,7 @@ namespace ATC { electronTimeIntegration_(TimeIntegrator::IMPLICIT), temperatureIntegrator_(nullptr), nsubcycle_(1), - exchangeFlag_(true), + exchangeFlag_(true), baseSize_(0) { physicsModel_ = new PhysicsModelTwoTemperature(matFileName); @@ -39,7 +39,7 @@ namespace ATC { rhsMaskIntrinsic_(TEMPERATURE,SOURCE) = true; atc_->fieldMask_(TEMPERATURE,EXTRINSIC_SOURCE) = true; } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -49,7 +49,7 @@ namespace ATC { } //-------------------------------------------------------- - // modify + // modify //-------------------------------------------------------- bool ExtrinsicModelTwoTemperature::modify(int narg, char **arg) { @@ -174,12 +174,12 @@ namespace ATC { else if (electronTimeIntegration_ == TimeIntegrator::IMPLICIT) { double alpha = 1; // backwards Euler temperatureIntegrator_ = new FieldImplicitEulerIntegrator( - ELECTRON_TEMPERATURE, physicsModel_, atc_->feEngine_, atc_, + ELECTRON_TEMPERATURE, physicsModel_, atc_->feEngine_, atc_, rhsMask, alpha); } else if (electronTimeIntegration_ == TimeIntegrator::EXPLICIT) { temperatureIntegrator_ = new FieldExplicitEulerIntegrator( - ELECTRON_TEMPERATURE, physicsModel_, atc_->feEngine_, atc_, + ELECTRON_TEMPERATURE, physicsModel_, atc_->feEngine_, atc_, rhsMask); } double dt = atc_->lammpsInterface_->dt(); @@ -267,18 +267,18 @@ namespace ATC { // output[1] = total electron energy // output[2] = average electron temperature - if (n == baseSize_) { + if (n == baseSize_) { Array mask(1); FIELD_MATS energy; mask(0) = ELECTRON_TEMPERATURE; - - (atc_->feEngine_)->compute_energy(mask, + + (atc_->feEngine_)->compute_energy(mask, atc_->fields(), physicsModel_, atc_->elementToMaterialMap_, energy); // convert to lammps energy units - double mvv2e = (atc_->lammps_interface())->mvv2e(); + double mvv2e = (atc_->lammps_interface())->mvv2e(); double electronEnergy = mvv2e * energy[ELECTRON_TEMPERATURE].col_sum(); value = electronEnergy; return true; @@ -288,7 +288,7 @@ namespace ATC { value = electronTemperature; return true; } - + return false; } diff --git a/lib/atc/ExtrinsicModelTwoTemperature.h b/lib/atc/ExtrinsicModelTwoTemperature.h index bf1979f400..0f89a5173e 100644 --- a/lib/atc/ExtrinsicModelTwoTemperature.h +++ b/lib/atc/ExtrinsicModelTwoTemperature.h @@ -25,7 +25,7 @@ namespace ATC { //-------------------------------------------------------- class ExtrinsicModelTwoTemperature : public ExtrinsicModel { - + public: // constructor @@ -50,7 +50,7 @@ namespace ATC { /** Add model-specific output data */ virtual void output(OUTPUT_LIST & outputData); - + /** set up LAMMPS display variables */ virtual int size_vector(int externalSize); diff --git a/lib/atc/FE_Element.cpp b/lib/atc/FE_Element.cpp index 299b9f191d..a57484299b 100644 --- a/lib/atc/FE_Element.cpp +++ b/lib/atc/FE_Element.cpp @@ -45,22 +45,22 @@ static const double localCoordinatesTolerance = 1.e-09; } int FE_Element::num_ips() const - { - return feInterpolate_->num_ips(); + { + return feInterpolate_->num_ips(); } int FE_Element::num_face_ips() const - { - return feInterpolate_->num_face_ips(); + { + return feInterpolate_->num_face_ips(); } - void FE_Element::face_coordinates(const DENS_MAT &eltCoords, + void FE_Element::face_coordinates(const DENS_MAT &eltCoords, const int faceID, DENS_MAT & faceCoords) const { faceCoords.reset(nSD_, numFaceNodes_); - for (int inode=0; inode < numFaceNodes_; inode++) + for (int inode=0; inode < numFaceNodes_; inode++) { int id = localFaceConn_(faceID,inode); for (int isd=0; isd 1.0) xiGuess(0) = 0.; if (fabs(xiGuess(1)) > 1.0) xiGuess(1) = 0.; if (fabs(xiGuess(2)) > 1.0) xiGuess(2) = 0.; - - // iteratively solve the equation by calculating the global + + // iteratively solve the equation by calculating the global // position of the guess and bringing the difference between it // and the actual global position of x to zero // @@ -127,12 +127,12 @@ static const double localCoordinatesTolerance = 1.e-09; while (count < localCoordinatesMaxIterations_) { feInterpolate_->compute_N_dNdr(xiGuess,N,dNdr); xGuess = N*eltCoordsT; - xDiff = xGuess-x; + xDiff = xGuess-x; // determine if the guess is close enough. // if it is, take it and run // if not, use Newton's method to update the guess - if (!dbl_geq(abs(xDiff(0)),tolerance_) && - !dbl_geq(abs(xDiff(1)),tolerance_) && + if (!dbl_geq(abs(xDiff(0)),tolerance_) && + !dbl_geq(abs(xDiff(1)),tolerance_) && !dbl_geq(abs(xDiff(2)),tolerance_)) { converged = true; xi = xiGuess; @@ -160,11 +160,11 @@ static const double localCoordinatesTolerance = 1.e-09; xi(i) = 2.0*(x(i)-min)/(max-min) - 1.0; } } - else if (projectionGuess_ == CENTROID_LINEARIZED) { + else if (projectionGuess_ == CENTROID_LINEARIZED) { DENS_VEC xi0(nSD_); xi0 = 0; DENS_VEC x0(nSD_), dx(nSD_); - centroid(eltCoords,x0); - dx = x - x0; + centroid(eltCoords,x0); + dx = x - x0; vector ts; ts.reserve(nSD_); tangents(eltCoords,xi0,ts); DENS_VEC & t1 = ts[0]; @@ -178,7 +178,7 @@ static const double localCoordinatesTolerance = 1.e-09; xi(1) = J2/J; xi(2) = J3/J; } - else if (projectionGuess_ == TWOD_ANALYTIC) { + else if (projectionGuess_ == TWOD_ANALYTIC) { // assume x-y planar and HEX8 double x0 = x(0), y0 = x(1); double X[4] = {eltCoords(0,0),eltCoords(0,1),eltCoords(0,2),eltCoords(0,3)}; @@ -194,13 +194,13 @@ static const double localCoordinatesTolerance = 1.e-09; xi1[0] = (4*x0 - X[0] + xi2[0]*X[0] - X[0] + xi2[0]*X[0] - X[0] - xi2[0]*X[0] - X[0] - xi2[0]*X[0])/(-X[0] + xi2[0]*X[0] + X[0] - xi2[0]*X[0] + X[0] + xi2[0]*X[0] - X[0] - xi2[0]*X[0]); xi1[1] = (4*x0 - X[0] + xi2[0]*X[0] - X[0] + xi2[0]*X[0] - X[0] - xi2[0]*X[0] - X[0] - xi2[0]*X[0])/(-X[0] + xi2[0]*X[0] + X[0] - xi2[0]*X[0] + X[0] + xi2[0]*X[0] - X[0] - xi2[0]*X[0]); // choose which one gives back x - xi(0) = xi1[0]; - xi(1) = xi2[0]; - xi(2) = 0; + xi(0) = xi1[0]; + xi(1) = xi2[0]; + xi(2) = 0; } } - + bool FE_Element::range_check(const DENS_MAT &eltCoords, const DENS_VEC &x) const { @@ -214,7 +214,7 @@ static const double localCoordinatesTolerance = 1.e-09; // ------------------------------------------------------------- - // Note: Only works for convex elements with planar faces with + // Note: Only works for convex elements with planar faces with // outward normals // ------------------------------------------------------------- bool FE_Element::contains_point(const DENS_MAT &eltCoords, @@ -229,7 +229,7 @@ static const double localCoordinatesTolerance = 1.e-09; bool inside = true; for (int faceID=0; faceIDface_normal(faceCoords, + feInterpolate_->face_normal(faceCoords, 0, normal); faceToPoint = x - column(faceCoords, 0); @@ -258,8 +258,8 @@ static const double localCoordinatesTolerance = 1.e-09; if (dbl_geq(eltCoords(dim,it),min)) { ++it; } else { - // set min to this node's coord in the specified dim, if it's - // smaller than the value previously stored + // set min to this node's coord in the specified dim, if it's + // smaller than the value previously stored min = eltCoords(dim,it); } } else { @@ -277,7 +277,7 @@ static const double localCoordinatesTolerance = 1.e-09; } } } - + // ------------------------------------------------------------- // shape_function calls should stay generic at all costs // ------------------------------------------------------------- @@ -306,7 +306,7 @@ static const double localCoordinatesTolerance = 1.e-09; local_coordinates(eltCoords, x, xi); feInterpolate_->shape_function(eltCoords, xi, N, dNdx); - } + } void FE_Element::shape_function_derivatives(const DENS_MAT eltCoords, const VECTOR &x, @@ -316,7 +316,7 @@ static const double localCoordinatesTolerance = 1.e-09; local_coordinates(eltCoords, x, xi); feInterpolate_->shape_function_derivatives(eltCoords, xi, dNdx); - } + } void FE_Element::shape_function(const DENS_MAT eltCoords, @@ -334,8 +334,8 @@ static const double localCoordinatesTolerance = 1.e-09; DIAG_MAT &weights) { DENS_MAT faceCoords; - face_coordinates(eltCoords, faceID, faceCoords); - + face_coordinates(eltCoords, faceID, faceCoords); + feInterpolate_->face_shape_function(eltCoords, faceCoords, faceID, N, n, weights); } @@ -348,8 +348,8 @@ static const double localCoordinatesTolerance = 1.e-09; DIAG_MAT &weights) { DENS_MAT faceCoords; - face_coordinates(eltCoords, faceID, faceCoords); - + face_coordinates(eltCoords, faceID, faceCoords); + feInterpolate_->face_shape_function(eltCoords, faceCoords, faceID, N, dN, Nn, weights); } @@ -357,7 +357,7 @@ static const double localCoordinatesTolerance = 1.e-09; double FE_Element::face_normal(const DENS_MAT &eltCoords, const int faceID, int ip, - DENS_VEC &normal) + DENS_VEC &normal) { DENS_MAT faceCoords; face_coordinates(eltCoords, faceID, faceCoords); @@ -373,12 +373,12 @@ static const double localCoordinatesTolerance = 1.e-09; { feInterpolate_->tangents(eltCoords,localCoords,tangents,normalize); } - - + + // ============================================================= // class FE_ElementHex // ============================================================= - FE_ElementHex::FE_ElementHex(int numNodes, + FE_ElementHex::FE_ElementHex(int numNodes, int numFaceNodes, int numNodes1d) : FE_Element(3, // number of spatial dimensions @@ -396,126 +396,126 @@ static const double localCoordinatesTolerance = 1.e-09; // / // / // z - + // Basic properties of element: vol_ = 8.0; faceArea_ = 4.0; - + // Order-specific information: if (numNodes != 8 && numNodes != 20 && numNodes != 27) { - throw ATC_Error("Unrecognized interpolation order specified " - "for element class: \n" - " element only knows how to construct lin " + throw ATC_Error("Unrecognized interpolation order specified " + "for element class: \n" + " element only knows how to construct lin " "and quad elements."); } localCoords_.resize(nSD_,numNodes_); localFaceConn_ = Array2D(numFaces_,numFaceNodes_); - + // Matrix of local nodal coordinates - localCoords_(0,0) = -1; localCoords_(0,4) = -1; - localCoords_(1,0) = -1; localCoords_(1,4) = -1; + localCoords_(0,0) = -1; localCoords_(0,4) = -1; + localCoords_(1,0) = -1; localCoords_(1,4) = -1; localCoords_(2,0) = -1; localCoords_(2,4) = 1; - // - localCoords_(0,1) = 1; localCoords_(0,5) = 1; - localCoords_(1,1) = -1; localCoords_(1,5) = -1; + // + localCoords_(0,1) = 1; localCoords_(0,5) = 1; + localCoords_(1,1) = -1; localCoords_(1,5) = -1; localCoords_(2,1) = -1; localCoords_(2,5) = 1; // - localCoords_(0,2) = 1; localCoords_(0,6) = 1; - localCoords_(1,2) = 1; localCoords_(1,6) = 1; + localCoords_(0,2) = 1; localCoords_(0,6) = 1; + localCoords_(1,2) = 1; localCoords_(1,6) = 1; localCoords_(2,2) = -1; localCoords_(2,6) = 1; // - localCoords_(0,3) = -1; localCoords_(0,7) = -1; - localCoords_(1,3) = 1; localCoords_(1,7) = 1; + localCoords_(0,3) = -1; localCoords_(0,7) = -1; + localCoords_(1,3) = 1; localCoords_(1,7) = 1; localCoords_(2,3) = -1; localCoords_(2,7) = 1; if (numNodes >= 20) { // only for quads - localCoords_(0,8) = 0; localCoords_(0,14) = 1; - localCoords_(1,8) = -1; localCoords_(1,14) = 1; + localCoords_(0,8) = 0; localCoords_(0,14) = 1; + localCoords_(1,8) = -1; localCoords_(1,14) = 1; localCoords_(2,8) = -1; localCoords_(2,14) = 0; - // - localCoords_(0,9) = 1; localCoords_(0,15) = -1; - localCoords_(1,9) = 0; localCoords_(1,15) = 1; + // + localCoords_(0,9) = 1; localCoords_(0,15) = -1; + localCoords_(1,9) = 0; localCoords_(1,15) = 1; localCoords_(2,9) = -1; localCoords_(2,15) = 0; // - localCoords_(0,10) = 0; localCoords_(0,16) = 0; - localCoords_(1,10) = 1; localCoords_(1,16) = -1; + localCoords_(0,10) = 0; localCoords_(0,16) = 0; + localCoords_(1,10) = 1; localCoords_(1,16) = -1; localCoords_(2,10) = -1; localCoords_(2,16) = 1; // - localCoords_(0,11) = -1; localCoords_(0,17) = 1; - localCoords_(1,11) = 0; localCoords_(1,17) = 0; + localCoords_(0,11) = -1; localCoords_(0,17) = 1; + localCoords_(1,11) = 0; localCoords_(1,17) = 0; localCoords_(2,11) = -1; localCoords_(2,17) = 1; // - localCoords_(0,12) = -1; localCoords_(0,18) = 0; - localCoords_(1,12) = -1; localCoords_(1,18) = 1; + localCoords_(0,12) = -1; localCoords_(0,18) = 0; + localCoords_(1,12) = -1; localCoords_(1,18) = 1; localCoords_(2,12) = 0; localCoords_(2,18) = 1; // - localCoords_(0,13) = 1; localCoords_(0,19) = -1; - localCoords_(1,13) = -1; localCoords_(1,19) = 0; + localCoords_(0,13) = 1; localCoords_(0,19) = -1; + localCoords_(1,13) = -1; localCoords_(1,19) = 0; localCoords_(2,13) = 0; localCoords_(2,19) = 1; if (numNodes >= 27) { // only for quads - localCoords_(0,20) = 0; localCoords_(0,24) = 1; - localCoords_(1,20) = 0; localCoords_(1,24) = 0; + localCoords_(0,20) = 0; localCoords_(0,24) = 1; + localCoords_(1,20) = 0; localCoords_(1,24) = 0; localCoords_(2,20) = 0; localCoords_(2,24) = 0; // - localCoords_(0,21) = 0; localCoords_(0,25) = 0; - localCoords_(1,21) = 0; localCoords_(1,25) = -1; + localCoords_(0,21) = 0; localCoords_(0,25) = 0; + localCoords_(1,21) = 0; localCoords_(1,25) = -1; localCoords_(2,21) = -1; localCoords_(2,25) = 0; // - localCoords_(0,22) = 0; localCoords_(0,26) = 0; - localCoords_(1,22) = 0; localCoords_(1,26) = 1; + localCoords_(0,22) = 0; localCoords_(0,26) = 0; + localCoords_(1,22) = 0; localCoords_(1,26) = 1; localCoords_(2,22) = 1; localCoords_(2,26) = 0; // - localCoords_(0,23) = -1; - localCoords_(1,23) = 0; + localCoords_(0,23) = -1; + localCoords_(1,23) = 0; localCoords_(2,23) = 0; } } // Matrix of local face connectivity // -x // +x - localFaceConn_(0,0) = 0; localFaceConn_(1,0) = 1; - localFaceConn_(0,1) = 4; localFaceConn_(1,1) = 2; - localFaceConn_(0,2) = 7; localFaceConn_(1,2) = 6; - localFaceConn_(0,3) = 3; localFaceConn_(1,3) = 5; + localFaceConn_(0,0) = 0; localFaceConn_(1,0) = 1; + localFaceConn_(0,1) = 4; localFaceConn_(1,1) = 2; + localFaceConn_(0,2) = 7; localFaceConn_(1,2) = 6; + localFaceConn_(0,3) = 3; localFaceConn_(1,3) = 5; if (numNodes >= 20) { - localFaceConn_(0,4) = 12; localFaceConn_(1,4) = 9; - localFaceConn_(0,5) = 19; localFaceConn_(1,5) = 14; - localFaceConn_(0,6) = 15; localFaceConn_(1,6) = 17; - localFaceConn_(0,7) = 11; localFaceConn_(1,7) = 13; + localFaceConn_(0,4) = 12; localFaceConn_(1,4) = 9; + localFaceConn_(0,5) = 19; localFaceConn_(1,5) = 14; + localFaceConn_(0,6) = 15; localFaceConn_(1,6) = 17; + localFaceConn_(0,7) = 11; localFaceConn_(1,7) = 13; if (numNodes >= 27) { localFaceConn_(0,8) = 23; localFaceConn_(1,8) = 24; } } // -y // +y - localFaceConn_(2,0) = 0; localFaceConn_(3,0) = 3; - localFaceConn_(2,1) = 1; localFaceConn_(3,1) = 7; - localFaceConn_(2,2) = 5; localFaceConn_(3,2) = 6; - localFaceConn_(2,3) = 4; localFaceConn_(3,3) = 2; + localFaceConn_(2,0) = 0; localFaceConn_(3,0) = 3; + localFaceConn_(2,1) = 1; localFaceConn_(3,1) = 7; + localFaceConn_(2,2) = 5; localFaceConn_(3,2) = 6; + localFaceConn_(2,3) = 4; localFaceConn_(3,3) = 2; if (numNodes >= 20) { - localFaceConn_(2,4) = 8; localFaceConn_(3,4) = 15; - localFaceConn_(2,5) = 13; localFaceConn_(3,5) = 18; - localFaceConn_(2,6) = 16; localFaceConn_(3,6) = 14; - localFaceConn_(2,7) = 12; localFaceConn_(3,7) = 10; + localFaceConn_(2,4) = 8; localFaceConn_(3,4) = 15; + localFaceConn_(2,5) = 13; localFaceConn_(3,5) = 18; + localFaceConn_(2,6) = 16; localFaceConn_(3,6) = 14; + localFaceConn_(2,7) = 12; localFaceConn_(3,7) = 10; if (numNodes >= 27) { localFaceConn_(2,8) = 25; localFaceConn_(3,8) = 26; } } - + // -z // +z - localFaceConn_(4,0) = 0; localFaceConn_(5,0) = 4; - localFaceConn_(4,1) = 3; localFaceConn_(5,1) = 5; - localFaceConn_(4,2) = 2; localFaceConn_(5,2) = 6; - localFaceConn_(4,3) = 1; localFaceConn_(5,3) = 7; + localFaceConn_(4,0) = 0; localFaceConn_(5,0) = 4; + localFaceConn_(4,1) = 3; localFaceConn_(5,1) = 5; + localFaceConn_(4,2) = 2; localFaceConn_(5,2) = 6; + localFaceConn_(4,3) = 1; localFaceConn_(5,3) = 7; if (numNodes >= 20) { - localFaceConn_(4,4) = 8; localFaceConn_(5,4) = 16; - localFaceConn_(4,5) = 11; localFaceConn_(5,5) = 17; - localFaceConn_(4,6) = 10; localFaceConn_(5,6) = 18; - localFaceConn_(4,7) = 9; localFaceConn_(5,7) = 19; + localFaceConn_(4,4) = 8; localFaceConn_(5,4) = 16; + localFaceConn_(4,5) = 11; localFaceConn_(5,5) = 17; + localFaceConn_(4,6) = 10; localFaceConn_(5,6) = 18; + localFaceConn_(4,7) = 9; localFaceConn_(5,7) = 19; if (numNodes >= 27) { localFaceConn_(4,8) = 21; localFaceConn_(5,8) = 22; } @@ -530,7 +530,7 @@ static const double localCoordinatesTolerance = 1.e-09; } // determine alignment and skewness to see which guess we should use - + } FE_ElementHex::~FE_ElementHex() @@ -538,18 +538,18 @@ static const double localCoordinatesTolerance = 1.e-09; // Handled by base class } - void FE_ElementHex::set_quadrature(FeIntQuadrature type) - { + void FE_ElementHex::set_quadrature(FeIntQuadrature type) + { feInterpolate_->set_quadrature(HEXA,type); } - + bool FE_ElementHex::contains_point(const DENS_MAT &eltCoords, const DENS_VEC &x) const { if (! range_check(eltCoords,x) ) return false; DENS_VEC xi; - bool converged = local_coordinates(eltCoords,x,xi); + bool converged = local_coordinates(eltCoords,x,xi); if (!converged) return false; for (int i=0; i r - // 0 1 + // 0 1 // // (This is as dictated by the EXODUSII standard.) // @@ -631,18 +631,18 @@ static const double localCoordinatesTolerance = 1.e-09; // Basic properties of element: vol_ = 1.0/6.0; // local volume faceArea_ = 1.0/2.0; - + // Order-specific information: if (numNodes != 4 && numNodes != 10) { - throw ATC_Error("Unrecognized interpolation order specified " - "for element class: \n" - " element only knows how to construct lin " + throw ATC_Error("Unrecognized interpolation order specified " + "for element class: \n" + " element only knows how to construct lin " "and quad elements."); } - + localCoords_.resize(nSD_+1, numNodes_); localFaceConn_ = Array2D(numFaces_,numFaceNodes_); - + // Matrix of local nodal coordinates // // Remember, there's actually another coordinate too (u), coming @@ -653,45 +653,45 @@ static const double localCoordinatesTolerance = 1.e-09; // // The first three axes correspond to x, y, and z (essentially), // for the canonical element. - + // Everyone gets these nodes... localCoords_(0,0) = 0; localCoords_(0,2) = 0; - localCoords_(1,0) = 0; localCoords_(1,2) = 1; + localCoords_(1,0) = 0; localCoords_(1,2) = 1; localCoords_(2,0) = 0; localCoords_(2,2) = 0; localCoords_(3,0) = 1; localCoords_(3,2) = 0; // - localCoords_(0,1) = 1; localCoords_(0,3) = 0; - localCoords_(1,1) = 0; localCoords_(1,3) = 0; - localCoords_(2,1) = 0; localCoords_(2,3) = 1; + localCoords_(0,1) = 1; localCoords_(0,3) = 0; + localCoords_(1,1) = 0; localCoords_(1,3) = 0; + localCoords_(2,1) = 0; localCoords_(2,3) = 1; localCoords_(3,1) = 0; localCoords_(3,3) = 0; if (numNodes >= 10) { // ...quads get even more! localCoords_(0,4) = 0.5; localCoords_(0,5) = 0.5; - localCoords_(1,4) = 0.0; localCoords_(1,5) = 0.5; + localCoords_(1,4) = 0.0; localCoords_(1,5) = 0.5; localCoords_(2,4) = 0.0; localCoords_(2,5) = 0.0; localCoords_(3,4) = 0.5; localCoords_(3,5) = 0.0; // - localCoords_(0,6) = 0.0; localCoords_(0,7) = 0.0; - localCoords_(1,6) = 0.5; localCoords_(1,7) = 0.0; - localCoords_(2,6) = 0.0; localCoords_(2,7) = 0.5; + localCoords_(0,6) = 0.0; localCoords_(0,7) = 0.0; + localCoords_(1,6) = 0.5; localCoords_(1,7) = 0.0; + localCoords_(2,6) = 0.0; localCoords_(2,7) = 0.5; localCoords_(3,6) = 0.5; localCoords_(3,7) = 0.5; // - localCoords_(0,8) = 0.5; localCoords_(0,9) = 0.0; - localCoords_(1,8) = 0.0; localCoords_(1,9) = 0.5; - localCoords_(2,8) = 0.5; localCoords_(2,9) = 0.5; + localCoords_(0,8) = 0.5; localCoords_(0,9) = 0.0; + localCoords_(1,8) = 0.0; localCoords_(1,9) = 0.5; + localCoords_(2,8) = 0.5; localCoords_(2,9) = 0.5; localCoords_(3,8) = 0.0; localCoords_(3,9) = 0.0; } - + // Matrix of local face connectivity: - // ...opposite point 0, ...opposite point 2, + // ...opposite point 0, ...opposite point 2, localFaceConn_(0,0) = 1; localFaceConn_(2,0) = 0; localFaceConn_(0,1) = 2; localFaceConn_(2,1) = 1; localFaceConn_(0,2) = 3; localFaceConn_(2,2) = 3; - + // ...opposite point 1, ...opposite point 3. - localFaceConn_(1,0) = 2; localFaceConn_(3,0) = 0; - localFaceConn_(1,1) = 0; localFaceConn_(3,1) = 2; - localFaceConn_(1,2) = 3; localFaceConn_(3,2) = 1; + localFaceConn_(1,0) = 2; localFaceConn_(3,0) = 0; + localFaceConn_(1,1) = 0; localFaceConn_(3,1) = 2; + localFaceConn_(1,2) = 3; localFaceConn_(3,2) = 1; feInterpolate_ = new FE_InterpolateSimpLin(this); } @@ -701,8 +701,8 @@ static const double localCoordinatesTolerance = 1.e-09; // Handled by base class } - void FE_ElementTet::set_quadrature(FeIntQuadrature type) - { + void FE_ElementTet::set_quadrature(FeIntQuadrature type) + { feInterpolate_->set_quadrature(TETRA,type); } diff --git a/lib/atc/FE_Element.h b/lib/atc/FE_Element.h index 8c4dbc844b..1150c90063 100644 --- a/lib/atc/FE_Element.h +++ b/lib/atc/FE_Element.h @@ -12,7 +12,7 @@ namespace ATC { enum ProjectionGuessType { - COORDINATE_ALIGNED=0, + COORDINATE_ALIGNED=0, CENTROID_LINEARIZED, TWOD_ANALYTIC}; @@ -23,23 +23,23 @@ namespace ATC { * @class FE_Element * @brief Base class for a finite element holding info for canonical element */ - + class FE_Element { - + public: - + /////////////////////////////////////////////////////////////////////////// // - // CONSTRUCTOR AND DESTRUCTOR + // CONSTRUCTOR AND DESTRUCTOR FE_Element(const int nSD, - int numFaces, + int numFaces, int numNodes, int numFaceNodes, int numNodes1d); virtual ~FE_Element(); - + /////////////////////////////////////////////////////////////////////////// // // GETTERS @@ -49,23 +49,23 @@ namespace ATC { /** get number of element nodes */ int num_elt_nodes() { return numNodes_; } - + /** get number of element nodes */ int num_elt_nodes_1d() { return numNodes1d_; } - + /** get number of faces */ int num_faces() { return numFaces_; } - + /** get number of face nodes */ int num_face_nodes() { return numFaceNodes_; } - + // Getters for FE_Interpoate to have access to coordinates and connectivity /** get canonical coordinates */ const DENS_MAT &local_coords() const { return localCoords_; } /** get canonical coordinates in 1d */ - DENS_VEC local_coords_1d() const; - + DENS_VEC local_coords_1d() const; + /** get canonical connectivity of nodes and faces */ const Array2D &local_face_conn() const { return localFaceConn_; } @@ -78,29 +78,29 @@ namespace ATC { // the following two are pass-throughs to the interpolate class, and // can thus only be declared in the class body (or else the // interpolate class is "incomplete" and cannot be referenced) - + /** get number of integration points */ int num_ips() const; /** get number of integration points */ int num_face_ips() const; - + /** order of interpolation */ - int order() const {return numNodes1d_;} + int order() const {return numNodes1d_;} /** compute the quadrature for a given element type */ - virtual void set_quadrature(FeIntQuadrature type) = 0; + 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, std::vector &mapping) const; /** extract face coordinates from element coordinates */ - void face_coordinates(const DENS_MAT &eltCoords, + void face_coordinates(const DENS_MAT &eltCoords, const int faceID, DENS_MAT &faceCoords) const; - /** set initial guess type for point in element search */ - void set_projection_guess(ProjectionGuessType type) + /** set initial guess type for point in element search */ + void set_projection_guess(ProjectionGuessType type) { projectionGuess_ = type;} /////////////////////////////////////////////////////////////////////////// // @@ -122,7 +122,7 @@ namespace ATC { /** check if element bounding box contains the given point */ bool range_check(const DENS_MAT &eltCoords, const DENS_VEC & x) const; - /** get the min and max coordinate of any point in an element in a + /** get the min and max coordinate of any point in an element in a * dimension */ void bounds_in_dim(const DENS_MAT &eltCoords, const int dim, double &min, double &max) const; @@ -133,7 +133,7 @@ namespace ATC { virtual void shape_function(const VECTOR & xi, DENS_VEC &N) const; - /** + /** * compute shape functions at all ip's: * indexed: N(ip,node) * dN[nsd](ip,node) @@ -141,11 +141,11 @@ namespace ATC { */ virtual void shape_function(const DENS_MAT eltCoords, DENS_MAT &N, - std::vector &dN, + std::vector &dN, DIAG_MAT &weights); - /** - * compute shape functions and derivatives at a single point, + /** + * compute shape functions and derivatives at a single point, * given the point and the element that contains it * indexed: N(node) */ @@ -153,8 +153,8 @@ namespace ATC { const VECTOR &x, DENS_VEC &N); - /** - * compute shape functions and derivatives at a single point, + /** + * compute shape functions and derivatives at a single point, * given the point and the element that contains it * indexed: N(node) * dNdx(ip,nSD) @@ -164,17 +164,17 @@ namespace ATC { DENS_VEC &N, DENS_MAT &dNdx); - /** - * compute shape functions and derivatives at a single point, + /** + * compute shape functions and derivatives at a single point, * given the point and the element that contains it - * indexed: + * indexed: * dNdx(ip,nSD) */ virtual void shape_function_derivatives(const DENS_MAT eltCoords, const VECTOR &x, DENS_MAT &dNdx); - /** + /** * compute shape functions at all face ip's: * indexed: N(ip,node) * n[nsd](ip,node) @@ -186,7 +186,7 @@ namespace ATC { DENS_MAT &n, DIAG_MAT &weights); - /** + /** * compute shape functions at all face ip's: * indexed: N(ip,node) * dN[nsd](ip,node) @@ -200,32 +200,32 @@ namespace ATC { std::vector &Nn, DIAG_MAT &weights); - /** + /** * compute normal vector from the specified face * indexed: normal(nSD) */ virtual double face_normal(const DENS_MAT &eltCoords, const int faceID, int ip, - DENS_VEC &normal); - - /** + DENS_VEC &normal); + + /** * compute tangents to local coordinates - * indexed: + * indexed: */ virtual void tangents(const DENS_MAT &eltCoords, const DENS_VEC &x, std::vector & tangents, - const bool normalize=false) const; + const bool normalize=false) const; protected: /////////////////////////////////////////////////////////////////////////// // // HELPERS - - /** - * generate the appropriate interpolation class + + /** + * generate the appropriate interpolation class */ FE_Interpolate *interpolate_factory(std::string interpolateType); @@ -233,11 +233,11 @@ namespace ATC { virtual void initial_local_coordinates(const DENS_MAT &eltCoords, const DENS_VEC &x, DENS_VEC &xiInitial) const; - + /////////////////////////////////////////////////////////////////////////// // // PROTECTED MEMBERS - + // Currently used interpolation class FE_Interpolate *feInterpolate_; @@ -251,7 +251,7 @@ namespace ATC { // Number of face nodes int numFaceNodes_; // Number of nodes in one dimension - int numNodes1d_; + int numNodes1d_; // local coords of nodes: localCoords_(isd, ip) @@ -269,7 +269,7 @@ namespace ATC { /** tolerance used in solving Newton's method for local coordinates */ double tolerance_; ProjectionGuessType projectionGuess_; - + }; @@ -290,7 +290,7 @@ namespace ATC { ~FE_ElementHex(); - void set_quadrature(FeIntQuadrature type); + void set_quadrature(FeIntQuadrature type); bool contains_point(const DENS_MAT &eltCoords, const DENS_VEC &x) const; @@ -312,7 +312,7 @@ namespace ATC { void write_restart(FILE *); ~FE_ElementRect(); - + bool local_coordinates(const DENS_MAT &eltCoords, const DENS_VEC &x, DENS_VEC &xi) const; @@ -320,7 +320,7 @@ namespace ATC { protected: virtual bool contains_point(const DENS_MAT &eltCoords, const DENS_VEC &x) const; - + }; @@ -338,10 +338,10 @@ namespace ATC { // Dump state info to disk for later restart (unimplemented) void write_restart(FILE *); - + ~FE_ElementTet(); - void set_quadrature(FeIntQuadrature type); + void set_quadrature(FeIntQuadrature type); bool local_coordinates(const DENS_MAT &eltCoords, const DENS_VEC &x, diff --git a/lib/atc/FE_Engine.cpp b/lib/atc/FE_Engine.cpp index 9e3c5180e2..fc07b5e638 100644 --- a/lib/atc/FE_Engine.cpp +++ b/lib/atc/FE_Engine.cpp @@ -38,14 +38,14 @@ namespace ATC{ { // Nothing to do here } - + //----------------------------------------------------------------- FE_Engine::~FE_Engine() { if (feMesh_) delete feMesh_; } //----------------------------------------------------------------- - + void FE_Engine::initialize() { if (!feMesh_) throw ATC_Error("FE_Engine has no mesh"); @@ -59,7 +59,7 @@ namespace ATC{ nElems_ = feMesh_->num_elements(); nNodesUnique_ = feMesh_->num_nodes_unique(); nNodes_ = feMesh_->num_nodes(); - + // arrays & matrices _weights_.reset(nIPsPerElement_,nIPsPerElement_); _N_.reset(nIPsPerElement_,nNodesPerElement_); @@ -69,13 +69,13 @@ namespace ATC{ _Bfluxes_.assign(nSD_, DENS_MAT()); // faces _fweights_.reset(nIPsPerElement_,nIPsPerElement_); - _fN_.reset(nIPsPerFace_,nNodesPerElement_); + _fN_.reset(nIPsPerFace_,nNodesPerElement_); _fdN_.assign(nSD_, DENS_MAT(nIPsPerFace_, nNodesPerElement_)); _nN_.assign(nSD_, DENS_MAT(nIPsPerFace_, nNodesPerElement_)); // remove specified elements if (nullElements_.size() > 0) delete_elements(nullElements_); - + initialized_ = true; } } @@ -84,8 +84,8 @@ namespace ATC{ { if (is_partitioned()) return; - feMesh_->partition_mesh(); - + feMesh_->partition_mesh(); + // now do all FE_Engine data structure partitioning // partition nullElements_ @@ -115,7 +115,7 @@ namespace ATC{ int nIPsPerElement_new = feMesh_->num_ips_per_element(); int nIPsPerFace_new = feMesh_->num_ips_per_face(); - + if (nIPsPerElement_ != nIPsPerElement_new) { // arrays & matrices nIPsPerElement_ = nIPsPerElement_new; @@ -129,11 +129,11 @@ namespace ATC{ // faces nIPsPerFace_ = nIPsPerFace_new; _fweights_.reset(nIPsPerElement_,nIPsPerElement_); - _fN_.reset(nIPsPerFace_,nNodesPerElement_); + _fN_.reset(nIPsPerFace_,nNodesPerElement_); _fdN_.assign(nSD_, DENS_MAT(nIPsPerFace_, nNodesPerElement_)); _nN_.assign(nSD_, DENS_MAT(nIPsPerFace_, nNodesPerElement_)); } - + } //----------------------------------------------------------------- @@ -142,7 +142,7 @@ namespace ATC{ bool match = false; /*! \page man_mesh_create fix_modify AtC mesh create \section syntax - fix_modify AtC mesh create + fix_modify AtC mesh create \n - nx ny nz = number of elements in x, y, z - region-id = id of region that is to be meshed @@ -156,11 +156,11 @@ namespace ATC{ \section related \ref man_mesh_quadrature \section default - When created, mesh defaults to gauss2 (2-point Gaussian) quadrature. + 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) { + if (strcmp(arg[argIdx],"mesh")==0) { argIdx++; // create mesh if (strcmp(arg[argIdx],"create")==0) { @@ -172,7 +172,7 @@ namespace ATC{ string box = arg[argIdx++]; Array periodicity(3); - periodicity(0) = (strcmp(arg[argIdx++],"p")==0) ? true : false; + periodicity(0) = (strcmp(arg[argIdx++],"p")==0) ? true : false; periodicity(1) = (strcmp(arg[argIdx++],"p")==0) ? true : false; periodicity(2) = (strcmp(arg[argIdx++],"p")==0) ? true : false; @@ -214,7 +214,7 @@ namespace ATC{ \section related \ref man_mesh_create \section default - none + none */ else if (strcmp(arg[argIdx],"quadrature")==0) { argIdx++; @@ -223,30 +223,30 @@ namespace ATC{ set_quadrature(quadEnum); match = true; } - /*! \page man_mesh_read fix_modify AtC mesh read + /*! \page man_mesh_read fix_modify AtC mesh read \section syntax - fix_modify AtC mesh read - - filename = name of file containing mesh to be read + fix_modify AtC mesh read + - filename = name of file containing mesh to be read - f p p = periodicity flags for x, y, z \section examples fix_modify AtC mesh read myComponent.mesh p p p \n fix_modify AtC mesh read myOtherComponent.exo \section description Reads a mesh from a text or exodus file, and assigns periodic - boundary conditions if needed. + boundary conditions if needed. \section restrictions \section related \section default - periodicity flags are false by default + periodicity flags are false by default */ else if (strcmp(arg[argIdx],"read")==0) { argIdx++; string meshFile = arg[argIdx++]; - + Array periodicity(3); periodicity = false; if (argIdx < narg) { - periodicity(0) = (strcmp(arg[argIdx++],"p")==0) ? true : false; + periodicity(0) = (strcmp(arg[argIdx++],"p")==0) ? true : false; periodicity(1) = (strcmp(arg[argIdx++],"p")==0) ? true : false; periodicity(2) = (strcmp(arg[argIdx++],"p")==0) ? true : false; } @@ -254,7 +254,7 @@ namespace ATC{ if (periodicity(0) || periodicity(1) || periodicity(2)) { meshFile = "periodic_"+meshFile; - stringstream ss; + stringstream ss; ss << "writing periodicity corrected mesh: " << meshFile; print_msg(communicator_,ss.str()); feMesh_->write_mesh(meshFile); @@ -262,14 +262,14 @@ namespace ATC{ } match = true; } - /*! \page man_mesh_write fix_modify AtC mesh write + /*! \page man_mesh_write fix_modify AtC mesh write \section syntax - fix_modify AtC mesh write + fix_modify AtC mesh write - filename = name of file to write mesh \section examples fix_modify AtC mesh write myMesh.mesh \n \section description - Writes a mesh to a text file. + Writes a mesh to a text file. \section restrictions \section related \section default @@ -337,26 +337,26 @@ namespace ATC{ return match; } //----------------------------------------------------------------- - void FE_Engine::parse_partitions(int & argIdx, int narg, char ** arg, + void FE_Engine::parse_partitions(int & argIdx, int narg, char ** arg, int idof, Array & dx ) const { - double x[3] = {0,0,0}; + double x[3] = {0,0,0}; int nx = dx.size(); // parse relative values for each element if (is_numeric(arg[argIdx])) { - for (int i = 0; i < nx; ++i) { + for (int i = 0; i < nx; ++i) { if (is_numeric(arg[argIdx])) { dx(i) = atof(arg[argIdx++]); } else throw ATC_Error("not enough element partitions"); } } // each segment of the piecewise function is length-normalized separately - else if (strcmp(arg[argIdx],"position-number-density")==0) { + else if (strcmp(arg[argIdx],"position-number-density")==0) { argIdx++; double *y = new double[nx]; double *w = new double[nx]; int *n = new int[nx]; int nn = 0; - while (argIdx < narg) { + while (argIdx < narg) { if (! is_numeric(arg[argIdx])) break; y[nn] = atof(arg[argIdx++]); n[nn] = atoi(arg[argIdx++]); @@ -364,7 +364,7 @@ namespace ATC{ } if (n[nn-1] != nx) throw ATC_Error("total element partitions do not match"); int k = 0; - for (int i = 1; i < nn; ++i) { + for (int i = 1; i < nn; ++i) { int dn = n[i]-n[i-1]; double dy = y[i]-y[i-1]; double w0 = w[i-1]; @@ -372,7 +372,7 @@ namespace ATC{ double lx = 0; double *l = new double[dn]; for (int j = 0; j < dn; ++j) { - double x = (j+0.5)/dn; + double x = (j+0.5)/dn; double dl = w0+x*dw; lx += dl; l[j]= dl; @@ -392,11 +392,11 @@ namespace ATC{ else { XT_Function * f = XT_Function_Mgr::instance()->function(&(arg[argIdx]),narg-argIdx); argIdx++; - while (argIdx < narg) { + while (argIdx < narg) { if (! is_numeric(arg[argIdx++])) break; } - for (int i = 0; i < nx; ++i) { - x[idof] = (i+0.5)/nx; dx(i) = f->f(x,0.); + for (int i = 0; i < nx; ++i) { + x[idof] = (i+0.5)/nx; dx(i) = f->f(x,0.); } } } @@ -416,13 +416,13 @@ namespace ATC{ outputManager_.initialize(outputPrefix, otypes); if (!feMesh_) throw ATC_Error("output needs mesh"); if (!initialized_) initialize(); - if (!feMesh_->coordinates() || !feMesh_->connectivity()) + if (!feMesh_->coordinates() || !feMesh_->connectivity()) throw ATC_Error("output mesh not properly initialized"); - if (!feMesh_->coordinates()->nCols() || - !feMesh_->connectivity()->nCols()) + if (!feMesh_->coordinates()->nCols() || + !feMesh_->connectivity()->nCols()) throw ATC_Error("output mesh is empty"); - if (rank == 0) - outputManager_.write_geometry(feMesh_->coordinates(), + if (rank == 0) + outputManager_.write_geometry(feMesh_->coordinates(), feMesh_->connectivity()); outputManager_.print_custom_names(); } @@ -432,15 +432,15 @@ namespace ATC{ //----------------------------------------------------------------- void FE_Engine::write_geometry(void) { - outputManager_.write_geometry(feMesh_->coordinates(), + outputManager_.write_geometry(feMesh_->coordinates(), feMesh_->connectivity()); } // ------------------------------------------------------------- - // write data + // write data // ------------------------------------------------------------- - void FE_Engine::write_data(double time, - FIELDS &soln, + void FE_Engine::write_data(double time, + FIELDS &soln, OUTPUT_LIST *data) { outputManager_.write_data( @@ -449,12 +449,12 @@ namespace ATC{ } // ------------------------------------------------------------- - // write data + // write data // ------------------------------------------------------------- void FE_Engine::write_data(double time, OUTPUT_LIST *data) { outputManager_.write_data( - time, data, + time, data, feMesh_->node_map()->data()); } @@ -469,7 +469,7 @@ namespace ATC{ // ------------------------------------------------------------- // amend mesh for cut at specified faces // ------------------------------------------------------------- - void FE_Engine::cut_mesh(const set &faceSet, + void FE_Engine::cut_mesh(const set &faceSet, const set &nodeSet) { feMesh_->cut_mesh(faceSet,nodeSet); @@ -523,7 +523,7 @@ namespace ATC{ DENS_MAT &vP = fieldsAtIPs[_fieldName_]; // gradients of field at integration points -> to be computed DENS_MAT_VEC &dvP = gradFieldsAtIPs[_fieldName_]; - + if (_fieldName_ == ELECTRON_WAVEFUNCTION_ENERGIES ) { vP = vI; continue; @@ -543,7 +543,7 @@ namespace ATC{ } } // ------------------------------------------------------------- - // interpolate fields + // interpolate fields // Currently, this function will break if called with an unowned ielem. // Currently, this function is only called with owned ielems. // ------------------------------------------------------------- @@ -570,7 +570,7 @@ namespace ATC{ DENS_MAT &vP = fieldsAtIPs[_fieldName_]; // field values at element nodes DENS_MAT &vIe = localElementFields[_fieldName_]; - + if (_fieldName_ == ELECTRON_WAVEFUNCTION_ENERGIES ) { vP = vI; continue; @@ -587,13 +587,13 @@ namespace ATC{ } // ------------------------------------------------------------- - // compute dimensionless stiffness matrix using native quadrature + // compute dimensionless stiffness matrix using native quadrature // ------------------------------------------------------------- void FE_Engine::stiffness_matrix(SPAR_MAT &matrix) const { - // assemble consistent mass + // assemble consistent mass matrix.reset(nNodesUnique_,nNodesUnique_);// zero since partial fill - DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); + DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); vector myElems = feMesh_->owned_elts(); for (vector::iterator elemsIter = myElems.begin(); @@ -604,16 +604,16 @@ namespace ATC{ // evaluate shape functions feMesh_->shape_function(ielem, _N_, _dN_, _weights_); // _N_ unused // perform quadrature - elementMassMatrix = _dN_[0].transMat(_weights_*_dN_[0]); + elementMassMatrix = _dN_[0].transMat(_weights_*_dN_[0]); for (int i = 1; i < nSD_; ++i) { - elementMassMatrix += _dN_[i].transMat(_weights_*_dN_[i]); + elementMassMatrix += _dN_[i].transMat(_weights_*_dN_[i]); } // get connectivity _conn_ = feMesh_->element_connectivity_unique(ielem); - for (int i = 0; i < nNodesPerElement_; ++i) + for (int i = 0; i < nNodesPerElement_; ++i) { int inode = _conn_(i); - for (int j = 0; j < nNodesPerElement_; ++j) + for (int j = 0; j < nNodesPerElement_; ++j) { int jnode = _conn_(j); matrix.add(inode, jnode, elementMassMatrix(i,j)); @@ -646,7 +646,7 @@ namespace ATC{ FieldName colField = row_col.second; bool BB = rhsMask(rowField,FLUX); bool NN = rhsMask(rowField,SOURCE); - DENS_MAT elementMatrix(nNodesPerElement_,nNodesPerElement_); + DENS_MAT elementMatrix(nNodesPerElement_,nNodesPerElement_); DENS_MAT coefsAtIPs; vector myElems = feMesh_->owned_elts(); @@ -663,20 +663,20 @@ namespace ATC{ // interpolate fields and gradients (nonlinear only) interpolate_fields(ielem,fields,_conn_,_N_,_dN_,_weights_, _fieldsAtIPs_,_gradFieldsAtIPs_); - + // evaluate Physics model - + if (! (physicsModel->null(rowField,imat)) ) { - if (BB && physicsModel->weak_equation(rowField)-> + if (BB && physicsModel->weak_equation(rowField)-> has_BB_tangent_coefficients() ) { physicsModel->weak_equation(rowField)-> BB_tangent_coefficients(colField, _fieldsAtIPs_, mat, coefsAtIPs); - DIAG_MAT D(column(coefsAtIPs,0)); + DIAG_MAT D(column(coefsAtIPs,0)); D = _weights_*D; elementMatrix = _dN_[0].transMat(D*_dN_[0]); for (int i = 1; i < nSD_; i++) { elementMatrix += _dN_[i].transMat(D*_dN_[i]); - } + } } else { elementMatrix.reset(nNodesPerElement_,nNodesPerElement_); @@ -685,29 +685,29 @@ namespace ATC{ has_NN_tangent_coefficients() ) { physicsModel->weak_equation(rowField)-> NN_tangent_coefficients(colField, _fieldsAtIPs_, mat, coefsAtIPs); - DIAG_MAT D(column(coefsAtIPs,0)); + DIAG_MAT D(column(coefsAtIPs,0)); D = _weights_*D; elementMatrix += _N_.transMat(D*_N_); } // assemble - for (int i = 0; i < nNodesPerElement_; ++i) - { - int inode = _conn_(i); + for (int i = 0; i < nNodesPerElement_; ++i) + { + int inode = _conn_(i); for (int j = 0; j < nNodesPerElement_; ++j) { int jnode = _conn_(j); tangent.add(inode, jnode, elementMatrix(i,j)); } - } + } } - } + } #ifdef ISOLATE_FE sparse_allsum(communicator_,tangent); #else LammpsInterface::instance()->sparse_allsum(tangent); #endif - tangent.compress(); - } + tangent.compress(); + } // ------------------------------------------------------------- // compute tangent using given quadrature for one (field,field) pair @@ -733,7 +733,7 @@ namespace ATC{ int nips = weights.nCols(); if (nips>0) { // compute fields and gradients of fields at given ips - + GRAD_FIELD_MATS gradFieldsAtIPs; FIELD_MATS fieldsAtIPs; for (_fieldItr_ = fields.begin(); _fieldItr_ != fields.end(); _fieldItr_++) { @@ -755,11 +755,11 @@ namespace ATC{ if ( indices.size() > 0) atomMatls++; } bool singleMaterial = ( atomMatls == 1 ); - + if (! singleMaterial ) throw ATC_Error("FE_Engine::compute_tangent_matrix-given quadrature can not handle multiple atom material currently"); if (singleMaterial) { - int imat = 0; + int imat = 0; const Material * mat = physicsModel->material(imat); // evaluate Physics model if (! (physicsModel->null(rowField,imat)) ) { @@ -767,18 +767,18 @@ namespace ATC{ has_BB_tangent_coefficients() ) { physicsModel->weak_equation(rowField)-> BB_tangent_coefficients(colField, fieldsAtIPs, mat, coefsAtIPs); - DIAG_MAT D(column(coefsAtIPs,0)); + DIAG_MAT D(column(coefsAtIPs,0)); D = weights*D; K = (*dN[0]).transMat(D*(*dN[0])); for (int i = 1; i < nSD_; i++) { K += (*dN[i]).transMat(D*(*dN[i])); - } + } } if (NN && physicsModel->weak_equation(rowField)-> has_NN_tangent_coefficients() ) { physicsModel->weak_equation(rowField)-> NN_tangent_coefficients(colField, fieldsAtIPs, mat, coefsAtIPs); - DIAG_MAT D(column(coefsAtIPs,0)); + DIAG_MAT D(column(coefsAtIPs,0)); D = weights*D; K += N.transMat(D*N); } @@ -786,13 +786,13 @@ namespace ATC{ } } // share information between processors - int count = nn*nn; + int count = nn*nn; DENS_MAT K_sum(nn,nn); allsum(communicator_, K.ptr(), K_sum.ptr(), count); // create sparse from dense tangent.reset(K_sum,tol_sparse); tangent.compress(); - } + } // ------------------------------------------------------------- // compute a consistent mass matrix for native quadrature @@ -802,16 +802,16 @@ namespace ATC{ const FIELDS &fields, const PhysicsModel * physicsModel, const Array & elementMaterials, - + CON_MASS_MATS & massMatrices, const DenseMatrix *elementMask) const { int nfields = field_mask.size(); vector usedFields; - - DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); - + + DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); + // (JAT, 04/21/11) FIX THIS DENS_MAT capacity; @@ -819,7 +819,7 @@ namespace ATC{ for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); SPAR_MAT & M = massMatrices[_fieldName_].set_quantity(); - + // compresses 2May11 if (M.has_template()) { M = 0; } else { M.reset(nNodesUnique_,nNodesUnique_); } @@ -828,12 +828,12 @@ namespace ATC{ // element wise assembly vector myElems = feMesh_->owned_elts(); - for (vector::iterator elemsIter = myElems.begin(); + for (vector::iterator elemsIter = myElems.begin(); elemsIter != myElems.end(); - ++elemsIter) + ++elemsIter) { int ielem = *elemsIter; - // if element is masked, skip + // if element is masked, skip if (elementMask && !(*elementMask)(ielem,0)) continue; // material id int imat = elementMaterials(ielem); @@ -847,11 +847,11 @@ namespace ATC{ if (! (physicsModel->null(_fieldName_,imat)) ) { physicsModel->weak_equation(_fieldName_)-> M_integrand(_fieldsAtIPs_, mat, capacity); - DIAG_MAT rho(column(capacity,0)); + DIAG_MAT rho(column(capacity,0)); elementMassMatrix = _N_.transMat(_weights_*rho*_N_); // assemble - for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + for (int i = 0; i < nNodesPerElement_; ++i) { + int inode = _conn_(i); for (int j = 0; j < nNodesPerElement_; ++j) { int jnode = _conn_(j); M.add(inode, jnode, elementMassMatrix(i,j)); @@ -873,27 +873,27 @@ namespace ATC{ // fix zero diagonal entries due to null material elements for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); - - SPAR_MAT & M = massMatrices[_fieldName_].set_quantity(); + + SPAR_MAT & M = massMatrices[_fieldName_].set_quantity(); for (int inode = 0; inode < nNodesUnique_; ++inode) { if (! M.has_entry(inode,inode)) { - M.set(inode,inode,1.0); - } + M.set(inode,inode,1.0); + } } M.compress(); } - } + } // ------------------------------------------------------------- - // compute dimensionless consistent mass using native quadrature + // compute dimensionless consistent mass using native quadrature // ------------------------------------------------------------- void FE_Engine::compute_mass_matrix(SPAR_MAT &massMatrix) const { // assemble nnodes X nnodes matrix massMatrix.reset(nNodesUnique_,nNodesUnique_);// zero since partial fill - DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); + DENS_MAT elementMassMatrix(nNodesPerElement_,nNodesPerElement_); vector myElems = feMesh_->owned_elts(); for (vector::iterator elemsIter = myElems.begin(); elemsIter != myElems.end(); @@ -903,7 +903,7 @@ namespace ATC{ // evaluate shape functions feMesh_->shape_function(ielem, _N_, _weights_); // perform quadrature - elementMassMatrix = _N_.transMat(_weights_*_N_); + elementMassMatrix = _N_.transMat(_weights_*_N_); // get connectivity _conn_ = feMesh_->element_connectivity_unique(ielem); for (int i = 0; i < nNodesPerElement_; ++i) { @@ -932,9 +932,9 @@ namespace ATC{ int nn = N.nCols(); int nips = N.nRows(); DENS_MAT tmp_mass_matrix_local(nn,nn), tmp_mass_matrix(nn,nn); - if (nips>0) { tmp_mass_matrix_local = N.transMat(weights*N); } + if (nips>0) { tmp_mass_matrix_local = N.transMat(weights*N); } // share information between processors - int count = nn*nn; + int count = nn*nn; allsum(communicator_, tmp_mass_matrix_local.ptr(), tmp_mass_matrix.ptr(), count); @@ -943,12 +943,12 @@ namespace ATC{ } // ------------------------------------------------------------- - // compute dimensionless lumped mass using native quadrature + // compute dimensionless lumped mass using native quadrature // ------------------------------------------------------------- void FE_Engine::compute_lumped_mass_matrix(DIAG_MAT & M) const { M.reset(nNodesUnique_,nNodesUnique_); // zero since partial fill - // assemble lumped diagonal mass + // assemble lumped diagonal mass DENS_VEC Nvec(nNodesPerElement_); vector myElems = feMesh_->owned_elts(); for (vector::iterator elemsIter = myElems.begin(); @@ -972,7 +972,7 @@ namespace ATC{ } // ------------------------------------------------------------- - // compute physical lumped mass using native quadrature + // compute physical lumped mass using native quadrature // ------------------------------------------------------------- void FE_Engine::compute_lumped_mass_matrix( const Array& field_mask, @@ -984,9 +984,9 @@ namespace ATC{ { int nfields = field_mask.size(); // zero initialize for assembly - for (int j = 0; j < nfields; ++j) { + for (int j = 0; j < nfields; ++j) { DIAG_MAT & M = massMatrices[field_mask(j)].set_quantity(); - M.reset(nNodesUnique_,nNodesUnique_); + M.reset(nNodesUnique_,nNodesUnique_); } // assemble diagonal matrix vector myElems = feMesh_->owned_elts(); @@ -1005,13 +1005,13 @@ namespace ATC{ DENS_MAT capacity; for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); - if (! physicsModel->null(_fieldName_,imat)) { + if (! physicsModel->null(_fieldName_,imat)) { physicsModel->weak_equation(_fieldName_)-> M_integrand(_fieldsAtIPs_, mat, capacity); _Nmat_ = _N_.transMat(_weights_*capacity); DIAG_MAT & M = massMatrices[_fieldName_].set_quantity(); for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + int inode = _conn_(i); M(inode,inode) += _Nmat_(i,0); } @@ -1030,24 +1030,24 @@ namespace ATC{ for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); DIAG_MAT & M = massMatrices[_fieldName_].set_quantity(); - if (M(inode,inode) == 0.0) { - M(inode,inode) = 1.0; + if (M(inode,inode) == 0.0) { + M(inode,inode) = 1.0; } } } } // ------------------------------------------------------------- - // compute physical lumped mass using given quadrature + // compute physical lumped mass using given quadrature // ------------------------------------------------------------- void FE_Engine::compute_lumped_mass_matrix( - const Array &field_mask, + const Array &field_mask, const FIELDS &fields, const PhysicsModel * physicsModel, const Array > & pointMaterialGroups, - const DIAG_MAT &weights, + const DIAG_MAT &weights, const SPAR_MAT &N, - MASS_MATS &M) const // mass matrices + MASS_MATS &M) const // mass matrices { int nips = weights.nCols(); int nfields = field_mask.size(); @@ -1058,7 +1058,7 @@ namespace ATC{ M_local[_fieldName_].reset(nNodesUnique_,nNodesUnique_); M[_fieldName_].reset(nNodesUnique_,nNodesUnique_); } - + if (nips>0) { // compute fields at given ips // compute all fields since we don't the capacities dependencies @@ -1070,7 +1070,7 @@ namespace ATC{ fieldsAtIPs[_fieldName_].reset(nips,dof); fieldsAtIPs[_fieldName_] = N*field; } - + // treat single material point sets specially int nMatls = pointMaterialGroups.size(); int atomMatls = 0; @@ -1090,7 +1090,7 @@ namespace ATC{ stringstream ss; ss << " WARNING: multiple materials in atomic region"; print_msg(communicator_,ss.str()); } - + // setup data structures FIELD_MATS capacities; // evaluate physics model & compute capacity|density for requested fields @@ -1104,8 +1104,8 @@ namespace ATC{ const FIELD & f = (fields.find(_fieldName_))->second; capacities[_fieldName_].reset(f.nRows(),f.nCols()); capacities[_fieldName_] = 1.; - - } + + } else { physicsModel->weak_equation(_fieldName_)-> M_integrand(fieldsAtIPs, mat, capacities[_fieldName_]); @@ -1133,7 +1133,7 @@ namespace ATC{ for (set::const_iterator iter=indices.begin(); iter != indices.end(); iter++, i++ ) { for (int dof = 0; dof < ndof; ++dof) { - fieldsGroup[_fieldName_](i,dof) + fieldsGroup[_fieldName_](i,dof) = fieldsAtIPs[_fieldName_](*iter,dof); } } @@ -1145,7 +1145,7 @@ namespace ATC{ const FIELD & f = (fields.find(_fieldName_))->second; groupCapacities[_fieldName_].reset(f.nRows(),f.nCols()); groupCapacities[_fieldName_] = 1.; - } + } else { physicsModel->weak_equation(_fieldName_)-> M_integrand(fieldsGroup, mat, groupCapacities[_fieldName_]); @@ -1153,14 +1153,14 @@ namespace ATC{ int i = 0; for (set::const_iterator iter=indices.begin(); iter != indices.end(); iter++, i++ ) { - capacities[_fieldName_](*iter,0) + capacities[_fieldName_](*iter,0) = groupCapacities[_fieldName_](i,0); } } } } } - + // integrate & assemble for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); @@ -1168,7 +1168,7 @@ namespace ATC{ column(N.transMat(weights*capacities[_fieldName_]),0) ); } } - + // Share information between processors for (int j = 0; j < nfields; ++j) { _fieldName_ = field_mask(j); @@ -1177,16 +1177,16 @@ namespace ATC{ allsum(communicator_, M_local[_fieldName_].ptr(), myMassMat.ptr(), count); } } - + //----------------------------------------------------------------- // compute assembled average gradient evaluated at the nodes //----------------------------------------------------------------- void FE_Engine::compute_gradient_matrix(SPAR_MAT_VEC & grad_matrix) const { // zero - DENS_MAT_VEC tmp_grad_matrix(nSD_); + DENS_MAT_VEC tmp_grad_matrix(nSD_); for (int i = 0; i < nSD_; i++) { - tmp_grad_matrix[i].reset(nNodesUnique_,nNodesUnique_); + tmp_grad_matrix[i].reset(nNodesUnique_,nNodesUnique_); } // element wise assembly Array count(nNodesUnique_); count = 0; @@ -1202,7 +1202,7 @@ namespace ATC{ // get connectivity _conn_ = feMesh_->element_connectivity_unique(ielem); for (int j = 0; j < nIPsPerElement_; ++j) { - int jnode = _conn_(j); + int jnode = _conn_(j); count(jnode) += 1; for (int i = 0; i < nNodesPerElement_; ++i) { int inode = _conn_(i); @@ -1265,7 +1265,7 @@ namespace ATC{ const Material * mat = physicsModel->material(imat); interpolate_fields(ielem,fields,_conn_,_N_,_dN_,_weights_, _fieldsAtIPs_,_gradFieldsAtIPs_); - + // assemble for (int n = 0; n < mask.size(); n++) { _fieldName_ = mask(n); @@ -1276,8 +1276,8 @@ namespace ATC{ _fieldItr_ = fields.find(_fieldName_); _Nmat_ = _N_.transMat(_weights_*elementEnergy); DENS_MAT & energy = energies[_fieldName_]; - for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + for (int i = 0; i < nNodesPerElement_; ++i) { + int inode = _conn_(i); energy(inode,0) += _Nmat_(i,0); } } @@ -1319,24 +1319,24 @@ namespace ATC{ // Iterate over elements partitioned onto current processor. vector myElems = feMesh_->owned_elts(); - for (vector::iterator elemsIter = myElems.begin(); + for (vector::iterator elemsIter = myElems.begin(); elemsIter != myElems.end(); - ++elemsIter) + ++elemsIter) { int ielem = *elemsIter; - // Skip masked elements + // Skip masked elements if (elementMask && !(*elementMask)(ielem,0)) continue; int imat = elementMaterials(ielem); // material id const Material * mat = physicsModel->material(imat); - + // interpolate field values to integration points interpolate_fields(ielem,fields,_conn_,_N_,_dN_,_weights_, _fieldsAtIPs_,_gradFieldsAtIPs_); - + // rescale by _weights_, a diagonal matrix _Nw_ = _weights_*_N_; for (int j = 0; j < nSD_; ++j) _dNw_[j] = _weights_*_dN_[j]; - + // evaluate physics model and assemble // _Nfluxes is a set of fields for (int n = 0; n < rhsMask.nRows(); n++) { @@ -1347,15 +1347,15 @@ namespace ATC{ _fieldItr_ = fields.find(_fieldName_); const DENS_MAT & field = (_fieldItr_->second).quantity(); DENS_MAT & myRhs(rhs[_fieldName_].set_quantity()); - + int dof = field.nCols(); bool has = physicsModel->weak_equation(_fieldName_)-> N_integrand(_fieldsAtIPs_,_gradFieldsAtIPs_, mat, _Nfluxes_); if (!has) continue; _Nmat_ = _Nw_.transMat(_Nfluxes_); - - for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + + for (int i = 0; i < nNodesPerElement_; ++i) { + int inode = _conn_(i); for (int k = 0; k < dof; ++k) { myRhs(inode,k) += _Nmat_(i,k); } @@ -1366,29 +1366,29 @@ namespace ATC{ _fieldName_ = FieldName(n); if (!rhsMask(_fieldName_,FLUX)) continue; if (physicsModel->null(_fieldName_,imat)) continue; - + _fieldItr_ = fields.find(_fieldName_); const DENS_MAT & field = (_fieldItr_->second).quantity(); DENS_MAT & myRhs(rhs[_fieldName_].set_quantity()); - + int dof = field.nCols(); physicsModel->weak_equation(_fieldName_)-> B_integrand(_fieldsAtIPs_, _gradFieldsAtIPs_, mat, _Bfluxes_); for (int j = 0; j < nSD_; j++) { _Nmat_ = _dNw_[j].transMat(_Bfluxes_[j]); - for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + for (int i = 0; i < nNodesPerElement_; ++i) { + int inode = _conn_(i); for (int k = 0; k < dof; ++k) { myRhs(inode,k) += _Nmat_(i,k); - } + } } } - } + } } vector::iterator _fieldIter_; - for (_fieldIter_ = usedFields.begin(); _fieldIter_ != usedFields.end(); + for (_fieldIter_ = usedFields.begin(); _fieldIter_ != usedFields.end(); ++_fieldIter_) { // myRhs is where we put the global result for this field. _fieldName_ = *_fieldIter_; @@ -1397,7 +1397,7 @@ namespace ATC{ // Sum matrices in-place across all processors into myRhs. allsum(communicator_,MPI_IN_PLACE, myRhs.ptr(), myRhs.size()); } - } + } // ------------------------------------------------------------- // compute rhs using given quadrature @@ -1423,12 +1423,12 @@ namespace ATC{ rhs_local[_fieldName_].reset(nrows,ncols); } } - + int nips = weights.nCols(); if (nips>0) { // compute fields and gradients of fields at given ips - + GRAD_FIELD_MATS gradFieldsAtIPs; FIELD_MATS fieldsAtIPs; for (_fieldItr_ = fields.begin(); _fieldItr_ != fields.end(); _fieldItr_++) { @@ -1443,16 +1443,16 @@ namespace ATC{ } // setup data structures - FIELD_MATS Nfluxes; - GRAD_FIELD_MATS Bfluxes; + FIELD_MATS Nfluxes; + GRAD_FIELD_MATS Bfluxes; for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); int index = (int) _fieldName_; if ( rhsMask(index,FLUX) ) { - Bfluxes[_fieldName_].assign(nSD_, DENS_MAT()); + Bfluxes[_fieldName_].assign(nSD_, DENS_MAT()); } } - + // treat single material point sets specially int nMatls = pointMaterialGroups.size(); int atomMatls = 0; @@ -1461,9 +1461,9 @@ namespace ATC{ if ( indices.size() > 0) atomMatls++; } bool singleMaterial = ( atomMatls == 1 ); - + // evaluate physics model - if (singleMaterial) + if (singleMaterial) { int imat = 0; const Material * mat = physicsModel->material(imat); @@ -1482,21 +1482,21 @@ namespace ATC{ } } } - else + else { - - + + // 1) permanent workspace with per-row mapped clones per matl // from caller/atc // 2) per point calls to N/B_integrand // 3) collect internalToAtom into materials and use mem-cont clones // what about dof for matrices and data storage: clone _matrix_ - - // for each material group: + + // for each material group: // set up storage DENS_MAT group_Nfluxes; - DENS_MAT_VEC group_Bfluxes; - group_Bfluxes.reserve(nSD_); + DENS_MAT_VEC group_Bfluxes; + group_Bfluxes.reserve(nSD_); FIELD_MATS fieldsGroup; GRAD_FIELD_MATS gradFieldsGroup; for (_fieldItr_ = fields.begin(); _fieldItr_ != fields.end(); _fieldItr_++) { @@ -1504,14 +1504,14 @@ namespace ATC{ const DENS_MAT & field = (_fieldItr_->second).quantity(); int ndof = field.nCols(); gradFieldsGroup[_fieldName_].assign(nSD_,DENS_MAT(nips,ndof)); - + Nfluxes[_fieldName_].reset(nips,ndof); Bfluxes[_fieldName_].assign(nSD_,DENS_MAT(nips,ndof)); //} } // copy fields - for ( int imat = 0; imat < pointMaterialGroups.size(); imat++) + for ( int imat = 0; imat < pointMaterialGroups.size(); imat++) { const set & indices = pointMaterialGroups(imat); const Material * mat = physicsModel->material(0); @@ -1528,16 +1528,16 @@ namespace ATC{ (gradFieldsGroup[_fieldName_][j]).reset(npts,ndof); } for (int dof = 0; dof < ndof; ++dof) { - fieldsGroup[_fieldName_](i,dof) + fieldsGroup[_fieldName_](i,dof) = fieldsAtIPs[_fieldName_](*iter,dof); for (int j = 0; j < nSD_; ++j) { - gradFieldsGroup[_fieldName_][j](i,dof) + gradFieldsGroup[_fieldName_][j](i,dof) = gradFieldsAtIPs[_fieldName_][j](*iter,dof); } } } } - // calculate forces, & assemble + // calculate forces, & assemble for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); _fieldItr_ = fields.find(_fieldName_); @@ -1558,14 +1558,14 @@ namespace ATC{ } } } - // calculate forces, & assemble + // calculate forces, & assemble for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); if (physicsModel->null(_fieldName_,imat)) continue; int index = (int) _fieldName_; if ( rhsMask(index,FLUX) ) { _fieldItr_ = fields.find(_fieldName_); - const DENS_MAT & field = (_fieldItr_->second).quantity(); + const DENS_MAT & field = (_fieldItr_->second).quantity(); int ndof = field.nCols(); physicsModel->weak_equation(_fieldName_)-> B_integrand(fieldsGroup, gradFieldsGroup, mat, group_Bfluxes); @@ -1582,24 +1582,24 @@ namespace ATC{ } } } // endif multiple materials - + // assemble : N/Bfluxes -> rhs_local for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); int index = (int) _fieldName_; if ( rhsMask(index,SOURCE) && Nfluxes[_fieldName_].nCols() > 0 ) { - rhs_local[_fieldName_] + rhs_local[_fieldName_] += N.transMat(weights*Nfluxes[_fieldName_]); } if ( rhsMask(index,FLUX) && (Bfluxes[_fieldName_][0]).nCols() > 0 ) { for (int j = 0; j < nSD_; ++j) { - rhs_local[_fieldName_] + rhs_local[_fieldName_] += dN[j]->transMat(weights*Bfluxes[_fieldName_][j]); } } } } // end nips > 0 - + // Share information between processors: rhs_local -> rhs for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); @@ -1629,7 +1629,7 @@ namespace ATC{ if (nips>0) { FIELD_MATS Nfluxes; // compute fields and gradients of fields at given ips - + GRAD_FIELD_MATS gradFieldsAtIPs; FIELD_MATS fieldsAtIPs; for (_fieldItr_ = fields.begin(); _fieldItr_ != fields.end(); _fieldItr_++) { @@ -1651,10 +1651,10 @@ namespace ATC{ if ( indices.size() > 0) atomMatls++; } bool singleMaterial = ( atomMatls == 1 ); - - + + // evaluate physics model - if (singleMaterial) + if (singleMaterial) { int imat = 0; const Material * mat = physicsModel->material(imat); @@ -1670,11 +1670,11 @@ namespace ATC{ } } } - else + else { throw ATC_Error("compute source does not handle multiple materials currently"); } - + // assemble for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); @@ -1684,7 +1684,7 @@ namespace ATC{ } } } - + // no need to share information between processors } @@ -1735,24 +1735,24 @@ namespace ATC{ B_integrand(_fieldsAtIPs_, _gradFieldsAtIPs_, mat, _Bfluxes_); for (int j = 0; j < nSD_; j++) { _Nmat_ = _Nw_.transMat(_Bfluxes_[j]); - for (int i = 0; i < nNodesPerElement_; ++i) { - int inode = _conn_(i); + for (int i = 0; i < nNodesPerElement_; ++i) { + int inode = _conn_(i); for (int k = 0; k < dof; ++k) { - fluxes[_fieldName_][j](inode,k) += _Nmat_(i,k); - } - } + fluxes[_fieldName_][j](inode,k) += _Nmat_(i,k); + } + } } - } - } + } + } // Assemble partial results for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); if (!rhsMask(_fieldName_,FLUX)) continue; for (int j = 0; j < nSD_; j++) { - allsum(communicator_,MPI_IN_PLACE, fluxes[_fieldName_][j].ptr(), fluxes[_fieldName_][j].size()); - } + allsum(communicator_,MPI_IN_PLACE, fluxes[_fieldName_][j].ptr(), fluxes[_fieldName_][j].size()); + } } - } + } //----------------------------------------------------------------- // boundary flux using native quadrature @@ -1773,8 +1773,8 @@ namespace ATC{ } } - FIELD_MATS localElementFields; - GRAD_FIELD_MATS gradFieldsAtIPs; + FIELD_MATS localElementFields; + GRAD_FIELD_MATS gradFieldsAtIPs; FIELD_MATS fieldsAtIPs; for (_fieldItr_ = fields.begin(); _fieldItr_ != fields.end(); _fieldItr_++) { @@ -1788,7 +1788,7 @@ namespace ATC{ fieldsAtIPs[_fieldName_].reset(nIPsPerFace_,dof); localElementFields[_fieldName_].reset(nNodesPerElement_,dof); } - + // element wise assembly set< PAIR >::iterator iter; for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { @@ -1809,7 +1809,7 @@ namespace ATC{ _fieldName_ = _fieldItr_->first; const DENS_MAT & field = (_fieldItr_->second).quantity(); int dof = field.nCols(); - + for (int i = 0; i < nNodesPerElement_; i++) { for (int j = 0; j < dof; j++) { localElementFields[_fieldName_](i,j) = field(_conn_(i),j); @@ -1874,8 +1874,8 @@ namespace ATC{ const DenseMatrix * elementMask, const set * nodeSet) const { - - + + FIELDS rhs, rhsSubset; for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); @@ -1888,19 +1888,19 @@ namespace ATC{ rhsSubset[_fieldName_].reset(nrows,ncols); } } - + // R_I = - int_Omega Delta _N_I .q dV compute_rhs_vector(rhsMask, fields, physicsModel, elementMaterials, rhs, elementMask); // R_I^md = - int_Omega^md Delta _N_I .q dV - compute_rhs_vector(rhsMask, fields, physicsModel, pointMaterialGroups, + compute_rhs_vector(rhsMask, fields, physicsModel, pointMaterialGroups, _weights_, N, dN, rhsSubset); // flux_I = 1/Delta V_I V_I^md R_I + R_I^md // where : Delta V_I = int_Omega _N_I dV for (int n = 0; n < rhsMask.nRows(); n++) { _fieldName_ = FieldName(n); - if ( rhsMask(_fieldName_,FLUX) ) { + if ( rhsMask(_fieldName_,FLUX) ) { if (nodeSet) { _fieldItr_ = fields.find(_fieldName_); const DENS_MAT & field = (_fieldItr_->second).quantity(); @@ -1918,7 +1918,7 @@ namespace ATC{ } } else { - flux[_fieldName_] + flux[_fieldName_] = rhsSubset[_fieldName_].quantity() - flux_mask*(rhs[_fieldName_].quantity()); } } @@ -1930,7 +1930,7 @@ namespace ATC{ { int dof = field.nCols(); DENS_MAT eField(nNodesPerElement_, dof); - int nips = nIPsPerElement_; + int nips = nIPsPerElement_; DENS_MAT ipField(nips, dof); DENS_VEC integral(dof); integral = 0; for (ESET::const_iterator itr = eset.begin(); itr != eset.end(); ++itr) { @@ -1943,19 +1943,19 @@ namespace ATC{ for (int j = 0; j < dof; j++) { eField(i,j) = field(_conn_(i),j); }} ipField = _N_*eField; - for (int i = 0; i < nips; ++i) { + for (int i = 0; i < nips; ++i) { for (int j = 0; j < dof; ++j) { - integral(j) += ipField(i,j)*_weights_[i]; + integral(j) += ipField(i,j)*_weights_[i]; } } - } + } // assemble partial results allsum(communicator_,MPI_IN_PLACE, integral.ptr(), integral.size()); return integral; } //----------------------------------------------------------------- - // Robin boundary flux using native quadrature + // Robin boundary flux using native quadrature // integrate \int_delV _N_I s(x,t).n dA //----------------------------------------------------------------- void FE_Engine::add_robin_fluxes(const Array2D &rhsMask, @@ -1964,13 +1964,13 @@ namespace ATC{ const ROBIN_SURFACE_SOURCE & sourceFunctions, FIELDS &nodalSources) const { - + // sizing working arrays DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT faceSource; DENS_MAT localField; DENS_MAT xAtIPs(nSD_,nIPsPerFace_); - DENS_MAT uAtIPs(nIPsPerFace_,1); + DENS_MAT uAtIPs(nIPsPerFace_,1); FIELDS myNodalSources; // element wise assembly @@ -1978,15 +1978,15 @@ namespace ATC{ for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; + if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; DENS_MAT & s(nodalSources[_fieldName_].set_quantity()); myNodalSources[_fieldName_] = DENS_MAT(s.nRows(),s.nCols()); } for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; - + if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; + typedef map > FSET; const FSET *fset = (const FSET *)&(src_iter->second); FSET::const_iterator fset_iter; @@ -2001,7 +2001,7 @@ namespace ATC{ // evaluate location at ips feMesh_->face_shape_function(face, _fN_, _fdN_, _nN_, _fweights_); feMesh_->element_coordinates(elem, xCoords); - xAtIPs = xCoords*(_fN_.transpose()); + xAtIPs = xCoords*(_fN_.transpose()); // collect field _fieldItr_ = fields.find(_fieldName_); const DENS_MAT & field = (_fieldItr_->second).quantity(); @@ -2026,7 +2026,7 @@ namespace ATC{ faceSource(ip,idof) -= coefsAtIPs(ip,0)*uAtIPs(ip,0); } } - + // assemble DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); _Nmat_ = _fN_.transMat(_fweights_*faceSource); @@ -2034,23 +2034,23 @@ namespace ATC{ int inode = _conn_(i); for (int idof = 0; idof < nFieldDOF; ++idof) { s(inode,idof) += _Nmat_(i,idof); - } - } - } - } + } + } + } + } // assemble partial result matrices for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!rhsMask((int) _fieldName_,ROBIN_SOURCE)) continue; + if (!rhsMask((int) _fieldName_,ROBIN_SOURCE)) continue; DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); - allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); + allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); DENS_MAT & src(nodalSources[_fieldName_].set_quantity()); src += s; } } //----------------------------------------------------------------- - // Robin boundary flux stiffness using native quadrature + // Robin boundary flux stiffness using native quadrature // integrate \int_delV _N_I ds/du(x,t).n dA //----------------------------------------------------------------- void FE_Engine::add_robin_tangent(const Array2D &rhsMask, @@ -2059,7 +2059,7 @@ namespace ATC{ const ROBIN_SURFACE_SOURCE & sourceFunctions, SPAR_MAT &tangent) const { - + // sizing working arrays DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT coefsAtIPs; @@ -2073,8 +2073,8 @@ namespace ATC{ for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; - + if (!rhsMask((int)_fieldName_,ROBIN_SOURCE)) continue; + typedef map > FSET; const FSET *fset = (const FSET *)&(src_iter->second); FSET::const_iterator fset_iter; @@ -2089,7 +2089,7 @@ namespace ATC{ // evaluate location at ips feMesh_->face_shape_function(face, _fN_, _fdN_, _nN_, _fweights_); feMesh_->element_coordinates(elem, xCoords); - xAtIPs = xCoords*(_fN_.transpose()); + xAtIPs = xCoords*(_fN_.transpose()); // collect field _fieldItr_ = fields.find(_fieldName_); const DENS_MAT & field = (_fieldItr_->second).quantity(); @@ -2108,21 +2108,21 @@ namespace ATC{ column(xAtIPs,ip).ptr(),time); } } - + // assemble - DIAG_MAT D(column(coefsAtIPs,0)); - D *= -1; - D *= _fweights_; + DIAG_MAT D(column(coefsAtIPs,0)); + D *= -1; + D *= _fweights_; _Nmat_ = _fN_.transMat(D*_fN_); for (int i = 0; i < nNodesPerElement_; ++i) { int inode = _conn_(i); for (int j = 0; j < nNodesPerElement_; ++j) { int jnode = _conn_(j); K.add(inode, jnode, _Nmat_(i,j)); - } - } - } - } + } + } + } + } // assemble partial result matrices #ifdef ISOLATE_FE sparse_allsum(communicator_,K); @@ -2133,7 +2133,7 @@ namespace ATC{ } //----------------------------------------------------------------- - // Robin boundary flux using native quadrature + // Robin boundary flux using native quadrature // integrate \int_delV _N_I s(x,t).n dA //----------------------------------------------------------------- void FE_Engine::add_open_fluxes(const Array2D &rhsMask, @@ -2142,7 +2142,7 @@ namespace ATC{ FIELDS &nodalSources, const FieldName Velocity) const { - + // sizing working arrays DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT faceSource; @@ -2159,15 +2159,15 @@ namespace ATC{ for (face_iter=openFaces.begin(); face_iter!=openFaces.end(); face_iter++) { _fieldName_ = face_iter->first; - if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; + if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; DENS_MAT & s(nodalSources[_fieldName_].set_quantity()); myNodalSources[_fieldName_] = DENS_MAT(s.nRows(),s.nCols()); } for (face_iter=openFaces.begin(); face_iter!=openFaces.end(); face_iter++) { _fieldName_ = face_iter->first; - if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; - + if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; + typedef set FSET; const FSET *fset = (const FSET *)&(face_iter->second); FSET::const_iterator fset_iter; @@ -2220,23 +2220,23 @@ namespace ATC{ int inode = _conn_(i); for (int idof = 0; idof < nFieldDOF; ++idof) { s(inode,idof) += _Nmat_(i,idof); - } + } } - } - } + } + } // assemble partial result matrices for (face_iter=openFaces.begin(); face_iter!=openFaces.end(); face_iter++) { _fieldName_ = face_iter->first; - if (!rhsMask((int) _fieldName_,OPEN_SOURCE)) continue; + if (!rhsMask((int) _fieldName_,OPEN_SOURCE)) continue; DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); - allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); + allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); DENS_MAT & src(nodalSources[_fieldName_].set_quantity()); src += s; } } //----------------------------------------------------------------- - // Open boundary flux stiffness using native quadrature + // Open boundary flux stiffness using native quadrature // integrate \int_delV _N_I ds/du(x,t).n dA //----------------------------------------------------------------- void FE_Engine::add_open_tangent(const Array2D &rhsMask, @@ -2245,7 +2245,7 @@ namespace ATC{ SPAR_MAT &tangent, const FieldName Velocity) const { - + // sizing working arrays DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT faceSource; @@ -2259,10 +2259,10 @@ namespace ATC{ for (face_iter=openFaces.begin(); face_iter!=openFaces.end(); face_iter++) { _fieldName_ = face_iter->first; - if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; + if (!rhsMask((int)_fieldName_,OPEN_SOURCE)) continue; bool convective = false; if (_fieldName_ == Velocity) convective = true; - + typedef set FSET; const FSET *fset = (const FSET *)&(face_iter->second); FSET::const_iterator fset_iter; @@ -2315,10 +2315,10 @@ namespace ATC{ for (int j = 0; j < nNodesPerElement_; ++j) { int jnode = _conn_(j); K.add(inode, jnode, _Nmat_(i,j)); - } - } - } - } + } + } + } + } // assemble partial result matrices #ifdef ISOLATE_FE sparse_allsum(communicator_,K); @@ -2327,9 +2327,9 @@ namespace ATC{ #endif tangent += K; } - + //----------------------------------------------------------------- - // prescribed boundary flux using native quadrature + // prescribed boundary flux using native quadrature // integrate \int_delV _N_I s(x,t).n dA //----------------------------------------------------------------- void FE_Engine::add_fluxes(const Array &fieldMask, @@ -2337,7 +2337,7 @@ namespace ATC{ const SURFACE_SOURCE & sourceFunctions, FIELDS &nodalSources) const { - + // sizing working arrays DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT xAtIPs(nSD_,nIPsPerFace_); @@ -2349,15 +2349,15 @@ namespace ATC{ for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!fieldMask((int)_fieldName_)) continue; + if (!fieldMask((int)_fieldName_)) continue; DENS_MAT & s(nodalSources[_fieldName_].set_quantity()); myNodalSources[_fieldName_] = DENS_MAT(s.nRows(),s.nCols()); } for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!fieldMask((int)_fieldName_)) continue; - + if (!fieldMask((int)_fieldName_)) continue; + typedef map > FSET; const FSET *fset = (const FSET *)&(src_iter->second); FSET::const_iterator fset_iter; @@ -2376,17 +2376,17 @@ namespace ATC{ MultAB(xCoords,_fN_,xAtIPs,0,1); //xAtIPs = xCoords*(N.transpose()); // interpolate prescribed flux at ips of this element - + FSET::const_iterator face_iter = fset->find(face); - if (face_iter == fset->end()) - { + if (face_iter == fset->end()) + { stringstream ss; ss << "face not found" << std::endl; print_msg(communicator_,ss.str()); - + } - - + + int nFieldDOF = (face_iter->second).size(); faceSource.reset(nIPsPerFace_,nFieldDOF); for (int ip = 0; ip < nIPsPerFace_; ++ip) { @@ -2396,14 +2396,14 @@ namespace ATC{ faceSource(ip,idof) = f->f(column(xAtIPs,ip).ptr(),time); } } - + // assemble DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); _Nmat_ = _fN_.transMat(_fweights_*faceSource); - for (int i = 0; i < nNodesPerElement_; ++i) + for (int i = 0; i < nNodesPerElement_; ++i) { int inode = _conn_(i); - for (int idof = 0; idof < nFieldDOF; ++idof) + for (int idof = 0; idof < nFieldDOF; ++idof) { s(inode,idof) += _Nmat_(i,idof); } // end assemble nFieldDOF @@ -2413,16 +2413,16 @@ namespace ATC{ // assemble partial result matrices for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - if (!fieldMask((int)_fieldName_)) continue; + if (!fieldMask((int)_fieldName_)) continue; DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); - allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); + allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); DENS_MAT & src(nodalSources[_fieldName_].set_quantity()); src += s; } } //----------------------------------------------------------------- - // prescribed volume flux using native quadrature + // prescribed volume flux using native quadrature // integrate \int_V _N_I s(x,t) dV //----------------------------------------------------------------- void FE_Engine::add_sources(const Array &fieldMask, @@ -2430,14 +2430,14 @@ namespace ATC{ const VOLUME_SOURCE &sourceFunctions, FIELDS &nodalSources) const { - + // sizing working arrays DENS_MAT elemSource; DENS_MAT xCoords(nSD_,nNodesPerElement_); DENS_MAT xAtIPs(nSD_,nIPsPerElement_); FIELDS myNodalSources; - for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); + for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); src_iter != sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; int index = (int) _fieldName_; @@ -2456,12 +2456,12 @@ namespace ATC{ feMesh_->shape_function(ielem, _N_, _weights_); feMesh_->element_coordinates(ielem, xCoords); xAtIPs =xCoords*(_N_.transpose()); - for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); + for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); src_iter != sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; - int index = (int) _fieldName_; + int index = (int) _fieldName_; if ( fieldMask(index) ) { - const Array2D * thisSource + const Array2D * thisSource = (const Array2D *) &(src_iter->second); int nFieldDOF = thisSource->nCols(); elemSource.reset(nIPsPerElement_,nFieldDOF); @@ -2477,7 +2477,7 @@ namespace ATC{ // assemble _Nmat_ = _N_.transMat(_weights_*elemSource); DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); - + for (int i = 0; i < nNodesPerElement_; ++i) { int inode = _conn_(i); for (int idof = 0; idof < nFieldDOF; ++idof) { @@ -2488,13 +2488,13 @@ namespace ATC{ } } // Aggregate unmasked nodal sources on all processors. - for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); + for (VOLUME_SOURCE::const_iterator src_iter = sourceFunctions.begin(); src_iter != sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; int index = (int) _fieldName_; if (!fieldMask(index)) continue; DENS_MAT & s(myNodalSources[_fieldName_].set_quantity()); - allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); + allsum(communicator_,MPI_IN_PLACE, s.ptr(), s.size()); DENS_MAT & src(nodalSources[_fieldName_].set_quantity()); src += s; } @@ -2510,7 +2510,7 @@ namespace ATC{ FIELDS::const_iterator itr; for (itr=sources.begin(); itr!=sources.end(); itr++) { _fieldName_ = itr->first; - if (!fieldMask((int)_fieldName_)) continue; + if (!fieldMask((int)_fieldName_)) continue; DENS_MAT & src(nodalSources[_fieldName_].set_quantity()); const DENS_MAT & s((sources.find(_fieldName_)->second).quantity()); for (int inode = 0; inode < nNodesUnique_; ++inode) { @@ -2539,8 +2539,8 @@ namespace ATC{ // sizing working arrays DENS_MAT n(nSD_,nIPsPerFace_); DENS_MAT localElementFields(nNodesPerElement_,dof); - DENS_MAT integrals(dof,nSD_); - DENS_MAT fieldsAtIPs; + DENS_MAT integrals(dof,nSD_); + DENS_MAT fieldsAtIPs; // SJL shouldn't this just be _fieldsAtIPs_ // the data member? @@ -2603,7 +2603,7 @@ namespace ATC{ values(1,0) = integrals(3,0)+integrals(1,1)+integrals(5,2); values(2,0) = integrals(4,1)+integrals(5,1)+integrals(2,2); } - // (v.n) = v_j n_j + // (v.n) = v_j n_j else if (dof == 3) { // vector values.reset(1,1); values(0,0) = integrals(0,0)+integrals(1,1)+integrals(2,2); @@ -2625,7 +2625,7 @@ namespace ATC{ //----------------------------------------------------------------- // evaluate shape functions at given points //----------------------------------------------------------------- - + void FE_Engine::evaluate_shape_functions( const MATRIX & pt_coords, SPAR_MAT & N) const @@ -2633,12 +2633,12 @@ namespace ATC{ // Get shape function and derivatives at atomic locations int nnodes = feMesh_->num_nodes_unique(); int npts = pt_coords.nRows(); - + // loop over point (atom) coordinates DENS_VEC x(nSD_); Array node_index(nNodesPerElement_); DENS_VEC shp(nNodesPerElement_); - + N.reset(npts,nnodes); for (int i = 0; i < npts; ++i) { for (int k = 0; k < nSD_; ++k) { x(k) = pt_coords(i,k); } @@ -2648,7 +2648,7 @@ namespace ATC{ N.add(i,jnode,shp(j)); } } - N.compress(); + N.compress(); } //----------------------------------------------------------------- @@ -2668,12 +2668,12 @@ namespace ATC{ Array node_index(nNodesPerElement_); DENS_VEC shp(nNodesPerElement_); DENS_MAT dshp(nSD_,nNodesPerElement_); - + for (int k = 0; k < nSD_; ++k) { - dN[k]->reset(npts,nnodes); + dN[k]->reset(npts,nnodes); } - - N.reset(npts,nnodes); + + N.reset(npts,nnodes); for (int i = 0; i < npts; ++i) { for (int k = 0; k < nSD_; ++k) { x(k) = pt_coords(i,k); } feMesh_->shape_functions(x,shp,dshp,node_index); @@ -2685,9 +2685,9 @@ namespace ATC{ } } } - N.compress(); - for (int k = 0; k < nSD_; ++k) { - dN[k]->compress(); + N.compress(); + for (int k = 0; k < nSD_; ++k) { + dN[k]->compress(); } } @@ -2702,12 +2702,12 @@ namespace ATC{ // Get shape function and derivatives at atomic locations int nnodes = feMesh_->num_nodes_unique(); int npts = pt_coords.nRows(); - + // loop over point (atom) coordinates DENS_VEC x(nSD_); Array node_index(nNodesPerElement_); DENS_VEC shp(nNodesPerElement_); - + N.reset(npts,nnodes); for (int i = 0; i < npts; ++i) { for (int k = 0; k < nSD_; ++k) { x(k) = pt_coords(i,k); } @@ -2718,7 +2718,7 @@ namespace ATC{ N.add(i,jnode,shp(j)); } } - N.compress(); + N.compress(); } //----------------------------------------------------------------- @@ -2740,10 +2740,10 @@ namespace ATC{ DENS_VEC shp(nNodesPerElement_); DENS_MAT dshp(nSD_,nNodesPerElement_); for (int k = 0; k < nSD_; ++k) { - dN[k]->reset(npts,nnodes); + dN[k]->reset(npts,nnodes); } - - N.reset(npts,nnodes); + + N.reset(npts,nnodes); for (int i = 0; i < npts; ++i) { for (int k = 0; k < nSD_; ++k) { x(k) = pt_coords(i,k); } int eltId = pointToEltMap(i,0); @@ -2756,9 +2756,9 @@ namespace ATC{ } } } - N.compress(); - for (int k = 0; k < nSD_; ++k) { - dN[k]->compress(); + N.compress(); + for (int k = 0; k < nSD_; ++k) { + dN[k]->compress(); } } //----------------------------------------------------------------- @@ -2772,14 +2772,14 @@ namespace ATC{ int nnodes = feMesh_->num_nodes_unique(); int npts = pt_coords.nRows(); for (int k = 0; k < nSD_; ++k) { - dNdx[k]->reset(npts,nnodes); + dNdx[k]->reset(npts,nnodes); } // loop over point (atom) coordinates DENS_VEC x(nSD_); Array node_index(nNodesPerElement_); DENS_MAT dshp(nSD_,nNodesPerElement_); - + for (int i = 0; i < npts; ++i) { for (int k = 0; k < nSD_; ++k) { x(k) = pt_coords(i,k); } int eltId = pointToEltMap(i,0); @@ -2791,8 +2791,8 @@ namespace ATC{ } } } - for (int k = 0; k < nSD_; ++k) { - dNdx[k]->compress(); + for (int k = 0; k < nSD_; ++k) { + dNdx[k]->compress(); } } @@ -2816,7 +2816,7 @@ namespace ATC{ for (int i = 0; i < nNodes_; i++) { xI = feMesh_->global_coordinates(i); for (int j = 0; j < npts; j++) { - for (int k = 0; k < nSD_; ++k) { x(k) = ptCoords(j,k); } + for (int k = 0; k < nSD_; ++k) { x(k) = ptCoords(j,k); } dx = x - xI; if (kernelFunction_->in_support(dx)) bw = max(bw,abs(j-map_global_to_unique(i))); } @@ -2844,7 +2844,7 @@ namespace ATC{ for (int i = 0; i < nNodes_; i++) { xI = feMesh_->global_coordinates(i); for (int j = 0; j < npts; j++) { - for (int k = 0; k < nSD_; ++k) { x(k) = ptCoords(j,k); } + for (int k = 0; k < nSD_; ++k) { x(k) = ptCoords(j,k); } dx = x - xI; double val = kernelFunction_->value(dx); val *= kernelFunction_->dimensionality_factor(); @@ -2859,9 +2859,9 @@ namespace ATC{ // create a non-uniform rectangular mesh on a rectangular region //----------------------------------------------------------------- - void FE_Engine::create_mesh(Array & dx, - Array & dy, - Array & dz, + void FE_Engine::create_mesh(Array & dx, + Array & dy, + Array & dz, const char * regionName, Array periodicity) { @@ -2885,7 +2885,7 @@ namespace ATC{ if (dy(0) == 0.0) dy = (ymax-ymin)/dy.size(); if (dz(0) == 0.0) dz = (zmax-zmin)/dz.size(); - + feMesh_ = new FE_Rectangular3DMesh(dx,dy,dz, xmin, xmax, ymin, ymax, @@ -2893,8 +2893,8 @@ namespace ATC{ periodicity, xscale, yscale, zscale); stringstream ss; - ss << "created structured mesh with " << feMesh_->num_nodes() << " nodes, " - << feMesh_->num_nodes_unique() << " unique nodes, and " + ss << "created structured mesh with " << feMesh_->num_nodes() << " nodes, " + << feMesh_->num_nodes_unique() << " unique nodes, and " << feMesh_->num_elements() << " elements"; print_msg_once(communicator_,ss.str()); #ifdef ATC_VERBOSE @@ -2916,7 +2916,7 @@ namespace ATC{ double xl= xs/(ATC::LammpsInterface::instance()->xlattice()); double sumn = 0, sums = 0, suml = 0; double x = xmin; - for (int i = 0; i < dx.size(); ++i) { + for (int i = 0; i < dx.size(); ++i) { double dxn = dx(i)*xn; sumn += dxn; double dxs = dx(i)*xs; sums += dxs; double dxl = dx(i)*xl; suml += dxl; @@ -2953,7 +2953,7 @@ namespace ATC{ zmin, zmax, xscale, yscale, zscale); if (!isBox) throw ATC_Error("Region for FE mesh is not a box"); - + feMesh_ = new FE_Uniform3DMesh(nx,ny,nz, xmin, xmax, ymin, ymax, @@ -2961,8 +2961,8 @@ namespace ATC{ periodicity, xscale, yscale, zscale); stringstream ss; - ss << "created uniform mesh with " << feMesh_->num_nodes() << " nodes, " - << feMesh_->num_nodes_unique() << " unique nodes, and " + ss << "created uniform mesh with " << feMesh_->num_nodes() << " nodes, " + << feMesh_->num_nodes_unique() << " unique nodes, and " << feMesh_->num_elements() << " elements"; print_msg_once(communicator_,ss.str()); } diff --git a/lib/atc/FE_Engine.h b/lib/atc/FE_Engine.h index ade7626f80..4a3bedac7d 100644 --- a/lib/atc/FE_Engine.h +++ b/lib/atc/FE_Engine.h @@ -16,36 +16,36 @@ #include "mpi.h" namespace ATC { - + class ATC_Method; class FE_Element; class XT_Function; class KernelFunction; - + /** - * @class FE_Engine - * @brief Base class for computing and assembling mass matrix + * @class FE_Engine + * @brief Base class for computing and assembling mass matrix * and rhs vectors - */ - + */ + class FE_Engine{ public: /** constructor/s */ FE_Engine(MPI_Comm comm); - + /** destructor */ ~FE_Engine(); - + /** initialize */ void initialize(); - + MPI_Comm communicator() {return communicator_;} void partition_mesh(); void departition_mesh(); bool is_partitioned() const { return feMesh_->is_partitioned(); } - int map_elem_to_myElem(int elemID) const + int map_elem_to_myElem(int elemID) const { return feMesh_->map_elem_to_myElem(elemID); } - int map_myElem_to_elem(int myElemID) const + int map_myElem_to_elem(int myElemID) const { return feMesh_->map_myElem_to_elem(myElemID); } // note: it is misleading to declare the following const @@ -60,7 +60,7 @@ namespace ATC { // are more pertinent to other classes (FE_Interpolate, // for the most part) that it uses temporarily for space/ // time speedups while doing it's computations. - // + // // I approve of this usage of mutable, but the const/ // non-const member function declaring in this class is // really all wrong to begin with. @@ -71,7 +71,7 @@ namespace ATC { /** parser/modifier */ bool modify(int narg, char **arg); - + /** finish up */ void finish(); @@ -84,11 +84,11 @@ namespace ATC { /*@{*/ /** these assume the caller is handling the parallel collection */ void initialize_output(int rank, std::string outputPrefix, std::set otypes); - + /** write geometry */ void write_geometry(void); - - /** write data: data is arrayed over _unique_ nodes + + /** write data: data is arrayed over _unique_ nodes and then mapped by the engine */ void write_data(double time, FIELDS &soln, OUTPUT_LIST *data=nullptr); void write_data(double time, OUTPUT_LIST *data); @@ -102,7 +102,7 @@ namespace ATC { void delete_elements(const std::set &elementList); void cut_mesh(const std::set &cutFaces, const std::set &edgeNodes); - void add_global(const std::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 std::string field, const std::vector & names) @@ -175,18 +175,18 @@ namespace ATC { /** compute a dimensionless mass matrix */ void compute_mass_matrix(SPAR_MAT &mass_matrix) const; - + /** computes a dimensionless mass matrix for the given-quadrature */ void compute_mass_matrix(const DIAG_MAT &weights, const SPAR_MAT &N, SPAR_MAT &mass_matrix) const; - + /** compute a single dimensionless mass matrix */ void compute_lumped_mass_matrix(DIAG_MAT &lumped_mass_matrix) const; /** compute lumped mass matrix = diag (\int \rho N_I dV) */ void compute_lumped_mass_matrix( - const Array &mask, + const Array &mask, const FIELDS &fields, const PhysicsModel *physicsModel, const Array &elementMaterials, @@ -195,7 +195,7 @@ namespace ATC { /** compute dimensional lumped mass matrix using given quadrature */ void compute_lumped_mass_matrix( - const Array &mask, + const Array &mask, const FIELDS &fields, const PhysicsModel *physicsModel, const Array > &pointMaterialGroups, @@ -211,7 +211,7 @@ namespace ATC { const FIELDS &fields, const PhysicsModel *physicsModel, const Array &elementMaterials, - FIELD_MATS &energy, + FIELD_MATS &energy, const DenseMatrix *elementMask=nullptr, const IntegrationDomainType domain=FULL_DOMAIN) const; @@ -250,15 +250,15 @@ namespace ATC { const FIELDS &fields, const PhysicsModel *physicsModel, const Array &elementMaterials, - GRAD_FIELD_MATS &flux, + GRAD_FIELD_MATS &flux, const DenseMatrix *elementMask=nullptr) const; /** compute the flux on the MD/FE boundary */ - void compute_boundary_flux(const RHS_MASK &rhsMask, + void compute_boundary_flux(const RHS_MASK &rhsMask, const FIELDS &fields, const PhysicsModel *physicsModel, const Array &elementMaterials, - const std::set &faceSet, + const std::set &faceSet, FIELDS &rhs) const; /** compute the flux on using an L2 interpolation of the flux */ @@ -276,21 +276,21 @@ namespace ATC { const std::set *nodeSet=nullptr) const; /** compute prescribed flux given an array of functions of x & t */ - void add_fluxes(const Array &fieldMask, + void add_fluxes(const Array &fieldMask, const double time, - const SURFACE_SOURCE &sourceFunctions, + const SURFACE_SOURCE &sourceFunctions, FIELDS &nodalSources) const; - void compute_fluxes(const Array &fieldMask, + void compute_fluxes(const Array &fieldMask, const double time, - const SURFACE_SOURCE &sourceFunctions, + const SURFACE_SOURCE &sourceFunctions, FIELDS &nodalSources) const { SURFACE_SOURCE::const_iterator src_iter; for (src_iter=sourceFunctions.begin(); src_iter!=sourceFunctions.end(); src_iter++) { _fieldName_ = src_iter->first; if (!fieldMask((int)_fieldName_)) continue; - if (nodalSources[_fieldName_].nRows()==0) { - nodalSources[_fieldName_].reset(nNodesUnique_,1); + if (nodalSources[_fieldName_].nRows()==0) { + nodalSources[_fieldName_].reset(nNodesUnique_,1); } } add_fluxes(fieldMask, time, sourceFunctions, nodalSources); @@ -310,7 +310,7 @@ namespace ATC { SPAR_MAT &tangent) const; /** compute open flux given a face set */ - + void add_open_fluxes(const Array2D &rhsMask, const FIELDS &fields, const OPEN_SURFACE &openFaces, @@ -324,13 +324,13 @@ namespace ATC { const FieldName velocity = ELECTRON_VELOCITY) const; /** compute nodal vector of volume based sources */ - void add_sources(const Array &fieldMask, + void add_sources(const Array &fieldMask, const double time, - const VOLUME_SOURCE &sourceFunctions, + const VOLUME_SOURCE &sourceFunctions, FIELDS &nodalSources) const; - void add_sources(const Array &fieldMask, + void add_sources(const Array &fieldMask, const double time, - const FIELDS &sources, + const FIELDS &sources, FIELDS &nodalSources) const; /** compute surface flux of a nodal field */ @@ -356,37 +356,37 @@ namespace ATC { /*@{*/ /** evaluate shape function at a list of points in R^3 */ - void evaluate_shape_functions(const MATRIX &coords, + void evaluate_shape_functions(const MATRIX &coords, SPAR_MAT &N) const; /** evaluate shape function & derivatives at a list of points in R^3 */ - void evaluate_shape_functions(const MATRIX &coords, + void evaluate_shape_functions(const MATRIX &coords, SPAR_MAT &N, SPAR_MAT_VEC &dN) const; /** evaluate shape function at a list of points in R^3 */ - void evaluate_shape_functions(const MATRIX &coords, + void evaluate_shape_functions(const MATRIX &coords, const INT_ARRAY &pointToEltMap, SPAR_MAT &N) const; /** evaluate shape function & derivatives at a list of points in R^3 */ - void evaluate_shape_functions(const MATRIX &coords, + void evaluate_shape_functions(const MATRIX &coords, const INT_ARRAY &pointToEltMap, SPAR_MAT &N, - SPAR_MAT_VEC &dN) const; + SPAR_MAT_VEC &dN) const; /** evaluate shape derivatives at a list of points in R^3 */ - void evaluate_shape_function_derivatives(const MATRIX &coords, + void evaluate_shape_function_derivatives(const MATRIX &coords, const INT_ARRAY &pointToEltMap, SPAR_MAT_VEC &dN) const; - void shape_functions(const VECTOR &x, + void shape_functions(const VECTOR &x, DENS_VEC &shp, Array &node_list) const { feMesh_->shape_functions(x,shp,node_list); } void shape_functions(const VECTOR & x, - DENS_VEC& shp, + DENS_VEC& shp, DENS_MAT& dshp, Array &node_list) const { feMesh_->shape_functions(x,shp,dshp,node_list); } @@ -405,7 +405,7 @@ namespace ATC { void shape_functions(const VECTOR &x, const int eltId, - DENS_VEC &shp, + DENS_VEC &shp, DENS_MAT &dshp, Array &node_list) const { feMesh_->shape_functions(x,eltId,shp,dshp,node_list); } @@ -425,21 +425,21 @@ namespace ATC { /** \name nodeset */ //---------------------------------------------------------------- /** pass through */ - void create_nodeset(const std::string &name, const std::set &nodeset) + void create_nodeset(const std::string &name, const std::set &nodeset) { feMesh_->create_nodeset(name,nodeset); } //---------------------------------------------------------------- /** \name accessors */ //---------------------------------------------------------------- /*@{*/ - /** even though these are pass-throughs there is a necessary + /** even though these are pass-throughs there is a necessary * translation */ /** return number of unique nodes */ int num_nodes() const { return feMesh_->num_nodes_unique(); } - + /** return number of total nodes */ int nNodesTotal() const { return feMesh_->num_nodes(); } - + /** return number of elements */ int num_elements() const { return feMesh_->num_elements(); } int my_num_elements() const { return feMesh_->my_num_elements(); } @@ -448,53 +448,53 @@ namespace ATC { int num_nodes_per_element() const { return feMesh_->num_nodes_per_element(); } /** return element connectivity */ - void element_connectivity(const int eltID, + void element_connectivity(const int eltID, Array & nodes) const { feMesh_->element_connectivity_unique(eltID, nodes); } - + /** return face connectivity */ - void face_connectivity(const PAIR &faceID, + void face_connectivity(const PAIR &faceID, Array &nodes) const { feMesh_->face_connectivity_unique(faceID, nodes); } /** in lieu of pass-throughs const accessors ... */ /** return const ptr to mesh */ const FE_Mesh* fe_mesh() const { return feMesh_; } - + /** return number of spatial dimensions */ int nsd() const { return feMesh_->num_spatial_dimensions(); } - + /** return if the FE mesh has been created */ int has_mesh() const { return feMesh_!=nullptr; } - + /** get nodal coordinates for a given element */ void element_coordinates(const int eltIdx, DENS_MAT &coords) { feMesh_->element_coordinates(eltIdx,coords); } /** get nodal coordinates for a given element */ - void element_field(const int eltIdx, const DENS_MAT field, + void element_field(const int eltIdx, const DENS_MAT field, DENS_MAT &local_field) { feMesh_->element_field(eltIdx, field, local_field); } /** access list of elements to be deleted */ const std::set &null_elements(void) const - { return nullElements_; } + { return nullElements_; } /** access to the amended nodal coordinate values */ - const DENS_MAT &nodal_coordinates(void) const + const DENS_MAT &nodal_coordinates(void) const { return (*feMesh_->coordinates()); } - /** map global node numbering to unique node numbering for + /** map global node numbering to unique node numbering for * amended mesh */ - int map_global_to_unique(const int global_id) const + int map_global_to_unique(const int global_id) const { return (*feMesh_->node_map())(global_id); } - + int number_of_global_nodes(void) const { return nNodes_; } /*@}*/ /** set kernel */ - + void set_kernel(KernelFunction* ptr); KernelFunction *kernel(int /* i */) { return kernelFunction_; } KernelFunction *kernel() { return kernelFunction_; } @@ -512,8 +512,8 @@ namespace ATC { /** auxiliary kernel function */ KernelFunction *kernelFunction_; - - /** initialized flag */ + + /** initialized flag */ bool initialized_; void parse_partitions(int & argIdx, int narg, char ** arg, @@ -521,13 +521,13 @@ namespace ATC { void print_partitions(double xmin, double xmax, Array &dx) const; /** create a uniform, structured mesh */ - void create_mesh(Array &dx, - Array &dy, - Array &dz, + void create_mesh(Array &dx, + Array &dy, + Array &dz, const char *regionName, Array periodic); - void create_mesh(int nx, int ny, int nz, + void create_mesh(int nx, int ny, int nz, const char *regionName, Array periodic); @@ -537,11 +537,11 @@ namespace ATC { /** data that can be used for a subset of original mesh */ std::set nullElements_; - + /** faces upon which nodes are duplicated */ std::set cutFaces_; std::set cutEdge_; - + /** workspace */ int nNodesPerElement_; int nSD_; @@ -551,9 +551,9 @@ namespace ATC { mutable int nIPsPerElement_; mutable int nIPsPerFace_; mutable FeIntQuadrature quadrature_; - mutable FIELDS::const_iterator _fieldItr_; + mutable FIELDS::const_iterator _fieldItr_; mutable FieldName _fieldName_; - + /** sized arrays */ mutable DIAG_MAT _weights_; mutable DENS_MAT _N_, _Nw_; @@ -565,14 +565,14 @@ namespace ATC { /** unsized arrays */ mutable DENS_MAT _Nmat_; mutable FIELD_MATS _fieldsAtIPs_; - mutable GRAD_FIELD_MATS _gradFieldsAtIPs_; + mutable GRAD_FIELD_MATS _gradFieldsAtIPs_; mutable DENS_MAT _Nfluxes_; mutable AliasArray _conn_; mutable DENS_MAT_VEC _Bfluxes_; - + /** output object */ OutputManager outputManager_; - + }; }; // end namespace ATC diff --git a/lib/atc/FE_Interpolate.cpp b/lib/atc/FE_Interpolate.cpp index 5e5bd5ecf1..1522be3383 100644 --- a/lib/atc/FE_Interpolate.cpp +++ b/lib/atc/FE_Interpolate.cpp @@ -31,7 +31,7 @@ namespace ATC { } void FE_Interpolate::set_quadrature(FeEltGeometry geo, - FeIntQuadrature quad) + FeIntQuadrature quad) { if (feQuadList_.count(quad) == 0) { feQuad_ = new FE_Quadrature(geo,quad); @@ -47,7 +47,7 @@ namespace ATC { int numEltNodes = feElement_->num_elt_nodes(); int numFaces = feElement_->num_faces(); int numFaceNodes = feElement_->num_face_nodes(); - + int numIPs = feQuad_->numIPs; DENS_MAT &ipCoords = feQuad_->ipCoords; int numFaceIPs = feQuad_->numFaceIPs; @@ -79,7 +79,7 @@ namespace ATC { compute_N_dNdr(thisIP,thisN,thisdNdr); } } - + // Compute 2D face shape function derivatives dNdrFace2D_.assign(numFaceIPs,DENS_MAT(nSD_-1,numFaceNodes)); for (int ip = 0; ip < numFaceIPs; ip++) { @@ -111,14 +111,14 @@ namespace ATC { N.resize(numEltNodes); DENS_MAT dNdr(nSD_,numEltNodes,false); compute_N_dNdr(xi,N,dNdr); - + DENS_MAT eltCoordsT = transpose(eltCoords); DENS_MAT dxdr, drdx; - + dxdr = dNdr*eltCoordsT; drdx = inv(dxdr); dNdx = drdx*dNdr; - } + } void FE_Interpolate::shape_function_derivatives(const DENS_MAT &eltCoords, const VECTOR &xi, @@ -126,16 +126,16 @@ namespace ATC { { int numEltNodes = feElement_->num_elt_nodes(); DENS_MAT dNdr(nSD_,numEltNodes,false); - - DENS_VEC N(numEltNodes); + + DENS_VEC N(numEltNodes); compute_N_dNdr(xi,N,dNdr); DENS_MAT eltCoordsT = transpose(eltCoords); DENS_MAT dxdr, drdx; dxdr = dNdr*eltCoordsT; // tangents or Jacobian matrix - + drdx = inv(dxdr); dNdx = drdx*dNdr; // dN/dx = dN/dxi (dx/dxi)^-1 - } + } void FE_Interpolate::tangents(const DENS_MAT &eltCoords, const VECTOR &xi, @@ -143,15 +143,15 @@ namespace ATC { { int numEltNodes = feElement_->num_elt_nodes(); DENS_MAT dNdr(nSD_,numEltNodes,false); - - DENS_VEC N(numEltNodes); + + DENS_VEC N(numEltNodes); compute_N_dNdr(xi,N,dNdr); //dNdr.print("dNdr"); DENS_MAT eltCoordsT = transpose(eltCoords); //eltCoordsT.print("elt coords"); dxdr = dNdr*eltCoordsT; //dxdr.print("dxdr"); - } + } void FE_Interpolate::tangents(const DENS_MAT &eltCoords, const VECTOR &xi, @@ -162,7 +162,7 @@ namespace ATC { tangents(eltCoords,xi,dxdr); //dxdr.print("dxdr-post"); dxdxi.resize(nSD_); - //for (int i = 0; i < nSD_; ++i) dxdxi[i] = CLON_VEC(dxdr,CLONE_COL,i); + //for (int i = 0; i < nSD_; ++i) dxdxi[i] = CLON_VEC(dxdr,CLONE_COL,i); for (int i = 0; i < nSD_; ++i) { dxdxi[i].resize(nSD_); for (int j = 0; j < nSD_; ++j) { @@ -192,7 +192,7 @@ namespace ATC { DIAG_MAT &weights) { int numEltNodes = feElement_->num_elt_nodes(); - + // Transpose eltCoords DENS_MAT eltCoordsT(transpose(eltCoords)); @@ -201,7 +201,7 @@ namespace ATC { // Set sizes of matrices and vectors if ((int)dN.size() != nSD_) dN.resize(nSD_); - for (int isd = 0; isd < nSD_; isd++) + for (int isd = 0; isd < nSD_; isd++) dN[isd].resize(feQuad_->numIPs,numEltNodes); weights.resize(feQuad_->numIPs,feQuad_->numIPs); @@ -218,7 +218,7 @@ namespace ATC { // Compute dNdx and fill dN matrix dNdx = drdx * dNdr_[ip]; for (int isd = 0; isd < nSD_; isd++) - for (int inode = 0; inode < numEltNodes; inode++) + for (int inode = 0; inode < numEltNodes; inode++) dN[isd](ip,inode) = dNdx(isd,inode); // Compute jacobian determinant of dxdr at this ip @@ -227,9 +227,9 @@ namespace ATC { + dxdr(0,2) * (dxdr(1,0)*dxdr(2,1) - dxdr(1,1)*dxdr(2,0)); // Compute ip weight - weights(ip,ip) = feQuad_->ipWeights(ip)*J; + weights(ip,ip) = feQuad_->ipWeights(ip)*J; } - + } //----------------------------------------------------------------- @@ -268,9 +268,9 @@ namespace ATC { } // Compute ip weight - weights(ip,ip) = feQuad_->ipFaceWeights(ip)*J; + weights(ip,ip) = feQuad_->ipFaceWeights(ip)*J; } - + } void FE_Interpolate::face_shape_function(const DENS_MAT &eltCoords, @@ -323,9 +323,9 @@ namespace ATC { } // Compute ip weight - weights(ip,ip) = feQuad_->ipFaceWeights(ip)*J; + weights(ip,ip) = feQuad_->ipFaceWeights(ip)*J; } - + } // ------------------------------------------------------------- @@ -333,7 +333,7 @@ namespace ATC { // ------------------------------------------------------------- double FE_Interpolate::face_normal(const DENS_MAT &faceCoords, int ip, - DENS_VEC &normal) + DENS_VEC &normal) { // Compute dx/dr for deformed element DENS_MAT faceCoordsT = transpose(faceCoords); @@ -345,8 +345,8 @@ namespace ATC { normal(2) = dxdr(0,0)*dxdr(1,1) - dxdr(0,1)*dxdr(1,0); // Jacobian (3D) - double J = sqrt(normal(0)*normal(0) + - normal(1)*normal(1) + + double J = sqrt(normal(0)*normal(0) + + normal(1)*normal(1) + normal(2)*normal(2)); double invJ = 1.0/J; normal(0) *= invJ; @@ -354,24 +354,24 @@ namespace ATC { normal(2) *= invJ; return J; } - + int FE_Interpolate::num_ips() const - { - return feQuad_->numIPs; + { + return feQuad_->numIPs; } int FE_Interpolate::num_face_ips() const - { - return feQuad_->numFaceIPs; + { + return feQuad_->numFaceIPs; } - + /********************************************************* * Class FE_InterpolateCartLagrange * * For computing Lagrange shape functions using Cartesian * coordinate systems (all quads/hexes fall under this - * category, and any elements derived by degenerating + * category, and any elements derived by degenerating * them). Not to be used for serendipity elements, which * should be implemented for SPEED. * @@ -395,7 +395,7 @@ namespace ATC { const DENS_VEC &localCoords1d = feElement_->local_coords_1d(); int numEltNodes = feElement_->num_elt_nodes(); int numEltNodes1d = feElement_->num_elt_nodes_1d(); - + DENS_MAT lagrangeTerms(nSD_,numEltNodes1d); DENS_MAT lagrangeDenom(nSD_,numEltNodes1d); lagrangeTerms = 1.0; @@ -404,7 +404,7 @@ namespace ATC { for (int inode = 0; inode < numEltNodes1d; ++inode) { for (int icont = 0; icont < numEltNodes1d; ++icont) { if (inode != icont) { - lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - + lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - localCoords1d(icont)); lagrangeTerms(iSD,inode) *= (point(iSD)-localCoords1d(icont)); } @@ -439,7 +439,7 @@ namespace ATC { // *** see comments for compute_N_dNdr *** const DENS_VEC &localCoords1d = feElement_->local_coords_1d(); int numEltNodes1d = feElement_->num_elt_nodes_1d(); - + DENS_MAT lagrangeTerms(nD,numEltNodes1d); DENS_MAT lagrangeDenom(nD,numEltNodes1d); DENS_MAT lagrangeDeriv(nD,numEltNodes1d); @@ -453,7 +453,7 @@ namespace ATC { for (int icont = 0; icont < numEltNodes1d; ++icont) { if (inode != icont) { lagrangeTerms(iSD,inode) *= (point(iSD)-localCoords1d(icont)); - lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - + lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - localCoords1d(icont)); for (int dcont=0; dcont mapping(nD); for (int inode=0; inodelocal_coords_1d(); int numEltNodes = feElement_->num_elt_nodes(); int numEltNodes1d = feElement_->num_elt_nodes_1d(); - + // lagrangeTerms stores the numerator for the various Lagrange polynomials // in one dimension, that will be used to produce the three dimensional // shape functions @@ -526,13 +526,13 @@ namespace ATC { for (int inode = 0; inode < numEltNodes1d; ++inode) { for (int icont = 0; icont < numEltNodes1d; ++icont) { if (inode != icont) { - // each dimension and each 1d node per dimension has a + // each dimension and each 1d node per dimension has a // contribution from all nodes besides the current node lagrangeTerms(iSD,inode) *= (point(iSD)-localCoords1d(icont)); - lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - + lagrangeDenom(iSD,inode) *= (localCoords1d(inode) - localCoords1d(icont)); // complciated; each sum produced by the product rule has one - // "derivative", and the rest are just identical to the terms + // "derivative", and the rest are just identical to the terms // above for (int dcont=0; dcontlocal_coords(); double invVol = 1.0/(feElement_->vol()); int numEltNodes = feElement_->num_elt_nodes(); - + for (int inode = 0; inode < numEltNodes; ++inode) { N(inode) = invVol; for (int isd = 0; isd < nSD_; ++isd) { @@ -633,7 +633,7 @@ namespace ATC { // *** see comments for compute_N_dNdr *** const DENS_MAT &localCoords = feElement_->local_coords(); double invVol = 1.0/vol; - + for (int inode = 0; inode < numNodes; ++inode) { for (int idr = 0; idr < nD; ++idr) { dNdr(idr,inode) = invVol; @@ -641,7 +641,7 @@ namespace ATC { for (int id = 0; id < nD; ++id) { for (int idr = 0; idr < nD; ++idr) { if (id == idr) dNdr(idr,inode) *= localCoords(id,inode); - else dNdr(idr,inode) *= 1.0 + + else dNdr(idr,inode) *= 1.0 + point(id)*localCoords(id,inode); } } @@ -656,7 +656,7 @@ namespace ATC { const DENS_MAT &localCoords = feElement_->local_coords(); double invVol = 1.0/(feElement_->vol()); int numEltNodes = feElement_->num_elt_nodes(); - + // Fill in for each node for (int inode = 0; inode < numEltNodes; ++inode) { // Intiialize shape function and derivatives @@ -670,20 +670,20 @@ namespace ATC { // One term for each dimension, only deriv in deriv's dimension for (int idr = 0; idr < nSD_; ++idr) { if (isd == idr) dNdr(idr,inode) *= localCoords(isd,inode); - else dNdr(idr,inode) *= 1.0 + + else dNdr(idr,inode) *= 1.0 + point(isd)*localCoords(isd,inode); } } } } - + /********************************************************* * Class FE_InterpolateCartSerendipity * * For computing shape functions for quadratic serendipity * elements, implemented for SPEED. - * + * *********************************************************/ FE_InterpolateCartSerendipity::FE_InterpolateCartSerendipity( FE_Element *feElement) @@ -696,7 +696,7 @@ namespace ATC { { // Handled by base class } - + void FE_InterpolateCartSerendipity::compute_N(const VECTOR &point, VECTOR &N) { @@ -704,14 +704,14 @@ namespace ATC { const DENS_MAT &localCoords = feElement_->local_coords(); double invVol = 1.0/(feElement_->vol()); int numEltNodes = feElement_->num_elt_nodes(); - + for (int inode = 0; inode < numEltNodes; ++inode) { N(inode) = invVol; for (int isd = 0; isd < nSD_; ++isd) { - if (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && - (isd == 0)) || + if (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && + (isd == 0)) || ((inode == 9 || inode == 11 || inode == 17 || inode == 19) && - (isd == 1)) || + (isd == 1)) || ((inode == 12 || inode == 13 || inode == 14 || inode == 15) && (isd == 2))) { N(inode) *= (1.0 - pow(point(isd),2))*2; @@ -742,7 +742,7 @@ namespace ATC { bool serendipityNode = false; double productRule1 = 0.0; double productRule2 = 0.0; - + if (nD != 3 && nD != 2) { ATC_Error("Serendipity dNdr calculations are too hard-wired to do " "what you want them to. Only 2D and 3D currently work."); @@ -757,15 +757,15 @@ namespace ATC { // identify nodes/dims differently if 3d or 2d case if (nD == 3) { serendipityNode = - (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && - (id == 0)) || + (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && + (id == 0)) || ((inode == 9 || inode == 11 || inode == 17 || inode == 19) && - (id == 1)) || + (id == 1)) || ((inode == 12 || inode == 13 || inode == 14 || inode == 15) && (id == 2))); } else if (nD == 2) { serendipityNode = - (((inode == 4 || inode == 6) && (id == 0)) || + (((inode == 4 || inode == 6) && (id == 0)) || ((inode == 5 || inode == 7) && (id == 1))); } if (serendipityNode) { @@ -794,7 +794,7 @@ namespace ATC { productRule2 = (point(0)*localCoords(0,inode) + point(1)*localCoords(1,inode) - 1); } - productRule1 = dNdr(idr,inode) * + productRule1 = dNdr(idr,inode) * (1 + point(idr)*localCoords(idr,inode)); productRule2 *= dNdr(idr,inode); dNdr(idr,inode) = productRule1 + productRule2; @@ -830,17 +830,17 @@ namespace ATC { // "0-coordinate" is in the same dimension as the one we're currently // iterating over. If that's the case, we want to contribute to its // shape functions and derivatives in a modified way: - if (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && - (isd == 0)) || + if (((inode == 8 || inode == 10 || inode == 16 || inode == 18) && + (isd == 0)) || ((inode == 9 || inode == 11 || inode == 17 || inode == 19) && - (isd == 1)) || + (isd == 1)) || ((inode == 12 || inode == 13 || inode == 14 || inode == 15) && (isd == 2))) { // If the 1d shape function dimension matches the derivative // dimension... if (isd == idr) { // contribute to N; sloppy, but this is the easiest way to get - // N to work right without adding extra, arguably unnecessary + // N to work right without adding extra, arguably unnecessary // loops, while also computing the shape functions N(inode) *= (1.0 - pow(point(isd),2))*2; // contribute to dNdr with the derivative of this shape function @@ -869,7 +869,7 @@ namespace ATC { } for (int idr = 0; idr < nSD_; ++idr) { if (inode < 8) { - productRule1 = dNdr(idr,inode) * + productRule1 = dNdr(idr,inode) * (1 + point(idr)*localCoords(idr,inode)); productRule2 = dNdr(idr,inode) * (point(0)*localCoords(0,inode) + point(1)*localCoords(1,inode) + @@ -883,7 +883,7 @@ namespace ATC { /********************************************************* * Class FE_InterpolateSimpLin - * + * * For computing linear shape functions of simplices, * which are rather different from those computed * in Cartesian coordinates. @@ -895,7 +895,7 @@ namespace ATC { * *********************************************************/ FE_InterpolateSimpLin::FE_InterpolateSimpLin( - FE_Element *feElement) + FE_Element *feElement) : FE_Interpolate(feElement) { set_quadrature(TETRA,GAUSS2); @@ -910,7 +910,7 @@ namespace ATC { VECTOR &N) { int numEltNodes = feElement_->num_elt_nodes(); - + // Fill in for each node for (int inode = 0; inode < numEltNodes; ++inode) { if (inode == 0) { @@ -948,7 +948,7 @@ namespace ATC { // (which map to x, y, and z). Therefore, the derivative in // each dimension are -1. // - // The idea is similar for 2 dimensions, which this can + // The idea is similar for 2 dimensions, which this can // handle as well. for (int idr = 0; idr < nD; ++idr) { if (inode == 0) { @@ -965,7 +965,7 @@ namespace ATC { DENS_MAT &dNdr) const { int numEltNodes = feElement_->num_elt_nodes(); - + // Fill in for each node for (int inode = 0; inode < numEltNodes; ++inode) { // Fill N... diff --git a/lib/atc/FE_Interpolate.h b/lib/atc/FE_Interpolate.h index 9e0b1388c1..6c5d7d1339 100644 --- a/lib/atc/FE_Interpolate.h +++ b/lib/atc/FE_Interpolate.h @@ -22,7 +22,7 @@ namespace ATC { FE_Interpolate(FE_Element *feElement); virtual ~FE_Interpolate(); - + /** compute the quadrature for a given element type */ void set_quadrature(FeEltGeometry geo, FeIntQuadrature quad); @@ -30,14 +30,14 @@ namespace ATC { * quadrature */ virtual void precalculate_shape_functions(); - /** compute the shape functions at the given point; + /** compute the shape functions at the given point; * we use CLON_VECs */ virtual void compute_N(const VECTOR &point, VECTOR &N) = 0; - + // middle args get no names because they won't be used by some // child classes. - /** compute the shape function derivatives at the given point; + /** compute the shape function derivatives at the given point; * generic, so can work for 2D or 3D case */ virtual void compute_dNdr(const VECTOR &point, const int, @@ -51,7 +51,7 @@ namespace ATC { VECTOR &N, DENS_MAT &dNdr) const = 0; - /** compute shape functions at a single point, given the local + /** compute shape functions at a single point, given the local * coordinates; eltCoords needed for derivatives: * indexed: N(node) * dN[nsd](node) */ @@ -72,7 +72,7 @@ namespace ATC { * weights(ip) */ virtual void shape_function(const DENS_MAT &eltCoords, DENS_MAT &N, - std::vector &dN, + std::vector &dN, DIAG_MAT &weights); /** compute shape functions at all face ip's: @@ -132,7 +132,7 @@ namespace ATC { // matrix of shape functions at ip's: N_(ip, node) DENS_MAT N_; - + std::vector dNdr_; // matrix of shape functions at ip's: N_(ip, node) @@ -160,7 +160,7 @@ namespace ATC { virtual void compute_N(const VECTOR &point, VECTOR &N); - + virtual void compute_dNdr(const VECTOR &point, const int numNodes, const int nD, @@ -187,7 +187,7 @@ namespace ATC { virtual void compute_N(const VECTOR &point, VECTOR &N); - + virtual void compute_dNdr(const VECTOR &point, const int numNodes, const int nD, @@ -214,7 +214,7 @@ namespace ATC { virtual void compute_N(const VECTOR &point, VECTOR &N); - + virtual void compute_dNdr(const VECTOR &point, const int numNodes, const int nD, @@ -242,7 +242,7 @@ namespace ATC { virtual void compute_N(const VECTOR &point, VECTOR &N); - + // middle args get no names because they won't be used by some // child classes. virtual void compute_dNdr(const VECTOR &, diff --git a/lib/atc/FE_Mesh.cpp b/lib/atc/FE_Mesh.cpp index 6af29ee37e..a516dbfee8 100644 --- a/lib/atc/FE_Mesh.cpp +++ b/lib/atc/FE_Mesh.cpp @@ -41,10 +41,10 @@ namespace ATC { // class FE_Mesh // ============================================================= FE_Mesh::FE_Mesh() - : decomposition_(false), + : decomposition_(false), lammpsPartition_(false), partitioned_(false), - nNodes_(0), + nNodes_(0), nNodesUnique_(0), feElement_(nullptr), twoDimensional_(false), @@ -66,7 +66,7 @@ namespace ATC { { bool match = false; - if (strcmp(arg[0],"mesh")==0) + if (strcmp(arg[0],"mesh")==0) { /*! \page man_mesh_create_faceset_box fix_modify AtC mesh create_faceset box \section syntax @@ -75,7 +75,7 @@ namespace ATC { - = id to assign to the collection of FE faces - = coordinates of the bounding box that is coincident with the desired FE faces - - = "in" gives inner faces to the box, + - = "in" gives inner faces to the box, "out" gives the outer faces to the box - units = option to specify real as opposed to lattice units \section examples @@ -88,46 +88,46 @@ namespace ATC { \section default The default options are units = lattice and the use of outer faces */ - /*! \page man_mesh_create_faceset_plane fix_modify AtC mesh create_faceset plane + /*! \page man_mesh_create_faceset_plane fix_modify AtC mesh create_faceset plane \section syntax - fix_modify AtC mesh create_faceset plane + fix_modify AtC mesh create_faceset plane [units] - = id to assign to the collection of FE faces - - = coordinate directions that define plane on which faceset lies + - = coordinate directions that define plane on which faceset lies - ,, = plane is specified as the x|y|z=val1 plane bounded by - the segments x|y|z = [lval2,uval2] + the segments x|y|z = [lval2,uval2] - units = option to specify real as opposed to lattice units \section examples fix_modify AtC mesh create_faceset xyplane plane y 0 x -4 0 \section description - Command to assign an id to a set of FE faces. + Command to assign an id to a set of FE faces. \section restrictions - Only viable for rectangular grids. + Only viable for rectangular grids. \section related \section default The default option is units = lattice. */ - if (strcmp(arg[1],"create_faceset")==0) + if (strcmp(arg[1],"create_faceset")==0) { int argIdx = 2; string tag = arg[argIdx++]; - if (strcmp(arg[argIdx],"plane")==0) + if (strcmp(arg[argIdx],"plane")==0) { argIdx++; int ndir, idir[3], isgn; double xlimits[3][2]; parse_plane(argIdx, narg, arg, ndir, idir, isgn, xlimits); - if (xlimits[idir[1]][0] == xlimits[idir[1]][1]) + if (xlimits[idir[1]][0] == xlimits[idir[1]][1]) split_values(xlimits[idir[1]][0],xlimits[idir[1]][1]); - if (xlimits[idir[2]][0] == xlimits[idir[2]][1]) + if (xlimits[idir[2]][0] == xlimits[idir[2]][1]) split_values(xlimits[idir[2]][0],xlimits[idir[2]][1]); parse_units(argIdx,narg,arg, xlimits[0][0],xlimits[0][1], xlimits[1][0],xlimits[1][1], xlimits[2][0],xlimits[2][1]); if (ndir > 1) { - create_faceset(tag, xlimits[idir[0]][0], idir[0], isgn, - idir[1], xlimits[idir[1]][0], xlimits[idir[1]][1], + create_faceset(tag, xlimits[idir[0]][0], idir[0], isgn, + idir[1], xlimits[idir[1]][0], xlimits[idir[1]][1], idir[2], xlimits[idir[2]][0], xlimits[idir[2]][1]); } else { @@ -136,7 +136,7 @@ namespace ATC { match = true; } // bounding_box - else + else { if (strcmp(arg[argIdx],"box")==0) argIdx++; double xmin = parse_min(arg[argIdx++]); @@ -146,7 +146,7 @@ namespace ATC { double zmin = parse_min(arg[argIdx++]); double zmax = parse_max(arg[argIdx++]); bool outward = true; - if (narg > argIdx && (strcmp(arg[argIdx++],"in") == 0)) + if (narg > argIdx && (strcmp(arg[argIdx++],"in") == 0)) outward = false; parse_units(argIdx,narg,arg, xmin,xmax,ymin,ymax,zmin,zmax); create_faceset(tag, xmin, xmax, ymin, ymax, zmin, zmax, outward); @@ -205,7 +205,7 @@ namespace ATC { \section syntax fix_modify AtC mesh add_to_nodeset - - = id of FE nodeset to be added to + - = id of FE nodeset to be added to - = coordinates of the bounding box that contains the desired nodes to be added \section examples @@ -316,13 +316,13 @@ namespace ATC { } /*! \page man_mesh_output fix_modify AtC mesh output \section syntax - fix_modify AtC mesh output + fix_modify AtC mesh output \section examples fix_modify AtC mesh output meshData \n \section description Command to output mesh and associated data: nodesets, facesets, and elementsets. This data is only output once upon initialization since - currently the mesh is static. Creates (binary, "gold" format) Ensight + currently the mesh is static. Creates (binary, "gold" format) Ensight output of mesh data. \section restrictions none @@ -340,11 +340,11 @@ namespace ATC { } // ------------------------------------------------------------- void FE_Mesh::parse_units(int & argIdx, int narg, char ** arg, - double & xmin, double & xmax, double & ymin, double & ymax, + double & xmin, double & xmax, double & ymin, double & ymax, double & zmin, double & zmax) { if (narg > argIdx && (strcmp(arg[argIdx++],"units") == 0)) {} - else + else { // scale from lattice units to physical units xmin *= xscale_; xmax *= xscale_; ymin *= yscale_; ymax *= yscale_; @@ -354,7 +354,7 @@ namespace ATC { // ------------------------------------------------------------- // parse plane // ------------------------------------------------------------- - void FE_Mesh::parse_plane(int & argIdx, int narg, char ** arg, + void FE_Mesh::parse_plane(int & argIdx, int narg, char ** arg, int & ndir, int * idir, int & isgn, double xlimits[][2]) { ndir = 0; @@ -375,14 +375,14 @@ namespace ATC { if (narg > argIdx ) { if (string_to_index(arg[argIdx],i2dir)) { argIdx++; - xlimits[i2dir][0] = parse_min(arg[argIdx++]); + xlimits[i2dir][0] = parse_min(arg[argIdx++]); xlimits[i2dir][1] = parse_max(arg[argIdx++]); idir[ndir++] = i2dir; } if (narg > argIdx ) { if (string_to_index(arg[argIdx],i3dir)) { argIdx++; - xlimits[i3dir][0] = parse_min(arg[argIdx++]); + xlimits[i3dir][0] = parse_min(arg[argIdx++]); xlimits[i3dir][1] = parse_max(arg[argIdx++]); } } @@ -398,13 +398,13 @@ namespace ATC { idir[ndir++] = i3dir; } if ((idir[0]==idir[1]) || (idir[0]==idir[2]) || (idir[1]==idir[2]) ) { - throw ATC_Error( "inconsistent directions in plane:"+to_string(idir[0]+1)+" "+to_string(idir[1]+1)+" "+to_string(idir[2]+1)); + throw ATC_Error( "inconsistent directions in plane:"+to_string(idir[0]+1)+" "+to_string(idir[1]+1)+" "+to_string(idir[2]+1)); } } // ------------------------------------------------------------- // initialize // ------------------------------------------------------------- - void FE_Mesh::initialize(void) + void FE_Mesh::initialize(void) { bool aligned = is_aligned(); @@ -413,15 +413,15 @@ namespace ATC { ATC::LammpsInterface::instance()->print_msg_once("WARNING: mesh is not aligned with the coordinate directions atom-to-element mapping will be expensive"); // if HEX8 -> orient(); } - bool twoD = is_two_dimensional(); + bool twoD = is_two_dimensional(); if (twoD) { feElement_->set_projection_guess(TWOD_ANALYTIC); - if (feElement_->order()< 3) hasPlanarFaces_ = true; + if (feElement_->order()< 3) hasPlanarFaces_ = true; ATC::LammpsInterface::instance()->print_msg_once(" mesh is two dimensional"); } } //----------------------------------------------------------------- - + //----------------------------------------------------------------- void FE_Mesh::write_mesh(string meshFile) { @@ -460,7 +460,7 @@ namespace ATC { out << name << " " << nset.size() << "\n"; set::const_iterator iter; for (iter = nset.begin(); iter != nset.end(); iter++) { - out << *iter << " " ; + out << *iter << " " ; } out << "\n"; } @@ -478,7 +478,7 @@ namespace ATC { DENS_MAT eltCoords; for (int ielem = 0; ielem < nElts_; ielem++) { element_coordinates(ielem,eltCoords); - feElement_->tangents(eltCoords,xi0,tangents,true); + feElement_->tangents(eltCoords,xi0,tangents,true); for (unsigned i = 0; i < tangents.size(); i++) { // find maximum value for which global axis its closest to @@ -519,7 +519,7 @@ namespace ATC { // element_type // ------------------------------------------------------------- string FE_Mesh::element_type(void) const { - int npe = feElement_->num_elt_nodes(); + int npe = feElement_->num_elt_nodes(); if (npe == 4) { return "TET4"; } else if (npe == 8) { return "HEX8"; } else if (npe == 20) { return "HEX20"; } @@ -541,7 +541,7 @@ namespace ATC { xCoords(isd,inode) = nodalCoords_(isd,id); } } - + } // ------------------------------------------------------------- // position @@ -553,7 +553,7 @@ namespace ATC { const int nne = num_nodes_per_element(); DENS_VEC N; feElement_->shape_function(xi,N); - x.reset(nSD_); + x.reset(nSD_); for (int inode=0; inodesecond; } @@ -665,8 +665,8 @@ namespace ATC { { NODE_SET_MAP::const_iterator iter = elementSetMap_.find(name); if (name == "all") return elementSetAll_; - else if (iter == elementSetMap_.end()) - throw ATC_Error( "No elementset with name " + name + " found."); + else if (iter == elementSetMap_.end()) + throw ATC_Error( "No elementset with name " + name + " found."); else return iter->second; } @@ -683,7 +683,7 @@ namespace ATC { } else { NODE_SET_MAP::const_iterator iter = nodeSetMap_.find(name); - if (iter == nodeSetMap_.end()) + if (iter == nodeSetMap_.end()) throw ATC_Error( "No nodeset with name " + name + " found."); nodeset_to_minimal_elementset(iter->second,elemSet); if (elemSet.size()==0) { @@ -724,7 +724,7 @@ namespace ATC { } else { NODE_SET_MAP::const_iterator iter = nodeSetMap_.find(name); - if (iter == nodeSetMap_.end()) + if (iter == nodeSetMap_.end()) throw ATC_Error( "No nodeset with name " + name + " found."); nodeset_to_maximal_elementset(iter->second,elemSet); if (elemSet.size()==0) { @@ -760,10 +760,10 @@ namespace ATC { { int npe = num_nodes_per_element(); set::const_iterator itr; - for (itr = elemSet.begin(); itr != elemSet.end(); itr++) + for (itr = elemSet.begin(); itr != elemSet.end(); itr++) { int ielem = *itr; - for (int inode=0; inode < npe; inode++) + for (int inode=0; inode < npe; inode++) { int node = element_connectivity_global(ielem, inode); nodeSet.insert(node); @@ -778,22 +778,22 @@ namespace ATC { (const string & name, set nodeSet) const { if (name == "all") - for (int ielem = 0; ielem < nElts_; ielem++) + for (int ielem = 0; ielem < nElts_; ielem++) nodeSet.insert(ielem); - else + else { ELEMENT_SET_MAP::const_iterator iter = elementSetMap_.find(name); - if (iter == elementSetMap_.end()) + if (iter == elementSetMap_.end()) throw ATC_Error( "No elementset with name " + name + " found."); int npe = num_nodes_per_element(); const set &elemSet = iter->second; set::const_iterator itr; - for (itr = elemSet.begin(); itr != elemSet.end(); itr++) + for (itr = elemSet.begin(); itr != elemSet.end(); itr++) { int ielem = *itr; - for (int inode=0; inode < npe; inode++) + for (int inode=0; inode < npe; inode++) { int node = element_connectivity_unique(ielem, inode); nodeSet.insert(node); @@ -818,17 +818,17 @@ namespace ATC { { // return: set - complement_of_set if (name == "all") { return;} - else + else { elementset_to_nodeset(name,nodeSet); set compElemSet; elementset_complement(name,compElemSet); int npe = num_nodes_per_element(); set::const_iterator itr; - for (itr = compElemSet.begin(); itr != compElemSet.end(); itr++) + for (itr = compElemSet.begin(); itr != compElemSet.end(); itr++) { int ielem = *itr; - for (int inode=0; inode < npe; inode++) + for (int inode=0; inode < npe; inode++) { int node = element_connectivity_unique(ielem, inode); nodeSet.erase(node); @@ -846,14 +846,14 @@ namespace ATC { { // return: set - complement_of_set if (name == "all") { return;} - else + else { ELEMENT_SET_MAP::const_iterator iter = elementSetMap_.find(name); - if (iter == elementSetMap_.end()) + if (iter == elementSetMap_.end()) throw ATC_Error( "No elementset with name " + name + " found."); const set &elemSet = iter->second; - for (int ielem = 0; ielem < nElts_; ielem++) + for (int ielem = 0; ielem < nElts_; ielem++) { if(elemSet.find(ielem) == elemSet.end() ) cElemSet.insert(ielem); } @@ -866,7 +866,7 @@ namespace ATC { void FE_Mesh::elementset_complement (const set & elemSet, set & cElemSet) const { - for (int ielem = 0; ielem < nElts_; ielem++) + for (int ielem = 0; ielem < nElts_; ielem++) { if(elemSet.find(ielem) == elemSet.end() ) cElemSet.insert(ielem); } @@ -880,15 +880,15 @@ namespace ATC { for (int inode = 0; inode < nNodesUnique_; inode++) nodeSet.insert(inode); } - else + else { FACE_SET_MAP::const_iterator faceset = faceSetMap_.find(name); - if (faceset == faceSetMap_.end()) + if (faceset == faceSetMap_.end()) throw ATC_Error( "No faceset with name " + name + " found."); const set & faceSet = faceset->second; set::const_iterator iter; Array conn; - for (iter = faceSet.begin(); iter != faceSet.end(); iter++) + for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { PAIR face = *iter; face_connectivity_unique(face,conn); @@ -903,7 +903,7 @@ namespace ATC { { set::const_iterator iter; Array conn; - for (iter = faceSet.begin(); iter != faceSet.end(); iter++) + for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { PAIR face = *iter; face_connectivity_unique(face,conn); @@ -922,15 +922,15 @@ namespace ATC { for (int inode = 0; inode < nNodes_; inode++) nodeSet.insert(inode); } - else + else { FACE_SET_MAP::const_iterator faceset = faceSetMap_.find(name); - if (faceset == faceSetMap_.end()) + if (faceset == faceSetMap_.end()) throw ATC_Error( "No faceset with name " + name + " found."); const set & faceSet = faceset->second; set::const_iterator iter; Array conn; - for (iter = faceSet.begin(); iter != faceSet.end(); iter++) + for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { PAIR face = *iter; face_connectivity(face,conn); @@ -945,7 +945,7 @@ namespace ATC { { set::const_iterator iter; Array conn; - for (iter = faceSet.begin(); iter != faceSet.end(); iter++) + for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { PAIR face = *iter; face_connectivity(face,conn); @@ -983,19 +983,19 @@ namespace ATC { } nodeSetMap_[name] = nodeSet; - if (ATC::LammpsInterface::instance()->rank_zero()) { + if (ATC::LammpsInterface::instance()->rank_zero()) { stringstream ss; - ss << "created nodeset " << name + ss << "created nodeset " << name << " with " << nodeSet.size() << " nodes"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } } void FE_Mesh::create_nodeset(const string & name, - double xmin, + double xmin, double xmax, - double ymin, + double ymin, double ymax, - double zmin, + double zmin, double zmax) { // Make sure we don't already have a nodeset with this name @@ -1027,9 +1027,9 @@ namespace ATC { nodeSetMap_[name] = nodeSet; - if (ATC::LammpsInterface::instance()->rank_zero()) { + if (ATC::LammpsInterface::instance()->rank_zero()) { stringstream ss; - ss << "created nodeset " << name + ss << "created nodeset " << name << " with " << nodeSet.size() << " nodes"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } @@ -1039,11 +1039,11 @@ namespace ATC { // add_to_nodeset // ------------------------------------------------------------- void FE_Mesh::add_to_nodeset(const string & name, - double xmin, + double xmin, double xmax, - double ymin, + double ymin, double ymax, - double zmin, + double zmin, double zmax) { // Make sure we already have a nodeset with this name @@ -1075,7 +1075,7 @@ namespace ATC { nodeSetMap_[name].insert(nodeSet.begin(),nodeSet.end()); - if (ATC::LammpsInterface::instance()->rank_zero()) { + if (ATC::LammpsInterface::instance()->rank_zero()) { stringstream ss; ss << "added " << nodeSet.size() << " nodes to nodeset " << name ; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); @@ -1086,17 +1086,17 @@ namespace ATC { // create_faceset // ------------------------------------------------------------- void FE_Mesh::create_faceset(const string & name, - double xmin, + double xmin, double xmax, - double ymin, + double ymin, double ymax, - double zmin, - double zmax, + double zmin, + double zmax, bool outward) { // Make sure we don't already have a nodeset with this name FACE_SET_MAP::iterator iter = faceSetMap_.find(name); - if (iter != faceSetMap_.end()) + if (iter != faceSetMap_.end()) throw ATC_Error( "A faceset with name " + name + " is already defined."); set faceSet; @@ -1105,24 +1105,24 @@ namespace ATC { const int nf = num_faces_per_element(); const int npf = num_nodes_per_face(); const Array2D & face_conn = local_face_connectivity(); - for (int ielem = 0; ielem < nElts_; ielem++) + for (int ielem = 0; ielem < nElts_; ielem++) { - for (int iface = 0; iface < nf; iface++) + for (int iface = 0; iface < nf; iface++) { bool in = true; - bool on_xmin = true, on_xmax = true; + bool on_xmin = true, on_xmax = true; bool on_ymin = true, on_ymax = true; bool on_zmin = true, on_zmax = true; bool x_neg = false, x_pos = false; bool y_neg = false, y_pos = false; bool z_neg = false, z_pos = false; double x,y,z; - for (int inode = 0; inode < npf; inode++) + for (int inode = 0; inode < npf; inode++) { x = nodalCoords_(0,connectivity_(face_conn(iface,inode),ielem)); y = nodalCoords_(1,connectivity_(face_conn(iface,inode),ielem)); z = nodalCoords_(2,connectivity_(face_conn(iface,inode),ielem)); - + if ( x + tol < xmin) { in = false; break; } if ( x - tol > xmax) { in = false; break; } if ( y + tol < ymin) { in = false; break; } @@ -1139,7 +1139,7 @@ namespace ATC { } if (in) { // note based on structured grid - if (outward) + if (outward) { if (on_xmin && iface==0) { x_neg = true;} if (on_xmax && iface==1) { x_pos = true;} @@ -1148,7 +1148,7 @@ namespace ATC { if (on_zmin && iface==4) { z_neg = true;} if (on_zmax && iface==5) { z_pos = true;} } - else + else { if (on_xmin && iface==1) { x_pos = true;} if (on_xmax && iface==0) { x_neg = true;} @@ -1157,7 +1157,7 @@ namespace ATC { if (on_zmin && iface==5) { z_pos = true;} if (on_zmax && iface==4) { z_neg = true;} } - + if ( (x_neg || x_pos) || (y_neg || y_pos) || (z_neg || z_pos) ) { PAIR face(ielem,iface); faceSet.insert(face); @@ -1168,16 +1168,16 @@ namespace ATC { if (faceSet.empty()) throw ATC_Error( "faceset "+name+" is empty."); faceSetMap_[name] = faceSet; - if (ATC::LammpsInterface::instance()->comm_rank() == 0) { + if (ATC::LammpsInterface::instance()->comm_rank() == 0) { stringstream ss; - ss << "created faceset " << name + ss << "created faceset " << name << " with " << faceSet.size() << " faces"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } } void FE_Mesh::create_faceset(const string & name, - double xRef, + double xRef, int nIdx, int nSgn, int nIdx2, double x2lo, double x2hi, int nIdx3, double x3lo, double x3hi) @@ -1185,7 +1185,7 @@ namespace ATC { double xtol = tolerance(xRef); // Make sure we don't already have a faceset with this name FACE_SET_MAP::iterator iter = faceSetMap_.find(name); - if (iter != faceSetMap_.end()) + if (iter != faceSetMap_.end()) throw ATC_Error( "A faceset with name "+name+" is already defined."); bool finite2 = (nIdx2 >= 0); @@ -1196,9 +1196,9 @@ namespace ATC { int nf = num_faces_per_element(); int npf = num_nodes_per_face(); const Array2D & face_conn = local_face_connectivity(); - for (int ielem = 0; ielem < nElts_; ielem++) + for (int ielem = 0; ielem < nElts_; ielem++) { - for (int iface = 0; iface < nf; iface++) + for (int iface = 0; iface < nf; iface++) { bool in = true; // all nodes must be on the plane @@ -1216,9 +1216,9 @@ namespace ATC { } } // check correct orientation - if (in) + if (in) { - if ( (nIdx == 0 && iface==0 && nSgn == -1) + if ( (nIdx == 0 && iface==0 && nSgn == -1) || (nIdx == 0 && iface==1 && nSgn == 1) || (nIdx == 1 && iface==2 && nSgn == -1) || (nIdx == 1 && iface==3 && nSgn == 1) @@ -1232,13 +1232,13 @@ namespace ATC { } } - if (faceSet.empty()) + if (faceSet.empty()) throw ATC_Error( "faceset "+name+" is empty."); faceSetMap_[name] = faceSet; - if (ATC::LammpsInterface::instance()->comm_rank() == 0) { + if (ATC::LammpsInterface::instance()->comm_rank() == 0) { stringstream ss; - ss << "created faceset " << name + ss << "created faceset " << name << " with " << faceSet.size() << " faces"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } @@ -1248,11 +1248,11 @@ namespace ATC { // create_elementset // ------------------------------------------------------------- void FE_Mesh::create_elementset(const string & name, - double xmin, + double xmin, double xmax, - double ymin, + double ymin, double ymax, - double zmin, + double zmin, double zmax) { // Make sure we don't already have a elementset with this name @@ -1285,11 +1285,11 @@ namespace ATC { // create a minimal element set from all the nodes included in the region set elemSet; int npe = num_nodes_per_element(); - for (int ielem=0; ielem < nElts_; ielem++) + for (int ielem=0; ielem < nElts_; ielem++) { int inode = 0; bool in = true; - while (in && inode < npe) + while (in && inode < npe) { int node = connectivityUnique_(inode, ielem); set::const_iterator iter = nodeSet.find(node); @@ -1304,9 +1304,9 @@ namespace ATC { } elementSetMap_[name] = elemSet; - if (ATC::LammpsInterface::instance()->comm_rank() == 0) { + if (ATC::LammpsInterface::instance()->comm_rank() == 0) { stringstream ss; - ss << "created elementset " << name + ss << "created elementset " << name << " with " << elemSet.size() << " elements"; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } @@ -1349,8 +1349,8 @@ namespace ATC { // ------------------------------------------------------------- // mappings from element id to associated nodes // ------------------------------------------------------------- - - + + void FE_Mesh::element_connectivity_global(const int eltID, Array & nodes) const { @@ -1360,16 +1360,16 @@ namespace ATC { // use connectivity arrays if (decomposition_ && partitioned_) { for (int inode = 0; inode < npe; inode++) { - nodes(inode) = myConnectivity_(inode, map_elem_to_myElem(eltID)); + nodes(inode) = myConnectivity_(inode, map_elem_to_myElem(eltID)); } } else { for (int inode = 0; inode < npe; inode++) { - nodes(inode) = connectivity_(inode, eltID); + nodes(inode) = connectivity_(inode, eltID); } } } // ------------------------------------------------------------- - // + // // ------------------------------------------------------------- void FE_Mesh::element_connectivity_unique(const int eltID, Array & nodes) const @@ -1380,17 +1380,17 @@ namespace ATC { // use connectivity arrays if (decomposition_ && partitioned_) { for (int inode = 0; inode < npe; inode++) { - nodes(inode) = myConnectivityUnique_(inode, map_elem_to_myElem(eltID)); + nodes(inode) = myConnectivityUnique_(inode, map_elem_to_myElem(eltID)); } } else { for (int inode = 0; inode < npe; inode++) { - nodes(inode) = connectivityUnique_(inode, eltID); + nodes(inode) = connectivityUnique_(inode, eltID); } } } // ------------------------------------------------------------- - // + // // ------------------------------------------------------------- int FE_Mesh::element_connectivity_global(const int eltID, const int inode) const @@ -1402,7 +1402,7 @@ namespace ATC { } } // ------------------------------------------------------------- - // + // // ------------------------------------------------------------- int FE_Mesh::element_connectivity_unique(const int eltID, const int inode) const @@ -1414,7 +1414,7 @@ namespace ATC { } } // ------------------------------------------------------------- - // + // // ------------------------------------------------------------- AliasArray FE_Mesh::element_connectivity_global(const int eltID) const { @@ -1425,7 +1425,7 @@ namespace ATC { } } // ------------------------------------------------------------- - // + // // ------------------------------------------------------------- AliasArray FE_Mesh::element_connectivity_unique(const int eltID) const { @@ -1449,23 +1449,23 @@ namespace ATC { int FE_Mesh::map_elem_to_myElem(int elemID) const { - + return elemToMyElemMap_.find(elemID)->second; } int FE_Mesh::map_myElem_to_elem(int myElemID) const { - return myElts_[myElemID]; + return myElts_[myElemID]; } - + // ------------------------------------------------------------- // shape function evaluation // ------------------------------------------------------------- - + // set quadrature scheme pass-through - void FE_Mesh::set_quadrature(FeIntQuadrature type) - { - feElement_->set_quadrature(type); + void FE_Mesh::set_quadrature(FeIntQuadrature type) + { + feElement_->set_quadrature(type); } // shape function evaluation @@ -1475,12 +1475,12 @@ namespace ATC { { // get element id from global coordinates int eltID = map_to_element(x); - + // call appropriate function below, with eltID shape_functions(x,eltID,N,nodeList); } - void FE_Mesh::shape_functions(const DENS_VEC &x, + void FE_Mesh::shape_functions(const DENS_VEC &x, DENS_VEC &N, DENS_MAT &dNdx, Array &nodeList) const @@ -1500,10 +1500,10 @@ namespace ATC { // Get element node coordinates from mesh DENS_MAT eltCoords; element_coordinates(eltID, eltCoords); - + // pass through call feElement_->shape_function(eltCoords,x,N); - + // determine nodes which correspond to shape function indices element_connectivity_unique(eltID,nodeList); } @@ -1520,7 +1520,7 @@ namespace ATC { // pass through call feElement_->shape_function(eltCoords,x,N,dNdx); - + // determine nodes which correspond to shp function indices element_connectivity_unique(eltID,nodeList); } @@ -1536,13 +1536,13 @@ namespace ATC { // pass through call feElement_->shape_function_derivatives(eltCoords,x,dNdx); - + // determine nodes which correspond to shp function indices element_connectivity_unique(eltID,nodeList); } void FE_Mesh::shape_function(const int eltID, - DENS_MAT &N, + DENS_MAT &N, DIAG_MAT &weights) const { // unused data (but required to calc weights) @@ -1553,7 +1553,7 @@ namespace ATC { } void FE_Mesh::shape_function(int eltID, - DENS_MAT &N, + DENS_MAT &N, vector &dN, DIAG_MAT &weights) const { @@ -1572,7 +1572,7 @@ namespace ATC { { int eltID = face.first; int faceID = face.second; - + // Get element node coordinates from mesh DENS_MAT eltCoords; element_coordinates(eltID,eltCoords); @@ -1589,7 +1589,7 @@ namespace ATC { { int eltID = face.first; int faceID = face.second; - + // Get element node coordinates from mesh DENS_MAT eltCoords; element_coordinates(eltID,eltCoords); @@ -1604,7 +1604,7 @@ namespace ATC { { int eltID = face.first; int faceID = face.second; - + // Get element node coordinates from mesh DENS_MAT eltCoords; element_coordinates(eltID,eltCoords); @@ -1639,7 +1639,7 @@ namespace ATC { nodesets[nodeset].reset(size,1); set::const_iterator iter; for (iter = nset.begin(); iter != nset.end(); iter++) { - (nodesets[nodeset])(*iter,0) = 1; + (nodesets[nodeset])(*iter,0) = 1; } subsetData[nodeset] = & nodesets[nodeset]; } @@ -1671,7 +1671,7 @@ namespace ATC { Array nodes; element_connectivity_unique(*iter, nodes); for(int i = 0; i < nodes.size(); ++i) { - (elemsets[elemset])(nodes(i),0) = 1; + (elemsets[elemset])(nodes(i),0) = 1; } } subsetData[elemset] = & elemsets[elemset]; @@ -1690,7 +1690,7 @@ namespace ATC { bool FE_Mesh::is_owned_elt(int elt) const { - return (find(myElts_.begin(), myElts_.end(), elt) != myElts_.end()); + return (find(myElts_.begin(), myElts_.end(), elt) != myElts_.end()); } @@ -1700,9 +1700,9 @@ namespace ATC { // ------------------------------------------------------------- // ------------------------------------------------------------- FE_3DMesh::FE_3DMesh(const string elementType, - const int nNodes, + const int nNodes, const int nElements, - const Array2D *connectivity, + const Array2D *connectivity, const DENS_MAT *nodalCoordinates, const Array periodicity, const Array< pair< string, set > > *nodeSets): @@ -1724,7 +1724,7 @@ namespace ATC { throw ATC_Error("Unrecognized element type specified."); } - + nSD_ = 3; nNodes_ = nNodes; nNodesUnique_ = nNodes; @@ -1739,7 +1739,7 @@ namespace ATC { nodalCoords_ = (*nodalCoordinates); // set minimum element size - minEltSize_ = 1.e20; + minEltSize_ = 1.e20; for (int i=0; i< connectivity_.nCols(); ++i) { int n1 = connectivity_(0,i); int n2 = connectivity_(1,i); @@ -1754,12 +1754,12 @@ namespace ATC { setup_periodicity(); // Create the "all" elementset, the "all" nodeset, and the read-in nodesets. - for (int elem = 0; elem < nElts_; elem++) elementSetAll_.insert(elem); + for (int elem = 0; elem < nElts_; elem++) elementSetAll_.insert(elem); for (int node = 0; node < nNodesUnique_; node++) nodeSetAll_.insert(node); const Array > > & sets = *nodeSets; for (int nodeSet = 0; nodeSet < sets.size(); ++nodeSet) { const set & nset = sets(nodeSet).second; - set copy; + set copy; if (compactRemap_.size() > 0) { for (set::iterator itr = nset.begin(); itr != nset.end(); itr++) { copy.insert(globalToUniqueMap_(compactRemap_(*itr))); @@ -1772,17 +1772,17 @@ namespace ATC { } create_nodeset(sets(nodeSet).first, copy); } - + // Insert nodes and elements into KD-tree for PIE search. if (tree_ == nullptr) { - tree_ = KD_Tree::create_KD_tree(feElement_->num_elt_nodes(), nNodes_, + tree_ = KD_Tree::create_KD_tree(feElement_->num_elt_nodes(), nNodes_, &nodalCoords_, nElts_, connectivity_); } } FE_3DMesh::~FE_3DMesh() { - if (tree_) delete tree_; + if (tree_) delete tree_; } // ------------------------------------------------------------- @@ -1802,7 +1802,7 @@ namespace ATC { if (periodicity_(2)) { fix_periodicity(3); } if (periodicity_(1)) { fix_periodicity(2); } if (periodicity_(0)) { fix_periodicity(1); } - + // renumber to compact unique numbering // unique nodes map to the same id with global to unique @@ -1914,8 +1914,8 @@ namespace ATC { ATC::LammpsInterface::instance()->print_msg_once(ss.str()); return true; } - - void FE_3DMesh::set_unique_connectivity(void) + + void FE_3DMesh::set_unique_connectivity(void) { int numEltNodes = feElement_->num_elt_nodes(); connectivityUnique_.reset(numEltNodes, nElts_); @@ -1987,14 +1987,14 @@ namespace ATC { // add duplicate coordinates int iNew = nNodes_; int iNewUnique = nNodesUnique_; - for (itr = dupNodes.begin(); itr != dupNodes.end(); + for (itr = dupNodes.begin(); itr != dupNodes.end(); itr++,iNew++) { int iOld = *itr; oldToNewMap[iOld] = iNew; // global ids if (iOld == node_map(iOld)) { // non-image atom - node_map(iNew) = iNewUnique++; - } else { - node_map(iNew) = -1; + node_map(iNew) = iNewUnique++; + } else { + node_map(iNew) = -1; } for(int j = 0; j < nsd; j++) { coordinates(j,iNew) = coordinates(j,iOld); @@ -2002,7 +2002,7 @@ namespace ATC { } nNodes_ = iNew; nNodesUnique_ = iNewUnique; - for (itr = dupNodes.begin(); itr != dupNodes.end(); + for (itr = dupNodes.begin(); itr != dupNodes.end(); itr++,iNew++) { int iOld = *itr; iNew = oldToNewMap[iOld]; // global ids @@ -2016,7 +2016,7 @@ namespace ATC { const int nnf = num_nodes_per_face(); const Array2D & local_conn = feElement_->local_face_conn(); set< PAIR >::iterator iter; - for (iter = faceSet.begin(); iter != faceSet.end(); iter++) + for (iter = faceSet.begin(); iter != faceSet.end(); iter++) { PAIR face = *iter; int eltID=face.first, faceID=face.second; @@ -2026,7 +2026,7 @@ namespace ATC { if (oldToNewMap.find(id) != oldToNewMap.end() ) { int new_id = (*oldToNewMap.find(id)).second; connectivity_(lid,eltID) = new_id; - connectivityUnique_(lid, eltID) = node_map(new_id); + connectivityUnique_(lid, eltID) = node_map(new_id); } } } @@ -2045,7 +2045,7 @@ namespace ATC { set newToOld; map oldToNewMap; elementset_to_nodeset(elementsNew,newToOld); - int nNodesNew = newToOld.size(); + int nNodesNew = newToOld.size(); set::const_iterator itr; // coordinates & node map (from nodes to data) @@ -2073,9 +2073,9 @@ namespace ATC { for(int j = 0; j < nPE; j++) { int old_node = connectivity_(j,ielem); map::iterator map_itr = oldToNewMap.find(old_node); - if (map_itr == oldToNewMap.end()) { - stringstream ss; - ss << "map failure " << old_node << "\n"; + if (map_itr == oldToNewMap.end()) { + stringstream ss; + ss << "map failure " << old_node << "\n"; ATC::LammpsInterface::instance()->print_msg(ss.str()); } int node = map_itr->second; @@ -2089,9 +2089,9 @@ namespace ATC { } // ------------------------------------------------------------- - // partition_mesh + // partition_mesh // ------------------------------------------------------------- - + void FE_3DMesh::partition_mesh() { if (lammpsPartition_) { @@ -2108,8 +2108,8 @@ namespace ATC { // use the KD tree for partitioning, getting more blocks than // processors if (tree_ == nullptr) { - tree_ = KD_Tree::create_KD_tree(feElement_->num_elt_nodes(), - nNodes_, &nodalCoords_, + tree_ = KD_Tree::create_KD_tree(feElement_->num_elt_nodes(), + nNodes_, &nodalCoords_, nElts_, connectivity_); } @@ -2119,14 +2119,14 @@ namespace ATC { // divide between all processors, we get the next-highest // power of 2. vector > procEltLists = tree_->getElemIDs(depth); - + // Make sure the KD tree is behaving as expected. assert(procEltLists.size() >= nProcs); - + // If the KD-tree was not able to return enough divisions, // duplicate the largest list. - - // elements, then the division would be more even. + + // elements, then the division would be more even. vector >::iterator it; if (numNonempty(procEltLists) < nProcs) { // Find the list of maximum size and assign it to empty processors @@ -2142,7 +2142,7 @@ namespace ATC { } } } - + // We will store the owning processor for each element. int * eltToOwners = new int[nElts_]; for (int i = 0; i < nElts_; ++i) { @@ -2180,7 +2180,7 @@ namespace ATC { partitioned_ = false; } - void FE_3DMesh::prune_duplicate_elements(vector > & procEltLists, + void FE_3DMesh::prune_duplicate_elements(vector > & procEltLists, int * eltToOwners) { int procID = 0; @@ -2195,7 +2195,7 @@ namespace ATC { // record it as belonging to processor *it. if (eltToOwners[*it] == -1) { eltToOwners[*it] = procID; - } + } else { // If it does have a processor in eltToOwners, then we need // to remove it from either processor *topIt or from the processor @@ -2205,7 +2205,7 @@ namespace ATC { // Delete element from processor *topIt, if it has more elements. it = topIt->erase(it); --it; - } + } else { // Delete element from conflicting processor otherwise. toErase = find(conflictingProc->begin(), conflictingProc->end(), *it); @@ -2219,9 +2219,9 @@ namespace ATC { } // ------------------------------------------------------------- - // lammps_partition_mesh + // lammps_partition_mesh // ------------------------------------------------------------- - + void FE_3DMesh::lammps_partition_mesh() { if (LammpsInterface::instance()->domain_triclinic()) { @@ -2234,10 +2234,10 @@ namespace ATC { LammpsInterface::instance()->sub_bounds(xlo, xhi, ylo, yhi, zlo, zhi); LammpsInterface::instance()->box_bounds(boxxlo, boxxhi, boxylo, boxyhi, boxzlo, boxzhi); - + myElts_.clear(); double xCent, yCent, zCent; - + // Assign elements to processors based on the centroid of the element. int numNodes = num_nodes_per_element(); for (int i = 0; i < nElts_; ++i) @@ -2259,7 +2259,7 @@ namespace ATC { if (yCent < boxylo) yCent = boxylo; if (yCent < boxyhi) yCent = boxyhi; if (zCent < boxzlo) zCent = boxzlo; - if (zCent < boxzhi) zCent = boxzhi; + if (zCent < boxzhi) zCent = boxzhi; if ( dbl_geq(xCent, xlo) && ((xhi == boxxhi) || !dbl_geq(xCent, xhi)) && dbl_geq(yCent, ylo) && @@ -2284,13 +2284,13 @@ namespace ATC { nodeset_to_maximal_elementset(nodes,elms); myAndGhostElts_.clear(); set::const_iterator iter; - for (iter=elms.begin(); iter!=elms.end(); iter++) + for (iter=elms.begin(); iter!=elms.end(); iter++) {myAndGhostElts_.push_back(*iter);} distribute_mesh_data(); } partitioned_ = true; return; - + } void FE_3DMesh::redistribute_extra_proclists(vector > &procEltLists, @@ -2300,7 +2300,7 @@ namespace ATC { faceAdjacencies = -1; // Set all values to -1, indicating uninitialized/uncalculated int currentElt, adjacentElt, procID; - + // Put all of the hobos onto one master list, allHomelessElts. list allHomelessElts; vector oneHomelessList; @@ -2309,11 +2309,11 @@ namespace ATC { for (int i = 0; i < nHoboLists; ++i) { current = min_element(procEltLists.begin(), procEltLists.end(), vectorCompSize); oneHomelessList = *current; - allHomelessElts.insert(allHomelessElts.end(), + allHomelessElts.insert(allHomelessElts.end(), oneHomelessList.begin(), oneHomelessList.end()); current->clear(); } - + // Make sure the hobos lose their association with their old processor. list::iterator it; for (it = allHomelessElts.begin(); it != allHomelessElts.end(); it++){ @@ -2322,34 +2322,34 @@ namespace ATC { // Figure out which elements the hobos are adjacent to. That way, they // will know what processors they can be redistributed to. - compute_face_adjacencies(allHomelessElts, faceAdjacencies); + compute_face_adjacencies(allHomelessElts, faceAdjacencies); // Place homeless elements onto lists that correspond to actual processors. while (!allHomelessElts.empty()) { currentElt = allHomelessElts.back(); - + // This will store the ID of the processor with the fewest elements // so far that has an element adjacent to currentElt. PAIR smallestProc(-1, INT_MAX); - + // Iterate over the faces, check the processors of adjacent elements, - // and slate the element to go on the adjacent processor with the fewest + // and slate the element to go on the adjacent processor with the fewest // elements. for (int localFaceID = 0; localFaceID < num_faces_per_element(); ++localFaceID) { - adjacentElt = faceAdjacencies(currentElt, localFaceID); - + adjacentElt = faceAdjacencies(currentElt, localFaceID); + // This means that there is no adjacency through this face. if (adjacentElt >= nElts_) continue; - + procID = eltToOwners[adjacentElt]; // The procID > -1 check makes sure we're not adjacent to another // homeless element by this face, in which case it won't have a // processor to put currentElt onto yet. if (procID > -1 && ((int) procEltLists[procID].size()) < smallestProc.second) { smallestProc = PAIR(procID, procEltLists[procID].size()); - } + } } - + allHomelessElts.pop_back(); // If we couldn't find an adjacent element that had a processor, @@ -2357,7 +2357,7 @@ namespace ATC { if (smallestProc.first == -1) { allHomelessElts.push_front(currentElt); } - // Otherwise, put it onto the processor with the fewest elements that + // Otherwise, put it onto the processor with the fewest elements that // we found. else { procEltLists[smallestProc.first].push_back(currentElt); @@ -2366,8 +2366,8 @@ namespace ATC { } } - - void FE_3DMesh::compute_face_adjacencies(const list &elts, + + void FE_3DMesh::compute_face_adjacencies(const list &elts, DENS_MAT &faceAdjacencies) { list::const_iterator cit; @@ -2382,9 +2382,9 @@ namespace ATC { // Put the first node's elements into the accumulator to start. vector vIntersect = uniqueNodeToElementMap_(faceNodes(0)); vector vCurrent; - // set_intersect requires a vector large enough to contain the - // max possible intersect, which cannot be larger than the entirety - // of the first vector involved. + // set_intersect requires a vector large enough to contain the + // max possible intersect, which cannot be larger than the entirety + // of the first vector involved. vector vTemp(vIntersect.size(), -1); // Find the intersection of each of the nodes' element vectors. for (int ithOnFace = 1; ithOnFace < num_nodes_per_face(); ++ithOnFace) { @@ -2404,32 +2404,32 @@ namespace ATC { if (vIntersect.size() == 2) { // We want to choose the element id of NOT the current // element to be listed as the adjacency. - - // well, but that requires more complicated memoization and + + // well, but that requires more complicated memoization and // this doesn't take much extra time. if (*cit == vIntersect[0]) { faceAdjacencies(*cit, localFaceID) = vIntersect[1]; - } + } else { faceAdjacencies(*cit, localFaceID) = vIntersect[0]; } - } + } // This means the element is on the border. else if (vIntersect.size() == 1) { faceAdjacencies(*cit, localFaceID) = INT_MAX; - } + } else { // This should never ever happen! The nodes should at least // share one element, since they are all on one face! // There should also never be more than two elements on the - // same face... that would defy mathematics and physics in + // same face... that would defy mathematics and physics in // every way. } } } } - // Sometimes we want to count the number of vectors that actually + // Sometimes we want to count the number of vectors that actually // have stuff in them. We use this. int FE_3DMesh::numNonempty(vector > & v) { @@ -2450,10 +2450,10 @@ namespace ATC { vector matches = vector(); // Search through each of the nearest elements - for (vector::iterator elem = candidates.begin(); + for (vector::iterator elem = candidates.begin(); elem < candidates.end(); elem++) { if (contains_point(*elem, query)) { - matches.push_back(*elem); // Keep track of the elements + matches.push_back(*elem); // Keep track of the elements // which contain it } } @@ -2477,7 +2477,7 @@ namespace ATC { } //----------------------------------------------------------------------- - void FE_3DMesh::distribute_mesh_data() + void FE_3DMesh::distribute_mesh_data() { myNElts_ = myElts_.size(); @@ -2531,10 +2531,10 @@ namespace ATC { borders_[1][0] = xmax; borders_[1][1] = ymax; borders_[1][2] = zmax; - L_[0] = xmax-xmin; + L_[0] = xmax-xmin; L_[1] = ymax-ymin; L_[2] = zmax-zmin; - n_[0] = hx_.size(); + n_[0] = hx_.size(); n_[1] = hy_.size(); n_[2] = hz_.size(); // Compute region size and element size @@ -2556,13 +2556,13 @@ namespace ATC { nSD_ = 3; x_.reserve(nSD_); for (int i = 0; i < nSD_; ++i) {x_.push_back(Array(n_[i]+1)); } - Array & xI = x_[0]; + Array & xI = x_[0]; xI(0) = xmin; for (int i = 0; i < n_[0]; ++i) { xI(i+1) = xI(i)+hx_(i); } - Array & yI = x_[1]; + Array & yI = x_[1]; yI(0) = ymin; for (int i = 0; i < n_[1]; ++i) { yI(i+1) = yI(i)+hy_(i); } - Array & zI = x_[2]; + Array & zI = x_[2]; zI(0) = zmin; for (int i = 0; i < n_[2]; ++i) { zI(i+1) = zI(i)+hz_(i); } @@ -2620,9 +2620,9 @@ namespace ATC { } // ------------------------------------------------------------- - // partition_mesh + // partition_mesh // ------------------------------------------------------------- - + void FE_Rectangular3DMesh::partition_mesh() { if (lammpsPartition_) { @@ -2632,7 +2632,7 @@ namespace ATC { if (partitioned_) return; - // Currently this code has been rather naively copied from + // Currently this code has been rather naively copied from // FE_Uniform3DMesh::partition_mesh() // Determine dimensions of mesh in order to partition according to largest dimension. @@ -2645,10 +2645,10 @@ namespace ATC { int numProcs; MPI_Comm_size(MPI_COMM_WORLD, &numProcs); - + int processorRank; MPI_Comm_rank(MPI_COMM_WORLD, &processorRank); - + // Spatially partition along the largest dimension. procs_.clear(); if (max(max(L_[0], L_[1]), L_[2]) == L_[0]) { @@ -2687,9 +2687,9 @@ namespace ATC { myNodes_.push_back(i); } } - + // Distribute each element to the correct processor - assign it to the processor - // which owns its node of lowest index. (this partitioning scheme is unambiguous) + // which owns its node of lowest index. (this partitioning scheme is unambiguous) myElts_.clear(); for (int i = 0; i < nElts_; ++i) { int min = INT_MAX; @@ -2705,7 +2705,7 @@ namespace ATC { /* Commented out because ghost nodes are never used and dx_ is not a member of FE_Rectangular3DMesh. - // Compute the facesets that describes the left and right boundaries + // Compute the facesets that describes the left and right boundaries // in order to determine ghost nodes. int leftMult = 0; while ((leftMult+1)*dx_[partitionAxis_] < procs_[processorRank]) { @@ -2745,13 +2745,13 @@ namespace ATC { nNodesUnique_ = 1; for (int i = 0; i < 3; i++) { nNodesUnique_ *= (n_[i] + 1 - periodicity_(i)); - } - + } + // form maximal nodeset for (int i = 0; i < nNodesUnique_; i++) { - nodeSetAll_.insert(i); + nodeSetAll_.insert(i); } - + // Create global-to-unique map: globalToUniqueMap_(ig) = iu globalToUniqueMap_.reset(nNodes_); uniqueToGlobalMap_.reset(nNodesUnique_); @@ -2762,7 +2762,7 @@ namespace ATC { for (int i = 0; i <= n_[0]; ++i) { int iper = (i == n_[0] && periodicity_(0)) ? 0 : i; int id = i + j*(n_[0]+1) + k*(n_[0]+1)*(n_[1]+1); - int uid = iper + jper*(n_[0]+1-periodicity_(0)) + int uid = iper + jper*(n_[0]+1-periodicity_(0)) + kper*(n_[0]+1-periodicity_(0))*(n_[1]+1-periodicity_(1)); globalToUniqueMap_(id) = uid; uniqueToGlobalMap_(uid) = id; @@ -2773,7 +2773,7 @@ namespace ATC { // form maximal elementset for (int i = 0; i < nElts_; i++) { - elementSetAll_.insert(i); + elementSetAll_.insert(i); } } @@ -2788,7 +2788,7 @@ namespace ATC { int shift = int(diff/L_[i]); if (diff < 0.) shift--; y -= shift*L_[i]; - } + } // project into element ix[i] = x_[i].index(y); if (fabs(y-borders_[0][i]) < tol) { ix[i] = 0; } // on the lower boundary @@ -2898,15 +2898,15 @@ namespace ATC { // ------------------------------------------------------------- // destructor // ------------------------------------------------------------- - FE_Uniform3DMesh::~FE_Uniform3DMesh() + FE_Uniform3DMesh::~FE_Uniform3DMesh() { // Clean up is currently unimplemented } // ------------------------------------------------------------- - // partition_mesh + // partition_mesh // ------------------------------------------------------------- - + void FE_Uniform3DMesh::partition_mesh() { if (lammpsPartition_) { @@ -2926,10 +2926,10 @@ namespace ATC { int numProcs; MPI_Comm_size(MPI_COMM_WORLD, &numProcs); - + int processorRank; MPI_Comm_rank(MPI_COMM_WORLD, &processorRank); - + // Spatially partition along the largest dimension. procs_.clear(); if (max(max(L_[0], L_[1]), L_[2]) == L_[0]) { @@ -2968,9 +2968,9 @@ namespace ATC { myNodes_.push_back(i); } } - + // Distribute each element to the correct processor - assign it to the processor - // which owns its node of lowest index. (this partitioning scheme is unambiguous) + // which owns its node of lowest index. (this partitioning scheme is unambiguous) myElts_.clear(); for (int i = 0; i < nElts_; ++i) { int min = INT_MAX; @@ -2983,7 +2983,7 @@ namespace ATC { } } - // Compute the facesets that describes the left and right boundaries + // Compute the facesets that describes the left and right boundaries // in order to determine ghost nodes. int leftMult = 0; while ((leftMult+1)*dx_[partitionAxis_] < procs_[processorRank]) { @@ -3020,11 +3020,11 @@ namespace ATC { // ------------------------------------------------------------- int FE_Uniform3DMesh::map_to_element(const DENS_VEC &x) const { - // countx[i] is the number of the element, where 1 is the + // countx[i] is the number of the element, where 1 is the // element adjacent to the lower border, in the ith direction int countx[3]; for (int i = 0; i < 3; ++i) { - // handle points on upper boundary; not sure why this is + // handle points on upper boundary; not sure why this is // hard-coded in, though... if (fabs(x(i)-borders_[1][i]) < tol) { countx[i] = n_[i] - 1; @@ -3032,26 +3032,26 @@ namespace ATC { // find the x, y, and z bins for the point in the mesh countx[i] = (int)floor((x(i)-borders_[0][i])/dx_[i]); } - + // handle points out-of-range [0:nx-1] w/ periodicity if (countx[i] < 0 || countx[i] >= n_[i]) { if (periodicity_(i)) { countx[i] = countx[i] % n_[i]; // handles c++ ambiguous mod problems - if (countx[i] < 0) countx[i] += n_[i]; + if (countx[i] < 0) countx[i] += n_[i]; } else { - string msg = " point maps outside " - "of mesh, coordinate " + - index_to_string(i) + " " + to_string(x(i)) + - " not in " + to_string(borders_[0][i]) + + string msg = " point maps outside " + "of mesh, coordinate " + + index_to_string(i) + " " + to_string(x(i)) + + " not in " + to_string(borders_[0][i]) + " : " + to_string(borders_[1][i]); throw ATC_Error(FILELINE,msg); } } } - int elt = countx[2]*(n_[0]*n_[1]) + - countx[1]*n_[0] + + int elt = countx[2]*(n_[0]*n_[1]) + + countx[1]*n_[0] + countx[0]; return elt; } diff --git a/lib/atc/FE_Mesh.h b/lib/atc/FE_Mesh.h index 0b2df7b656..e3a77c4239 100644 --- a/lib/atc/FE_Mesh.h +++ b/lib/atc/FE_Mesh.h @@ -31,7 +31,7 @@ namespace ATC { /** constructor */ FE_Mesh(); - + /** destructor */ virtual ~FE_Mesh(); @@ -65,41 +65,41 @@ namespace ATC { /** evaluate shape function at real coordinates */ void position(const int elem, - const VECTOR &xi, + const VECTOR &xi, DENS_VEC &x) const; /** evaluate shape function at real coordinates */ - void shape_functions(const VECTOR &x, + void shape_functions(const VECTOR &x, DENS_VEC &N, Array &nodeList) const; /** evaluate shape function at real coordinates */ - void shape_functions(const VECTOR &x, + void shape_functions(const VECTOR &x, DENS_VEC &N, Array &nodeList, const Array &) const; /** evaluate shape function at real coordinates */ - void shape_functions(const DENS_VEC &x, + void shape_functions(const DENS_VEC &x, DENS_VEC &N, DENS_MAT &dNdx, Array &nodeList) const; /** evaluate shape function at real coordinates */ - void shape_functions(const VECTOR &x, + void shape_functions(const VECTOR &x, const int eltID, DENS_VEC &N, Array &nodeList) const; /** evaluate shape function at real coordinates */ - void shape_functions(const DENS_VEC &x, + void shape_functions(const DENS_VEC &x, const int eltID, DENS_VEC &N, DENS_MAT &dNdx, Array &nodeList) const; /** evaluate shape function at real coordinates */ - void shape_function_derivatives(const DENS_VEC &x, + void shape_function_derivatives(const DENS_VEC &x, const int eltID, DENS_MAT &dNdx, Array &nodeList) const; @@ -176,7 +176,7 @@ namespace ATC { } } - /** + /** * return spatial coordinates for element nodes on eltID, * indexed xCoords(isd,inode) */ @@ -199,21 +199,21 @@ namespace ATC { virtual int map_to_element(const DENS_VEC &x) const = 0; /** map global node numbering to unique node numbering */ - int map_global_to_unique(const int global_id) const + int map_global_to_unique(const int global_id) const { return globalToUniqueMap_(global_id); } - inline const Array& global_to_unique_map(void) const + inline const Array& global_to_unique_map(void) const { return globalToUniqueMap_; } /** map unique node numbering a global node numbering */ - int map_unique_to_global(const int unique_id) + int map_unique_to_global(const int unique_id) { return uniqueToGlobalMap_(unique_id); } - inline const Array& unique_to_global_map(void) const + inline const Array& unique_to_global_map(void) const { return uniqueToGlobalMap_; } @@ -248,43 +248,43 @@ namespace ATC { /** get the minimal element set from a nodeset by name */ - void nodeset_to_minimal_elementset(const std::string &name, + void nodeset_to_minimal_elementset(const std::string &name, std::set &elemSet) const; /** get the minimal element set from a set of nodes */ - void nodeset_to_minimal_elementset(const std::set &nodeSet, + void nodeset_to_minimal_elementset(const std::set &nodeSet, std::set &elemSet) const; /** get the maximal element set from a nodeset by name */ - void nodeset_to_maximal_elementset(const std::string &name, + void nodeset_to_maximal_elementset(const std::string &name, std::set &elemSet) const; /** get the maximal element set from a set of nodes */ - void nodeset_to_maximal_elementset(const std::set &nodeSet, + void nodeset_to_maximal_elementset(const std::set &nodeSet, std::set &elemSet) const; /** get complement of element set by name */ - void elementset_complement(const std::string &name, + void elementset_complement(const std::string &name, std::set &elemSet) const; - void elementset_complement(const std::set &elemSet, + void elementset_complement(const std::set &elemSet, std::set &elemSetComplement) const; /** get the node set from an element set by name */ - void elementset_to_minimal_nodeset(const std::string &name, + void elementset_to_minimal_nodeset(const std::string &name, std::set &nodeSet) const; - void elementset_to_nodeset(const std::string &name, + void elementset_to_nodeset(const std::string &name, std::set nodeSet) const; - void elementset_to_nodeset(const std::set &elemSet, + void elementset_to_nodeset(const std::set &elemSet, std::set nodeSet) const; std::set elementset_to_nodeset(const std::string &name) const; /** convert faceset to nodeset in _unique_ node numbering */ - void faceset_to_nodeset(const std::string &name, + void faceset_to_nodeset(const std::string &name, std::set &nodeSet) const; - void faceset_to_nodeset(const std::set &faceSet, + void faceset_to_nodeset(const std::set &faceSet, std::set &nodeSet) const; - void faceset_to_nodeset_global(const std::string &name, + void faceset_to_nodeset_global(const std::string &name, std::set &nodeSet) const; - void faceset_to_nodeset_global(const std::set &faceSet, + void faceset_to_nodeset_global(const std::set &faceSet, std::set &nodeSet) const; /** get face set from the string name assigned to the set */ @@ -294,7 +294,7 @@ namespace ATC { void create_faceset(const std::string & name, double xmin, double xmax, double ymin, double ymax, - double zmin, double zmax, + double zmin, double zmax, bool outward); /** create face set with tag "name" from faces aligned with plane */ void create_faceset(const std::string & name, double x, int idir, int isgn, @@ -303,7 +303,7 @@ namespace ATC { /** cut mesh */ virtual void cut_mesh(const std::set & faceSet, const std::set & nodeSet) = 0; - + /** delete elements */ virtual void delete_elements(const std::set & elementList) = 0; @@ -330,10 +330,10 @@ namespace ATC { /** return number of faces per element */ int num_faces_per_element() const; - + /** return number of nodes per face */ int num_nodes_per_face() const; - + /** return number of integration points per face */ int num_ips_per_face() const; @@ -341,7 +341,7 @@ namespace ATC { when mesh is not partitioned. */ Array2D * connectivity(void) { return &connectivity_; } /** return a pointer to the connectivity */ - DENS_MAT * coordinates(void) { return &nodalCoords_;} + DENS_MAT * coordinates(void) { return &nodalCoords_;} /** Engine nodeMap stuff */ Array *node_map(void) { return &globalToUniqueMap_;} @@ -353,19 +353,19 @@ namespace ATC { /** local face connectivity */ const Array2D & local_face_connectivity() const; - - /** element size in each direction */ - virtual void bounding_box(const int ielem, - DENS_VEC & xmin, DENS_VEC & xmax); /** element size in each direction */ - virtual void element_size(const int ielem, - double & hx, double & hy, double & hz); + virtual void bounding_box(const int ielem, + DENS_VEC & xmin, DENS_VEC & xmax); /** element size in each direction */ - virtual double min_element_size(void) const {return 0.0 ;} + virtual void element_size(const int ielem, + double & hx, double & hy, double & hz); - /** get nodal coordinates for a given element */ + /** element size in each direction */ + virtual double min_element_size(void) const {return 0.0 ;} + + /** get nodal coordinates for a given element */ void element_field(const int eltIdx, const DENS_MAT f, DENS_MAT &local_field) { @@ -387,25 +387,25 @@ namespace ATC { virtual double coordinate_tolerance(void) const {return 1.e-8;} /** element type */ - std::string element_type(void) const ; + std::string element_type(void) const ; /** output mesh subsets */ - void output(std::string prefix) const; - + void output(std::string prefix) const; + /* Parallelization data members */ - + /** return element vector for this processor */ const std::vector & owned_elts() const { return myElts_; } - const std::vector & owned_and_ghost_elts() const { + const std::vector & owned_and_ghost_elts() const { return (decomposition_) ? myAndGhostElts_: myElts_; } bool is_owned_elt(int elt) const; - + protected: - void parse_plane(int & argIdx, int narg, char ** arg, + void parse_plane(int & argIdx, int narg, char ** arg, int & ndir, int * idir, int & isgn, double xlimits[][2]); - void parse_units(int & argIdx, int narg, char ** arg, + void parse_units(int & argIdx, int narg, char ** arg, double & xmin, double & xmax, double & ymin, double & ymax, double & zmin, double & zmax); /** will this mesh use data decomposition? */ @@ -488,9 +488,9 @@ namespace ATC { /** maps between my IDs and the total IDs */ std::map elemToMyElemMap_; - + /** Lists of ghost nodes/neighbor ghost nodes */ - std::vector ghostNodesL_; + std::vector ghostNodesL_; std::vector ghostNodesR_; std::vector shareNodesL_; std::vector shareNodesR_; @@ -509,11 +509,11 @@ namespace ATC { class FE_3DMesh : public FE_Mesh { public: /** constructor */ - FE_3DMesh(){}; + FE_3DMesh(){}; /** constructor for read-in mesh **/ // can later be extended to take nodesets, elementsets, etc. - FE_3DMesh(const std::string elementType, + FE_3DMesh(const std::string elementType, const int nNodes, const int nElements, const Array2D *connectivity, @@ -532,34 +532,34 @@ namespace ATC { /** Removes duplicate elements that appear in more than one vector within procEltLists. **/ - void prune_duplicate_elements(std::vector > &procEltLists, + void prune_duplicate_elements(std::vector > &procEltLists, int *eltToOwners); - + /** Takes procEltLists, and if there are more than nProcs of them it takes the extra elements and distributes them to other vectors in procEltLists. */ - + // processors if during pruning processors end up // elementless. This is slightly complicated because of // ghost nodes. void redistribute_extra_proclists(std::vector > &procEltLists, int *eltToOwners, int nProcs); - + /** This takes in a dense matrix and a list of elements and fills in a standard adjacency list (within the matrix) for those elements. **/ - + // 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 std::list &elts, + void compute_face_adjacencies(const std::list &elts, DENS_MAT &faceAdjacencies); /** Counts the number of nonempty vectors in a vector of vectors. **/ int numNonempty(std::vector > &v); - - /** In the partitioning, we want to sort vectors of integers by size, - and furthermore we want empty vectors to count as the "largest" + + /** 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() (std::vector l, std::vector r) { @@ -578,12 +578,12 @@ namespace ATC { } virtual void cut_mesh(const std::set &faceSet, const std::set &nodeSet); - + virtual void delete_elements(const std::set &elementSet); /** map spatial location to element */ virtual int map_to_element(const DENS_VEC &x) const; - + /** sends out data to processors during partitioning */ void distribute_mesh_data(); protected: @@ -610,18 +610,18 @@ namespace ATC { /** * @class FE_Rectangular3DMesh - * @brief Derived class for a structured mesh with - * variable element sizes in x, y, and z directions + * @brief Derived class for a structured mesh with + * variable element sizes in x, y, and z directions */ class FE_Rectangular3DMesh : public FE_3DMesh { public: /** constructor */ - FE_Rectangular3DMesh(){}; + FE_Rectangular3DMesh(){}; FE_Rectangular3DMesh( const Array & hx, const Array & hy, const Array & hz, - const double xmin, const double xmax, + const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax, const Array periodicity, @@ -631,13 +631,13 @@ namespace ATC { /** destructor */ virtual ~FE_Rectangular3DMesh() {}; - + void partition_mesh(void); void departition_mesh(void); /** map spatial location to element */ - virtual int map_to_element(const DENS_VEC &x) const; + virtual int map_to_element(const DENS_VEC &x) const; protected: @@ -650,7 +650,7 @@ namespace ATC { /** Region size in each direction */ double L_[3]; - + /** create global-to-unique node mapping */ virtual void setup_periodicity(); // note no "tol" @@ -665,11 +665,11 @@ namespace ATC { /** * @class FE_Uniform3DMesh - * @brief Derived class for a uniform structured mesh with - * fixed element sizes in x, y, and z directions + * @brief Derived class for a uniform structured mesh with + * fixed element sizes in x, y, and z directions */ class FE_Uniform3DMesh : public FE_Rectangular3DMesh { - + public: /** constructor */ @@ -690,8 +690,8 @@ namespace ATC { void partition_mesh(void); void departition_mesh(void); - - virtual void element_size(const int /* ielem */, + + virtual void element_size(const int /* ielem */, double &hx, double &hy, double &hz) { hx = L_[0]/n_[0]; hy = L_[1]/n_[1]; hz = L_[2]/n_[2]; } @@ -699,7 +699,7 @@ namespace ATC { { 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; + virtual int map_to_element(const DENS_VEC &x) const; private: // only used by this class /** Element size in each direction */ diff --git a/lib/atc/FE_Quadrature.h b/lib/atc/FE_Quadrature.h index 922ade05cb..870b01d279 100644 --- a/lib/atc/FE_Quadrature.h +++ b/lib/atc/FE_Quadrature.h @@ -39,27 +39,27 @@ namespace ATC { ipFaceWeights.reset(numFaceIPs); // "Matrix" of integration point location - ipCoords(0,0) = 0.0; - ipCoords(1,0) = 0.0; + ipCoords(0,0) = 0.0; + ipCoords(1,0) = 0.0; ipCoords(2,0) = 0.0; // Integration point for each face - ipFaceCoords[0](0,0) = -1.0; ipFaceCoords[3](0,0) = 0.0; - ipFaceCoords[0](1,0) = 0.0; ipFaceCoords[3](1,0) = 1.0; + ipFaceCoords[0](0,0) = -1.0; ipFaceCoords[3](0,0) = 0.0; + ipFaceCoords[0](1,0) = 0.0; ipFaceCoords[3](1,0) = 1.0; ipFaceCoords[0](2,0) = 0.0; ipFaceCoords[3](2,0) = 0.0; // - ipFaceCoords[1](0,0) = 1.0; ipFaceCoords[4](0,0) = 0.0; - ipFaceCoords[1](1,0) = 0.0; ipFaceCoords[4](1,0) = 0.0; + ipFaceCoords[1](0,0) = 1.0; ipFaceCoords[4](0,0) = 0.0; + ipFaceCoords[1](1,0) = 0.0; ipFaceCoords[4](1,0) = 0.0; ipFaceCoords[1](2,0) = 0.0; ipFaceCoords[4](2,0) = -1.0; // ipFaceCoords[2](0,0) = 0.0; ipFaceCoords[5](0,0) = 0.0; - ipFaceCoords[2](1,0) = -1.0; ipFaceCoords[5](1,0) = 0.0; + ipFaceCoords[2](1,0) = -1.0; ipFaceCoords[5](1,0) = 0.0; ipFaceCoords[2](2,0) = 0.0; ipFaceCoords[5](2,0) = 1.0; - + // 2D integration scheme for the faces - ipFace2DCoords(0,0) = 0.0; + ipFace2DCoords(0,0) = 0.0; ipFace2DCoords(1,0) = 0.0; - + // Integration point weights ipWeights = 8.0; @@ -85,41 +85,41 @@ namespace ATC { // Dictates difference in node locations for nodal/GAUSS2 double a = 1.0/sqrt(3.0); if (quad == NODAL) a = 1.0; - - // Matrix of integration point locations & follows local + + // Matrix of integration point locations & follows local // conn - ipCoords(0,0) = -a; ipCoords(0,4) = -a; - ipCoords(1,0) = -a; ipCoords(1,4) = -a; + ipCoords(0,0) = -a; ipCoords(0,4) = -a; + ipCoords(1,0) = -a; ipCoords(1,4) = -a; ipCoords(2,0) = -a; ipCoords(2,4) = a; // - ipCoords(0,1) = a; ipCoords(0,5) = a; - ipCoords(1,1) = -a; ipCoords(1,5) = -a; + ipCoords(0,1) = a; ipCoords(0,5) = a; + ipCoords(1,1) = -a; ipCoords(1,5) = -a; ipCoords(2,1) = -a; ipCoords(2,5) = a; // - ipCoords(0,2) = a; ipCoords(0,6) = a; - ipCoords(1,2) = a; ipCoords(1,6) = a; + ipCoords(0,2) = a; ipCoords(0,6) = a; + ipCoords(1,2) = a; ipCoords(1,6) = a; ipCoords(2,2) = -a; ipCoords(2,6) = a; // - ipCoords(0,3) = -a; ipCoords(0,7) = -a; - ipCoords(1,3) = a; ipCoords(1,7) = a; + ipCoords(0,3) = -a; ipCoords(0,7) = -a; + ipCoords(1,3) = a; ipCoords(1,7) = a; ipCoords(2,3) = -a; ipCoords(2,7) = a; // Integration points by face - ipFaceCoords[0](0,0) = -1; ipFaceCoords[3](0,0) = -a; - ipFaceCoords[0](1,0) = -a; ipFaceCoords[3](1,0) = 1; + ipFaceCoords[0](0,0) = -1; ipFaceCoords[3](0,0) = -a; + ipFaceCoords[0](1,0) = -a; ipFaceCoords[3](1,0) = 1; ipFaceCoords[0](2,0) = -a; ipFaceCoords[3](2,0) = -a; - // - ipFaceCoords[0](0,1) = -1; ipFaceCoords[3](0,1) = a; - ipFaceCoords[0](1,1) = a; ipFaceCoords[3](1,1) = 1; - ipFaceCoords[0](2,1) = -a; ipFaceCoords[3](2,1) = -a; - // - ipFaceCoords[0](0,2) = -1; ipFaceCoords[3](0,2) = a; - ipFaceCoords[0](1,2) = a; ipFaceCoords[3](1,2) = 1; - ipFaceCoords[0](2,2) = a; ipFaceCoords[3](2,2) = a; - // - ipFaceCoords[0](0,3) = -1; ipFaceCoords[3](0,3) = -a; - ipFaceCoords[0](1,3) = -a; ipFaceCoords[3](1,3) = 1; - ipFaceCoords[0](2,3) = a; ipFaceCoords[3](2,3) = a; + // + ipFaceCoords[0](0,1) = -1; ipFaceCoords[3](0,1) = a; + ipFaceCoords[0](1,1) = a; ipFaceCoords[3](1,1) = 1; + ipFaceCoords[0](2,1) = -a; ipFaceCoords[3](2,1) = -a; + // + ipFaceCoords[0](0,2) = -1; ipFaceCoords[3](0,2) = a; + ipFaceCoords[0](1,2) = a; ipFaceCoords[3](1,2) = 1; + ipFaceCoords[0](2,2) = a; ipFaceCoords[3](2,2) = a; + // + ipFaceCoords[0](0,3) = -1; ipFaceCoords[3](0,3) = -a; + ipFaceCoords[0](1,3) = -a; ipFaceCoords[3](1,3) = 1; + ipFaceCoords[0](2,3) = a; ipFaceCoords[3](2,3) = a; ipFaceCoords[1](0,0) = 1; ipFaceCoords[4](0,0) = -a; ipFaceCoords[1](1,0) = -a; ipFaceCoords[4](1,0) = -a; @@ -136,30 +136,30 @@ namespace ATC { ipFaceCoords[1](0,3) = 1; ipFaceCoords[4](0,3) = -a; ipFaceCoords[1](1,3) = -a; ipFaceCoords[4](1,3) = a; ipFaceCoords[1](2,3) = a; ipFaceCoords[4](2,3) = -1; - - ipFaceCoords[2](0,0) = -a; ipFaceCoords[5](0,0) = -a; - ipFaceCoords[2](1,0) = -1; ipFaceCoords[5](1,0) = -a; + + ipFaceCoords[2](0,0) = -a; ipFaceCoords[5](0,0) = -a; + ipFaceCoords[2](1,0) = -1; ipFaceCoords[5](1,0) = -a; ipFaceCoords[2](2,0) = -a; ipFaceCoords[5](2,0) = 1; - // - ipFaceCoords[2](0,1) = a; ipFaceCoords[5](0,1) = a; - ipFaceCoords[2](1,1) = -1; ipFaceCoords[5](1,1) = -a; - ipFaceCoords[2](2,1) = -a; ipFaceCoords[5](2,1) = 1; - // - ipFaceCoords[2](0,2) = a; ipFaceCoords[5](0,2) = a; - ipFaceCoords[2](1,2) = -1; ipFaceCoords[5](1,2) = a; - ipFaceCoords[2](2,2) = a; ipFaceCoords[5](2,2) = 1; - // - ipFaceCoords[2](0,3) = -a; ipFaceCoords[5](0,3) = -a; - ipFaceCoords[2](1,3) = -1; ipFaceCoords[5](1,3) = a; - ipFaceCoords[2](2,3) = a; ipFaceCoords[5](2,3) = 1; - - // Integration points for all faces ignoring the + // + ipFaceCoords[2](0,1) = a; ipFaceCoords[5](0,1) = a; + ipFaceCoords[2](1,1) = -1; ipFaceCoords[5](1,1) = -a; + ipFaceCoords[2](2,1) = -a; ipFaceCoords[5](2,1) = 1; + // + ipFaceCoords[2](0,2) = a; ipFaceCoords[5](0,2) = a; + ipFaceCoords[2](1,2) = -1; ipFaceCoords[5](1,2) = a; + ipFaceCoords[2](2,2) = a; ipFaceCoords[5](2,2) = 1; + // + ipFaceCoords[2](0,3) = -a; ipFaceCoords[5](0,3) = -a; + ipFaceCoords[2](1,3) = -1; ipFaceCoords[5](1,3) = a; + ipFaceCoords[2](2,3) = a; ipFaceCoords[5](2,3) = 1; + + // Integration points for all faces ignoring the // redundant dim - ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,2) = a; - ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,2) = a; - // - ipFace2DCoords(0,1) = a; ipFace2DCoords(0,3) = -a; - ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,3) = a; + ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,2) = a; + ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,2) = a; + // + ipFace2DCoords(0,1) = a; ipFace2DCoords(0,3) = -a; + ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,3) = a; // Integration point weights ipWeights = 1.0; @@ -185,36 +185,36 @@ namespace ATC { // Use GAUSS2 for faces for now... double a = 1.0/sqrt(3.0); - - // Matrix of integration point locations - ipCoords(0,0) = 1.0; ipCoords(0,3) = 0.0; - ipCoords(1,0) = 0.0; ipCoords(1,3) = -1.0; + + // Matrix of integration point locations + ipCoords(0,0) = 1.0; ipCoords(0,3) = 0.0; + ipCoords(1,0) = 0.0; ipCoords(1,3) = -1.0; ipCoords(2,0) = 0.0; ipCoords(2,3) = 0.0; - // - ipCoords(0,1) = -1.0; ipCoords(0,4) = 0.0; - ipCoords(1,1) = 0.0; ipCoords(1,4) = 0.0; + // + ipCoords(0,1) = -1.0; ipCoords(0,4) = 0.0; + ipCoords(1,1) = 0.0; ipCoords(1,4) = 0.0; ipCoords(2,1) = 0.0; ipCoords(2,4) = 1.0; - // - ipCoords(0,2) = 0.0; ipCoords(0,5) = 0.0; - ipCoords(1,2) = 1.0; ipCoords(1,5) = 0.0; + // + ipCoords(0,2) = 0.0; ipCoords(0,5) = 0.0; + ipCoords(1,2) = 1.0; ipCoords(1,5) = 0.0; ipCoords(2,2) = 0.0; ipCoords(2,5) = -1.0; // Integration points by face - ipFaceCoords[0](0,0) = -1; ipFaceCoords[3](0,0) = -a; - ipFaceCoords[0](1,0) = -a; ipFaceCoords[3](1,0) = 1; + ipFaceCoords[0](0,0) = -1; ipFaceCoords[3](0,0) = -a; + ipFaceCoords[0](1,0) = -a; ipFaceCoords[3](1,0) = 1; ipFaceCoords[0](2,0) = -a; ipFaceCoords[3](2,0) = -a; - // - ipFaceCoords[0](0,1) = -1; ipFaceCoords[3](0,1) = -a; - ipFaceCoords[0](1,1) = a; ipFaceCoords[3](1,1) = 1; - ipFaceCoords[0](2,1) = -a; ipFaceCoords[3](2,1) = a; - // - ipFaceCoords[0](0,2) = -1; ipFaceCoords[3](0,2) = a; - ipFaceCoords[0](1,2) = a; ipFaceCoords[3](1,2) = 1; - ipFaceCoords[0](2,2) = a; ipFaceCoords[3](2,2) = a; - // - ipFaceCoords[0](0,3) = -1; ipFaceCoords[3](0,3) = a; - ipFaceCoords[0](1,3) = -a; ipFaceCoords[3](1,3) = 1; - ipFaceCoords[0](2,3) = a; ipFaceCoords[3](2,3) = -a; + // + ipFaceCoords[0](0,1) = -1; ipFaceCoords[3](0,1) = -a; + ipFaceCoords[0](1,1) = a; ipFaceCoords[3](1,1) = 1; + ipFaceCoords[0](2,1) = -a; ipFaceCoords[3](2,1) = a; + // + ipFaceCoords[0](0,2) = -1; ipFaceCoords[3](0,2) = a; + ipFaceCoords[0](1,2) = a; ipFaceCoords[3](1,2) = 1; + ipFaceCoords[0](2,2) = a; ipFaceCoords[3](2,2) = a; + // + ipFaceCoords[0](0,3) = -1; ipFaceCoords[3](0,3) = a; + ipFaceCoords[0](1,3) = -a; ipFaceCoords[3](1,3) = 1; + ipFaceCoords[0](2,3) = a; ipFaceCoords[3](2,3) = -a; ipFaceCoords[1](0,0) = 1; ipFaceCoords[4](0,0) = -a; ipFaceCoords[1](1,0) = -a; ipFaceCoords[4](1,0) = -a; @@ -231,30 +231,30 @@ namespace ATC { ipFaceCoords[1](0,3) = 1; ipFaceCoords[4](0,3) = -a; ipFaceCoords[1](1,3) = -a; ipFaceCoords[4](1,3) = a; ipFaceCoords[1](2,3) = a; ipFaceCoords[4](2,3) = -1; - - ipFaceCoords[2](0,0) = -a; ipFaceCoords[5](0,0) = -a; - ipFaceCoords[2](1,0) = -1; ipFaceCoords[5](1,0) = -a; + + ipFaceCoords[2](0,0) = -a; ipFaceCoords[5](0,0) = -a; + ipFaceCoords[2](1,0) = -1; ipFaceCoords[5](1,0) = -a; ipFaceCoords[2](2,0) = -a; ipFaceCoords[5](2,0) = 1; - // - ipFaceCoords[2](0,1) = -a; ipFaceCoords[5](0,1) = a; - ipFaceCoords[2](1,1) = -1; ipFaceCoords[5](1,1) = -a; - ipFaceCoords[2](2,1) = a; ipFaceCoords[5](2,1) = 1; - // - ipFaceCoords[2](0,2) = a; ipFaceCoords[5](0,2) = a; - ipFaceCoords[2](1,2) = -1; ipFaceCoords[5](1,2) = a; - ipFaceCoords[2](2,2) = a; ipFaceCoords[5](2,2) = 1; - // - ipFaceCoords[2](0,3) = a; ipFaceCoords[5](0,3) = -a; - ipFaceCoords[2](1,3) = -1; ipFaceCoords[5](1,3) = a; - ipFaceCoords[2](2,3) = -a; ipFaceCoords[5](2,3) = 1; - - // Integration points for all faces ignoring the + // + ipFaceCoords[2](0,1) = -a; ipFaceCoords[5](0,1) = a; + ipFaceCoords[2](1,1) = -1; ipFaceCoords[5](1,1) = -a; + ipFaceCoords[2](2,1) = a; ipFaceCoords[5](2,1) = 1; + // + ipFaceCoords[2](0,2) = a; ipFaceCoords[5](0,2) = a; + ipFaceCoords[2](1,2) = -1; ipFaceCoords[5](1,2) = a; + ipFaceCoords[2](2,2) = a; ipFaceCoords[5](2,2) = 1; + // + ipFaceCoords[2](0,3) = a; ipFaceCoords[5](0,3) = -a; + ipFaceCoords[2](1,3) = -1; ipFaceCoords[5](1,3) = a; + ipFaceCoords[2](2,3) = -a; ipFaceCoords[5](2,3) = 1; + + // Integration points for all faces ignoring the // redundant dim - ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,2) = a; - ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,2) = a; - // - ipFace2DCoords(0,1) = a; ipFace2DCoords(0,3) = -a; - ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,3) = a; + ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,2) = a; + ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,2) = a; + // + ipFace2DCoords(0,1) = a; ipFace2DCoords(0,3) = -a; + ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,3) = a; // Integration point weights ipWeights = 4.0/3.0; @@ -278,166 +278,166 @@ namespace ATC { ipFaceWeights.reset(numFaceIPs); double a = sqrt(3.0/5.0); - - // Matrix of integration point locations & follows local + + // Matrix of integration point locations & follows local // conn - ipCoords(0,0) = -a; ipCoords(0,16) = -a; - ipCoords(1,0) = -a; ipCoords(1,16) = -a; + ipCoords(0,0) = -a; ipCoords(0,16) = -a; + ipCoords(1,0) = -a; ipCoords(1,16) = -a; ipCoords(2,0) = -a; ipCoords(2,16) = 0; - // - ipCoords(0,1) = a; ipCoords(0,17) = -a; - ipCoords(1,1) = -a; ipCoords(1,17) = a; + // + ipCoords(0,1) = a; ipCoords(0,17) = -a; + ipCoords(1,1) = -a; ipCoords(1,17) = a; ipCoords(2,1) = -a; ipCoords(2,17) = 0; - // - ipCoords(0,2) = a; ipCoords(0,18) = a; - ipCoords(1,2) = a; ipCoords(1,18) = -a; + // + ipCoords(0,2) = a; ipCoords(0,18) = a; + ipCoords(1,2) = a; ipCoords(1,18) = -a; ipCoords(2,2) = -a; ipCoords(2,18) = 0; - // - ipCoords(0,3) = -a; ipCoords(0,19) = a; - ipCoords(1,3) = a; ipCoords(1,19) = a; + // + ipCoords(0,3) = -a; ipCoords(0,19) = a; + ipCoords(1,3) = a; ipCoords(1,19) = a; ipCoords(2,3) = -a; ipCoords(2,19) = 0; - ipCoords(0,4) = -a; ipCoords(0,20) = 0; - ipCoords(1,4) = -a; ipCoords(1,20) = 0; + ipCoords(0,4) = -a; ipCoords(0,20) = 0; + ipCoords(1,4) = -a; ipCoords(1,20) = 0; ipCoords(2,4) = a; ipCoords(2,20) = -a; - - ipCoords(0,5) = a; ipCoords(0,21) = 0; - ipCoords(1,5) = -a; ipCoords(1,21) = 0; + + ipCoords(0,5) = a; ipCoords(0,21) = 0; + ipCoords(1,5) = -a; ipCoords(1,21) = 0; ipCoords(2,5) = a; ipCoords(2,21) = a; - - ipCoords(0,6) = a; ipCoords(0,22) = 0; - ipCoords(1,6) = a; ipCoords(1,22) = -a; + + ipCoords(0,6) = a; ipCoords(0,22) = 0; + ipCoords(1,6) = a; ipCoords(1,22) = -a; ipCoords(2,6) = a; ipCoords(2,22) = 0; - - ipCoords(0,7) = -a; ipCoords(0,23) = 0; - ipCoords(1,7) = a; ipCoords(1,23) = a; + + ipCoords(0,7) = -a; ipCoords(0,23) = 0; + ipCoords(1,7) = a; ipCoords(1,23) = a; ipCoords(2,7) = a; ipCoords(2,23) = 0; - ipCoords(0,8) = 0; ipCoords(0,24) = -a; - ipCoords(1,8) = -a; ipCoords(1,24) = 0; + ipCoords(0,8) = 0; ipCoords(0,24) = -a; + ipCoords(1,8) = -a; ipCoords(1,24) = 0; ipCoords(2,8) = -a; ipCoords(2,24) = 0; - - ipCoords(0,9) = 0; ipCoords(0,25) = a; - ipCoords(1,9) = -a; ipCoords(1,25) = 0; + + ipCoords(0,9) = 0; ipCoords(0,25) = a; + ipCoords(1,9) = -a; ipCoords(1,25) = 0; ipCoords(2,9) = a; ipCoords(2,25) = 0; - - ipCoords(0,10) = 0; ipCoords(0,26) = 0; - ipCoords(1,10) = a; ipCoords(1,26) = 0; + + ipCoords(0,10) = 0; ipCoords(0,26) = 0; + ipCoords(1,10) = a; ipCoords(1,26) = 0; ipCoords(2,10) = -a; ipCoords(2,26) = 0; - - ipCoords(0,11) = 0; - ipCoords(1,11) = a; - ipCoords(2,11) = a; + + ipCoords(0,11) = 0; + ipCoords(1,11) = a; + ipCoords(2,11) = a; ipCoords(0,12) = -a; ipCoords(1,12) = 0; ipCoords(2,12) = -a; - + ipCoords(0,13) = -a; ipCoords(1,13) = 0; ipCoords(2,13) = a; - + ipCoords(0,14) = a; ipCoords(1,14) = 0; ipCoords(2,14) = -a; - + ipCoords(0,15) = a; ipCoords(1,15) = 0; ipCoords(2,15) = a; // Integration points by face - ipFaceCoords[0](0,0) = -1; ipFaceCoords[0](0,5) = -1; - ipFaceCoords[0](1,0) = -a; ipFaceCoords[0](1,5) = 0; + ipFaceCoords[0](0,0) = -1; ipFaceCoords[0](0,5) = -1; + ipFaceCoords[0](1,0) = -a; ipFaceCoords[0](1,5) = 0; ipFaceCoords[0](2,0) = -a; ipFaceCoords[0](2,5) = a; - // - ipFaceCoords[0](0,1) = -1; ipFaceCoords[0](0,6) = -1; - ipFaceCoords[0](1,1) = a; ipFaceCoords[0](1,6) = -a; - ipFaceCoords[0](2,1) = -a; ipFaceCoords[0](2,6) = 0; - // - ipFaceCoords[0](0,2) = -1; ipFaceCoords[0](0,7) = -1; - ipFaceCoords[0](1,2) = a; ipFaceCoords[0](1,7) = a; - ipFaceCoords[0](2,2) = a; ipFaceCoords[0](2,7) = 0; - // - ipFaceCoords[0](0,3) = -1; ipFaceCoords[0](0,8) = -1; - ipFaceCoords[0](1,3) = -a; ipFaceCoords[0](1,8) = 0; - ipFaceCoords[0](2,3) = a; ipFaceCoords[0](2,8) = 0; // - ipFaceCoords[0](0,4) = -1; - ipFaceCoords[0](1,4) = 0; - ipFaceCoords[0](2,4) = -a; - - ipFaceCoords[1](0,0) = 1; ipFaceCoords[1](0,5) = 1; - ipFaceCoords[1](1,0) = -a; ipFaceCoords[1](1,5) = 0; + ipFaceCoords[0](0,1) = -1; ipFaceCoords[0](0,6) = -1; + ipFaceCoords[0](1,1) = a; ipFaceCoords[0](1,6) = -a; + ipFaceCoords[0](2,1) = -a; ipFaceCoords[0](2,6) = 0; + // + ipFaceCoords[0](0,2) = -1; ipFaceCoords[0](0,7) = -1; + ipFaceCoords[0](1,2) = a; ipFaceCoords[0](1,7) = a; + ipFaceCoords[0](2,2) = a; ipFaceCoords[0](2,7) = 0; + // + ipFaceCoords[0](0,3) = -1; ipFaceCoords[0](0,8) = -1; + ipFaceCoords[0](1,3) = -a; ipFaceCoords[0](1,8) = 0; + ipFaceCoords[0](2,3) = a; ipFaceCoords[0](2,8) = 0; + // + ipFaceCoords[0](0,4) = -1; + ipFaceCoords[0](1,4) = 0; + ipFaceCoords[0](2,4) = -a; + + ipFaceCoords[1](0,0) = 1; ipFaceCoords[1](0,5) = 1; + ipFaceCoords[1](1,0) = -a; ipFaceCoords[1](1,5) = 0; ipFaceCoords[1](2,0) = -a; ipFaceCoords[1](2,5) = a; - // - ipFaceCoords[1](0,1) = 1; ipFaceCoords[1](0,6) = 1; - ipFaceCoords[1](1,1) = a; ipFaceCoords[1](1,6) = -a; - ipFaceCoords[1](2,1) = -a; ipFaceCoords[1](2,6) = 0; - // - ipFaceCoords[1](0,2) = 1; ipFaceCoords[1](0,7) = 1; - ipFaceCoords[1](1,2) = a; ipFaceCoords[1](1,7) = a; - ipFaceCoords[1](2,2) = a; ipFaceCoords[1](2,7) = 0; - // - ipFaceCoords[1](0,3) = 1; ipFaceCoords[1](0,8) = 1; - ipFaceCoords[1](1,3) = -a; ipFaceCoords[1](1,8) = 0; - ipFaceCoords[1](2,3) = a; ipFaceCoords[1](2,8) = 0; // - ipFaceCoords[1](0,4) = 1; - ipFaceCoords[1](1,4) = 0; - ipFaceCoords[1](2,4) = -a; - - ipFaceCoords[2](0,0) = -a; ipFaceCoords[2](0,5) = 0; - ipFaceCoords[2](1,0) = -1; ipFaceCoords[2](1,5) = -1; + ipFaceCoords[1](0,1) = 1; ipFaceCoords[1](0,6) = 1; + ipFaceCoords[1](1,1) = a; ipFaceCoords[1](1,6) = -a; + ipFaceCoords[1](2,1) = -a; ipFaceCoords[1](2,6) = 0; + // + ipFaceCoords[1](0,2) = 1; ipFaceCoords[1](0,7) = 1; + ipFaceCoords[1](1,2) = a; ipFaceCoords[1](1,7) = a; + ipFaceCoords[1](2,2) = a; ipFaceCoords[1](2,7) = 0; + // + ipFaceCoords[1](0,3) = 1; ipFaceCoords[1](0,8) = 1; + ipFaceCoords[1](1,3) = -a; ipFaceCoords[1](1,8) = 0; + ipFaceCoords[1](2,3) = a; ipFaceCoords[1](2,8) = 0; + // + ipFaceCoords[1](0,4) = 1; + ipFaceCoords[1](1,4) = 0; + ipFaceCoords[1](2,4) = -a; + + ipFaceCoords[2](0,0) = -a; ipFaceCoords[2](0,5) = 0; + ipFaceCoords[2](1,0) = -1; ipFaceCoords[2](1,5) = -1; ipFaceCoords[2](2,0) = -a; ipFaceCoords[2](2,5) = a; - // - ipFaceCoords[2](0,1) = -a; ipFaceCoords[2](0,6) = -a; - ipFaceCoords[2](1,1) = -1; ipFaceCoords[2](1,6) = -1; - ipFaceCoords[2](2,1) = a; ipFaceCoords[2](2,6) = 0; - // - ipFaceCoords[2](0,2) = a; ipFaceCoords[2](0,7) = a; - ipFaceCoords[2](1,2) = -1; ipFaceCoords[2](1,7) = -1; - ipFaceCoords[2](2,2) = a; ipFaceCoords[2](2,7) = 0; - // - ipFaceCoords[2](0,3) = a; ipFaceCoords[2](0,8) = 0; - ipFaceCoords[2](1,3) = -1; ipFaceCoords[2](1,8) = -1; - ipFaceCoords[2](2,3) = -a; ipFaceCoords[2](2,8) = 0; - // - ipFaceCoords[2](0,4) = 0; - ipFaceCoords[2](1,4) = -1; - ipFaceCoords[2](2,4) = -a; - - ipFaceCoords[3](0,0) = -a; ipFaceCoords[3](0,5) = 0; - ipFaceCoords[3](1,0) = 1; ipFaceCoords[3](1,5) = 1; + // + ipFaceCoords[2](0,1) = -a; ipFaceCoords[2](0,6) = -a; + ipFaceCoords[2](1,1) = -1; ipFaceCoords[2](1,6) = -1; + ipFaceCoords[2](2,1) = a; ipFaceCoords[2](2,6) = 0; + // + ipFaceCoords[2](0,2) = a; ipFaceCoords[2](0,7) = a; + ipFaceCoords[2](1,2) = -1; ipFaceCoords[2](1,7) = -1; + ipFaceCoords[2](2,2) = a; ipFaceCoords[2](2,7) = 0; + // + ipFaceCoords[2](0,3) = a; ipFaceCoords[2](0,8) = 0; + ipFaceCoords[2](1,3) = -1; ipFaceCoords[2](1,8) = -1; + ipFaceCoords[2](2,3) = -a; ipFaceCoords[2](2,8) = 0; + // + ipFaceCoords[2](0,4) = 0; + ipFaceCoords[2](1,4) = -1; + ipFaceCoords[2](2,4) = -a; + + ipFaceCoords[3](0,0) = -a; ipFaceCoords[3](0,5) = 0; + ipFaceCoords[3](1,0) = 1; ipFaceCoords[3](1,5) = 1; ipFaceCoords[3](2,0) = -a; ipFaceCoords[3](2,5) = a; - // - ipFaceCoords[3](0,1) = -a; ipFaceCoords[3](0,6) = -a; - ipFaceCoords[3](1,1) = 1; ipFaceCoords[3](1,6) = 1; - ipFaceCoords[3](2,1) = a; ipFaceCoords[3](2,6) = 0; - // - ipFaceCoords[3](0,2) = a; ipFaceCoords[3](0,7) = a; - ipFaceCoords[3](1,2) = 1; ipFaceCoords[3](1,7) = 1; - ipFaceCoords[3](2,2) = a; ipFaceCoords[3](2,7) = 0; - // - ipFaceCoords[3](0,3) = a; ipFaceCoords[3](0,8) = 0; - ipFaceCoords[3](1,3) = 1; ipFaceCoords[3](1,8) = 1; - ipFaceCoords[3](2,3) = -a; ipFaceCoords[3](2,8) = 0; - // - ipFaceCoords[3](0,4) = 0; - ipFaceCoords[3](1,4) = 1; - ipFaceCoords[3](2,4) = -a; - + // + ipFaceCoords[3](0,1) = -a; ipFaceCoords[3](0,6) = -a; + ipFaceCoords[3](1,1) = 1; ipFaceCoords[3](1,6) = 1; + ipFaceCoords[3](2,1) = a; ipFaceCoords[3](2,6) = 0; + // + ipFaceCoords[3](0,2) = a; ipFaceCoords[3](0,7) = a; + ipFaceCoords[3](1,2) = 1; ipFaceCoords[3](1,7) = 1; + ipFaceCoords[3](2,2) = a; ipFaceCoords[3](2,7) = 0; + // + ipFaceCoords[3](0,3) = a; ipFaceCoords[3](0,8) = 0; + ipFaceCoords[3](1,3) = 1; ipFaceCoords[3](1,8) = 1; + ipFaceCoords[3](2,3) = -a; ipFaceCoords[3](2,8) = 0; + // + ipFaceCoords[3](0,4) = 0; + ipFaceCoords[3](1,4) = 1; + ipFaceCoords[3](2,4) = -a; + ipFaceCoords[4](0,0) = -a; ipFaceCoords[4](0,5) = 0; ipFaceCoords[4](1,0) = -a; ipFaceCoords[4](1,5) = a; ipFaceCoords[4](2,0) = -1; ipFaceCoords[4](2,5) = -1; - // + // ipFaceCoords[4](0,1) = a; ipFaceCoords[4](0,6) = -a; ipFaceCoords[4](1,1) = -a; ipFaceCoords[4](1,6) = 0; ipFaceCoords[4](2,1) = -1; ipFaceCoords[4](2,6) = -1; - // + // ipFaceCoords[4](0,2) = a; ipFaceCoords[4](0,7) = a; ipFaceCoords[4](1,2) = a; ipFaceCoords[4](1,7) = 0; ipFaceCoords[4](2,2) = -1; ipFaceCoords[4](2,7) = -1; - // + // ipFaceCoords[4](0,3) = -a; ipFaceCoords[4](0,8) = 0; ipFaceCoords[4](1,3) = a; ipFaceCoords[4](1,8) = 0; ipFaceCoords[4](2,3) = -1; ipFaceCoords[4](2,8) = -1; @@ -445,19 +445,19 @@ namespace ATC { ipFaceCoords[4](0,4) = 0; ipFaceCoords[4](1,4) = -a; ipFaceCoords[4](2,4) = -1; - + ipFaceCoords[5](0,0) = -a; ipFaceCoords[5](0,5) = 0; ipFaceCoords[5](1,0) = -a; ipFaceCoords[5](1,5) = a; ipFaceCoords[5](2,0) = 1; ipFaceCoords[5](2,5) = 1; - // + // ipFaceCoords[5](0,1) = a; ipFaceCoords[5](0,6) = -a; ipFaceCoords[5](1,1) = -a; ipFaceCoords[5](1,6) = 0; ipFaceCoords[5](2,1) = 1; ipFaceCoords[5](2,6) = 1; - // + // ipFaceCoords[5](0,2) = a; ipFaceCoords[5](0,7) = a; ipFaceCoords[5](1,2) = a; ipFaceCoords[5](1,7) = 0; ipFaceCoords[5](2,2) = 1; ipFaceCoords[5](2,7) = 1; - // + // ipFaceCoords[5](0,3) = -a; ipFaceCoords[5](0,8) = 0; ipFaceCoords[5](1,3) = a; ipFaceCoords[5](1,8) = 0; ipFaceCoords[5](2,3) = 1; ipFaceCoords[5](2,8) = 1; @@ -465,23 +465,23 @@ namespace ATC { ipFaceCoords[5](0,4) = 0; ipFaceCoords[5](1,4) = -a; ipFaceCoords[5](2,4) = 1; - - // Integration points for all faces ignoring the + + // Integration points for all faces ignoring the // redundant dim - ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,5) = 0; - ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,5) = a; - // - ipFace2DCoords(0,1) = a; ipFace2DCoords(0,6) = -a; - ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,6) = 0; + ipFace2DCoords(0,0) = -a; ipFace2DCoords(0,5) = 0; + ipFace2DCoords(1,0) = -a; ipFace2DCoords(1,5) = a; // - ipFace2DCoords(0,2) = a; ipFace2DCoords(0,7) = a; - ipFace2DCoords(1,2) = a; ipFace2DCoords(1,7) = 0; - // - ipFace2DCoords(0,3) = -a; ipFace2DCoords(0,8) = 0; - ipFace2DCoords(1,3) = a; ipFace2DCoords(1,8) = 0; - // - ipFace2DCoords(0,4) = 0; - ipFace2DCoords(1,4) = -a; + ipFace2DCoords(0,1) = a; ipFace2DCoords(0,6) = -a; + ipFace2DCoords(1,1) = -a; ipFace2DCoords(1,6) = 0; + // + ipFace2DCoords(0,2) = a; ipFace2DCoords(0,7) = a; + ipFace2DCoords(1,2) = a; ipFace2DCoords(1,7) = 0; + // + ipFace2DCoords(0,3) = -a; ipFace2DCoords(0,8) = 0; + ipFace2DCoords(1,3) = a; ipFace2DCoords(1,8) = 0; + // + ipFace2DCoords(0,4) = 0; + ipFace2DCoords(1,4) = -a; // Integration point weights for (int i=0; i & rhsMask // copy + const Array2D< bool > & rhsMask // copy ) : atc_(atc), feEngine_(feEngine), @@ -35,20 +35,20 @@ FieldEulerIntegrator::FieldEulerIntegrator( // ==================================================================== FieldExplicitEulerIntegrator::FieldExplicitEulerIntegrator( const FieldName fieldName, - const PhysicsModel * physicsModel, + const PhysicsModel * physicsModel, /*const*/ FE_Engine * feEngine, /*const*/ ATC_Coupling * atc, - const Array2D< bool > & rhsMask // copy + const Array2D< bool > & rhsMask // copy ) : FieldEulerIntegrator(fieldName,physicsModel,feEngine,atc,rhsMask) { } // -------------------------------------------------------------------- -// update +// update // -------------------------------------------------------------------- void FieldExplicitEulerIntegrator::update(const double dt, double /* time */, FIELDS & fields, FIELDS & rhs) -{ +{ // write and add update mass matrix to handled time variation // update mass matrix to be consistent/lumped, and handle this in apply_inverse_mass_matrix atc_->compute_rhs_vector(rhsMask_, fields, rhs, @@ -63,14 +63,14 @@ FieldExplicitEulerIntegrator::FieldExplicitEulerIntegrator( // ==================================================================== FieldImplicitEulerIntegrator::FieldImplicitEulerIntegrator( const FieldName fieldName, - const PhysicsModel * physicsModel, + const PhysicsModel * physicsModel, /*const*/ FE_Engine * feEngine, /*const*/ ATC_Coupling * atc, - const Array2D< bool > & rhsMask, // copy + const Array2D< bool > & rhsMask, // copy const double alpha ) : FieldEulerIntegrator(fieldName,physicsModel,feEngine,atc,rhsMask), alpha_(alpha), - dT_(1.0e-6), + dT_(1.0e-6), maxRestarts_(50), maxIterations_(1000), tol_(1.0e-8) @@ -78,17 +78,17 @@ FieldImplicitEulerIntegrator::FieldImplicitEulerIntegrator( } // -------------------------------------------------------------------- -// update +// update // -------------------------------------------------------------------- void FieldImplicitEulerIntegrator::update(const double dt, double time, - FIELDS & fields, FIELDS & /* rhs */) + FIELDS & fields, FIELDS & /* rhs */) { // solver handles bcs - FieldImplicitSolveOperator solver(atc_, + FieldImplicitSolveOperator solver(atc_, fields, fieldName_, rhsMask_, physicsModel_, time, dt, alpha_); DiagonalMatrix preconditioner = solver.preconditioner(); DENS_VEC rT = solver.r(); - DENS_VEC dT(nNodes_); dT = dT_; + DENS_VEC dT(nNodes_); dT = dT_; DENS_MAT H(maxRestarts_+1, maxRestarts_); double tol = tol_; // tol returns the residual int iterations = maxIterations_; // iterations returns number of iterations @@ -106,10 +106,10 @@ void FieldImplicitEulerIntegrator::update(const double dt, double time, // ==================================================================== FieldImplicitDirectEulerIntegrator::FieldImplicitDirectEulerIntegrator( const FieldName fieldName, - const PhysicsModel * physicsModel, + const PhysicsModel * physicsModel, /*const*/ FE_Engine * feEngine, /*const*/ ATC_Coupling * atc, - const Array2D< bool > & rhsMask, // copy + const Array2D< bool > & rhsMask, // copy const double alpha ) : FieldEulerIntegrator(fieldName,physicsModel,feEngine,atc,rhsMask), alpha_(alpha),solver_(nullptr) @@ -125,24 +125,24 @@ FieldImplicitDirectEulerIntegrator::~FieldImplicitDirectEulerIntegrator() } // -------------------------------------------------------------------- -// initialize +// initialize // -------------------------------------------------------------------- void FieldImplicitDirectEulerIntegrator::initialize(const double dt, double /* time */, - FIELDS & /* fields */) -{ + FIELDS & /* fields */) +{ std::pair p(fieldName_,fieldName_); Array2D rmask = atc_->rhs_mask(); - rmask(fieldName_,FLUX) = true; + rmask(fieldName_,FLUX) = true; atc_->tangent_matrix(p,rmask,physicsModel_,_K_); _lhsMK_ = (1./dt)*(_M_)- alpha_*(_K_); _rhsMK_ = (1./dt)*(_M_)+(1.+alpha_)*(_K_); } // -------------------------------------------------------------------- -// update +// update // -------------------------------------------------------------------- void FieldImplicitDirectEulerIntegrator::update(const double /* dt */, double /* time */, - FIELDS & fields, FIELDS & rhs) -{ + FIELDS & fields, FIELDS & rhs) +{ atc_->compute_rhs_vector(rhsMask_, fields, rhs, FULL_DOMAIN, physicsModel_); CLON_VEC myRhs = column( rhs[fieldName_].set_quantity(),0); diff --git a/lib/atc/FieldEulerIntegrator.h b/lib/atc/FieldEulerIntegrator.h index fc3863311c..23df8a1c18 100644 --- a/lib/atc/FieldEulerIntegrator.h +++ b/lib/atc/FieldEulerIntegrator.h @@ -60,7 +60,7 @@ class FieldEulerIntegrator { const PhysicsModel * physicsModel_; /** field name */ - FieldName fieldName_; + FieldName fieldName_; /** rhs mask */ Array2D rhsMask_; diff --git a/lib/atc/FieldManager.cpp b/lib/atc/FieldManager.cpp index 8a7fb0d50b..c8874d49d2 100644 --- a/lib/atc/FieldManager.cpp +++ b/lib/atc/FieldManager.cpp @@ -22,7 +22,7 @@ typedef PerAtomQuantity PAQ; //----------------------------------------------------------------------------- //* restricted_atom_quantity //----------------------------------------------------------------------------- - DENS_MAN * FieldManager::restricted_atom_quantity(FieldName field, string name, PAQ * atomicQuantity) + DENS_MAN * FieldManager::restricted_atom_quantity(FieldName field, string name, PAQ * atomicQuantity) { if (name == "default") { name = field_to_restriction_name(field); } DENS_MAN * quantity = interscaleManager_.dense_matrix(name); @@ -35,7 +35,7 @@ typedef PerAtomQuantity PAQ; atomicQuantity = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS); } else { - + if (!atomicQuantity) { throw ATC_Error("FieldManager::restricted_atom_quantity - need to supply PAQ if restricted quantity does not already exist"); } @@ -68,18 +68,18 @@ typedef PerAtomQuantity PAQ; if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { - quantity = new OnTheFlyKernelAccumulationNormalized(atc_, atomic, - atc_->kernel_function(), - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyKernelAccumulationNormalized(atc_, atomic, + atc_->kernel_function(), + atc_->atom_coarsegraining_positions(), normalization); } else { - quantity = new OnTheFlyMeshAccumulationNormalized(atc_, atomic, - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyMeshAccumulationNormalized(atc_, atomic, + atc_->atom_coarsegraining_positions(), normalization); } } else { - quantity = new AtfProjection(atc_, atomic, - atc_->accumulant(), + quantity = new AtfProjection(atc_, atomic, + atc_->accumulant(), normalization); } interscaleManager_.add_dense_matrix(quantity,name); @@ -102,21 +102,21 @@ typedef PerAtomQuantity PAQ; } else if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { - quantity = new OnTheFlyKernelAccumulationNormalizedReferenced(atc_, - atomic, - atc_->kernel_function(), - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyKernelAccumulationNormalizedReferenced(atc_, + atomic, + atc_->kernel_function(), + atc_->atom_coarsegraining_positions(), normalization, reference); } else { - quantity = new OnTheFlyMeshAccumulationNormalizedReferenced(atc_, - atomic, - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyMeshAccumulationNormalizedReferenced(atc_, + atomic, + atc_->atom_coarsegraining_positions(), normalization, reference); } } else { - quantity = new AtfProjectionReferenced(atc_, atomic, + quantity = new AtfProjectionReferenced(atc_, atomic, atc_->accumulant(), reference, normalization); @@ -141,14 +141,14 @@ typedef PerAtomQuantity PAQ; } else if (atc_->kernel_on_the_fly()) { if (atc_->kernel_based()) { - quantity = new OnTheFlyKernelAccumulationNormalizedScaled(atc_, atomic, - atc_->kernel_function(), - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyKernelAccumulationNormalizedScaled(atc_, atomic, + atc_->kernel_function(), + atc_->atom_coarsegraining_positions(), normalization, scale); } else { - quantity = new OnTheFlyMeshAccumulationNormalizedScaled(atc_, atomic, - atc_->atom_coarsegraining_positions(), + quantity = new OnTheFlyMeshAccumulationNormalizedScaled(atc_, atomic, + atc_->atom_coarsegraining_positions(), normalization, scale); } @@ -203,7 +203,7 @@ typedef PerAtomQuantity PAQ; return projected_atom_quantity(NUMBER_DENSITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- -//* MOMENTUM +//* MOMENTUM //----------------------------------------------------------------------------- DENS_MAN * FieldManager::momentum(string name) { @@ -215,7 +215,7 @@ typedef PerAtomQuantity PAQ; return projected_atom_quantity(MOMENTUM,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- -//* VELOCITY +//* VELOCITY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::velocity(string name) { @@ -243,7 +243,7 @@ typedef PerAtomQuantity PAQ; return v; } //----------------------------------------------------------------------------- -//* PROJECTED_VELOCITY +//* PROJECTED_VELOCITY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::projected_velocity(string name) { @@ -251,7 +251,7 @@ typedef PerAtomQuantity PAQ; return projected_atom_quantity(PROJECTED_VELOCITY,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- -//* DISPLACEMENT +//* DISPLACEMENT //----------------------------------------------------------------------------- DENS_MAN * FieldManager::displacement(string name) { @@ -261,8 +261,8 @@ typedef PerAtomQuantity PAQ; PAQ * atomic = interscaleManager_.per_atom_quantity("AtomicMassWeightedDisplacement"); if (!atomic) { - FundamentalAtomQuantity * atomMasses = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS); - FundamentalAtomQuantity * atomPositions = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION); + FundamentalAtomQuantity * atomMasses = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_MASS); + FundamentalAtomQuantity * atomPositions = interscaleManager_.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION); atomic = new AtomicMassWeightedDisplacement(atc_,atomPositions, atomMasses, atc_->atom_reference_positions(), INTERNAL); interscaleManager_.add_per_atom_quantity(atomic,"AtomicMassWeightedDisplacement"); } @@ -296,12 +296,12 @@ typedef PerAtomQuantity PAQ; return u; } //----------------------------------------------------------------------------- -//* REFERENCE_POTENTIAL_ENERGY +//* REFERENCE_POTENTIAL_ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::reference_potential_energy(string /* name */) { DENS_MAN * rpe = interscaleManager_.dense_matrix(field_to_string(REFERENCE_POTENTIAL_ENERGY)); - if (! rpe ) { + if (! rpe ) { PAQ * atomic = interscaleManager_.per_atom_quantity("AtomicReferencePotential"); if (!atomic) { atomic = new AtcAtomQuantity(atc_); @@ -334,7 +334,7 @@ typedef PerAtomQuantity PAQ; return rpe; } //----------------------------------------------------------------------------- -//* POTENTIAL_ENERGY +//* POTENTIAL_ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::potential_energy(string name) { @@ -352,7 +352,7 @@ typedef PerAtomQuantity PAQ; } } //----------------------------------------------------------------------------- -//* TEMPERATURE +//* TEMPERATURE //----------------------------------------------------------------------------- DENS_MAN * FieldManager::temperature(string name) { @@ -367,10 +367,10 @@ typedef PerAtomQuantity 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,atc_->accumulant_weights()); + return scaled_projected_atom_quantity(KINETIC_TEMPERATURE,name,atomic,Tcoef,atc_->accumulant_weights()); } //----------------------------------------------------------------------------- -//* THERMAL_ENERGY +//* THERMAL_ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::thermal_energy(string name) { @@ -379,7 +379,7 @@ typedef PerAtomQuantity PAQ; return scaled_projected_atom_quantity(THERMAL_ENERGY,name,atomic,Ecoef,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- -//* KINETIC_ENERGY +//* KINETIC_ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::kinetic_energy(string name) { @@ -405,7 +405,7 @@ typedef PerAtomQuantity PAQ; return projected_atom_quantity(SPECIES_FLUX,name,atomic,atc_->accumulant_inverse_volumes()); } //----------------------------------------------------------------------------- -//* INTERNAL_ENERGY +//* INTERNAL_ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::internal_energy(string name) { @@ -417,7 +417,7 @@ typedef PerAtomQuantity PAQ; return ie; } //----------------------------------------------------------------------------- -//* ENERGY +//* ENERGY //----------------------------------------------------------------------------- DENS_MAN * FieldManager::energy(string name) { @@ -454,7 +454,7 @@ typedef PerAtomQuantity PAQ; return atomic; } //----------------------------------------------------------------------------- -//* 2 KE +//* 2 KE //----------------------------------------------------------------------------- PAQ * FieldManager::atomic_twice_kinetic_energy() { @@ -503,7 +503,7 @@ typedef PerAtomQuantity PAQ; PAQ * atomic = interscaleManager_.per_atom_quantity("AtomicSpeciesVelocity"); if (!atomic) { PAQ * atomVelocity = atomic_fluctuating_velocity(); - PAQ * atomSpecies = atomic_species_vector(); + PAQ * atomSpecies = atomic_species_vector(); atomic = new SpeciesVelocity(atc_,atomVelocity,atomSpecies); interscaleManager_.add_per_atom_quantity(atomic, "AtomicSpeciesVelocity"); } @@ -529,8 +529,8 @@ typedef PerAtomQuantity PAQ; { PAQ * quantity = interscaleManager_.per_atom_quantity(field_to_prolongation_name(field)); if (!quantity) { - - + + DENS_MAN * coarseQuantity = interscaleManager_.dense_matrix(field_to_string(field)); if (!coarseQuantity) coarseQuantity = nodal_atomic_field(field); if (!coarseQuantity) throw ATC_Error("can not prolong quantity: " + field_to_string(field) + " no field registered"); diff --git a/lib/atc/FieldManager.h b/lib/atc/FieldManager.h index b12db230c5..9deb6acc0a 100644 --- a/lib/atc/FieldManager.h +++ b/lib/atc/FieldManager.h @@ -17,7 +17,7 @@ namespace ATC { PROLONGED_VELOCITY}; typedef PerAtomQuantity PAQ; /** - * @class FieldManager + * @class FieldManager * @brief Manager for constructing fields from atomic data */ class FieldManager{ @@ -26,7 +26,7 @@ namespace ATC { FieldManager(ATC_Method * atc); virtual ~FieldManager(void){}; /** this function returns a (density) field derived from atomic data */ - DENS_MAN * nodal_atomic_field(FieldName fieldName, + DENS_MAN * nodal_atomic_field(FieldName fieldName, std::string name = "default") { switch (fieldName) { case CHARGE_DENSITY: return charge_density(name); @@ -51,17 +51,17 @@ namespace ATC { } } CanonicalName string_to_canonical_name(std::string name){ - if (name == "AtomicTwiceFluctuatingKineticEnergy") + if (name == "AtomicTwiceFluctuatingKineticEnergy") return ATOMIC_TWICE_FLUCTUATING_KINETIC_ENERGY; - else if (name == "AtomicTwiceKineticEnergy") + else if (name == "AtomicTwiceKineticEnergy") return ATOMIC_TWICE_KINETIC_ENERGY; - else if (name == "AtomicTwiceKineticEnergy") + else if (name == "AtomicTwiceKineticEnergy") return ATOMIC_TWICE_KINETIC_ENERGY; - else if (name == "AtomicFluctuatingVelocity") + else if (name == "AtomicFluctuatingVelocity") return ATOMIC_FLUCTUATING_VELOCITY; else if (name == "AtomicChargeVelocity") // ionic current return ATOMIC_CHARGE_VELOCITY; - else if (name == "AtomicSpeciesVelocity") // per species momentum + else if (name == "AtomicSpeciesVelocity") // per species momentum return ATOMIC_SPECIES_VELOCITY; else if (name == field_to_prolongation_name(VELOCITY)) return PROLONGED_VELOCITY; @@ -70,11 +70,11 @@ namespace ATC { } PAQ * per_atom_quantity(std::string name) { switch (string_to_canonical_name(name)) { - case ATOMIC_TWICE_FLUCTUATING_KINETIC_ENERGY: + case ATOMIC_TWICE_FLUCTUATING_KINETIC_ENERGY: return atomic_twice_fluctuating_kinetic_energy(); - case ATOMIC_TWICE_KINETIC_ENERGY: + case ATOMIC_TWICE_KINETIC_ENERGY: return atomic_twice_kinetic_energy(); - case ATOMIC_FLUCTUATING_VELOCITY: + case ATOMIC_FLUCTUATING_VELOCITY: return atomic_fluctuating_velocity(); case ATOMIC_CHARGE_VELOCITY: return atomic_charge_velocity(); @@ -82,7 +82,7 @@ namespace ATC { return atomic_species_velocity(); case PROLONGED_VELOCITY: return prolonged_field(VELOCITY); - default: + default: throw ATC_Error("FieldManager:: unknown PAQ"); return nullptr; } } diff --git a/lib/atc/Function.cpp b/lib/atc/Function.cpp index e73d64aaea..fb26cc0a18 100644 --- a/lib/atc/Function.cpp +++ b/lib/atc/Function.cpp @@ -89,7 +89,7 @@ namespace ATC { UXT_Function* UXT_Function_Mgr::copy_UXT_function(UXT_Function* other) { string tag = other->tag(); - + UXT_Function * returnFunction = nullptr; if (tag=="linear") { ScalarLinearFunction * other_cast = (ScalarLinearFunction*) other; @@ -103,7 +103,7 @@ namespace ATC { // ScalarLinearFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - ScalarLinearFunction::ScalarLinearFunction(int narg, double* args) + ScalarLinearFunction::ScalarLinearFunction(int narg, double* args) : UXT_Function(narg,args) { tag_ = "linear"; @@ -119,19 +119,19 @@ namespace ATC { // XT_Function //-------------------------------------------------------------------- //-------------------------------------------------------------------- - XT_Function::XT_Function(int narg, double* args) + XT_Function::XT_Function(int narg, double* args) { - if (narg > 5 ) { - x0[0] = args[0]; + if (narg > 5 ) { + x0[0] = args[0]; x0[1] = args[1]; x0[2] = args[2]; mask[0] = args[3]; mask[1] = args[4]; mask[2] = args[5]; - } + } else { - x0[0] = 0.0; + x0[0] = 0.0; x0[1] = 0.0; x0[2] = 0.0; mask[0] = 0.0; @@ -211,7 +211,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; double *dargs = (double *) alloca(sizeof(double) * narg); #endif for (int i = 0; i < narg; ++i) dargs[i] = atof(args[i+1]); - + return function(type, narg, dargs); } @@ -226,7 +226,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; XT_Function* XT_Function_Mgr::copy_XT_function(XT_Function* other) { string tag = other->tag(); - + XT_Function * returnFunction = nullptr; if (tag=="linear") { LinearFunction * other_cast = (LinearFunction*) other; @@ -268,14 +268,14 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // ConstantFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - ConstantFunction::ConstantFunction(int narg, double* args) + ConstantFunction::ConstantFunction(int narg, double* args) : XT_Function(narg,args), C0(args[0]) { tag_ = "constant"; } //-------------------------------------------------------------------- - ConstantFunction::ConstantFunction(double arg) + ConstantFunction::ConstantFunction(double arg) : XT_Function(1,&arg), C0(arg) { @@ -286,7 +286,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // LinearFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - LinearFunction::LinearFunction(int narg, double* args) + LinearFunction::LinearFunction(int narg, double* args) : XT_Function(narg,args) { C0 = args[6]; @@ -300,7 +300,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // PiecewiseLinearFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - PiecewiseLinearFunction::PiecewiseLinearFunction(int narg, double* args) + PiecewiseLinearFunction::PiecewiseLinearFunction(int narg, double* args) : XT_Function(narg,args) { int i=0, idx = 6, n = (narg-idx)/2; @@ -327,7 +327,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; if (index < 0) return fi(0); else if (index >= xi.size()-1 ) return fi(xi.size()-1); else { - double f = fi(index) + double f = fi(index) + (fi(index+1)-fi(index))*(s-xi(index))/(xi(index+1)-xi(index)); return f; } @@ -370,7 +370,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // QuadraticFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - QuadraticFunction::QuadraticFunction(int narg, double* args) + QuadraticFunction::QuadraticFunction(int narg, double* args) : XT_Function(narg,args) { C0 = args[6]; @@ -387,7 +387,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // SineFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - SineFunction::SineFunction(int narg, double* args) + SineFunction::SineFunction(int narg, double* args) : XT_Function(narg,args) { C = args[6]; @@ -403,7 +403,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // GaussianFunction //-------------------------------------------------------------------- //-------------------------------------------------------------------- - GaussianFunction::GaussianFunction(int narg, double* args) + GaussianFunction::GaussianFunction(int narg, double* args) : XT_Function(narg,args) { tau = args[6]; @@ -416,7 +416,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // GaussianTemporalRamp //-------------------------------------------------------------------- //-------------------------------------------------------------------- - GaussianTemporalRamp::GaussianTemporalRamp(int narg, double* args) + GaussianTemporalRamp::GaussianTemporalRamp(int narg, double* args) : GaussianFunction(narg,args) { tau_initial = args[9]; @@ -457,7 +457,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // TemporalRamp //-------------------------------------------------------------------- //-------------------------------------------------------------------- - TemporalRamp::TemporalRamp(int narg, double* args) + TemporalRamp::TemporalRamp(int narg, double* args) : XT_Function(narg,args) { f_initial = args[0]; @@ -471,7 +471,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; // RadialPower //-------------------------------------------------------------------- //-------------------------------------------------------------------- - RadialPower::RadialPower(int narg, double* args) + RadialPower::RadialPower(int narg, double* args) : XT_Function(narg,args) { C0 = args[6]; @@ -499,8 +499,8 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; fps_(i)=coef*fp; i++; } - // scale tangents - double dx, dx0 = xs_(1)-xs_(0); + // scale tangents + double dx, dx0 = xs_(1)-xs_(0); for (int i = 0; i < npts_ ; i++) { if (i == 0) { dx = xs_(1)-xs_(0); } else if (i+1 == npts_) { dx = xs_(npts_-1)-xs_(npts_-2); } @@ -512,14 +512,14 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; } - double InterpolationFunction::coordinate(double x, + double InterpolationFunction::coordinate(double x, double & f0, double & fp0, double & f1, double & fp1, double & inv_dx ) const { int i0 = xs_.index(x); int i1 = i0+1; if (i0 < 0) { double x0 = xs_(0), x1 = xs_(1); - inv_dx = 1./(x1-x0); + inv_dx = 1./(x1-x0); fp0 = fp1 = fps_(0); f1 = fs_(0); f0 = fp0*(x-xs_(0))+f1; @@ -527,7 +527,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; } else if (i1 >= npts_) { double x0 = xs_(npts_-2), x1 = xs_(npts_-1); - inv_dx = 1./(x1-x0); + inv_dx = 1./(x1-x0); fp0 = fp1 = fps_(i0); f0 = fs_(i0); f1 = fp0*(x-xs_(i0))+f0; @@ -535,7 +535,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; } else { double x0 = xs_(i0), x1 = xs_(i1); - inv_dx = 1./(x1-x0); + inv_dx = 1./(x1-x0); f0 = fs_ (i0); f1 = fs_ (i1); fp0 = fps_(i0); fp1 = fps_(i1); double t = (x-x0)*inv_dx; @@ -546,7 +546,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; { double f0,fp0,f1,fp1,inv_dx; double t = coordinate(x,f0,fp0,f1,fp1,inv_dx); - double t2 = t*t; + double t2 = t*t; double t3 = t*t2; double h00 = 2*t3 - 3*t2 + 1; double h10 = t3 - 2*t2 + t; @@ -559,7 +559,7 @@ XT_Function_Mgr * XT_Function_Mgr::myInstance_ = nullptr; { double f0,fp0,f1,fp1,inv_dx; double t = coordinate(x,f0,fp0,f1,fp1,inv_dx); - double t2 = t*t; + double t2 = t*t; double d00 = 6*t2 - 6*t; double d10 = 3*t2 - 4*t + 1; double d01 =-6*t2 + 6*t; diff --git a/lib/atc/Function.h b/lib/atc/Function.h index 0c654fa47c..7c40cf6c54 100644 --- a/lib/atc/Function.h +++ b/lib/atc/Function.h @@ -60,7 +60,7 @@ namespace ATC { }; - /** + /** * @class LinearFieldFunction * @brief Class for functions returning values linear a given field */ @@ -69,7 +69,7 @@ namespace ATC { public: LinearFieldFunction(int nargs, char** args); virtual ~LinearFieldFunction(void) {}; - + inline double f(double* u, double* /* x */, double /* t */) {return c1_*u[0]-c0_;} inline double dfd(FieldName /* field */, ARGS& /* args */) {return c1_;} @@ -124,16 +124,16 @@ namespace ATC { }; - /** + /** * @class ScalarLinearFunction - * @brief Class for functions returning values linear in space + * @brief Class for functions returning values linear in space */ class ScalarLinearFunction : public UXT_Function { public: ScalarLinearFunction(int nargs, double* args); virtual ~ScalarLinearFunction(void) {}; - + //inline double f(double* u, double* x, double t) {return c1_*(u[0]-c0_);} inline double f(double* u, double* /* x */, double /* t */) {return c1_*u[0]+c0_;} @@ -145,7 +145,7 @@ namespace ATC { /** * @class XT_Function - * @brief Base class for functions based on space and time variables + * @brief Base class for functions based on space and time variables */ class XT_Function { @@ -201,7 +201,7 @@ namespace ATC { /** * @class ConstantFunction - * @brief Class for functions returning constant values + * @brief Class for functions returning constant values */ class ConstantFunction : public XT_Function { @@ -209,33 +209,33 @@ namespace ATC { ConstantFunction(int nargs, double* args); ConstantFunction(double arg); virtual ~ConstantFunction(void) {}; - - inline double f(double* /* x */, double /* t */) + + inline double f(double* /* x */, double /* t */) {return C0;}; private : double C0; }; - /** + /** * @class LinearFunction - * @brief Class for functions returning values linear in space + * @brief Class for functions returning values linear in space */ class LinearFunction : public XT_Function { public: LinearFunction(int nargs, double* args); virtual ~LinearFunction(void) {}; - - double f(double* x, double /* t */) + + double f(double* x, double /* t */) {return mask[0]*(x[0]-x0[0])+mask[1]*(x[1]-x0[1])+mask[2]*(x[2]-x0[2]) + C0;}; private : double C0; }; - /** + /** * @class PiecewiseLinearFunction - * @brief Class for functions returning values piecewise linear in space + * @brief Class for functions returning values piecewise linear in space * along given direction */ @@ -243,31 +243,31 @@ namespace ATC { public: PiecewiseLinearFunction(int nargs, double* args); virtual ~PiecewiseLinearFunction(void) {}; - + double f(double* x, double t) ; private : - Array xi; - Array fi; + Array xi; + Array fi; }; - /** + /** * @class LinearTemporalRamp - * @brief Class for functions returning values linear in space and time + * @brief Class for functions returning values linear in space and time */ class LinearTemporalRamp : public XT_Function { public: LinearTemporalRamp(int nargs, double* args); ~LinearTemporalRamp(void) {}; - + double f(double* x, double t); double dfdt(double* x, double t); - + protected : double mask_slope[3]; double C0_initial, C0_slope; - + }; /** @@ -279,9 +279,9 @@ namespace ATC { public: QuadraticFunction(int nargs, double* args); virtual ~QuadraticFunction(void) {}; - - inline double f(double* x, double /* t */) - {return + + inline double f(double* x, double /* t */) + {return C2[0]*(x[0]-x0[0])*(x[0]-x0[0])+ C2[1]*(x[1]-x0[1])*(x[1]-x0[1])+ C2[2]*(x[2]-x0[2])*(x[2]-x0[2])+ @@ -295,7 +295,7 @@ namespace ATC { }; /** - * @class SineFunction + * @class SineFunction * @brief Class for functions returning values sinusoidally varying in space and time */ @@ -304,7 +304,7 @@ namespace ATC { SineFunction(int nargs, double* args); virtual ~SineFunction(void){}; - inline double f(double* x, double t) + inline double f(double* x, double t) {return C*sin( mask[0]*(x[0]-x0[0]) +mask[1]*(x[1]-x0[1]) +mask[2]*(x[2]-x0[2]) - w*t) + C0;}; @@ -324,7 +324,7 @@ namespace ATC { virtual ~GaussianFunction(void){}; // 1/(2 pi \sigma)^(n/2) exp(-1/2 x.x/\sigma^2 ) for n = dimension - inline double f(double* x, double /* t */) + inline double f(double* x, double /* t */) {return C*exp(-(mask[0]*(x[0]-x0[0])*(x[0]-x0[0]) +mask[1]*(x[1]-x0[1])*(x[1]-x0[1]) +mask[2]*(x[2]-x0[2])*(x[2]-x0[2]))/tau/tau) + C0;}; @@ -334,7 +334,7 @@ namespace ATC { }; /** - * @class GaussianTemporalRamp + * @class GaussianTemporalRamp * @brief Class for functions returning values according to a Gaussian distribution in space and linearly in time */ @@ -351,9 +351,9 @@ namespace ATC { double C_initial, C_slope; double C0_initial, C0_slope; }; - + /** - * @class TemporalRamp + * @class TemporalRamp * @brief Class for functions returning values constant in space and varying linearly in time */ @@ -361,11 +361,11 @@ namespace ATC { public: TemporalRamp(int nargs, double* args); virtual ~TemporalRamp(void) {}; - - inline double f(double* /* x */, double t) + + inline double f(double* /* x */, double t) {return f_initial + slope*t;}; - inline double dfdt(double* /* x */, double /* t */) + inline double dfdt(double* /* x */, double /* t */) {return slope;}; private : @@ -373,29 +373,29 @@ namespace ATC { }; /** - * @class RadialPower - * @brief Class for functions returning values based on distance from a fix point raised to a specified power + * @class RadialPower + * @brief Class for functions returning values based on distance from a fix point raised to a specified power */ class RadialPower : public XT_Function { public: RadialPower(int nargs, double* args); virtual ~RadialPower(void) {}; - - inline double f(double* x, double /* t */) + + inline double f(double* x, double /* t */) { double dx = x[0]-x0[0]; double dy = x[1]-x0[1]; double dz = x[2]-x0[2]; double r = mask[0]*dx*dx+mask[1]*dy*dy+mask[2]*dz*dz; r = sqrt(r); return C0*pow(r,n); }; - + private : double C0, n; }; /** * @class InterpolationFunction - * @brief Base class for interpolation functions + * @brief Base class for interpolation functions */ class InterpolationFunction { @@ -412,7 +412,7 @@ namespace ATC { double dfdt(const double t) const; protected: - double coordinate(double x, + double coordinate(double x, double & f0, double & fp0, double & f1, double & fp1, double & inv_dx) const; int npts_; Array xs_; diff --git a/lib/atc/FundamentalAtomicQuantity.cpp b/lib/atc/FundamentalAtomicQuantity.cpp index 63824bd0dd..108c0194ce 100644 --- a/lib/atc/FundamentalAtomicQuantity.cpp +++ b/lib/atc/FundamentalAtomicQuantity.cpp @@ -37,13 +37,13 @@ namespace ATC { if (atomType_ == ALL || atomType_ == PROC_GHOST) { if (nCols_==1) { // scalar double * lammpsQuantity = lammps_scalar(); - + for (int i = 0; i < atc_.nlocal_total(); i++) lammpsQuantity[i] = quantity_(i,0)/unitsConversion_; } else{ // vector double ** lammpsQuantity = lammps_vector(); - + for (int i = 0; i < atc_.nlocal_total(); i++) for (int j = 0; j < nCols_; j++) lammpsQuantity[i][j] = quantity_(i,j)/unitsConversion_; @@ -52,7 +52,7 @@ namespace ATC { // mapped copy else { int atomIndex; - + if (nCols_==1) { // scalar double * lammpsQuantity = lammps_scalar(); for (int i = 0; i < quantity_.nRows(); i++) { @@ -77,7 +77,7 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- // Class AtomMass - // Access-only operations when mass is + // Access-only operations when mass is // defined per type. //-------------------------------------------------------- //-------------------------------------------------------- @@ -98,7 +98,7 @@ namespace ATC { { const int * type = lammpsInterface_->atom_type(); const double * mass = lammpsInterface_->atom_mass(); - + if (atomType_ == ALL || atomType_ == PROC_GHOST) { for (int i = 0; i < quantity_.nRows(); i++) quantity_(i,0) = mass[type[i]]; diff --git a/lib/atc/FundamentalAtomicQuantity.h b/lib/atc/FundamentalAtomicQuantity.h index d5cf9f8a21..6a10b0e317 100644 --- a/lib/atc/FundamentalAtomicQuantity.h +++ b/lib/atc/FundamentalAtomicQuantity.h @@ -153,7 +153,7 @@ namespace ATC { // be initialized. //-------------------------------------------------------- //-------------------------------------------------------- - + class ComputedAtomQuantity : public ShallowAtomQuantity { public: @@ -220,7 +220,7 @@ namespace ATC { protected: /** pointer to Lammps compute, meant as rapid indexing only (do not use!) */ - COMPUTE_POINTER computePointer_; + COMPUTE_POINTER computePointer_; /** tag for Lammps compute */ std::string computeTag_; diff --git a/lib/atc/GMRES.h b/lib/atc/GMRES.h index a64fc70c00..269169047b 100644 --- a/lib/atc/GMRES.h +++ b/lib/atc/GMRES.h @@ -1,22 +1,22 @@ //***************************************************************** // Iterative template routine -- GMRES // -// GMRES solves the unsymmetric linear system Ax = b using the +// GMRES solves the unsymmetric linear system Ax = b using the // Generalized Minimum Residual method // -// GMRES follows the algorithm described on p. 20 of the +// GMRES follows the algorithm described on p. 20 of the // SIAM Templates book. // // The return value indicates convergence within max_iter (input) // iterations (0), or no convergence within max_iter iterations (1). // // Upon successful return, output arguments have the following values: -// +// // x -- approximate solution to Ax = b // max_iter -- the number of iterations performed before the // tolerance was reached // tol -- the residual after the final iteration -// +// //***************************************************************** #include @@ -29,12 +29,12 @@ template void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn); template < class Matrix, class Vector > -void +void Update(Vector &x, int k, Matrix &h, Vector &s, Vector v[]) { Vector y(s); - // Backsolve: + // Backsolve: for (int i = k; i >= 0; i--) { y(i) /= h(i,i); for (int j = i - 1; j >= 0; j--) @@ -47,7 +47,7 @@ Update(Vector &x, int k, Matrix &h, Vector &s, Vector v[]) template < class Real > -Real +Real abs(Real x) { return (x > 0 ? x : -x); @@ -56,7 +56,7 @@ abs(Real x) template < class Operator, class Vector, class Preconditioner, class Matrix, class Real > -int +int GMRES(const Operator &A, Vector &x, const Vector &b, const Preconditioner &M, Matrix &H, int &m, int &max_iter, Real &tol) @@ -64,15 +64,15 @@ GMRES(const Operator &A, Vector &x, const Vector &b, Real resid; int i, j = 1, k; Vector s(m+1), cs(m+1), sn(m+1), w; - + Vector p = inv(M)*b; Real normb = p.norm(); Vector r = inv(M) * (b - A * x); Real beta = r.norm(); - + if (normb == 0.0) normb = 1; - + if ((resid = r.norm() / normb) <= tol) { tol = resid; max_iter = 0; @@ -85,7 +85,7 @@ GMRES(const Operator &A, Vector &x, const Vector &b, v[0] = r * (1.0 / beta); // ??? r / beta s = 0.0; s(0) = beta; - + for (i = 0; i < m && j <= max_iter; i++, j++) { w = inv(M) * (A * v[i]); for (k = 0; k <= i; k++) { @@ -97,11 +97,11 @@ GMRES(const Operator &A, Vector &x, const Vector &b, for (k = 0; k < i; k++) ApplyPlaneRotation(H(k,i), H(k+1,i), cs(k), sn(k)); - + GeneratePlaneRotation(H(i,i), H(i+1,i), cs(i), sn(i)); ApplyPlaneRotation(H(i,i), H(i+1,i), cs(i), sn(i)); ApplyPlaneRotation(s(i), s(i+1), cs(i), sn(i)); - + if ((resid = abs(s(i+1)) / normb) < tol) { Update(x, i, H, s, v); tol = resid; @@ -120,14 +120,14 @@ GMRES(const Operator &A, Vector &x, const Vector &b, return 0; } } - + tol = resid; delete [] v; return 1; } -template +template void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) { if (dy == 0.0) { @@ -145,7 +145,7 @@ void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) } -template +template void ApplyPlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn) { Real temp = cs * dx + sn * dy; diff --git a/lib/atc/GhostManager.cpp b/lib/atc/GhostManager.cpp index 1482a5a47d..f73168d9c2 100644 --- a/lib/atc/GhostManager.cpp +++ b/lib/atc/GhostManager.cpp @@ -18,7 +18,7 @@ namespace ATC { // Class GhostManager //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -30,7 +30,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -46,7 +46,7 @@ namespace ATC { 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 @@ -91,7 +91,7 @@ namespace ATC { gamma_.push_back(atof(arg[argIndex++])); mu_.push_back(atof(arg[argIndex++])); } - + boundaryDynamics_ = DAMPED_LAYERS; needReset_ = true; return true; @@ -123,7 +123,7 @@ namespace ATC { ghostModifier_ = new GhostModifier(this); return; } - + switch (boundaryDynamics_) { case VERLET: { ghostModifier_ = new GhostModifier(this); @@ -175,7 +175,7 @@ namespace ATC { } } } - + //-------------------------------------------------------- // construct_transfers // sets/constructs all required dependency managed data @@ -184,7 +184,7 @@ namespace ATC { { ghostModifier_->construct_transfers(); } - + //-------------------------------------------------------- // initialize // initialize all data and variables before a run @@ -204,7 +204,7 @@ namespace ATC { { ghostModifier_->pre_exchange(); } - + //-------------------------------------------------------- // initial_integrate_velocity // velocity update in first part of velocity-verlet @@ -213,7 +213,7 @@ namespace ATC { { ghostModifier_->init_integrate_velocity(dt); } - + //-------------------------------------------------------- // initial_integrate_position // position update in first part of velocity-verlet @@ -246,7 +246,7 @@ namespace ATC { // Class GhostModifier //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -291,7 +291,7 @@ namespace ATC { { atomTimeIntegrator_->init_integrate_velocity(dt); } - + //-------------------------------------------------------- // initial_integrate_position // position update in first part of velocity-verlet @@ -315,7 +315,7 @@ namespace ATC { // Class GhostModifierPrescribed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -353,10 +353,10 @@ namespace ATC { 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 @@ -373,7 +373,7 @@ namespace ATC { // Class GhostModifierDampedHarmonic //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -399,7 +399,7 @@ namespace ATC { 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); @@ -431,7 +431,7 @@ namespace ATC { atomTimeIntegrator_->init_integrate_velocity(dt); #endif } - + //-------------------------------------------------------- // initial_integrate_position // position update in first part of velocity-verlet @@ -477,7 +477,7 @@ namespace ATC { // Class GhostModifierDampedHarmonicLayers //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -489,7 +489,7 @@ namespace ATC { ghostToBoundaryDistance_(nullptr), layerId_(nullptr) { - + // do nothing } @@ -500,7 +500,7 @@ namespace ATC { void GhostModifierDampedHarmonicLayers::construct_transfers() { GhostModifierDampedHarmonic::construct_transfers(); - + InterscaleManager & interscaleManager((ghostManager_->atc())->interscale_manager()); // transfer for distance to boundary @@ -529,14 +529,14 @@ namespace ATC { //-------------------------------------------------------- // find atomic mononlayers //-------------------------------------------------------- - bool compare( pair a, pair b) { + bool compare( pair a, pair b) { return (a.second < b.second); } int GhostModifierDampedHarmonicLayers::find_layers() { DENS_MAT & d(ghostToBoundaryDistance_->set_quantity()); DenseMatrix & ids = layerId_->set_quantity(); - + // get distances for every ghost atom for sorting // size arrays of length number of processors int commSize = LammpsInterface::instance()->comm_size(); @@ -608,7 +608,7 @@ namespace ATC { ATC::LammpsInterface::instance()->print_msg_once(msg.str()); return nlayers; } - + //-------------------------------------------------------- // compute distances to boundary faces //-------------------------------------------------------- @@ -640,7 +640,7 @@ namespace ATC { feMesh->face_connectivity_unique(PAIR(elt,face),faceNodes); // identify the boundary face by the face which contains only boundary nodes - isBoundaryFace = true; + isBoundaryFace = true; for (int i = 0; i < faceNodes.size(); ++i) { if (nodeType(faceNodes(i),0) != BOUNDARY) { isBoundaryFace = false; @@ -665,7 +665,7 @@ namespace ATC { } } centroid *= -1./double(nfe); // -1 gets outward normal from ATC region => all distances should be > 0 - + // for each boundary face get the normal // ASSUMES all faces are planar feMesh->face_normal(PAIR(elt,face),0,normal); @@ -692,7 +692,7 @@ namespace ATC { } } - + //-------------------------------------------------------- // final_integrate // velocity update in second part of velocity-verlet @@ -723,7 +723,7 @@ namespace ATC { // Class GhostIntegratorVerletSwap //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- diff --git a/lib/atc/GhostManager.h b/lib/atc/GhostManager.h index 9c3bbbe939..c697eb1bb1 100644 --- a/lib/atc/GhostManager.h +++ b/lib/atc/GhostManager.h @@ -26,7 +26,7 @@ namespace ATC { /** types of ghost boundary conditions in momentum */ enum BoundaryDynamicsType { NO_BOUNDARY_DYNAMICS=0, - VERLET, // performs velocity-verlet + VERLET, // performs velocity-verlet PRESCRIBED, // forces ghost locations to conform to interpolated finite element locations DAMPED_HARMONIC, // turns ghost atoms into spring-mass-dashpot systems DAMPED_LAYERS, // oer layer DAMPED_HARMONIC @@ -113,7 +113,7 @@ namespace ATC { */ class GhostModifier { - + public: // constructor @@ -171,7 +171,7 @@ namespace ATC { */ class GhostModifierPrescribed : public GhostModifier { - + public: // constructor @@ -210,7 +210,7 @@ namespace ATC { */ class GhostModifierDampedHarmonic : public GhostModifierPrescribed { - + public: // constructor @@ -276,7 +276,7 @@ namespace ATC { */ class GhostModifierDampedHarmonicLayers : public GhostModifierDampedHarmonic { - + public: // constructor @@ -308,7 +308,7 @@ namespace ATC { // data /** distance from all ghost atoms to boundary, i.e. boundary face of containing element */ PerAtomQuantity * ghostToBoundaryDistance_; - + /** layer id for ghost atoms */ PerAtomQuantity * layerId_; @@ -327,7 +327,7 @@ namespace ATC { */ class GhostIntegratorSwap : public GhostModifier { - + public: // constructor @@ -355,7 +355,7 @@ namespace ATC { /** internal to element map */ PerAtomQuantity * atomElement_; - + /** ghost to element map */ PerAtomQuantity * atomGhostElement_; diff --git a/lib/atc/ImplicitSolveOperator.cpp b/lib/atc/ImplicitSolveOperator.cpp index d66da8a0e3..a6e8a4b09a 100644 --- a/lib/atc/ImplicitSolveOperator.cpp +++ b/lib/atc/ImplicitSolveOperator.cpp @@ -41,7 +41,7 @@ ImplicitSolveOperator::operator * (const DENS_VEC & x) const // fast field. In brief, if the ODE for the fast field can be written: // // dx/dt = R(x) - // + // // A generalized discretization can be written: // // 1/dt * (x^n+1 - x^n) = alpha * R(x^n+1) + (1-alpha) * R(x^n) @@ -120,14 +120,14 @@ FieldImplicitSolveOperator(ATC_Coupling * atc, int nNodes = f.nRows(); set fixedNodes_ = atc_->prescribed_data_manager()->fixed_nodes(fieldName_); n_ = nNodes; - vector tag(nNodes); + vector tag(nNodes); set::const_iterator it; int i = 0; for (i = 0; i < nNodes; ++i) { tag[i] = true; } for (it=fixedNodes_.begin();it!=fixedNodes_.end();++it) {tag[*it]=false;} int m = 0; for (i = 0; i < nNodes; ++i) { if (tag[i]) freeNodes_[i]= m++; } //std::cout << " nodes " << n_ << " " << nNodes << "\n"; - + // Save current field x0_.reset(n_); to_free(f,x0_); @@ -143,7 +143,7 @@ FieldImplicitSolveOperator(ATC_Coupling * atc, massMask_.reset(1); massMask_(0) = fieldName_; rhs_[fieldName_].reset(nNodes,dof_); - // Compute the RHS vector R(T^n) + // Compute the RHS vector R(T^n) R0_.reset(n_); R_ .reset(n_); R(x0_, R0_); @@ -163,7 +163,7 @@ void FieldImplicitSolveOperator::to_free(const MATRIX &r, VECTOR &v) const v(i) = r(i,0); } } -void +void FieldImplicitSolveOperator::R(const DENS_VEC &x, DENS_VEC &v ) const { DENS_MAT & f = fields_[fieldName_].set_quantity(); @@ -192,7 +192,7 @@ void FieldImplicitSolveOperator::solution(const DENS_MAT & dx, DENS_MAT &f) cons } void FieldImplicitSolveOperator::rhs(const DENS_MAT & r, DENS_MAT &rhs) const { - + to_all(column(r,0),rhs); } diff --git a/lib/atc/ImplicitSolveOperator.h b/lib/atc/ImplicitSolveOperator.h index 8b9f28dc5b..483a0b900a 100644 --- a/lib/atc/ImplicitSolveOperator.h +++ b/lib/atc/ImplicitSolveOperator.h @@ -45,7 +45,7 @@ class ImplicitSolveOperator { mutable DENS_VEC R_; // condensed current double dt_; // timestep double alpha_; // implicit/explicit parameter (0 -> explicit, else implicit) - double epsilon0_; // small parameter to compute increment + double epsilon0_; // small parameter to compute increment }; /** diff --git a/lib/atc/InterscaleOperators.cpp b/lib/atc/InterscaleOperators.cpp index eeac14adf8..994652ba0c 100644 --- a/lib/atc/InterscaleOperators.cpp +++ b/lib/atc/InterscaleOperators.cpp @@ -41,7 +41,7 @@ namespace ATC{ { prefix_ = (atc_->lammps_interface())->fix_id() + prefix_; } - + //-------------------------------------------------------- // Destructor //-------------------------------------------------------- @@ -155,7 +155,7 @@ namespace ATC{ int myIndex = index; set::iterator it; bool isTemporary = (quantity->memory_type()==TEMPORARY); - + for (it = (quantity->dependentQuantities_).begin(); it != (quantity->dependentQuantities_).end(); it++) { // make sure that if quantity isn't persistent, none of it's dependencies are if ((*it)->memory_type()==PERSISTENT && isTemporary) { @@ -454,7 +454,7 @@ namespace ATC{ { // REFACTOR add check for duplicate entries DependencyManager * quantity = nullptr; - + quantity = find_in_list(perAtomQuantities_,tag); if (quantity) return quantity; quantity = find_in_list(perAtomIntQuantities_,tag); @@ -613,7 +613,7 @@ namespace ATC{ //-------------------------------------------------------- // pack_comm //-------------------------------------------------------- - int InterscaleManager::pack_comm(int index, double *buf, + int InterscaleManager::pack_comm(int index, double *buf, int pbc_flag, int *pbc) { int size = 0; diff --git a/lib/atc/InterscaleOperators.h b/lib/atc/InterscaleOperators.h index 40c5144bf8..4c72dc5c37 100644 --- a/lib/atc/InterscaleOperators.h +++ b/lib/atc/InterscaleOperators.h @@ -35,12 +35,12 @@ namespace ATC { //-------------------------------------------------------- class InterscaleManager { - + public: - + // constructor InterscaleManager(ATC_Method * atc); - + // destructor ~InterscaleManager(); @@ -52,7 +52,7 @@ namespace ATC { /** set lammps data prefix */ void set_lammps_data_prefix(); - + /** parser/modifier */ bool modify(int narg, char **arg); @@ -183,7 +183,7 @@ namespace ATC { int unpack_exchange(int i, double *buffer); /** packs up data for parallel transfer to ghost atoms on other processors */ - int pack_comm(int index, double *buf, + int pack_comm(int index, double *buf, int pbc_flag, int *pbc); /** unpacks data after parallel transfer to ghost atoms on other processors */ @@ -196,7 +196,7 @@ namespace ATC { void copy_arrays(int i, int j); protected: - + /** pointer to access ATC methods */ ATC_Method * atc_; @@ -422,7 +422,7 @@ namespace ATC { /** helper function to pack arrays of all data in a list, only valid with comm lists */ template - void pack_comm_loop(std::vector & list, int & size, int index, double *buf, + void pack_comm_loop(std::vector & list, int & size, int index, double *buf, int pbc_flag, int *pbc) { for (typename std::vector::iterator it = list.begin(); it != list.end(); ++it) @@ -455,9 +455,9 @@ namespace ATC { private: - + InterscaleManager(); - + }; } diff --git a/lib/atc/KD_Tree.cpp b/lib/atc/KD_Tree.cpp index 181be27dc5..a41e7ca75a 100644 --- a/lib/atc/KD_Tree.cpp +++ b/lib/atc/KD_Tree.cpp @@ -3,8 +3,8 @@ using std::vector; -KD_Tree *KD_Tree::create_KD_tree(const int nNodesPerElem, const int nNodes, - const DENS_MAT *nodalCoords, const int nElems, +KD_Tree *KD_Tree::create_KD_tree(const int nNodesPerElem, const int nNodes, + const DENS_MAT *nodalCoords, const int nElems, const Array2D &conn) { vector *points = new vector(); // Initialize an empty list of Nodes for (int node = 0; node < nNodes; node++) { // Insert all nodes into list @@ -30,7 +30,7 @@ KD_Tree::~KD_Tree() { delete rightChild_; } -KD_Tree::KD_Tree(vector *points, vector *elements, +KD_Tree::KD_Tree(vector *points, vector *elements, int dimension) : candElems_(elements) { // Set up comparison functions @@ -44,14 +44,14 @@ KD_Tree::KD_Tree(vector *points, vector *elements, } // Sort points by their coordinate in the current dimension - sort(points->begin(), points->end(), compare); + sort(points->begin(), points->end(), compare); sortedPts_ = points; // Pick the median point as the root of the tree size_t nNodes = points->size(); size_t med = nNodes/2; value_ = (*sortedPts_)[med]; - + // Recursively construct the left sub-tree vector *leftPts = new vector; vector *leftElems = new vector; @@ -103,8 +103,8 @@ KD_Tree::KD_Tree(vector *points, vector *elements, vector KD_Tree::find_nearest_elements(Node query, int dimension) { // if the root coordinate is less than the query coordinate - - + + // If the query point is less that the value (split) point of this // tree, either recurse to the left or return this node's elements // if there is no left child. @@ -132,10 +132,10 @@ vector KD_Tree::find_nearest_elements(Node query, int dimension) { } vector > KD_Tree::getElemIDs(int depth) { - + vector > result; vector > temp; - + assert(depth >= 0 ); if (depth == 0) { vector candElemIDs; @@ -164,6 +164,6 @@ vector > KD_Tree::getElemIDs(int depth) { temp = rightChild_->getElemIDs(depth); result.insert(result.end(), temp.begin(), temp.end()); } - + return result; } diff --git a/lib/atc/KD_Tree.h b/lib/atc/KD_Tree.h index 3877cd4099..1ef59358e0 100644 --- a/lib/atc/KD_Tree.h +++ b/lib/atc/KD_Tree.h @@ -14,7 +14,7 @@ class Node { // Zero argument constructor just for default initialization. } - Node(int node, double x, double y, double z) + Node(int node, double x, double y, double z) : index_(node) { coords_[0] = x; @@ -26,8 +26,8 @@ class Node { double coords_[3]; double distanceSquared(Node query) { - return pow(coords_[0] - query.coords_[0], 2) - + pow(coords_[1] - query.coords_[1], 2) + return pow(coords_[0] - query.coords_[0], 2) + + pow(coords_[1] - query.coords_[1], 2) + pow(coords_[2] - query.coords_[2], 2); } @@ -58,8 +58,8 @@ typedef std::pair > Elem; class KD_Tree { public: - static KD_Tree* create_KD_tree(const int nNodesPerElement, const int nNodes, - const DENS_MAT *points, const int nElems, + static KD_Tree* create_KD_tree(const int nNodesPerElement, const int nNodes, + const DENS_MAT *points, const int nElems, const Array2D &conn); KD_Tree(std::vector *points, std::vector *elems, @@ -67,13 +67,13 @@ class KD_Tree { ~KD_Tree(); - std::vector find_nearest(DENS_VEC query) { + std::vector 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))); } - + std::vector find_nearest_elements(Node query, int dimension=0); - + std::vector > getElemIDs(int depth); private: diff --git a/lib/atc/KernelFunction.cpp b/lib/atc/KernelFunction.cpp index 6095c14284..a9695efb01 100644 --- a/lib/atc/KernelFunction.cpp +++ b/lib/atc/KernelFunction.cpp @@ -11,12 +11,12 @@ using namespace ATC_Utility; static const double tol = 1.0e-8; -static const int line_ngauss = 10; +static const int line_ngauss = 10; static double line_xg[line_ngauss], line_wg[line_ngauss]; namespace ATC { - + //======================================================================== // KernelFunctionMgr //======================================================================== @@ -36,10 +36,10 @@ namespace ATC { //------------------------------------------------------------------------ KernelFunction* KernelFunctionMgr::function(char ** arg, int narg) { - /*! \page man_kernel_function fix_modify AtC kernel + /*! \page man_kernel_function fix_modify AtC kernel \section syntax fix_modify AtC kernel - - type (keyword) = step, cell, cubic_bar, cubic_cylinder, cubic_sphere, + - type (keyword) = step, cell, cubic_bar, cubic_cylinder, cubic_sphere, quartic_bar, quartic_cylinder, quartic_sphere \n - parameters :\n step = radius (double) \n @@ -54,7 +54,7 @@ namespace ATC { fix_modify AtC kernel cell 1.0 1.0 1.0 fix_modify AtC kernel quartic_sphere 10.0 \section description - + \section restrictions Must be used with the hardy AtC fix \n For bar kernel types, half-width oriented along x-direction \n @@ -80,11 +80,11 @@ namespace ATC { ptr = new KernelFunctionCell(2,parameters); } else if (strcmp(type,"cubic_bar")==0) { - double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length + double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length ptr = new KernelFunctionCubicBar(1,parameters); } else if (strcmp(type,"linear_bar")==0) { - double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length + double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length ptr = new KernelFunctionLinearBar(1,parameters); } else if (strcmp(type,"cubic_cylinder")==0) { @@ -96,7 +96,7 @@ namespace ATC { ptr = new KernelFunctionCubicSphere(1,parameters); } else if (strcmp(type,"quartic_bar")==0) { - double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length + double parameters[1] = {atof(arg[argIdx])}; // cutoff half-length ptr = new KernelFunctionQuarticBar(1,parameters); } else if (strcmp(type,"quartic_cylinder")==0) { @@ -126,7 +126,7 @@ namespace ATC { KernelFunction::KernelFunction(int /* nparameters */, double* parameters): Rc_(0),invRc_(0),nsd_(3), lammpsInterface_(LammpsInterface::instance()) - { + { Rc_ = parameters[0]; invRc_ = 1.0/Rc_; Rc_ = parameters[0]; @@ -142,8 +142,8 @@ namespace ATC { box_bounds[0][1],box_bounds[1][1], box_bounds[0][2],box_bounds[1][2]); for (int k = 0; k < 3; k++) { - box_length[k] = box_bounds[1][k] - box_bounds[0][k]; - } + box_length[k] = box_bounds[1][k] - box_bounds[0][k]; + } } // does an input node's kernel intersect bonds on this processor @@ -160,7 +160,7 @@ namespace ATC { if (i < nsd_) { kernel_bounds[0][i] -= (Rc_+lammpsInterface_->pair_cutoff()); kernel_bounds[1][i] += (Rc_+lammpsInterface_->pair_cutoff()); - contributes = contributes && (node(i) >= kernel_bounds[0][i]) + contributes = contributes && (node(i) >= kernel_bounds[0][i]) && (node(i) < kernel_bounds[1][i]); if (periodicity[i]) { if (node[i] <= box_bounds[0][i] + box_length[i]/2) { @@ -168,8 +168,8 @@ namespace ATC { } else { ghostNode[i] -= box_length[i]; } - ghostContributes = ghostContributes - && ((ghostNode(i) >= kernel_bounds[0][i]) || + ghostContributes = ghostContributes + && ((ghostNode(i) >= kernel_bounds[0][i]) || (node(i) >= kernel_bounds[0][i])) && ((ghostNode(i) < kernel_bounds[1][i]) || (node(i) < kernel_bounds[1][i])); @@ -202,12 +202,12 @@ namespace ATC { return 0.5*(lam2-lam1)*bhsum; } - // localization-volume intercepts for bond calculation + // localization-volume intercepts for bond calculation // bond intercept values assuming spherical support void KernelFunction::bond_intercepts(DENS_VEC& xa, DENS_VEC& xb, double &lam1, double &lam2) const { - if (nsd_ == 2) {// for cylinders, axis is always z! + if (nsd_ == 2) {// for cylinders, axis is always z! const int iaxis = 2; xa[iaxis] = 0.0; xb[iaxis] = 0.0; @@ -223,8 +223,8 @@ namespace ATC { bool a_in = (ra_n <= 1.0); bool b_in = (rb_n <= 1.0); if (a_in && b_in) { - lam1 = 0.0; - lam2 = 1.0; + lam1 = 0.0; + lam2 = 1.0; return; } DENS_VEC xab = xa - xb; @@ -240,7 +240,7 @@ namespace ATC { double aux = -0.5*(b-sqrt(discrim)); s1 = c/aux; s2 = aux/a; - } + } else { double aux = -0.5*(b+sqrt(discrim)); s1 = aux/a; @@ -249,15 +249,15 @@ namespace ATC { if (a_in && !b_in) { lam1 = s1; lam2 = 1.0; - } - else if (!a_in && b_in) { + } + else if (!a_in && b_in) { lam1 = 0.0; - lam2 = s2; + lam2 = s2; } else { - if (s1 >= 0.0 && s2 <= 1.0) { - lam1 = s1; - lam2 = s2; + if (s1 >= 0.0 && s2 <= 1.0) { + lam1 = s1; + lam2 = s2; } } } @@ -265,8 +265,8 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionStep::KernelFunctionStep - (int nparameters, double* parameters): - KernelFunction(nparameters, parameters) + (int nparameters, double* parameters): + KernelFunction(nparameters, parameters) { for (int k = 0; k < nsd_; k++ ) { if ((bool) periodicity[k]) { @@ -274,7 +274,7 @@ namespace ATC { throw ATC_Error("Size of localization volume is too large for periodic boundary condition"); } } - } + } } // function value @@ -284,7 +284,7 @@ namespace ATC { if (rn <= 1.0) { return 1.0; } else { return 0.0; } } - + // function derivative value void KernelFunctionStep::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const { @@ -295,8 +295,8 @@ namespace ATC { /** a step with rectangular support suitable for a rectangular grid */ // constructor KernelFunctionCell::KernelFunctionCell - (int nparameters, double* parameters): - KernelFunction(nparameters, parameters) + (int nparameters, double* parameters): + KernelFunction(nparameters, parameters) { hx = parameters[0]; hy = parameters[1]; @@ -309,7 +309,7 @@ namespace ATC { cellBounds_(3) = hy; cellBounds_(4) = -hz; cellBounds_(5) = hz; - + for (int k = 0; k < nsd_; k++ ) { if ((bool) periodicity[k]) { if (parameters[k] > 0.5*box_length[k]) { @@ -332,9 +332,9 @@ namespace ATC { for (int i=0; i<3; ++i) { kernel_bounds[0][i] -= (cellBounds_(i*2+1) + lammpsInterface_->pair_cutoff()); - kernel_bounds[1][i] += (cellBounds_(i*2+1) + + kernel_bounds[1][i] += (cellBounds_(i*2+1) + lammpsInterface_->pair_cutoff()); - contributes = contributes && (node(i) >= kernel_bounds[0][i]) + contributes = contributes && (node(i) >= kernel_bounds[0][i]) && (node(i) < kernel_bounds[1][i]); if (periodicity[i]) { if (node[i] <= box_bounds[0][i] + box_length[i]/2) { @@ -342,7 +342,7 @@ namespace ATC { } else { ghostNode[i] -= box_length[i]; } - ghostContributes = ghostContributes + ghostContributes = ghostContributes && ((ghostNode(i) >= kernel_bounds[0][i]) || (node(i) >= kernel_bounds[0][i])) && ((ghostNode(i) < kernel_bounds[1][i]) || @@ -367,13 +367,13 @@ namespace ATC { // function value double KernelFunctionCell::value(DENS_VEC& x_atom) const { - if ((cellBounds_(0) <= x_atom(0)) && (x_atom(0) < cellBounds_(1)) - && (cellBounds_(2) <= x_atom(1)) && (x_atom(1) < cellBounds_(3)) - && (cellBounds_(4) <= x_atom(2)) && (x_atom(2) < cellBounds_(5))) { - return 1.0; - } - else { - return 0.0; + if ((cellBounds_(0) <= x_atom(0)) && (x_atom(0) < cellBounds_(1)) + && (cellBounds_(2) <= x_atom(1)) && (x_atom(1) < cellBounds_(3)) + && (cellBounds_(4) <= x_atom(2)) && (x_atom(2) < cellBounds_(5))) { + return 1.0; + } + else { + return 0.0; } } @@ -382,7 +382,7 @@ namespace ATC { { deriv.reset(nsd_); } - + // bond intercept values for rectangular region : origin is the node position void KernelFunctionCell::bond_intercepts(DENS_VEC& xa, DENS_VEC& xb, double &lam1, double &lam2) const @@ -409,21 +409,21 @@ namespace ATC { double s = (cellBounds_(2*i+j) - xb(i))/xab(i); // check if between a & b if (s >= 0 && s <= 1) { - bool in_bounds = false; + bool in_bounds = false; DENS_VEC x = xb + s*xab; - if (i == 0) { + if (i == 0) { if ((cellBounds_(2) <= x(1)) && (x(1) <= cellBounds_(3)) && (cellBounds_(4) <= x(2)) && (x(2) <= cellBounds_(5))) { in_bounds = true; } } - else if (i == 1) { + else if (i == 1) { if ((cellBounds_(0) <= x(0)) && (x(0) <= cellBounds_(1)) && (cellBounds_(4) <= x(2)) && (x(2) <= cellBounds_(5))) { in_bounds = true; } } - else if (i == 2) { + else if (i == 2) { if ((cellBounds_(0) <= x(0)) && (x(0) <= cellBounds_(1)) && (cellBounds_(2) <= x(1)) && (x(1) <= cellBounds_(3))) { in_bounds = true; @@ -436,7 +436,7 @@ namespace ATC { } } } - } + } } throw ATC_Error("logic failure in HardyKernel Cell for single intersection\n"); } @@ -455,19 +455,19 @@ namespace ATC { if (s >= 0 && s <= 1) { // check if in face DENS_VEC x = xb + s*xab; - if (i == 0) { + if (i == 0) { if ((cellBounds_(2) <= x(1)) && (x(1) <= cellBounds_(3)) && (cellBounds_(4) <= x(2)) && (x(2) <= cellBounds_(5))) { ss[is++] = s; } } - else if (i == 1) { + else if (i == 1) { if ((cellBounds_(0) <= x(0)) && (x(0) <= cellBounds_(1)) && (cellBounds_(4) <= x(2)) && (x(2) <= cellBounds_(5))) { ss[is++] = s; } } - else if (i == 2) { + else if (i == 2) { if ((cellBounds_(0) <= x(0)) && (x(0) <= cellBounds_(1)) && (cellBounds_(2) <= x(1)) && (x(1) <= cellBounds_(3))) { ss[is++] = s; @@ -475,7 +475,7 @@ namespace ATC { } } } - } + } } if (is == 1) { // intersection occurs at a box edge - leave lam1 = lam2 @@ -496,8 +496,8 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionCubicSphere::KernelFunctionCubicSphere - (int nparameters, double* parameters): - KernelFunction(nparameters, parameters) + (int nparameters, double* parameters): + KernelFunction(nparameters, parameters) { for (int k = 0; k < nsd_; k++ ) { if ((bool) periodicity[k]) { @@ -515,7 +515,7 @@ namespace ATC { double rn=r/Rc_; if (rn < 1.0) { return 5.0*(1.0-3.0*rn*rn+2.0*rn*rn*rn); } else { return 0.0; } - } + } // function derivative value void KernelFunctionCubicSphere::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const @@ -526,8 +526,8 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionQuarticSphere::KernelFunctionQuarticSphere - (int nparameters, double* parameters): - KernelFunction(nparameters, parameters) + (int nparameters, double* parameters): + KernelFunction(nparameters, parameters) { for (int k = 0; k < nsd_; k++ ) { if ((bool) periodicity[k]) { @@ -539,13 +539,13 @@ namespace ATC { } // function value - double KernelFunctionQuarticSphere::value(DENS_VEC& x_atom) const + double KernelFunctionQuarticSphere::value(DENS_VEC& x_atom) const { double r=x_atom.norm(); double rn=r/Rc_; if (rn < 1.0) { return 35.0/8.0*pow((1.0-rn*rn),2); } else { return 0.0; } - } + } // function derivative value void KernelFunctionQuarticSphere::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const @@ -556,7 +556,7 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionCubicCyl::KernelFunctionCubicCyl - (int nparameters, double* parameters): + (int nparameters, double* parameters): KernelFunction(nparameters, parameters) { nsd_ = 2; @@ -578,7 +578,7 @@ namespace ATC { double rn=r/Rc_; if (rn < 1.0) { return 10.0/3.0*(1.0-3.0*rn*rn+2.0*rn*rn*rn); } else { return 0.0; } - } + } // function derivative value void KernelFunctionCubicCyl::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const @@ -589,7 +589,7 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionQuarticCyl::KernelFunctionQuarticCyl - (int nparameters, double* parameters): + (int nparameters, double* parameters): KernelFunction(nparameters, parameters) { nsd_ = 2; @@ -611,7 +611,7 @@ namespace ATC { double rn=r/Rc_; if (rn < 1.0) { return 3.0*pow((1.0-rn*rn),2); } else { return 0.0; } - } + } // function derivative value void KernelFunctionQuarticCyl::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const @@ -621,7 +621,7 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionCubicBar::KernelFunctionCubicBar - (int nparameters, double* parameters): + (int nparameters, double* parameters): KernelFunction(nparameters, parameters) { // Note: Bar is assumed to be oriented in the x(0) direction @@ -643,7 +643,7 @@ namespace ATC { double rn=r/Rc_; if (rn < 1.0) { return 2.0*(1.0-3.0*rn*rn+2.0*rn*rn*rn); } else { return 0.0; } - } + } // function derivative value void KernelFunctionCubicBar::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const @@ -654,7 +654,7 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionLinearBar::KernelFunctionLinearBar - (int nparameters, double* parameters): + (int nparameters, double* parameters): KernelFunction(nparameters, parameters) { // Note: Bar is assumed to be oriented in the z(0) direction @@ -675,7 +675,7 @@ namespace ATC { double rn=r/Rc_; if (rn < 1.0) { return 1.0-rn; } else { return 0.0; } - } + } // function derivative value void KernelFunctionLinearBar::derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const @@ -693,7 +693,7 @@ namespace ATC { //------------------------------------------------------------------------ // constructor KernelFunctionQuarticBar::KernelFunctionQuarticBar - (int nparameters, double* parameters): + (int nparameters, double* parameters): KernelFunction(nparameters, parameters) { // Note: Bar is assumed to be oriented in the x(0) direction @@ -716,7 +716,7 @@ namespace ATC { // if (rn < 1.0) { return 5.0/2.0*(1.0-6*rn*rn+8*rn*rn*rn-3*rn*rn*rn*rn); } - alternative quartic if (rn < 1.0) { return 15.0/8.0*pow((1.0-rn*rn),2); } else { return 0.0; } - } + } // function derivative value void KernelFunctionQuarticBar::derivative(const DENS_VEC& /* x_atom */, DENS_VEC& deriv) const diff --git a/lib/atc/KernelFunction.h b/lib/atc/KernelFunction.h index 6922ed9a7b..d26ab38209 100644 --- a/lib/atc/KernelFunction.h +++ b/lib/atc/KernelFunction.h @@ -9,8 +9,8 @@ namespace ATC { /** * @class KernelFunctionMgr - * @brief Base class for managing kernels - */ + * @brief Base class for managing kernels + */ class KernelFunctionMgr { public: /** Static instance of this class */ @@ -25,26 +25,26 @@ namespace ATC { }; /** - * @class KernelFunction - * @brief Base class for kernels for atom-continuum transfer - */ + * @class KernelFunction + * @brief Base class for kernels for atom-continuum transfer + */ class KernelFunction { public: - + // constructor KernelFunction(int nparameters, double* parameters); // destructor virtual ~KernelFunction() {}; // function value virtual double value(DENS_VEC& x_atom) const =0 ; - // function derivative + // function derivative virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const =0 ; // bond function value via quadrature virtual double bond(DENS_VEC& xa, DENS_VEC&xb, double lam1, double lam2) const; // localization-volume intercepts for bond calculation - virtual void bond_intercepts(DENS_VEC& xa, + virtual void bond_intercepts(DENS_VEC& xa, DENS_VEC& xb, double &lam1, double &lam2) const; virtual bool node_contributes(DENS_VEC node) const; virtual bool in_support(DENS_VEC node) const; @@ -54,7 +54,7 @@ namespace ATC { protected: double invVol_; // normalization factor double Rc_, invRc_; // cutoff radius - int nsd_ ; // number of dimensions + int nsd_ ; // number of dimensions /** pointer to lammps interface class */ LammpsInterface * lammpsInterface_; @@ -67,10 +67,10 @@ namespace ATC { }; /** - * @class KernelFunctionStep + * @class KernelFunctionStep * @brief Class for defining kernel function of a step with spherical support - */ - + */ + class KernelFunctionStep : public KernelFunction { public: @@ -80,7 +80,7 @@ namespace ATC { virtual ~KernelFunctionStep() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative + // function derivative virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; // bond function value virtual double bond(DENS_VEC& /* xa */, DENS_VEC& /* xb */, double lam1, double lam2) const @@ -88,27 +88,27 @@ namespace ATC { }; /** - * @class KernelFunctionCell + * @class KernelFunctionCell * @brief Class for defining kernel function of a step with rectangular support * suitable for a rectangular grid - */ - + */ + class KernelFunctionCell : public KernelFunction { public: // constructor - KernelFunctionCell(int nparameters, double* parameters); + KernelFunctionCell(int nparameters, double* parameters); // destructor virtual ~KernelFunctionCell() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; // bond function value virtual double bond(DENS_VEC& /* xa */, DENS_VEC& /* xb */, double lam1, double lam2) const {return lam2 -lam1;} // bond intercept values : origin is the node position - void bond_intercepts(DENS_VEC& xa, DENS_VEC& xb, + void bond_intercepts(DENS_VEC& xa, DENS_VEC& xb, double &lam1, double &lam2) const; bool node_contributes(DENS_VEC node) const; bool in_support(DENS_VEC dx) const; @@ -132,8 +132,8 @@ namespace ATC { virtual ~KernelFunctionCubicSphere() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; }; /** @@ -150,8 +150,8 @@ namespace ATC { virtual ~KernelFunctionQuarticSphere() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; }; /** @@ -168,8 +168,8 @@ namespace ATC { virtual ~KernelFunctionCubicCyl() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; virtual double dimensionality_factor(void) const { return 0.5; } }; @@ -181,21 +181,21 @@ namespace ATC { class KernelFunctionQuarticCyl : public KernelFunction { public: - + // constructor KernelFunctionQuarticCyl(int nparameters, double* parameters); // destructor virtual ~KernelFunctionQuarticCyl() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; virtual double dimensionality_factor(void) const { return 0.5; } }; /** * @class KernelFunctionCubicBar - * @brief Class for defining kernel function of a cubic with 1-dimensional (bar) support + * @brief Class for defining kernel function of a cubic with 1-dimensional (bar) support */ class KernelFunctionCubicBar : public KernelFunction { @@ -207,14 +207,14 @@ namespace ATC { virtual ~KernelFunctionCubicBar() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; virtual double dimensionality_factor(void) const { return 0.25; } }; /** * @class KernelFunctionCubicBar - * @brief Class for defining kernel function of a cubic with 1-dimensional (bar) support + * @brief Class for defining kernel function of a cubic with 1-dimensional (bar) support */ class KernelFunctionLinearBar : public KernelFunction { @@ -226,8 +226,8 @@ namespace ATC { virtual ~KernelFunctionLinearBar() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; virtual double dimensionality_factor(void) const { return 0.25; } }; @@ -246,8 +246,8 @@ namespace ATC { virtual ~KernelFunctionQuarticBar() {}; // function value virtual double value(DENS_VEC& x_atom) const; - // function derivative - virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; + // function derivative + virtual void derivative(const DENS_VEC& x_atom, DENS_VEC& deriv) const; virtual double dimensionality_factor(void) const { return 0.25; } }; diff --git a/lib/atc/KinetoThermostat.cpp b/lib/atc/KinetoThermostat.cpp index 89d598c102..7b571249f3 100644 --- a/lib/atc/KinetoThermostat.cpp +++ b/lib/atc/KinetoThermostat.cpp @@ -62,9 +62,9 @@ namespace ATC { //-------------------------------------------------------- // construct_methods: // instantiations desired regulator method(s) - + // dependence, but in general there is also a - // time integrator dependence. In general the + // time integrator dependence. In general the // precedence order is: // time filter -> time integrator -> thermostat // In the future this may need to be added if @@ -92,7 +92,7 @@ namespace ATC { if (timeFilterManager->need_reset() ) { timeFilter_ = timeFilterManager->construct(TimeFilterManager::EXPLICIT_IMPLICIT); } - + if (timeFilterManager->filter_dynamics()) { switch (regulatorTarget_) { case NONE: { @@ -130,7 +130,7 @@ namespace ATC { throw ATC_Error("Unknown thermostat target in Thermostat::initialize"); } } - + AtomicRegulator::reset_method(); } else { @@ -143,7 +143,7 @@ namespace ATC { // Class VelocityRescaleCombined //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -182,7 +182,7 @@ namespace ATC { // Class ThermostatRescaleCombined //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -219,7 +219,7 @@ namespace ATC { // Class KinetoThermostatRescale //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -239,7 +239,7 @@ namespace ATC { kinetostat_ = new VelocityRescaleCombined(kinetoThermostat); // data associated with stage 3 in ATC_Method::initialize lambdaMomentum_ = atomicRegulator_->regulator_data(regulatorPrefix_+"LambdaMomentum",atc_->nsd()); - lambdaEnergy_ = atomicRegulator_->regulator_data(regulatorPrefix_+"LambdaEnergy",1); + lambdaEnergy_ = atomicRegulator_->regulator_data(regulatorPrefix_+"LambdaEnergy",1); } //-------------------------------------------------------- @@ -334,7 +334,7 @@ namespace ATC { // update thermostat thermostat_->compute_thermostat(dt); - + // update kinetostat kinetostat_->compute_kinetostat(dt); @@ -383,7 +383,7 @@ namespace ATC { // Class ThermostatRescaleMixedKePeCombined //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -447,7 +447,7 @@ namespace ATC { // Class KinetoThermostatGlcFs //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -598,7 +598,7 @@ namespace ATC { // do full prediction if we just redid the shape functions if (full_prediction()) { this->compute_lambda(dt); - + atomThermostatForces_->unfix_quantity(); // allow update of atomic force applied by lambda } @@ -612,7 +612,7 @@ namespace ATC { if (full_prediction()) atomThermostatForces_->fix_quantity(); - + // SPLIT OUT FUNCTION TO CREATE DELTA VARIABLES IN BASES, ONLY NEED THESE // update predicted nodal variables for second half of time step // velocity @@ -672,8 +672,8 @@ namespace ATC { this->add_to_energy(myNodalAtomicLambdaPower,deltaEnergy2_,0.5*dt); atc_->apply_inverse_mass_matrix(deltaEnergy2_,TEMPERATURE); myTemperature += deltaEnergy2_; - - + + isFirstTimestep_ = false; } @@ -695,7 +695,7 @@ namespace ATC { void KinetoThermostatGlcFs::output(OUTPUT_LIST & /* outputData */) { // DO NOT CALL INDIVIDUAL REGULATORS - // OUTPUT TOTAL FORCE AND TOTAL POWER + // OUTPUT TOTAL FORCE AND TOTAL POWER // OUTPUT EACH LAMBDA } diff --git a/lib/atc/KinetoThermostat.h b/lib/atc/KinetoThermostat.h index bc40f19ed1..c025e4b4f9 100644 --- a/lib/atc/KinetoThermostat.h +++ b/lib/atc/KinetoThermostat.h @@ -25,23 +25,23 @@ namespace ATC { * @brief Manager class for atom-continuum simulataneous control of momentum and thermal energy */ class KinetoThermostat : public AtomicRegulator { - + public: // constructor KinetoThermostat(ATC_Coupling * atc, const std::string & regulatorPrefix = ""); - + // destructor virtual ~KinetoThermostat(){}; - + /** parser/modifier */ virtual bool modify(int narg, char **arg); /** instantiate up the desired method(s) */ virtual void construct_methods(); - + // data access, intended for method objects /** reset the nodal power to a prescribed value */ virtual void reset_lambda_contribution(const DENS_MAT & target, @@ -56,10 +56,10 @@ namespace ATC { int couplingMaxIterations_; private: - + // DO NOT define this KinetoThermostat(); - + }; /** @@ -67,12 +67,12 @@ namespace ATC { * @brief Class for kinetostat/thermostat algorithms using the shape function matrices * (thermostats have general for of N^T w N lambda = rhs) */ - + class KinetoThermostatShapeFunction : public RegulatorMethod { - + public: - + KinetoThermostatShapeFunction(AtomicRegulator * kinetoThermostat, int couplingMaxIterations, const std::string & /* regulatorPrefix */) : RegulatorMethod(kinetoThermostat), @@ -80,7 +80,7 @@ namespace ATC { KinetoThermostatShapeFunction(AtomicRegulator * kinetoThermostat, int couplingMaxIterations) : RegulatorMethod(kinetoThermostat), couplingMaxIterations_(couplingMaxIterations) {}; - + virtual ~KinetoThermostatShapeFunction() {}; /** instantiate all needed data */ @@ -108,25 +108,25 @@ namespace ATC { * @class VelocityRescaleCombined * @brief Enforces constraints on atomic velocity based on FE temperature and velocity */ - + class VelocityRescaleCombined : public VelocityGlc { - + public: friend class KinetoThermostatRescale; // since this is basically a set of member functions for friend - + VelocityRescaleCombined(AtomicRegulator * kinetostat); - + virtual ~VelocityRescaleCombined(){}; /** pre-run initialization of method data */ virtual void initialize(); - + /** applies kinetostat to atoms */ virtual void apply_mid_predictor(double /* dt */){}; /** applies kinetostat to atoms */ virtual void apply_post_corrector(double /* dt */){}; - + /** local shape function matrices are incompatible with this mode */ virtual bool use_local_shape_functions() const {return false;}; @@ -135,10 +135,10 @@ namespace ATC { // data /** reference to AtC FE velocity */ DENS_MAN & velocity_; - + /** RHS correct based on thermostat */ DENS_MAN * thermostatCorrection_; - + // methods /** sets up appropriate rhs for kinetostat equations */ virtual void set_kinetostat_rhs(DENS_MAT & rhs, double dt); @@ -161,29 +161,29 @@ namespace ATC { // DO NOT define this VelocityRescaleCombined(); - + }; /** * @class ThermostatRescaleCombined * @brief Enforces constraint on atomic kinetic energy based on FE temperature and velocity */ - + class ThermostatRescaleCombined : public ThermostatRescale { - + public: - + ThermostatRescaleCombined(AtomicRegulator * thermostat); - + virtual ~ThermostatRescaleCombined() {}; /** pre-run initialization of method data */ virtual void initialize(); - + // deactivate un-needed methods /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double /* dt */){}; - + protected: // data @@ -201,21 +201,21 @@ namespace ATC { // DO NOT define this ThermostatRescaleCombined(); - + }; /** * @class KinetoThermostatRescale * @brief Enforces constraints on atomic kinetic energy and velocity based on FE temperature and velocity */ - + class KinetoThermostatRescale : public KinetoThermostatShapeFunction { - + public: - + KinetoThermostatRescale(AtomicRegulator * kinetoThermostat, int couplingMaxIterations); - + virtual ~KinetoThermostatRescale(); /** instantiate all needed data */ @@ -223,7 +223,7 @@ namespace ATC { /** pre-run initialization of method data */ virtual void initialize(); - + /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); @@ -233,7 +233,7 @@ namespace ATC { /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: // methods @@ -275,29 +275,29 @@ namespace ATC { // DO NOT define this KinetoThermostatRescale(); - + }; /** * @class ThermostatRescaleMixedKePeCombined * @brief Enforces constraint on atomic kinetic energy based on FE temperature and velocity when the temperature is comprised of both KE and PE contributions */ - + class ThermostatRescaleMixedKePeCombined : public ThermostatRescaleMixedKePe { - + public: - + ThermostatRescaleMixedKePeCombined(AtomicRegulator * thermostat); - + virtual ~ThermostatRescaleMixedKePeCombined() {}; /** pre-run initialization of method data */ virtual void initialize(); - + // deactivate un-needed methods /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double /* dt */){}; - + protected: // data @@ -315,7 +315,7 @@ namespace ATC { // DO NOT define this ThermostatRescaleMixedKePeCombined(); - + }; /** @@ -323,16 +323,16 @@ namespace ATC { * @brief Enforces constraint on atomic kinetic energy based on FE temperature * when the temperature is a mix of the KE and PE */ - + class KinetoThermostatRescaleMixedKePe : public KinetoThermostatRescale { - + public: - + KinetoThermostatRescaleMixedKePe(AtomicRegulator * kinetoThermostat, int couplingMaxIterations); virtual ~KinetoThermostatRescaleMixedKePe() {}; - + protected: /** creates the appropriate rescaling thermostat */ @@ -342,22 +342,22 @@ namespace ATC { // DO NOT define this KinetoThermostatRescaleMixedKePe(); - + }; /** * @class KinetoThermostatGlcFs * @brief Class for regulation algorithms based on Gaussian least constraints (GLC) for fractional step (FS) algorithsm */ - + class KinetoThermostatGlcFs : public KinetoThermostatShapeFunction { - + public: - + KinetoThermostatGlcFs(AtomicRegulator * kinetoThermostat, int couplingMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~KinetoThermostatGlcFs() {}; /** instantiate all needed data */ @@ -374,7 +374,7 @@ namespace ATC { /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); - + /** get data for output */ virtual void output(OUTPUT_LIST & outputData); @@ -494,12 +494,12 @@ namespace ATC { /* *\/ */ /* class ThermostatFlux : public ThermostatGlcFs { */ - + /* public: */ - + /* ThermostatFlux(Thermostat * thermostat, */ /* const std::string & regulatorPrefix = ""); */ - + /* virtual ~ThermostatFlux() {}; */ /* /\** instantiate all needed data *\/ */ @@ -507,7 +507,7 @@ namespace ATC { /* /\** pre-run initialization of method data *\/ */ /* virtual void initialize(); */ - + /* protected: */ /* /\** sets up appropriate rhs for thermostat equations *\/ */ @@ -539,12 +539,12 @@ namespace ATC { /* *\/ */ /* class ThermostatFixed : public ThermostatGlcFs { */ - + /* public: */ - + /* ThermostatFixed(Thermostat * thermostat, */ /* const std::string & regulatorPrefix = ""); */ - + /* virtual ~ThermostatFixed() {}; */ /* /\** instantiate all needed data *\/ */ @@ -552,7 +552,7 @@ namespace ATC { /* /\** pre-run initialization of method data *\/ */ /* virtual void initialize(); */ - + /* /\** applies thermostat to atoms in the predictor phase *\/ */ /* virtual void apply_pre_predictor(double dt); */ @@ -568,7 +568,7 @@ namespace ATC { /* /\** determine if local shape function matrices are needed *\/ */ /* virtual bool use_local_shape_functions() const {return atomicRegulator_->use_localized_lambda();}; */ - + /* protected: */ /* // methods */ @@ -639,12 +639,12 @@ namespace ATC { /* *\/ */ /* class ThermostatFluxFiltered : public ThermostatFlux { */ - + /* public: */ - + /* ThermostatFluxFiltered(Thermostat * thermostat, */ /* const std::string & regulatorPrefix = ""); */ - + /* virtual ~ThermostatFluxFiltered() {}; */ /* /\** pre-run initialization of method data *\/ */ @@ -655,7 +655,7 @@ namespace ATC { /* /\** get data for output *\/ */ /* virtual void output(OUTPUT_LIST & outputData); */ - + /* protected: */ /* /\** sets up appropriate rhs for thermostat equations *\/ */ @@ -685,19 +685,19 @@ namespace ATC { /* * @brief Class for thermostatting using the temperature matching constraint and is compatible with */ /* the fractional step time-integration with time filtering */ /* *\/ */ - + /* class ThermostatFixedFiltered : public ThermostatFixed { */ - + /* public: */ - + /* ThermostatFixedFiltered(Thermostat * thermostat, */ /* const std::string & regulatorPrefix = ""); */ - + /* virtual ~ThermostatFixedFiltered() {}; */ /* /\** get data for output *\/ */ /* virtual void output(OUTPUT_LIST & outputData); */ - + /* protected: */ /* // methods */ @@ -734,7 +734,7 @@ namespace ATC { /* ThermostatFluxFixed(Thermostat * thermostat, */ /* bool constructThermostats = true); */ - + /* virtual ~ThermostatFluxFixed(); */ /* /\** instantiate all needed data *\/ */ @@ -751,7 +751,7 @@ namespace ATC { /* /\** applies thermostat to atoms in the post-corrector phase *\/ */ /* virtual void apply_post_corrector(double dt); */ - + /* /\** get data for output *\/ */ /* virtual void output(OUTPUT_LIST & outputData); */ @@ -787,7 +787,7 @@ namespace ATC { /* public: */ /* ThermostatFluxFixedFiltered(Thermostat * thermostat); */ - + /* virtual ~ThermostatFluxFixedFiltered(){}; */ /* private: */ diff --git a/lib/atc/Kinetostat.cpp b/lib/atc/Kinetostat.cpp index 676896a2f9..21c319dbae 100644 --- a/lib/atc/Kinetostat.cpp +++ b/lib/atc/Kinetostat.cpp @@ -28,7 +28,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // modify: // parses and adjusts kinetostat state based on @@ -46,20 +46,20 @@ namespace ATC { /*! \page man_control_momentum fix_modify AtC control momentum \section syntax fix_modify AtC control momentum none \n - + fix_modify AtC control momentum rescale \n - frequency (int) = time step frequency for applying displacement and velocity rescaling \n - + fix_modify AtC control momentum glc_displacement \n - + fix_modify AtC control momentum glc_velocity \n fix_modify AtC control momentum hoover \n - fix_modify AtC control momentum flux [faceset face_set_id, interpolate] + fix_modify AtC control momentum flux [faceset face_set_id, interpolate] - face_set_id (string) = id of boundary face set, if not specified - (or not possible when the atomic domain does not line up with - mesh boundaries) defaults to an atomic-quadrature approximate + (or not possible when the atomic domain does not line up with + mesh boundaries) defaults to an atomic-quadrature approximate evaulation\n \section examples fix_modify AtC control momentum glc_velocity \n @@ -108,7 +108,7 @@ namespace ATC { foundMatch = true; } } - + if (!foundMatch) foundMatch = AtomicRegulator::modify(narg,arg); if (foundMatch) @@ -126,13 +126,13 @@ namespace ATC { DENS_MAN * lambdaForceFiltered = regulator_data("LambdaForceFiltered",nsd_); lambdaForceFiltered->set_quantity() = target; } - + //-------------------------------------------------------- // initialize: // sets up methods before a run - + // dependence, but in general there is also a - // time integrator dependence. In general the + // time integrator dependence. In general the // precedence order is: // time filter -> time integrator -> kinetostat // In the future this may need to be added if @@ -147,7 +147,7 @@ namespace ATC { if (atc_->reset_methods()) { // eliminate existing methods delete_method(); - + DENS_MAT nodalGhostForceFiltered; TimeIntegrator::TimeIntegrationType myIntegrationType = (atc_->time_integrator(VELOCITY))->time_integration_type(); TimeFilterManager * timeFilterManager = atc_->time_filter_manager(); @@ -156,9 +156,9 @@ namespace ATC { myMethod = dynamic_cast(regulatorMethod_); nodalGhostForceFiltered = (myMethod->filtered_ghost_force()).quantity(); } - + // update time filter - + if (timeFilterManager->need_reset()) { if (myIntegrationType == TimeIntegrator::FRACTIONAL_STEP) { timeFilter_ = timeFilterManager->construct(TimeFilterManager::EXPLICIT_IMPLICIT); @@ -167,7 +167,7 @@ namespace ATC { timeFilter_ = timeFilterManager->construct(TimeFilterManager::IMPLICIT_UPDATE); } } - + if (timeFilterManager->filter_dynamics()) { switch (regulatorTarget_) { case NONE: { @@ -297,7 +297,7 @@ namespace ATC { // Class KinetostatShapeFunction //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -369,7 +369,7 @@ namespace ATC { // Class GlcKinetostat //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -391,7 +391,7 @@ namespace ATC { // needed fundamental quantities atomPositions_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_POSITION); - + // base class transfers KinetostatShapeFunction::construct_transfers(); } @@ -404,7 +404,7 @@ namespace ATC { { KinetostatShapeFunction::initialize(); - + // set up list of nodes using Hoover coupling // (a) nodes with prescribed values PrescribedDataManager * prescribedDataMgr(atc_->prescribed_data_manager()); @@ -455,7 +455,7 @@ namespace ATC { // Class DisplacementGlc //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -501,7 +501,7 @@ namespace ATC { else { linearSolverType_ = AtomicRegulator::CG_SOLVE; } - + // base class transfers GlcKinetostat::construct_transfers(); @@ -510,14 +510,14 @@ namespace ATC { atomKinetostatForce_ = new AtomicKinetostatForceDisplacement(atc_); interscaleManager.add_per_atom_quantity(atomKinetostatForce_, regulatorPrefix_+"AtomKinetostatForce"); - + // restricted force due to kinetostat nodalAtomicLambdaForce_ = new AtfShapeFunctionRestriction(atc_, atomKinetostatForce_, interscaleManager.per_atom_sparse_matrix("Interpolant")); interscaleManager.add_dense_matrix(nodalAtomicLambdaForce_, regulatorPrefix_+"NodalAtomicLambdaForce"); - + // nodal displacement restricted from atoms nodalAtomicMassWeightedDisplacement_ = interscaleManager.dense_matrix("NodalAtomicMassWeightedDisplacement"); } @@ -640,7 +640,7 @@ namespace ATC { DENS_MAT & nodalField, double weight) { - + DENS_MAT nodalLambdaRoc(nNodes_,nsd_); atc_->apply_inverse_mass_matrix(source, nodalLambdaRoc, @@ -666,13 +666,13 @@ namespace ATC { outputData[regulatorPrefix_+"NodalLambdaForce"] = &(_nodalAtomicLambdaForceOut_); } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class DisplacementGlcFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -683,7 +683,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // apply_pre_filtering // applies first step of filtering to @@ -750,13 +750,13 @@ namespace ATC { outputData[regulatorPrefix_+"NodalLambdaForce"] = &lambdaForceFiltered; } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class VelocityGlc //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -805,7 +805,7 @@ namespace ATC { else { linearSolverType_ = AtomicRegulator::CG_SOLVE; } - + // base class transfers GlcKinetostat::construct_transfers(); @@ -813,18 +813,18 @@ namespace ATC { atomKinetostatForce_ = new AtomicKinetostatForceVelocity(atc_); interscaleManager.add_per_atom_quantity(atomKinetostatForce_, regulatorPrefix_+"AtomKinetostatForce"); - + // restricted force due to kinetostat nodalAtomicLambdaForce_ = new AtfShapeFunctionRestriction(atc_, atomKinetostatForce_, interscaleManager.per_atom_sparse_matrix("Interpolant")); interscaleManager.add_dense_matrix(nodalAtomicLambdaForce_, regulatorPrefix_+"NodalAtomicLambdaForce"); - + // nodal momentum restricted from atoms nodalAtomicMomentum_ = interscaleManager.dense_matrix("NodalAtomicMomentum"); - + } //-------------------------------------------------------- @@ -891,7 +891,7 @@ namespace ATC { // set up rhs DENS_MAT rhs(nNodes_,nsd_); this->set_kinetostat_rhs(rhs,dt); - + // solve linear system for lambda solve_for_lambda(rhs,lambda_->set_quantity()); #ifdef OBSOLETE @@ -975,7 +975,7 @@ namespace ATC { DENS_MAT & nodalField, double weight) { - + DENS_MAT nodalLambdaRoc(nNodes_,nsd_); atc_->apply_inverse_mass_matrix(source, nodalLambdaRoc, @@ -984,7 +984,7 @@ namespace ATC { for (iter = hooverNodes_.begin(); iter != hooverNodes_.end(); ++iter) { nodalLambdaRoc(iter->first,iter->second) = 0.; } - + nodalField += weight*nodalLambdaRoc; } @@ -1000,18 +1000,18 @@ namespace ATC { outputData[regulatorPrefix_+"NodalLambdaForce"] = &(_nodalAtomicLambdaForceOut_); } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class VelocityGlcFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data //-------------------------------------------------------- - VelocityGlcFiltered::VelocityGlcFiltered(AtomicRegulator *kinetostat) + VelocityGlcFiltered::VelocityGlcFiltered(AtomicRegulator *kinetostat) : VelocityGlc(kinetostat), nodalAtomicVelocities_(atc_->nodal_atomic_field(VELOCITY)) { @@ -1087,7 +1087,7 @@ namespace ATC { // Class StressFlux //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -1152,7 +1152,7 @@ namespace ATC { atomKinetostatForce_ = new AtomicKinetostatForceStress(atc_,atomLambdas_); interscaleManager.add_per_atom_quantity(atomKinetostatForce_, regulatorPrefix_+"AtomKinetostatForce"); - + // restricted force due to kinetostat nodalAtomicLambdaForce_ = new AtfShapeFunctionRestriction(atc_, atomKinetostatForce_, @@ -1254,7 +1254,7 @@ namespace ATC { //-------------------------------------------------------- void StressFlux::set_kinetostat_rhs(DENS_MAT & rhs, double /* dt */) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV - \sum_g N_Ig^* f_g // sources are set in ATC transfer rhs.reset(nNodes_,nsd_); @@ -1262,9 +1262,9 @@ namespace ATC { if (nodalGhostForce_) { rhs -= nodalGhostForce_->quantity(); } - + // (b) for ess. bcs - + // form rhs : {sum_a (N_Ia * f_ia) - M_md * (ddupsilon/dt)_I} DENS_MAT rhsPrescribed = -1.*nodalForce_.quantity(); atc_->apply_inverse_mass_matrix(rhsPrescribed,VELOCITY); @@ -1352,7 +1352,7 @@ namespace ATC { // Class StressFluxGhost //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -1409,14 +1409,14 @@ namespace ATC { //-------------------------------------------------------- void StressFluxGhost::set_kinetostat_rhs(DENS_MAT & rhs, double /* dt */) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV - \sum_g N_Ig^* f_g // sources are set in ATC transfer rhs.reset(nNodes_,nsd_); rhs = momentumSource_.quantity(); - + // (b) for ess. bcs - + // form rhs : {sum_a (N_Ia * f_ia) - M_md * (ddupsilon/dt)_I} DENS_MAT rhsPrescribed = -1.*nodalForce_.quantity(); atc_->apply_inverse_mass_matrix(rhsPrescribed,VELOCITY); @@ -1434,7 +1434,7 @@ namespace ATC { // Class StressFluxFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -1453,14 +1453,14 @@ namespace ATC { void StressFluxFiltered::set_kinetostat_rhs(DENS_MAT & rhs, double dt) { // set basic terms - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV - \sum_g N_Ig^* f_g // sources are set in ATC transfer rhs.reset(nNodes_,nsd_); rhs = momentumSource_.quantity() - nodalGhostForceFiltered_.quantity(); - + // (b) for ess. bcs - + // form rhs : {sum_a (N_Ia * f_ia) - M_md * (ddupsilon/dt)_I} DENS_MAT rhsPrescribed = -1.*nodalForce_.quantity(); atc_->apply_inverse_mass_matrix(rhsPrescribed,VELOCITY); @@ -1530,7 +1530,7 @@ namespace ATC { // Class KinetostatGlcFs //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -1597,7 +1597,7 @@ namespace ATC { void KinetostatGlcFs::initialize() { KinetostatShapeFunction::initialize(); - + TimeFilterManager * timeFilterManager = atc_->time_filter_manager(); if (!timeFilterManager->end_equilibrate()) { // we should reset lambda and lambdaForce to zero in this case @@ -1675,7 +1675,7 @@ namespace ATC { // update filtered forces timeFilter_->apply_pre_step1(lambdaForceFiltered,nodalAtomicLambdaForce,dt); - // apply lambda force to atoms and compute instantaneous lambda force + // apply lambda force to atoms and compute instantaneous lambda force this->apply_to_atoms(atomVelocities_,nodalAtomicMomentum_, atomKinetostatForce_->quantity(), nodalAtomicLambdaForce,0.5*dt); @@ -1710,13 +1710,13 @@ namespace ATC { nodalAtomicPredictedMomentum_, atomKinetostatForce_->quantity(), myNodalAtomicLambdaForce,0.5*dt); - + // update predicted nodal variables for second half of time step this->add_to_momentum(myNodalAtomicLambdaForce,deltaMomentum_,0.5*dt); atc_->apply_inverse_mass_matrix(deltaMomentum_,VELOCITY); velocity_ += deltaMomentum_; } - + //-------------------------------------------------------- // apply_post_corrector: // apply the kinetostat to the atoms in the @@ -1746,7 +1746,7 @@ namespace ATC { atc_->apply_inverse_mass_matrix(deltaMomentum_,VELOCITY); velocity_ += deltaMomentum_; - + isFirstTimestep_ = false; } @@ -1787,7 +1787,7 @@ namespace ATC { // Class KinetostatFlux //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -1838,7 +1838,7 @@ namespace ATC { // sets up space for ghost force related variables if (atc_->groupbit_ghost()) { - MatrixDependencyManager * nodeToOverlapMap = + MatrixDependencyManager * nodeToOverlapMap = interscaleManager.dense_matrix_int(regulatorPrefix_+"NodeToOverlapMap"); GhostCouplingMatrix * shapeFunctionGhost = new GhostCouplingMatrix(atc_,interscaleManager.per_atom_sparse_matrix("InterpolantGhost"), regulatedNodes_, @@ -1861,7 +1861,7 @@ namespace ATC { void KinetostatFlux::initialize() { KinetostatGlcFs::initialize(); - + TimeFilterManager * timeFilterManager = atc_->time_filter_manager(); if (!timeFilterManager->end_equilibrate()) { // we should reset lambda and lambdaForce to zero in this case @@ -1894,13 +1894,13 @@ namespace ATC { interscaleManager.add_set_int(regulatedNodes_, regulatorPrefix_+"KinetostatRegulatedNodes"); } - + // if localized monitor nodes with applied fluxes if (atomicRegulator_->use_localized_lambda()) { if ((atomicRegulator_->coupling_mode() == Kinetostat::FLUX) && (atomicRegulator_->boundary_integration_type() != NO_QUADRATURE)) { // include boundary nodes applicationNodes_ = new FluxBoundaryNodes(atc_); - + boundaryNodes_ = new BoundaryNodes(atc_); interscaleManager.add_set_int(boundaryNodes_, regulatorPrefix_+"KinetostatBoundaryNodes"); @@ -1916,7 +1916,7 @@ namespace ATC { applicationNodes_ = regulatedNodes_; } - // special set of boundary elements for boundary flux quadrature + // special set of boundary elements for boundary flux quadrature if ((atomicRegulator_->boundary_integration_type() == FE_INTERPOLATION) && (atomicRegulator_->use_localized_lambda())) { elementMask_ = interscaleManager.dense_matrix_bool(regulatorPrefix_+"BoundaryElementMask"); @@ -1943,7 +1943,7 @@ namespace ATC { KinetostatGlcFs::apply_pre_predictor(dt); } - + //-------------------------------------------------------- // apply_post_corrector: // apply the kinetostat to the atoms in the @@ -1956,7 +1956,7 @@ namespace ATC { timeFilter_->apply_post_step1(nodalGhostForceFiltered_->set_quantity(), nodalGhostForce_->quantity(),dt); } - + // compute the kinetostat equation and update lambda KinetostatGlcFs::apply_post_corrector(dt); } @@ -1987,7 +1987,7 @@ namespace ATC { //-------------------------------------------------------- void KinetostatFlux::set_kinetostat_rhs(DENS_MAT & rhs, double /* dt */) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV - \sum_g N_Ig^* f_g // sources are set in ATC transfer rhs.reset(nNodes_,nsd_); @@ -2026,7 +2026,7 @@ namespace ATC { // Class KinetostatFluxGhost //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -2088,7 +2088,7 @@ namespace ATC { //-------------------------------------------------------- void KinetostatFluxGhost::set_kinetostat_rhs(DENS_MAT & rhs, double /* dt */) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV - \sum_g N_Ig^* f_g // sources are set in ATC transfer rhs.reset(nNodes_,nsd_); @@ -2107,7 +2107,7 @@ namespace ATC { // Class KinetostatFixed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and kinetostat data @@ -2211,14 +2211,14 @@ namespace ATC { else { throw ATC_Error("KinetostatFixed::construct_regulated_nodes - couldn't determine set of regulated nodes"); } - + interscaleManager.add_set_int(regulatedNodes_, regulatorPrefix_+"RegulatedNodes"); } applicationNodes_ = regulatedNodes_; - // special set of boundary elements for defining regulated atoms + // special set of boundary elements for defining regulated atoms if (atomicRegulator_->use_localized_lambda()) { elementMask_ = interscaleManager.dense_matrix_bool(regulatorPrefix_+"BoundaryElementMask"); if (!elementMask_) { @@ -2310,15 +2310,15 @@ namespace ATC { nodalAtomicMomentumFiltered_ = _tempNodalAtomicMomentumFiltered_; } } - + //-------------------------------------------------------- // apply_post_corrector: // apply the kinetostat to the atoms in the // post-corrector integration phase //-------------------------------------------------------- void KinetostatFixed::apply_post_corrector(double dt) - { - + { + bool halveForce = halve_force(); KinetostatGlcFs::apply_post_corrector(dt); @@ -2333,8 +2333,8 @@ namespace ATC { // 1) makes up for poor initial condition // 2) accounts for possibly large value of lambda when atomic shape function values change // from eulerian mapping after more than 1 timestep - // avoids unstable oscillations arising from - // thermostat having to correct for error introduced in lambda changing the + // avoids unstable oscillations arising from + // thermostat having to correct for error introduced in lambda changing the // shape function matrices *lambda_ *= 0.5; } @@ -2396,7 +2396,7 @@ namespace ATC { // Class KinetostatFluxFixed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- diff --git a/lib/atc/Kinetostat.h b/lib/atc/Kinetostat.h index e3e1c17e52..e8469a6bff 100644 --- a/lib/atc/Kinetostat.h +++ b/lib/atc/Kinetostat.h @@ -22,16 +22,16 @@ namespace ATC { */ class Kinetostat : public AtomicRegulator { - + public: // constructor Kinetostat(ATC_Coupling *atc, const std::string & regulatorPrefix = ""); - + // destructor virtual ~Kinetostat(){}; - + /** parser/modifier */ virtual bool modify(int narg, char **arg); @@ -53,14 +53,14 @@ namespace ATC { * @class KinetostatShapeFunction * @brief Base class for implementation of kinetostat algorithms based on FE shape functions */ - + class KinetostatShapeFunction : public RegulatorShapeFunction { - + public: - + KinetostatShapeFunction(AtomicRegulator *kinetostat, const std::string & regulatorPrefix = ""); - + virtual ~KinetostatShapeFunction(){}; /** instantiate all needed data */ @@ -95,23 +95,23 @@ namespace ATC { DENS_MAT _nodalAtomicLambdaForceOut_; // matrix for output only private: - + // DO NOT define this KinetostatShapeFunction(); }; - + /** * @class GlcKinetostat * @brief Base class for implementation of kinetostat algorithms based on Gaussian least constraints (GLC) */ - + class GlcKinetostat : public KinetostatShapeFunction { - + public: - + GlcKinetostat(AtomicRegulator *kinetostat); - + virtual ~GlcKinetostat(){}; /** instantiate all needed data */ @@ -139,30 +139,30 @@ namespace ATC { /** nodeset corresponding to Hoover coupling */ std::set > hooverNodes_; - + /** pointer to atom positions */ FundamentalAtomQuantity * atomPositions_; private: - + // DO NOT define this GlcKinetostat(); }; - + /** * @class DisplacementGlc * @brief Enforces GLC on atomic position based on FE displacement */ - + class DisplacementGlc : public GlcKinetostat { - + public: - + DisplacementGlc(AtomicRegulator * kinetostat); - + virtual ~DisplacementGlc(){}; - + /** instantiate all needed data */ virtual void construct_transfers(); @@ -177,9 +177,9 @@ namespace ATC { /** determine if local shape function matrices are needed */ virtual bool use_local_shape_functions() const {return (!atomicRegulator_->use_lumped_lambda_solve()) && atomicRegulator_->use_localized_lambda();}; - + protected: - + // methods /** set weighting factor for in matrix Nhat^T * weights * Nhat */ virtual void set_weights(); @@ -204,36 +204,36 @@ namespace ATC { DENS_MAN & nodalDisplacements_; private: - + // DO NOT define this DisplacementGlc(); - + }; /** * @class DisplacementGlcFiltered * @brief Enforces GLC on time filtered atomic position based on FE displacement */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class DisplacementGlcFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + class DisplacementGlcFiltered : public DisplacementGlc { - + public: - + DisplacementGlcFiltered(AtomicRegulator * kinetostat); - + virtual ~DisplacementGlcFiltered(){}; /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: - + // methods /** does initial filtering operations before main computation */ virtual void apply_pre_filtering(double dt); @@ -247,29 +247,29 @@ namespace ATC { DENS_MAN & nodalAtomicDisplacements_; private: - + // DO NOT define this DisplacementGlcFiltered(); - + }; /** * @class VelocityGlc * @brief Enforces GLC on atomic velocity based on FE velocity */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class VelocityGlc //-------------------------------------------------------- //-------------------------------------------------------- - + class VelocityGlc : public GlcKinetostat { - + public: - + VelocityGlc(AtomicRegulator * kinetostat); - + virtual ~VelocityGlc(){}; /** instantiate all needed data */ @@ -277,7 +277,7 @@ namespace ATC { /** pre-run initialization of method data */ virtual void initialize(); - + /** applies kinetostat to atoms */ virtual void apply_mid_predictor(double dt); @@ -286,12 +286,12 @@ namespace ATC { /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + /** determine if local shape function matrices are needed */ virtual bool use_local_shape_functions() const {return (!atomicRegulator_->use_lumped_lambda_solve()) && atomicRegulator_->use_localized_lambda();}; protected: - + // methods /** set weighting factor for in matrix Nhat^T * weights * Nhat */ virtual void set_weights(); @@ -321,31 +321,31 @@ namespace ATC { // DO NOT define this VelocityGlc(); - + }; /** * @class VelocityGlcFiltered * @brief Enforces GLC on time filtered atomic velocity based on FE velocity */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class VelocityGlcFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + class VelocityGlcFiltered : public VelocityGlc { - + public: - + VelocityGlcFiltered(AtomicRegulator * kinetostat); - + virtual ~VelocityGlcFiltered(){}; /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: // methods @@ -355,7 +355,7 @@ namespace ATC { virtual void set_kinetostat_rhs(DENS_MAT & rhs, double dt); /** computes the nodal FE force applied by the kinetostat */ virtual void compute_nodal_lambda_force(double dt); - + // data /** clone of FE nodal atomic velocity field */ DENS_MAN & nodalAtomicVelocities_; @@ -364,7 +364,7 @@ namespace ATC { // DO NOT define this VelocityGlcFiltered(); - + }; /** @@ -377,13 +377,13 @@ namespace ATC { // Class StressFlux //-------------------------------------------------------- //-------------------------------------------------------- - + class StressFlux : public GlcKinetostat { - + public: - + StressFlux(AtomicRegulator * kinetostat); - + virtual ~StressFlux(); /** instantiate all needed data */ @@ -408,7 +408,7 @@ namespace ATC { /** determine if local shape function matrices are needed */ virtual bool use_local_shape_functions() const {return ((!atomicRegulator_->use_lumped_lambda_solve()) && atomicRegulator_->use_localized_lambda());}; - + protected: // data @@ -459,13 +459,13 @@ namespace ATC { // Class StressFluxGhost //-------------------------------------------------------- //-------------------------------------------------------- - + class StressFluxGhost : public StressFlux { - + public: - + StressFluxGhost(AtomicRegulator * kinetostat); - + virtual ~StressFluxGhost() {}; /** instantiate all needed data */ @@ -473,7 +473,7 @@ namespace ATC { /** compute boundary flux, requires kinetostat input since it is part of the coupling scheme */ virtual void compute_boundary_flux(FIELDS & fields); - + protected: // methods @@ -493,19 +493,19 @@ namespace ATC { * @class StressFluxFiltered * @brief Enforces GLC on time filtered atomic forces based on FE stresses or accelerations */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class StressFluxFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + class StressFluxFiltered : public StressFlux { - + public: - + StressFluxFiltered(AtomicRegulator * kinetostat); - + virtual ~StressFluxFiltered(){}; /** adds in finite element rhs contributions */ @@ -513,7 +513,7 @@ namespace ATC { /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: // data @@ -522,7 +522,7 @@ namespace ATC { // methods /** sets up appropriate rhs for kinetostat equations */ virtual void set_kinetostat_rhs(DENS_MAT & rhs, double dt); - + /** apply forces to atoms */ virtual void apply_to_atoms(PerAtomQuantity * quantity, const DENS_MAT & lambdaAtom, @@ -540,14 +540,14 @@ namespace ATC { * @brief Base class for implementation of kinetostat algorithms based on Gaussian least constraints (GLC) * when fractional step time integration is used */ - + class KinetostatGlcFs : public KinetostatShapeFunction { - + public: - + KinetostatGlcFs(AtomicRegulator *kinetostat, const std::string & regulatorPrefix = ""); - + virtual ~KinetostatGlcFs(){}; /** instantiate all needed data */ @@ -564,7 +564,7 @@ namespace ATC { /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); - + /** get data for output */ virtual void output(OUTPUT_LIST & outputData); @@ -626,7 +626,7 @@ namespace ATC { DENS_MAT _velocityDelta_; // change in velocity when lambda force is applied private: - + // DO NOT define this KinetostatGlcFs(); @@ -637,14 +637,14 @@ namespace ATC { * @brief Implementation of kinetostat algorithms based on Gaussian least constraints (GLC) * which apply stresses when fractional step time integration is used */ - + class KinetostatFlux : public KinetostatGlcFs { - + public: - + KinetostatFlux(AtomicRegulator *kinetostat, const std::string & regulatorPrefix = ""); - + virtual ~KinetostatFlux(){}; /** instantiate all needed data */ @@ -680,7 +680,7 @@ namespace ATC { // member data /** reference to ATC sources coming from prescribed data, AtC coupling, and extrinsic coupling */ DENS_MAN & momentumSource_; - + /** force from ghost atoms restricted to nodes */ DENS_MAN * nodalGhostForce_; @@ -688,7 +688,7 @@ namespace ATC { DENS_MAN * nodalGhostForceFiltered_; private: - + // DO NOT define this KinetostatFlux(); @@ -698,14 +698,14 @@ namespace ATC { * @class KinetostatFluxGhost * @brief Implements ghost-atom boundary flux and other loads for fractional-step based kinetostats */ - + class KinetostatFluxGhost : public KinetostatFlux { - + public: - + KinetostatFluxGhost(AtomicRegulator *kinetostat, const std::string & regulatorPrefix = ""); - + virtual ~KinetostatFluxGhost(){}; /** instantiate all needed data */ @@ -726,7 +726,7 @@ namespace ATC { double dt); private: - + // DO NOT define this KinetostatFluxGhost(); @@ -737,14 +737,14 @@ namespace ATC { * @brief Implementation of kinetostat algorithms based on Gaussian least constraints (GLC) * which perform Hoover coupling when fractional step time integration is used */ - + class KinetostatFixed : public KinetostatGlcFs { - + public: - + KinetostatFixed(AtomicRegulator *kinetostat, const std::string & regulatorPrefix = ""); - + virtual ~KinetostatFixed(){}; /** instantiate all needed data */ @@ -819,7 +819,7 @@ namespace ATC { DENS_MAT _tempNodalAtomicMomentumFiltered_; // stores filtered momentum change in atoms for persistence during predictor private: - + // DO NOT define this KinetostatFixed(); @@ -836,7 +836,7 @@ namespace ATC { KinetostatFluxFixed(AtomicRegulator * kinetostat, bool constructThermostats = true); - + virtual ~KinetostatFluxFixed(); /** instantiate all needed data */ @@ -853,7 +853,7 @@ namespace ATC { /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); - + /** get data for output */ virtual void output(OUTPUT_LIST & outputData); diff --git a/lib/atc/LammpsInterface.cpp b/lib/atc/LammpsInterface.cpp index b123331ee7..ea8a64ec4c 100644 --- a/lib/atc/LammpsInterface.cpp +++ b/lib/atc/LammpsInterface.cpp @@ -16,7 +16,7 @@ #include "compute_cna_atom.h" // computes common-neighbor-analysis per atom #include "compute_coord_atom.h" // computes coordination number per atom #include "compute_ke_atom.h" // computes kinetic energy per atom -#include "modify.h" // +#include "modify.h" // #include "neighbor.h" // neighbors #include "neigh_list.h" // neighbor list #include "update.h" // timestepping information @@ -110,7 +110,7 @@ void LammpsInterface::comm_borders() const { lammps_->comm->borders(); } void LammpsInterface::sparse_allsum(SparseMatrix &toShare) const { toShare.compress(); - + // initialize MPI information int nProcs; int myRank; @@ -119,7 +119,7 @@ void LammpsInterface::sparse_allsum(SparseMatrix &toShare) const int error; - // get numbers of rows, columns, rowsCRS, and + // get numbers of rows, columns, rowsCRS, and // sizes (number of nonzero elements in matrix) SparseMatInfo *recInfo = new SparseMatInfo[nProcs]; SparseMatInfo myInfo; @@ -174,7 +174,7 @@ void LammpsInterface::sparse_allsum(SparseMatrix &toShare) const rec_ja, sizeCounts, sizeOffsets, MPI_INT, lammps_->world); if (error != MPI_SUCCESS) throw ATC_Error("error in sparse_allsum_colarray "+to_string(error)); - + // get the array of values double *rec_vals = new double[totalSize]; error = MPI_Allgatherv(toShare.ptr(), sizeCounts[myRank], MPI_DOUBLE, @@ -182,8 +182,8 @@ void LammpsInterface::sparse_allsum(SparseMatrix &toShare) const if (error != MPI_SUCCESS) throw ATC_Error("error in sparse_allsum_valarray "+to_string(error)); - INDEX *rec_ia_proc; - INDEX *rec_ja_proc; + INDEX *rec_ia_proc; + INDEX *rec_ja_proc; double *rec_vals_proc; for (int i = 0; i < nProcs; i++) { if (myRank != i) { @@ -191,24 +191,24 @@ void LammpsInterface::sparse_allsum(SparseMatrix &toShare) const rec_ia_proc = new INDEX[rowCounts[i]]; rec_ja_proc = new INDEX[sizeCounts[i]]; rec_vals_proc = new double[sizeCounts[i]]; - + // copy the data passed with MPI into the new spots - copy(rec_ia + rowOffsets[i], + copy(rec_ia + rowOffsets[i], rec_ia + rowOffsets[i] + rowCounts[i], rec_ia_proc); - copy(rec_ja + sizeOffsets[i], + copy(rec_ja + sizeOffsets[i], rec_ja + sizeOffsets[i] + sizeCounts[i], rec_ja_proc); - copy(rec_vals + sizeOffsets[i], + copy(rec_vals + sizeOffsets[i], rec_vals + sizeOffsets[i] + sizeCounts[i], rec_vals_proc); // Does anyone know why we have to declare tempMat here (as well as set it equal to - // something) to avoid segfaults? there are still segfaults, but they happen at a much + // something) to avoid segfaults? there are still segfaults, but they happen at a much // later stage of the game now (and for less benchmarks overall). SparseMatrix tempMat = - SparseMatrix(rec_ia_proc, rec_ja_proc, rec_vals_proc, - recInfo[i].size, recInfo[i].rows, + SparseMatrix(rec_ia_proc, rec_ja_proc, rec_vals_proc, + recInfo[i].size, recInfo[i].rows, recInfo[i].cols, recInfo[i].rowsCRS); toShare += tempMat; } @@ -259,7 +259,7 @@ int LammpsInterface::nghost() const { return lammps_->atom->nghost; } bool LammpsInterface::atoms_sorted() const { int sortfreq = lammps_->atom->sortfreq; - if (sortfreq > 0) { return true; } + if (sortfreq > 0) { return true; } else { return false; } } @@ -273,7 +273,7 @@ int LammpsInterface::ntypes() const { return lammps_->atom->ntypes; } double ** LammpsInterface::xatom() const { return lammps_->atom->x; } -int LammpsInterface::type_to_charge(int atype) const { +int LammpsInterface::type_to_charge(int atype) const { double *q = lammps_->atom->q; if (! q) return 0; int nlocal = lammps_->atom->nlocal; @@ -281,7 +281,7 @@ int LammpsInterface::type_to_charge(int atype) const { double aq = 0.0; for (int i = 0; i < nlocal; i++) { if (type[i] == atype) { - aq = q[i]; + aq = q[i]; break; } } @@ -380,7 +380,7 @@ double LammpsInterface::atom_quantity_conversion(FundamentalAtomQuantity quantit else throw ATC_Error("BAD type requested in atom_quantity_conversion"); } - + // ----------------------------------------------------------------- // domain interface methods // ----------------------------------------------------------------- @@ -391,7 +391,7 @@ int LammpsInterface::nregion() const { return lammps_->domain->nregion; } void LammpsInterface::box_bounds(double & boxxlo, double & boxxhi, double & boxylo, double & boxyhi, - double & boxzlo, double &boxzhi) const + double & boxzlo, double &boxzhi) const { if (lammps_->domain->triclinic == 0) { boxxlo = lammps_->domain->boxlo[0]; @@ -417,7 +417,7 @@ bool LammpsInterface::in_box(double * x) const box_bounds(xlo,xhi,ylo,yhi,zlo,zhi); if (x[0] >= xlo && x[0] < xhi && x[1] >= ylo && x[1] < yhi && - x[2] >= zlo && x[2] < zhi) + x[2] >= zlo && x[2] < zhi) return true; return false; } @@ -426,9 +426,9 @@ bool LammpsInterface::in_my_processor_box(double * x) const { if (x[0] >= lammps_->domain->sublo[0] && x[0] < lammps_->domain->subhi[0] && x[1] >= lammps_->domain->sublo[1] && x[1] < lammps_->domain->subhi[1] && - x[2] >= lammps_->domain->sublo[2] && x[2] < lammps_->domain->subhi[2]) + x[2] >= lammps_->domain->sublo[2] && x[2] < lammps_->domain->subhi[2]) return true; - if (! in_box(x)) + if (! in_box(x)) throw ATC_Error("point is in no processors box"); return false; } @@ -436,7 +436,7 @@ bool LammpsInterface::in_my_processor_box(double * x) const void LammpsInterface::sub_bounds(double & subxlo, double & subxhi, double & subylo, double & subyhi, - double & subzlo, double & subzhi) const + double & subzlo, double & subzhi) const { if (lammps_->domain->triclinic == 0) { subxlo = lammps_->domain->sublo[0]; @@ -457,8 +457,8 @@ int LammpsInterface::yperiodic() const { return lammps_->domain->yperiodic; } int LammpsInterface::zperiodic() const { return lammps_->domain->zperiodic; } -int LammpsInterface::nperiodic() const -{ +int LammpsInterface::nperiodic() const +{ int nprd = 0; if ( lammps_->domain->xperiodic > 0 ) { nprd++ ; } if ( lammps_->domain->yperiodic > 0 ) { nprd++ ; } @@ -467,10 +467,10 @@ int LammpsInterface::nperiodic() const } // correct posistions for periodic box -void LammpsInterface::periodicity_correction(double * x) const +void LammpsInterface::periodicity_correction(double * x) const { - int* periodicity = lammps_->domain->periodicity; - if (!refBoxIsSet_) set_reference_box(); + int* periodicity = lammps_->domain->periodicity; + if (!refBoxIsSet_) set_reference_box(); for (int m = 0; m < 3; m++) { if ((bool) periodicity[m]) { if (x[m] < lower_[m] || x[m] > upper_[m]) { @@ -483,15 +483,15 @@ void LammpsInterface::periodicity_correction(double * x) const } } -void LammpsInterface::set_reference_box(void) const +void LammpsInterface::set_reference_box(void) const { double * hi = lammps_->domain->boxhi; double * lo = lammps_->domain->boxlo; double * len = lammps_->domain->prd; for (int i = 0; i < 3; i++) { - upper_[i] = hi[i]; - lower_[i] = lo[i]; - length_[i] = len[i]; + upper_[i] = hi[i]; + lower_[i] = lo[i]; + length_[i] = len[i]; } refBoxIsSet_ = true; } @@ -503,7 +503,7 @@ double LammpsInterface::domain_yprd() const { return lammps_->domain->yprd; } double LammpsInterface::domain_zprd() const { return lammps_->domain->zprd; } -double LammpsInterface::domain_volume() const +double LammpsInterface::domain_volume() const { return (lammps_->domain->xprd)* (lammps_->domain->yprd)* @@ -520,7 +520,7 @@ int LammpsInterface::domain_triclinic() const { return lammps_->domain->triclini void LammpsInterface::box_periodicity(int & xperiodic, int & yperiodic, - int & zperiodic) const + int & zperiodic) const { xperiodic = lammps_->domain->xperiodic; yperiodic = lammps_->domain->yperiodic; @@ -548,11 +548,11 @@ bool LammpsInterface::region_bounds(const char * regionName, xscale = region_xscale(iRegion); yscale = region_yscale(iRegion); zscale = region_zscale(iRegion); - xmin = region_xlo(iRegion); + xmin = region_xlo(iRegion); xmax = region_xhi(iRegion); - ymin = region_ylo(iRegion); + ymin = region_ylo(iRegion); ymax = region_yhi(iRegion); - zmin = region_zlo(iRegion); + zmin = region_zlo(iRegion); zmax = region_zhi(iRegion); if (strcmp(region_style(iRegion),"block")==0) { return true; } else { return false; } @@ -588,10 +588,10 @@ double LammpsInterface::convert_units(double value, UnitsType in, UnitsType out, } else if (out==ATC) { if (units_style()==REAL) { - return value; + return value; } else if (units_style()==METAL) { - return convert_units(value, METAL, out, massExp, lenExp, timeExp)*1.0; + return convert_units(value, METAL, out, massExp, lenExp, timeExp)*1.0; } } else throw ATC_Error("can't convert"); @@ -602,10 +602,10 @@ double LammpsInterface::convert_units(double value, UnitsType in, UnitsType out, } else if (out==ATC) { if (units_style()==REAL) { - return convert_units(value, REAL, out, massExp, lenExp, timeExp)*1.0; + return convert_units(value, REAL, out, massExp, lenExp, timeExp)*1.0; } else if (units_style()==METAL) { - return value; + return value; } } else throw ATC_Error("can't convert"); @@ -626,9 +626,9 @@ double LammpsInterface::ylattice() const { return lammps_->domain->lattice->ylat double LammpsInterface::zlattice() const { return lammps_->domain->lattice->zlattice; } LammpsInterface::LatticeType LammpsInterface::lattice_style() const -{ - if (lammps_->domain->lattice) - return (LammpsInterface::LatticeType)lammps_->domain->lattice->style; +{ + if (lammps_->domain->lattice) + return (LammpsInterface::LatticeType)lammps_->domain->lattice->style; else throw ATC_Error("Lattice has not been defined"); } @@ -672,7 +672,7 @@ double LammpsInterface::near_neighbor_cutoff(void) const double alat = LammpsInterface::max_lattice_constant(); LatticeType type = lattice_style(); if (type == LammpsInterface::SC) { - cutoff = 0.5*(1.0+sqrt(2.0))*alat; + cutoff = 0.5*(1.0+sqrt(2.0))*alat; } else if (type == LammpsInterface::BCC) { cutoff = 0.5*(0.5*sqrt(3.0)+1.0)*alat; } else if (type == LammpsInterface::FCC) { @@ -682,16 +682,16 @@ double LammpsInterface::near_neighbor_cutoff(void) const } else if (type == LammpsInterface::DIAMOND) { cutoff = 0.5*(0.25*sqrt(3.0)+1.0/sqrt(2.0))*alat; } else if (type == LammpsInterface::SQ) { - cutoff = 0.5*(1.0+sqrt(2.0))*alat; + cutoff = 0.5*(1.0+sqrt(2.0))*alat; } else if (type == LammpsInterface::SQ2) { - cutoff = 0.5*(1.0/sqrt(2.0)+1.0)*alat; + cutoff = 0.5*(1.0/sqrt(2.0)+1.0)*alat; } else if (type == LammpsInterface::HEX) { - cutoff = 0.5*(1.0/sqrt(3.0)+1.0)*alat; + cutoff = 0.5*(1.0/sqrt(3.0)+1.0)*alat; } else { throw ATC_Error("Unknown lattice type"); } return cutoff; -} +} //* gets the unit cell vectors void LammpsInterface::unit_cell(double *a1, double *a2, double *a3) const @@ -702,7 +702,7 @@ void LammpsInterface::unit_cell(double *a1, double *a2, double *a3) const LAMMPS_NS::Lattice *lattice = lammps_->domain->lattice; // transform origin lattice->lattice2box(origin[0], origin[1], origin[2]); - + // copy reference lattice vectors memcpy(a[0], lattice->a1, 3*sizeof(double)); memcpy(a[1], lattice->a2, 3*sizeof(double)); @@ -710,7 +710,7 @@ void LammpsInterface::unit_cell(double *a1, double *a2, double *a3) const for (i=0; i<3; i++) { - lattice->lattice2box(a[i][0], a[i][1], a[i][2]); + lattice->lattice2box(a[i][0], a[i][1], a[i][2]); for (j=0; j<3; j++) a[i][j] -= origin[j]; } } @@ -727,7 +727,7 @@ int LammpsInterface::num_atoms_per_cell(void) const else if (comm_rank()==0) { //{throw ATC_Error("lattice style not currently supported by ATC");} print_msg_once("WARNING: Cannot get number of atoms per cell from lattice"); - naCell = 1; + naCell = 1; } return naCell; } @@ -736,7 +736,7 @@ int LammpsInterface::num_atoms_per_cell(void) const double LammpsInterface::volume_per_atom(void) const { double naCell = num_atoms_per_cell(); - double volPerAtom = + double volPerAtom = xlattice() * ylattice() * zlattice() / naCell; return volPerAtom; } @@ -762,24 +762,24 @@ void LammpsInterface::lattice(MATRIX &N, MATRIX &B) const double LammpsInterface::boltz() const{ return lammps_->force->boltz; } -double LammpsInterface::mvv2e() const{ return lammps_->force->mvv2e; } +double LammpsInterface::mvv2e() const{ return lammps_->force->mvv2e; } -double LammpsInterface::ftm2v()const { return lammps_->force->ftm2v; } +double LammpsInterface::ftm2v()const { return lammps_->force->ftm2v; } -double LammpsInterface::nktv2p()const{ return lammps_->force->nktv2p; } +double LammpsInterface::nktv2p()const{ return lammps_->force->nktv2p; } -double LammpsInterface::qqr2e() const{ return lammps_->force->qqr2e; } +double LammpsInterface::qqr2e() const{ return lammps_->force->qqr2e; } -double LammpsInterface::qe2f() const{ return lammps_->force->qe2f; } +double LammpsInterface::qe2f() const{ return lammps_->force->qe2f; } double LammpsInterface::dielectric()const{return lammps_->force->dielectric; } double LammpsInterface::qqrd2e()const{ return lammps_->force->qqrd2e; } double LammpsInterface::qv2e() const{ return qe2f()*ftm2v(); } -double LammpsInterface::pair_force(int i, int j, double rsq, - double & fmag_over_rmag) const -{ +double LammpsInterface::pair_force(int i, int j, double rsq, + double & fmag_over_rmag) const +{ int itype = (lammps_->atom->type)[i]; int jtype = (lammps_->atom->type)[j]; // return value is the energy @@ -789,9 +789,9 @@ double LammpsInterface::pair_force(int i, int j, double rsq, } return 0.0; } -double LammpsInterface::pair_force(int n, double rsq, - double & fmag_over_rmag) const -{ +double LammpsInterface::pair_force(int n, double rsq, + double & fmag_over_rmag) const +{ int i = bond_list_i(n); int j = bond_list_j(n); int type = bond_list_type(n); @@ -799,9 +799,9 @@ 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< std::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; if (n < nbonds) { return pair_force(n, rsq,fmag_over_rmag); @@ -814,9 +814,9 @@ double LammpsInterface::pair_force( } } double LammpsInterface::pair_force( - std::pair< std::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; if (n < nbonds) { return pair_force(n, rsq,fmag_over_rmag); @@ -829,7 +829,7 @@ double LammpsInterface::pair_force( } } double LammpsInterface::bond_stiffness(int i, int j, double rsq0) const -{ +{ const double perturbation = 1.e-8; double rsq1 = sqrt(rsq0)+perturbation; rsq1 *= rsq1; @@ -866,7 +866,7 @@ int LammpsInterface::delete_atom(int id) const } //* insert atom -int LammpsInterface::insert_atom(int atype, int amask, +int LammpsInterface::insert_atom(int atype, int amask, double *ax, double *av, double aq) const { LAMMPS_NS::Atom * atom = lammps_->atom; @@ -874,8 +874,8 @@ int LammpsInterface::insert_atom(int atype, int amask, int m = atom->nlocal - 1; atom->mask[m] = amask; atom->v[m][0] = av[0]; - atom->v[m][1] = av[1]; - atom->v[m][2] = av[2]; + atom->v[m][1] = av[1]; + atom->v[m][2] = av[2]; if (aq != 0) atom->q[m] = aq; int nfix = lammps_->modify->nfix; @@ -903,7 +903,7 @@ int LammpsInterface::reset_ghosts(int deln) const } //* energy for interactions within the shortrange cutoff -double LammpsInterface::shortrange_energy(double *coord, +double LammpsInterface::shortrange_energy(double *coord, int itype, int id, double /* max */) const { LAMMPS_NS::Atom * atom = lammps_->atom; @@ -919,7 +919,7 @@ double LammpsInterface::shortrange_energy(double *coord, double total_energy = 0.0; for (int j = 0; j < nall; j++) { - if (id == j) continue; + if (id == j) continue; // factor_lj = special_lj[sbmask(j)]; // factor_coul = special_coul[sbmask(j)]; //j &= NEIGHMASK; @@ -942,7 +942,7 @@ double LammpsInterface::shortrange_energy(int id, double max) const return shortrange_energy(x,type,id,max); } -POTENTIAL LammpsInterface::potential() const +POTENTIAL LammpsInterface::potential() const { // find pair style - FRAGILE const int nStyles = 4; @@ -951,7 +951,7 @@ POTENTIAL LammpsInterface::potential() const "lj/cut/coul/cut", "lj/charmm/coul/long"}; LAMMPS_NS::Pair *pair = nullptr; - for (int i = 0; i < nStyles; i++){ + for (int i = 0; i < nStyles; i++){ pair = lammps_->force->pair_match(pairStyles[i].c_str(),1); if (pair != nullptr) break; } @@ -973,7 +973,7 @@ int LammpsInterface::type_to_groupbit(int itype) const return int_allmax(groupbit); } -bool LammpsInterface::epsilons(int itype, POTENTIAL pair, double * epsilon0) const +bool LammpsInterface::epsilons(int itype, POTENTIAL pair, double * epsilon0) const { // grab energy parameters char * pair_parameter = new char[8]; @@ -1002,14 +1002,14 @@ bool LammpsInterface::set_epsilons(int itype, POTENTIAL pair, double * epsilon) delete [] pair_parameter; if (epsilons == nullptr) return false; //if (epsilons == nullptr) error->all(FLERR,"Fix concentration adapted pair style parameter not supported"); - // scale interactions + // scale interactions int i1,i2; for (int i = 1; i < ntypes()+1; i++) { if (i < itype) { i1 = i; i2 = itype; } else { i2 = i; i1 = itype; } epsilons[i1][i2] = epsilon[i-1]; } - + return true; } @@ -1081,12 +1081,12 @@ void LammpsInterface::advance_random_normal (RNG_POINTER p, int n) const { } //* Boltzmann's constant in M,L,T,t units -double LammpsInterface::kBoltzmann() const { +double LammpsInterface::kBoltzmann() const { return (lammps_->force->boltz)/(lammps_->force->mvv2e); } -//* Planck's constant -double LammpsInterface::hbar() const { +//* Planck's constant +double LammpsInterface::hbar() const { const int UNITS_STYLE = (int) units_style(); double hbar = 1.0; // LJ: Dimensionless if (UNITS_STYLE == 2) hbar = 15.1685792814; // Real: KCal/mol-fs @@ -1095,15 +1095,15 @@ double LammpsInterface::hbar() const { } //* Dulong-Petit heat capacity -double LammpsInterface::heat_capacity() const { +double LammpsInterface::heat_capacity() const { double rhoCp = dimension()*kBoltzmann()/volume_per_atom(); return rhoCp; } //* reference mass density for a *unit cell* // all that is needed is a unit cell: volume, types, mass per type -double LammpsInterface::mass_density(int* numPerType) const -{ +double LammpsInterface::mass_density(int* numPerType) const +{ const double *mass = lammps_->atom->mass; if (!mass) throw ATC_Error("cannot compute a mass density: no mass"); const int ntypes = lammps_->atom->ntypes; @@ -1156,7 +1156,7 @@ double * LammpsInterface::special_coul() const return lammps_->force->special_coul; } -//* flag for newton +//* flag for newton int LammpsInterface::newton_pair() const { return lammps_->force->newton_pair; @@ -1169,25 +1169,25 @@ int LammpsInterface::newton_pair() const int LammpsInterface::ngroup() const { return lammps_->group->ngroup; } int LammpsInterface::group_bit(string name) const -{ +{ return group_bit(group_index(name)); } int LammpsInterface::group_bit(int iGroup) const -{ +{ int mybit = 0; mybit |= lammps_->group->bitmask[iGroup]; if (mybit < 0 || mybit > MAX_GROUP_BIT) { string msg("LammpsInterface::group_bit() lammps group bit "+to_string(mybit)+" is out of range 0:"+to_string(MAX_GROUP_BIT)); throw ATC_Error(msg); } - + return mybit; } int LammpsInterface::group_index(string name) const -{ - int igroup = lammps_->group->find(name.c_str()); +{ + int igroup = lammps_->group->find(name.c_str()); if (igroup == -1) { string msg("LammpsInterface::group_index() lammps group "+name+" does not exist"); throw ATC_Error(msg); @@ -1197,12 +1197,12 @@ int LammpsInterface::group_index(string name) const int LammpsInterface::group_inverse_mask(int iGroup) const { - return lammps_->group->inversemask[iGroup]; + return lammps_->group->inversemask[iGroup]; } char * LammpsInterface::group_name(int iGroup) const -{ - return lammps_->group->names[iGroup]; +{ + return lammps_->group->names[iGroup]; } void LammpsInterface::group_bounds(int iGroup, double * b) const @@ -1220,9 +1220,9 @@ double * LammpsInterface::create_1d_double_array(int length, const char *name) c return lammps_->memory->create(myArray, length, name); } -double *LammpsInterface::grow_1d_double_array(double *array, +double *LammpsInterface::grow_1d_double_array(double *array, int length, - const char *name) const + const char *name) const { return lammps_->memory->grow(array, length, name); } @@ -1240,10 +1240,10 @@ void LammpsInterface::destroy_2d_double_array(double **d) const { lammps_->memory->destroy(d); } -double **LammpsInterface::grow_2d_double_array(double **array, - int n1, - int n2, - const char *name) const +double **LammpsInterface::grow_2d_double_array(double **array, + int n1, + int n2, + const char *name) const { return lammps_->memory->grow(array, n1, n2, name); } @@ -1254,9 +1254,9 @@ int * LammpsInterface::create_1d_int_array(int length, const char *name) const { return lammps_->memory->create(myArray, length, name); } -int *LammpsInterface::grow_1d_int_array(int *array, +int *LammpsInterface::grow_1d_int_array(int *array, int length, - const char *name) const + const char *name) const { return lammps_->memory->grow(array, length, name); } @@ -1322,22 +1322,22 @@ int** LammpsInterface::bond_list() const { return lammps_->neighbor->bondlist; char * LammpsInterface::region_name(int iRegion) const { - return lammps_->domain->regions[iRegion]->id; + return lammps_->domain->regions[iRegion]->id; } char * LammpsInterface::region_style(int iRegion) const -{ - return lammps_->domain->regions[iRegion]->style; +{ + return lammps_->domain->regions[iRegion]->style; } double LammpsInterface::region_xlo(int iRegion) const { - return lammps_->domain->regions[iRegion]->extent_xlo; + return lammps_->domain->regions[iRegion]->extent_xlo; } double LammpsInterface::region_xhi(int iRegion) const { - return lammps_->domain->regions[iRegion]->extent_xhi; + return lammps_->domain->regions[iRegion]->extent_xhi; } double LammpsInterface::region_ylo(int iRegion) const @@ -1362,7 +1362,7 @@ double LammpsInterface::region_zhi(int iRegion) const double LammpsInterface::region_xscale(int iRegion) const { - return lammps_->domain->regions[iRegion]->xscale; + return lammps_->domain->regions[iRegion]->xscale; } double LammpsInterface::region_yscale(int iRegion) const @@ -1372,10 +1372,10 @@ double LammpsInterface::region_yscale(int iRegion) const double LammpsInterface::region_zscale(int iRegion) const { - return lammps_->domain->regions[iRegion]->zscale; + return lammps_->domain->regions[iRegion]->zscale; } -int LammpsInterface::region_match(int iRegion, double x, double y, double z) const { +int LammpsInterface::region_match(int iRegion, double x, double y, double z) const { return lammps_->domain->regions[iRegion]->match(x,y,z); } @@ -1429,14 +1429,14 @@ int LammpsInterface::compute_ncols_peratom(COMPUTE_POINTER computePointer) const { LAMMPS_NS::Compute* cmpt = const_to_active(computePointer); int ndof = cmpt->size_peratom_cols; - if (ndof == 0 ) ndof = 1; + if (ndof == 0 ) ndof = 1; return ndof; } double* LammpsInterface::compute_vector_peratom(COMPUTE_POINTER computePointer) const { LAMMPS_NS::Compute* cmpt = const_to_active(computePointer); - if (!(cmpt->invoked_flag & INVOKED_PERATOM)) { + if (!(cmpt->invoked_flag & INVOKED_PERATOM)) { cmpt->compute_peratom(); cmpt->invoked_flag |= INVOKED_PERATOM; } @@ -1465,7 +1465,7 @@ LAMMPS_NS::Compute * LammpsInterface::const_to_active(COMPUTE_POINTER computePoi } // ----------------------------------------------------------------- -// compute pe/atom interface methods +// compute pe/atom interface methods // - the only compute "owned" by ATC // ----------------------------------------------------------------- int LammpsInterface::create_compute_pe_peratom(void) const @@ -1473,7 +1473,7 @@ int LammpsInterface::create_compute_pe_peratom(void) const char **list = new char*[4]; string atomPeName = compute_pe_name(); list[0] = (char *) atomPeName.c_str(); - list[1] = (char *) "all"; + list[1] = (char *) "all"; list[2] = (char *) "pe/atom"; list[3] = (char *) "pair"; @@ -1518,7 +1518,7 @@ void LammpsInterface::unwrap_coordinates(int iatom, double* xatom) const int xbox,ybox,zbox; // for triclinic, need to unwrap current atom coord via h matrix - + if (lammps_->domain->triclinic == 0) { xbox = (image[iatom] & 1023) - 512; ybox = (image[iatom] >> 10 & 1023) - 512; diff --git a/lib/atc/LammpsInterface.h b/lib/atc/LammpsInterface.h index 6883a9ca0b..d4470dbd0a 100644 --- a/lib/atc/LammpsInterface.h +++ b/lib/atc/LammpsInterface.h @@ -102,7 +102,7 @@ class LammpsInterface { }; // Provides a struct for easily passing/recovering data about SparseMats - struct SparseMatInfo { + struct SparseMatInfo { INDEX rows; INDEX cols; INDEX rowsCRS; @@ -116,9 +116,9 @@ class LammpsInterface { static void Destroy(); /** Set lammps pointer */ - void set_lammps(LAMMPS_NS::LAMMPS * lammps) - { - lammps_ = lammps; + void set_lammps(LAMMPS_NS::LAMMPS * lammps) + { + lammps_ = lammps; MPI_Comm_rank(lammps_->world, & commRank_); MPI_Comm_size(lammps_->world, & commSize_); } @@ -180,7 +180,7 @@ class LammpsInterface { void sparse_allsum(SparseMatrix &toShare) const #ifdef ISOLATE_FE { - MPI_Wrappers::sparse_allsum(lammps_->world, toShare); + MPI_Wrappers::sparse_allsum(lammps_->world, toShare); } #else ; @@ -248,27 +248,27 @@ class LammpsInterface { MPI_Wrappers::stop(lammps_->world, msg); } std::string read_file(std::string filename) const; - void write_file(std::string filename, std::string contents, + void write_file(std::string filename, std::string contents, std::ofstream::openmode mode = std::ofstream::out) const { if (! comm_rank()) { std::ofstream f(filename.c_str(),mode); f << contents; f.close(); - } + } // ignore other ranks and assume they are consistent } // end MPI -------------------------------------------------------------------- void print_debug(std::string msg="") const { - std::cout << "rank " << comm_rank() << " " << msg << "\n" << std::flush; + std::cout << "rank " << comm_rank() << " " << msg << "\n" << std::flush; barrier(); } int comm_rank(void) const { return commRank_;} int comm_size(void) const { return commSize_;} bool rank_zero(void) const { return (commRank_==0);} - bool serial(void) const { + bool serial(void) const { int size = 1; MPI_Comm_size(lammps_->world,&size); return (size==1); } @@ -280,12 +280,12 @@ class LammpsInterface { std::stringstream full_msg; if (serial()) { full_msg << " ATC: " << msg << "\n"; - } + } else { full_msg << " ATC: P" << me << ", " << msg << "\n"; } 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()); } @@ -312,7 +312,7 @@ class LammpsInterface { std::stringstream full_msg; if (serial()) { full_msg << " ATC: " << tag << data << "\n"; - } + } else { int commSize = comm_size(); double *recv = new double[commSize]; @@ -360,13 +360,13 @@ class LammpsInterface { int nghost() const; int nmax() const; int ntypes() const; - double ** xatom() const; - double ** vatom() const; - double ** fatom() const; - const int * atom_mask() const; + double ** xatom() const; + double ** vatom() const; + double ** fatom() const; + const int * atom_mask() const; int * atom_mask(); - int * atom_type() const; - int * atom_tag() const; + int * atom_type() const; + int * atom_tag() const; int * atom_to_molecule() const; int * num_bond() const; int ** bond_atom() const; @@ -442,7 +442,7 @@ class LammpsInterface { } /*@}*/ void minimum_image(double & dx, double & dy, double & dz) const; - void closest_image(const double * const xi, const double * const xj, double * const xjImage) const; + void closest_image(const double * const xi, const double * const xj, double * const xjImage) const; /** \name Methods that interface with Update class */ @@ -451,7 +451,7 @@ class LammpsInterface { //double minimize_energy() { return lammps_->update->minimize->ecurrent; } double minimize_energy() const { return lammps_->update->minimize->eprevious; } /*@}*/ - + /** \name Methods that interface with Lattice class */ /*@{*/ double xlattice() const; @@ -487,12 +487,12 @@ 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(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_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; - LAMMPS_NS::PairEAM * pair_eam(void) const; + LAMMPS_NS::PairEAM * pair_eam(void) const; double bond_stiffness(int i, int j, double rsq) const; /*@}*/ @@ -500,12 +500,12 @@ class LammpsInterface { /*@{*/ int delete_atom(int id) const; int insert_atom(int type, int mask, double* x, double* v, double q = 0) const; - double shortrange_energy(double *x, int type, int id = -1, + double shortrange_energy(double *x, int type, int id = -1, double max = big_) const; int reset_ghosts(int dn) const; double shortrange_energy(int id, double max = big_) const; POTENTIAL potential(void) const; - int type_to_groupbit(int itype) const; + int type_to_groupbit(int itype) const; int change_type(int itype, int jtype) const; int count_type(int itype) const; bool epsilons(int type, POTENTIAL p, double * epsilons) const; @@ -549,7 +549,7 @@ class LammpsInterface { j %= n; } return factor_coul; - } + } /*@}*/ /** \name Methods that interface with Group class */ @@ -613,8 +613,8 @@ class LammpsInterface { /*@{*/ int bond_list_length() const; int ** bond_list() const; // direct access - int * bond_list(int n) const { return bond_list()[n];} - int bond_list_i(int n) const { return bond_list(n)[0];} + int * bond_list(int n) const { return bond_list()[n];} + int bond_list_i(int n) const { return bond_list(n)[0];} int bond_list_j(int n) const { return bond_list(n)[1];} int bond_list_type(int n) const { return bond_list(n)[2];} /*@}*/ @@ -636,9 +636,9 @@ class LammpsInterface { /*@}*/ /** \name Methods that interface with compute class */ - enum COMPUTE_INVOKED + enum COMPUTE_INVOKED {INVOKED_SCALAR=1,INVOKED_VECTOR=2,INVOKED_ARRAY=4,INVOKED_PERATOM=8}; - enum PER_ATOM_COMPUTE + enum PER_ATOM_COMPUTE {PE_ATOM, STRESS_ATOM, CENTRO_ATOM, @@ -662,7 +662,7 @@ class LammpsInterface { 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();}; /*@}*/ - + /** Return lammps pointer -- only as a last resort! */ diff --git a/lib/atc/LinearSolver.cpp b/lib/atc/LinearSolver.cpp index 0204ddd938..06683981e7 100644 --- a/lib/atc/LinearSolver.cpp +++ b/lib/atc/LinearSolver.cpp @@ -11,7 +11,7 @@ using std::set; namespace ATC { -const double kPenalty = 1.0e4; +const double kPenalty = 1.0e4; const double kTol = 1.0e-8; const int kMaxDirect = 1000; @@ -45,7 +45,7 @@ LinearSolver::LinearSolver( maxIterations_(0), maxRestarts_(0), tol_(0), parallel_(parallel) { - // deep copy + // deep copy matrixCopy_ = A; matrixSparse_ = &matrixCopy_; setup(); @@ -63,13 +63,13 @@ LinearSolver::LinearSolver( initializedMatrix_(true), initializedInverse_(false), matrixModified_(false), - allowReinitialization_(false), + allowReinitialization_(false), homogeneousBCs_(false), bcs_(nullptr), // null implies no constraints will be added later rhs_(nullptr), rhsDense_(), b_(nullptr), matrix_(A), - matrixDense_(), + matrixDense_(), matrixFreeFree_(), matrixFreeFixed_(),matrixInverse_(), penalty_(1), maxIterations_(0), maxRestarts_(0), tol_(0), @@ -77,7 +77,7 @@ LinearSolver::LinearSolver( { // shallow copy matrixSparse_ = &A; - setup(); + setup(); } @@ -96,7 +96,7 @@ void LinearSolver::setup(void) if (solverType_ < 0) { if (nVariables_ > kMaxDirect ) { solverType_ = ITERATIVE_SOLVE_SYMMETRIC; - constraintHandlerType_ = PENALIZE_CONSTRAINTS; + constraintHandlerType_ = PENALIZE_CONSTRAINTS; } else { solverType_ = DIRECT_SOLVE; @@ -113,7 +113,7 @@ void LinearSolver::setup(void) // -------------------------------------------------------------------- // Initialize // -------------------------------------------------------------------- -void LinearSolver::allow_reinitialization(void) +void LinearSolver::allow_reinitialization(void) { if (constraintHandlerType_ == PENALIZE_CONSTRAINTS) { if (matrixModified_ ) throw ATC_Error("LinearSolver: can't allow reinitialization after matrix has been modified"); @@ -124,7 +124,7 @@ void LinearSolver::allow_reinitialization(void) void LinearSolver::initialize(const BC_SET * bcs) { - if (bcs) { + if (bcs) { if (! allowReinitialization_ ) throw ATC_Error("LinearSolver: reinitialization not allowed"); //if (! bcs_ ) throw ATC_Error("LinearSolver: adding constraints after constructing without constraints is not allowed"); // shallow --> deep copy @@ -164,7 +164,7 @@ void LinearSolver::initialize_matrix(void) add_matrix_penalty(); } else if (constraintHandlerType_ == CONDENSE_CONSTRAINTS) { - partition_matrix(); + partition_matrix(); } initializedMatrix_ = true; } @@ -182,12 +182,12 @@ void LinearSolver::initialize_inverse(void) else { // DIRECT_SOLVE if (constraintHandlerType_ == CONDENSE_CONSTRAINTS) { if( num_unknowns() > 0 ) { - matrixInverse_ = inv(matrixFreeFree_); + matrixInverse_ = inv(matrixFreeFree_); } } else { // NO_CONSTRAINTS || PENALIZE_CONSTRAINTS matrixDense_ = matrixSparse_->dense_copy(); // need dense for lapack - matrixInverse_ = inv(matrixDense_); + matrixInverse_ = inv(matrixDense_); } } initializedInverse_ = true; @@ -219,7 +219,7 @@ void LinearSolver::add_matrix_penalty(void) { penalty_ = kPenalty; // relative to matrix diagonal SPAR_MAT & A = matrixCopy_; - penalty_ *= (A.diag()).maxabs(); + penalty_ *= (A.diag()).maxabs(); BC_SET::const_iterator itr; for (itr = bcs_->begin(); itr != bcs_->end(); itr++) { int i = itr->first; @@ -253,7 +253,7 @@ void LinearSolver::partition_matrix(void) if (matrixDense_.nRows() == 0) matrixDense_ =matrixSparse_->dense_copy(); DENS_MAT & K = matrixDense_; - K.row_partition(freeSet_,matrixFreeFree_,matrixFreeFixed_); + K.row_partition(freeSet_,matrixFreeFree_,matrixFreeFixed_); } // -------------------------------------------------------------------- @@ -269,7 +269,7 @@ void LinearSolver::add_rhs_penalty() int size = r.nRows(); b.reset(size); for (int i = 0; i < size; i++) { - b(i) = r(i); + b(i) = r(i); } if ( ! homogeneousBCs_ ){ @@ -304,7 +304,7 @@ void LinearSolver::add_rhs_influence() for (itr = bcs_->begin(); itr != bcs_->end(); itr++,i++) { double v = itr->second; xFixed(i,0) = -v; - } + } b = matrixFreeFixed_*xFixed; // matrix and bcs have same ordering } else { @@ -314,7 +314,7 @@ void LinearSolver::add_rhs_influence() set::const_iterator iter; int i = 0; for (iter = freeSet_.begin(); iter != freeSet_.end(); iter++,i++) { - b(i) += r(*iter); + b(i) += r(*iter); } b_ = &rhsDense_; } @@ -347,15 +347,15 @@ void LinearSolver::eigen_system( DENS_MAT & eigenvalues, DENS_MAT & eigenvectors const DENS_MAT * Mp =M; DENS_MAT MM; DENS_MAT KM; - if (constraintHandlerType_ == CONDENSE_CONSTRAINTS) { + if (constraintHandlerType_ == CONDENSE_CONSTRAINTS) { Kp = &matrixFreeFree_; if (M) { DENS_MAT MfreeFixed; // not used - M->row_partition(freeSet_,MM,MfreeFixed); + M->row_partition(freeSet_,MM,MfreeFixed); Mp = &MM; } } - else { + else { if (matrixDense_.nRows() == 0) matrixDense_ =matrixSparse_->dense_copy(); Kp = &matrixDense_; } @@ -399,9 +399,9 @@ bool LinearSolver::solve(VECTOR & x, const VECTOR & b) } const VECTOR & r = *b_; if (solverType_ == ITERATIVE_SOLVE_SYMMETRIC) { - - - + + + if (parallel_) { A = new PAR_SPAR_MAT(LammpsInterface::instance()->world(), *matrixSparse_); } @@ -434,7 +434,7 @@ bool LinearSolver::solve(VECTOR & x, const VECTOR & b) DENS_MAT H(maxRestarts_+1, maxRestarts_); DENS_VEC xx(nVariables_); DENS_VEC bb; - bb = b; + bb = b; int convergence = GMRES(*A, xx, bb, PC, H, restarts, iterations, tol); if (convergence>0) { stringstream ss; @@ -443,7 +443,7 @@ bool LinearSolver::solve(VECTOR & x, const VECTOR & b) ss << " residual: " << tol; throw ATC_Error(ss.str()); } - x.copy(xx.ptr(),xx.nRows()); + x.copy(xx.ptr(),xx.nRows()); } else { // DIRECT_SOLVE const DENS_MAT & invA = matrixInverse_; @@ -532,7 +532,7 @@ void LinearSolver::greens_function(int I, VECTOR & G_I) ss << " residual: " << tol; throw ATC_Error(ss.str()); } - x.copy(xx.ptr(),xx.nRows()); + x.copy(xx.ptr(),xx.nRows()); } else { const DENS_MAT & invA = matrixInverse_; @@ -556,7 +556,7 @@ void LinearSolver::greens_function(int I, VECTOR & G_I) for (int i = 0; i < nVariables_; ++i) x(i) = invA(I,i); } } - + delete A; } diff --git a/lib/atc/LinearSolver.h b/lib/atc/LinearSolver.h index 1d429d8816..b1078a35ba 100644 --- a/lib/atc/LinearSolver.h +++ b/lib/atc/LinearSolver.h @@ -22,19 +22,19 @@ namespace ATC { * @brief a class to solve a system of linear equations * A x = b subject to a set of constraints { x_i = y_i } */ - + class LinearSolver { public: enum LinearSolveType { - AUTO_SOLVE=-1, + AUTO_SOLVE=-1, DIRECT_SOLVE=0, ITERATIVE_SOLVE, ITERATIVE_SOLVE_SYMMETRIC }; enum LinearSolveConstraintHandlingType { - AUTO_HANDLE_CONSTRAINTS=-1, + AUTO_HANDLE_CONSTRAINTS=-1, NO_CONSTRAINTS=0, CONDENSE_CONSTRAINTS, PENALIZE_CONSTRAINTS @@ -44,7 +44,7 @@ class LinearSolver { LinearSolver( // does not assume that A is persistent const SPAR_MAT & A, // lhs matrix "deep" copy const BC_SET & bcs, // constraints - const int solverType = AUTO_SOLVE, + const int solverType = AUTO_SOLVE, const int bcHandlerType = -1, bool parallel = false ); @@ -57,10 +57,10 @@ class LinearSolver { /** Destructor */ virtual ~LinearSolver() {}; - /** (re)initialize - - if bcs are provided the lhs matrix is re-configured - for the new constraints - - if the class is to be reused with new constraints + /** (re)initialize + - if bcs are provided the lhs matrix is re-configured + for the new constraints + - if the class is to be reused with new constraints allow_reinitialization must be called before first solve, etc */ void allow_reinitialization(void); // depending on method save a copy of A void set_homogeneous_bcs(void) { homogeneousBCs_ = true;} // for nonlinear solver, solve for increment @@ -71,15 +71,15 @@ class LinearSolver { - if a "b" is provided it is used as the new rhs */ bool solve(VECTOR & x, const VECTOR & b); - /** greens function + /** greens function - returns the solution to a Kronecker delta rhs b = {0 0 .. 1 .. 0 0} and with homogeneous constraints {x_i = 0} */ void greens_function(int I, VECTOR & G_I); /** eigensystem - - returns the e-values & e-vectors for constrained system Ax + v x = 0 + - returns the e-values & e-vectors for constrained system Ax + v x = 0 - if M is provided the eval problem : ( A + v M ) x = 0 is solved*/ - void eigen_system(DENS_MAT & eigenvalues, DENS_MAT & eigenvectors, + void eigen_system(DENS_MAT & eigenvalues, DENS_MAT & eigenvectors, const DENS_MAT * M = nullptr); /** access to penalty coefficient @@ -87,16 +87,16 @@ class LinearSolver { double penalty_coefficient(void) const {return penalty_;}; /** change iterative solver parameters */ - void set_max_iterations(const int maxIter) { + void set_max_iterations(const int maxIter) { if (solverType_ != ITERATIVE_SOLVE && solverType_ != ITERATIVE_SOLVE_SYMMETRIC ) throw ATC_Error("inappropriate parameter set in LinearSolver"); maxIterations_=maxIter; } void set_tolerance(const double tol) { tol_=tol;} - + /* access to number of unknowns */ - int num_unknowns(void) const - { + int num_unknowns(void) const + { int nUnknowns = nVariables_; if (bcs_) { nUnknowns -= bcs_->size(); } return nUnknowns; @@ -132,27 +132,27 @@ class LinearSolver { void set_fixed_values(VECTOR & x); /** constraints container */ - const BC_SET * bcs_; + const BC_SET * bcs_; /** rhs vector/s */ - const VECTOR * rhs_; + const VECTOR * rhs_; DENS_VEC rhsDense_; // modified const VECTOR * b_; // points to appropriate rhs /** lhs matrix */ - const SPAR_MAT & matrix_; + const SPAR_MAT & matrix_; SPAR_MAT matrixCopy_; // a copy that will be modified by penalty methods SPAR_MAT matrixOriginal_; // a copy that is used for re-initialization const SPAR_MAT * matrixSparse_; // points to matrix_ or matrixCopy_ - DENS_MAT matrixDense_; // a dense copy for lapack + DENS_MAT matrixDense_; // a dense copy for lapack /** partitioned matrix - condense constraints */ DENS_MAT matrixFreeFree_, matrixFreeFixed_; /** maps for free and fixed variables for partitioned matrix - condense */ - std::set freeSet_, fixedSet_; + std::set freeSet_, fixedSet_; std::map freeGlobalToCondensedMap_; /** inverse matrix matrix - direct solve */ diff --git a/lib/atc/MPI_Wrappers.cpp b/lib/atc/MPI_Wrappers.cpp index b8a8ab77b7..d49f81d925 100644 --- a/lib/atc/MPI_Wrappers.cpp +++ b/lib/atc/MPI_Wrappers.cpp @@ -221,14 +221,14 @@ namespace MPI_Wrappers { void sparse_allsum(MPI_Comm comm,SparseMatrix &toShare) const { toShare.compress(); - + // initialize MPI information int nProcs = size(comm); int myRank = rank(comm);; int error; - // get numbers of rows, columns, rowsCRS, and + // get numbers of rows, columns, rowsCRS, and // sizes (number of nonzero elements in matrix) SparseMatInfo *recInfo = new SparseMatInfo[nProcs]; SparseMatInfo myInfo; @@ -283,7 +283,7 @@ void sparse_allsum(MPI_Comm comm,SparseMatrix &toShare) const rec_ja, sizeCounts, sizeOffsets, MPI_INT, lammps_->world); if (error != MPI_SUCCESS) throw ATC_Error("error in sparse_allsum_colarray "+to_string(error)); - + // get the array of values double *rec_vals = new double[totalSize]; error = MPI_Allgatherv(toShare.ptr(), sizeCounts[myRank], MPI_DOUBLE, @@ -291,8 +291,8 @@ void sparse_allsum(MPI_Comm comm,SparseMatrix &toShare) const if (error != MPI_SUCCESS) throw ATC_Error("error in sparse_allsum_valarray "+to_string(error)); - INDEX *rec_ia_proc; - INDEX *rec_ja_proc; + INDEX *rec_ia_proc; + INDEX *rec_ja_proc; double *rec_vals_proc; for (int i = 0; i < nProcs; i++) { if (myRank != i) { @@ -300,24 +300,24 @@ void sparse_allsum(MPI_Comm comm,SparseMatrix &toShare) const rec_ia_proc = new INDEX[rowCounts[i]]; rec_ja_proc = new INDEX[sizeCounts[i]]; rec_vals_proc = new double[sizeCounts[i]]; - + // copy the data passed with MPI into the new spots - copy(rec_ia + rowOffsets[i], + copy(rec_ia + rowOffsets[i], rec_ia + rowOffsets[i] + rowCounts[i], rec_ia_proc); - copy(rec_ja + sizeOffsets[i], + copy(rec_ja + sizeOffsets[i], rec_ja + sizeOffsets[i] + sizeCounts[i], rec_ja_proc); - copy(rec_vals + sizeOffsets[i], + copy(rec_vals + sizeOffsets[i], rec_vals + sizeOffsets[i] + sizeCounts[i], rec_vals_proc); // Does anyone know why we have to declare tempMat here (as well as set it equal to - // something) to avoid segfaults? there are still segfaults, but they happen at a much + // something) to avoid segfaults? there are still segfaults, but they happen at a much // later stage of the game now (and for less benchmarks overall). SparseMatrix tempMat = - SparseMatrix(rec_ia_proc, rec_ja_proc, rec_vals_proc, - recInfo[i].size, recInfo[i].rows, + SparseMatrix(rec_ia_proc, rec_ja_proc, rec_vals_proc, + recInfo[i].size, recInfo[i].rows, recInfo[i].cols, recInfo[i].rowsCRS); toShare += tempMat; } @@ -330,13 +330,13 @@ void sparse_allsum(MPI_Comm comm,SparseMatrix &toShare) const } #endif - void print_msg(MPI_Comm comm, string msg) + void print_msg(MPI_Comm comm, string msg) { if (serial(comm)) { cout << " ATC: " << msg << "\n"; } else { cout << " ATC: P" << rank(comm) << ", " << msg << "\n"; } } - void print_msg_once(MPI_Comm comm, string msg, bool prefix, bool endline) + void print_msg_once(MPI_Comm comm, string msg, bool prefix, bool endline) { if (rank_zero(comm)) { if (prefix) cout << " ATC: "; diff --git a/lib/atc/Material.cpp b/lib/atc/Material.cpp index 64673d7993..5509064b9e 100644 --- a/lib/atc/Material.cpp +++ b/lib/atc/Material.cpp @@ -92,13 +92,13 @@ namespace ATC { \n end \n tag - a unique identifier for the material type which can be referenced in input decks. Multiple materials are specified using different tag regions, terminated with an 'end', in the material file. - units - the LAMMPS units system the material is based on, used as a check against the actual LAMMPS units. AtC units are consistent units using the LAMMPS length, mass, time, charge, and volts. The only units conversion occuring within AtC are LAMMPS to AtC units and charge to volts units. + units - the LAMMPS units system the material is based on, used as a check against the actual LAMMPS units. AtC units are consistent units using the LAMMPS length, mass, time, charge, and volts. The only units conversion occuring within AtC are LAMMPS to AtC units and charge to volts units. \section examples material Argon real ------- end \section description - Starts a section in which material properties can be specified. Materials are organized by material, identified by a tag, and all associated material models are specified within its scope. Unspecified material properties use defaults as indicated or are considered as null. Null material properties contribute no value to integrals using them. Material properties defined which are not part of the physics model are ignored. Functions which are specified correspond to those implemented in the code and there is no mechanism for user-specified material models unless they are added to the main code.\n + Starts a section in which material properties can be specified. Materials are organized by material, identified by a tag, and all associated material models are specified within its scope. Unspecified material properties use defaults as indicated or are considered as null. Null material properties contribute no value to integrals using them. Material properties defined which are not part of the physics model are ignored. Functions which are specified correspond to those implemented in the code and there is no mechanism for user-specified material models unless they are added to the main code.\n \section restrictions Material models are only used for evaluating finite element integrals with for physics models they are associated with. \section related @@ -112,7 +112,7 @@ namespace ATC { constantDensity_.reset(NUM_FIELDS); constantDensity_ = false; - + rhoCp_ = ATC::LammpsInterface::instance()->heat_capacity(); parameters_["heat_capacity"] = rhoCp_; heatCapacity_ = rhoCp_; @@ -122,7 +122,7 @@ namespace ATC { constantDensity_(DISPLACEMENT) = true; constantDensity_(VELOCITY) = true; - electronDragPower_ = new ElectronDragPower(); + electronDragPower_ = new ElectronDragPower(); vector line; while(fileId.good()) { @@ -133,13 +133,13 @@ namespace ATC { return; } } - /*! \page man_mat_heat_capacity material heat_capcity + /*! \page man_mat_heat_capacity material heat_capcity \section syntax heat_capacity constant\n capacity \n - end \n + end \n \section description - Overrides use of lattice heat capacity using Dulong-Petit law for continuum regions. \n + Overrides use of lattice heat capacity using Dulong-Petit law for continuum regions. \n \section restrictions Only valid with AtC models incorporating a phonon temperature: thermal, two-temperature, drift-diffusion \section related @@ -163,13 +163,13 @@ namespace ATC { } } } - /*! \page man_mat_heat_flux material heat_flux + /*! \page man_mat_heat_flux material heat_flux \section syntax heat_flux linear\n conductivity \n - end \n + end \n \section description - Specifies a heat flux proportional to the temperature gradient. \n + Specifies a heat flux proportional to the temperature gradient. \n \section restrictions Only valid with AtC models incorporating a phonon temperature: thermal, two-temperature, drift-diffusion \section related @@ -192,17 +192,17 @@ namespace ATC { } } } - /*! \page man_mat_electron_heat_flux material electron_heat_flux + /*! \page man_mat_electron_heat_flux material electron_heat_flux \section syntax electron_heat_flux \n \n - end \n + end \n null - no electron heat flux contributions \n linear - a heat flux proportional to the temperature gradient, parameter is 'conductivity'\n power_law - a heat flux proportional to the temperature gradient and ratio of electron to phonon temperatures, parameter is 'conductivity'\n thermopower - same as power_law but with an addition proportional to the electron current, parameters are 'conductivity' but it also uses the Seebeck coefficient defined elsewhere \section description - Specifies the form for the electron heat flux. \n + Specifies the form for the electron heat flux. \n \section restrictions Only valid with AtC models incorporating an electron temperature: two-temperature, drift-diffusion \section related @@ -239,25 +239,25 @@ namespace ATC { } } else if (line[1] == "thermopower") { - + if (! electronFlux_) { throw ATC_Error( "for thermopower please define electron_flux before electron_heat_flux"); } if (electronHeatFlux_) delete electronHeatFlux_; - electronHeatFlux_ = new ElectronHeatFluxThermopower(fileId, + electronHeatFlux_ = new ElectronHeatFluxThermopower(fileId, parameters_, electronFlux_); } } - /*! \page man_mat_electron_heat_capacity material electron_heat_capacity + /*! \page man_mat_electron_heat_capacity material electron_heat_capacity \section syntax electron_heat_capacity \n capacity \n - end \n + end \n no_density - if this keyword is present, the electron density does not multiply the capacity\n constant - a constant electron heat flux \n linear - a heat flux proportional to the electron temperature\n \section description - Specifies the form for the electron heat capacity. \n + Specifies the form for the electron heat capacity. \n \section restrictions Only valid with AtC models incorporating an electron temperature: two-temperature, drift-diffusion \section related @@ -296,17 +296,17 @@ namespace ATC { } } } - /*! \page man_mat_electron_phonon_exchange material electron_phonon_exchange + /*! \page man_mat_electron_phonon_exchange material electron_phonon_exchange \section syntax electron_phonon_exchange \n \n - end \n + end \n null - no electron heat flux contributions \n linear - an energy exchange proportional to the temperature difference between the electron and phonon temperatures, parameter is 'coefficient'\n power_law - same as linear, but the temperature difference is raised to a specified power, parameters are 'coefficient' and 'exponent'\n hertel - exchange proportional to temperature difference to the 5th divided by the electron temperature, the coefficient is a function of the mass enhancement and Debeye temperature, parameters are 'debeye_temperature' and 'mass_enhancement' \section description - Specifies the form for the electron/phonon heat exchange. \n + Specifies the form for the electron/phonon heat exchange. \n \section restrictions Only valid with AtC models incorporating an electron temperature: two-temperature, drift-diffusion \section related @@ -322,14 +322,14 @@ namespace ATC { } else if (line[1] == "linear") { if (electronPhononExchange_) delete electronPhononExchange_; - electronPhononExchange_ = new ElectronPhononExchangeLinear(fileId, + electronPhononExchange_ = new ElectronPhononExchangeLinear(fileId, parameters_); } else if (line[1] == "power_law") { linearSource_(TEMPERATURE) = false; linearSource_(ELECTRON_TEMPERATURE) = false; if (electronPhononExchange_) delete electronPhononExchange_; - electronPhononExchange_ = new ElectronPhononExchangePowerLaw(fileId, + electronPhononExchange_ = new ElectronPhononExchangePowerLaw(fileId, parameters_); } else if (line[1] == "hertel") { @@ -339,16 +339,16 @@ namespace ATC { electronPhononExchange_ = new ElectronPhononExchangeHertel(fileId,parameters_,this); } } - /*! \page man_mass_density material mass_density + /*! \page man_mass_density material mass_density \section syntax mass_density \n \n - end \n + end \n no entry - compute mass density from the lattice using the mass of the first type, no keyword or values\n basis - compute mass density for the given number of atoms of each type in the lattice, no keyword, values are one integer per type specifying the number of atoms of that type in the lattice\n constant - prescribed mass density, keyword = density, value = desired mass density \section description - Specifies the mass density of the system. \n + Specifies the mass density of the system. \n \section restrictions Valid for all AtC physics models. \section related @@ -401,14 +401,14 @@ namespace ATC { \section syntax stress \n \n - end \n + end \n null - no electron heat flux contributions \n linear - a stress tensor proportional to the displacements, keywords are 'modulus' and 'poissons_ratio'\n cubic - an anisotropic linear stress tensor, keywords are 'c11', 'c12', and 'c44'\n damped_cubic - same as cubic, with a damping term proportional to the velocity vector, keywords are 'c11', 'c12', 'c44', and the damping parameter 'gamma'\n cauchy_born - stress tensor is computed using the Cauchy-Born formalism from the lattice and given potential, keywords are 'pairstyle', 'linear' (linearizes the Cauchy-Born relationship), or 'temperature' (the temperature used to determine the Cauchy-Born stress). The 'pairstyle' lines are followed by values of 'lj/cut', 'lj/smooth/linear', and 'eam', the latter two of which are followed on the line by the value for the cut-off radius. The 'lj/cut' and 'lj/smooth/linear' pairstyles are followed on the next line using the keyword 'pair_coeff' followed by value of the pair-coefficients \sigma and \epsilon. \section description - Specifies the form for the mechanical stress tensor. \n + Specifies the form for the mechanical stress tensor. \n \section restrictions Only valid with AtC models incorporating a mechanical stress: elastic \section related @@ -444,7 +444,7 @@ namespace ATC { cb.inv_atom_volume = 1.0 / lmp->volume_per_atom(); cb.e2mvv = 1.0 / lmp->mvv2e(); cb.boltzmann = lmp->boltz(); - cb.atom_mass = lmp->atom_mass(1); + cb.atom_mass = lmp->atom_mass(1); if (stress_) delete stress_; stress_ = new StressCauchyBorn(fileId, cb); } @@ -457,15 +457,15 @@ namespace ATC { viscousStress_ = new ViscousStressConstant(fileId); } } - /*! \page man_body_force material body_force + /*! \page man_body_force material body_force \section syntax body_force \n \n - end \n + end \n electric_field - adds body force proportional to the electric field and charge density, no keywords or values\n viscous - adds a body force proportional to the velocity vector, keyword = gamma (damping parameter) followed by its value\n \section description - Specifies body forces acting on the system. \n + Specifies body forces acting on the system. \n \section restrictions Valid for all AtC mechanical models: elastic \section related @@ -519,10 +519,10 @@ namespace ATC { \section syntax electric_field linear\n permittivity \n - end \n + end \n Provide a value for the permittivity or use LAMMPS' value if no value is given.\n \section description - Specifies the electric displacement vector to be proportional to the electric field. \n + Specifies the electric displacement vector to be proportional to the electric field. \n \section restrictions Valid for AtC physics models using electric fields: fem_efield, drift-diffusion \section related @@ -556,7 +556,7 @@ namespace ATC { ss << ", lattice constant= " << LammpsInterface::instance()->max_lattice_constant() ; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); LammpsInterface::UnitsType utype = LammpsInterface::instance()->units_style(); - if ( utype != LammpsInterface::REAL + if ( utype != LammpsInterface::REAL && utype != LammpsInterface::METAL) { ATC::LammpsInterface::instance()->print_msg_once("WARNING: must use a unit system where: [Energy/force] = [Length] and [charge] = e"); // note this is so that: perm0/e = 1 / (Epotential_units * Length) @@ -598,10 +598,10 @@ namespace ATC { } else if (line[1] == "linear") { if (electronDragPower_) delete electronDragPower_; - electronDragPower_ = new ElectronDragPowerLinear(fileId, + electronDragPower_ = new ElectronDragPowerLinear(fileId, parameters_, this); - } + } } else if (line[0] == "electron_recombination") { registry_. insert("electron_recombination"); @@ -617,24 +617,24 @@ namespace ATC { } else if (line[0] == "equilibrium_carrier_density") { electronEquilibriumDensity_ = value; - parameters_["equilibrium_carrier_density"] + parameters_["equilibrium_carrier_density"] = electronEquilibriumDensity_; } } } } - /*! \page man_mat_electron_density material electron_density + /*! \page man_mat_electron_density material electron_density \section syntax electron_density \n \n - end \n + end \n null - no electron density constitutive model, uses the state variable \n linear - density is proportional to the electric field, keyword is 'coefficient' followed by its value\n interpolation - interpolates in a look-up table contained in a file provided after the 'interpolation' word, keywords are 'scale' and 'number_of_points', followed by their values \n exponential - density is based on Boltzmann statistics for the electric potential above an activation energy, keywords are 'intrinsic_concentration', 'intrinsic_energy', and reference_temperature', followed by their values\n fermi_dirac - density is based on Fermi-Dirac statistics for the electric potential relative to an activation energy, keywords are 'fermi_energy', 'reference_temperature', 'band_edge', 'donor_ionization_energy', and 'donor_concentration' \section description - Specifies the form for the electron density. \n + Specifies the form for the electron density. \n \section restrictions Only valid with AtC models incorporating an electrons: electrostatic, two-temperature, drift-diffusion \section related @@ -664,7 +664,7 @@ namespace ATC { electronChargeDensity_ = new ElectronChargeDensityExponential(fileId, parameters_); } else if (line[1] == "fermi_dirac") { - registry_. insert("band_edge_potential"); + registry_. insert("band_edge_potential"); //linearSource_(ELECTRIC_POTENTIAL) = false; // treated as constant if (electronChargeDensity_) delete electronChargeDensity_; electronChargeDensity_ = new ElectronChargeDensityFermiDirac(fileId, parameters_); @@ -707,7 +707,7 @@ void Material::thermal_energy( const FIELD_MATS &fields, DENS_MAT &energy) const { - + const DENS_MAT & T = (fields.find(TEMPERATURE))->second; energy = heatCapacity_ * T; }; @@ -738,7 +738,7 @@ void Material::mass_density( const FIELD_MATS &fields, DENS_MAT &density) const { - + int nNodes = 0; FIELD_MATS::const_iterator field = fields.find(MASS_DENSITY); if (field != fields.end()) { @@ -760,8 +760,8 @@ void Material::electron_mass_density( const FIELD_MATS &fields, DENS_MAT &density) const { - - + + int nNodes = 0; FIELD_MATS::const_iterator field = fields.find(ELECTRON_DENSITY); //if (field != fields.end()) { @@ -873,7 +873,7 @@ bool Material::electron_recombination( recombination = n; recombination -= electronEquilibriumDensity_; recombination *= -electronRecombinationInvTau_; - return true; + return true; } //--------------------------------------------------------------------- bool Material::electron_charge_density( diff --git a/lib/atc/Material.h b/lib/atc/Material.h index 5a835d446b..58920ab48e 100644 --- a/lib/atc/Material.h +++ b/lib/atc/Material.h @@ -9,7 +9,7 @@ #include "ATC_Error.h" #include "LammpsInterface.h" -namespace ATC +namespace ATC { class BodyForce; class Stress; @@ -22,7 +22,7 @@ namespace ATC class ElectronDragPower; /** - * @class Material + * @class Material * @brief Base class for computing and storing properties and fields for a material */ @@ -42,14 +42,14 @@ namespace ATC /** check material has required interfaces */ bool check_registry(const std::set functionList) const - { + { std::set::const_iterator itr; for (itr=functionList.begin(); itr!=functionList.end(); itr++) { if (registry_.find(*itr) == registry_.end()) { std::stringstream ss; ss << "WARNING: material: [" << tag_ << "] cannot find " << *itr ; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); - } + } if (registry_.find(*itr) == registry_.end()) return false; } return true; @@ -57,7 +57,7 @@ namespace ATC /** access to material parameters */ bool parameter(const std::string name, double & value) const - { + { std::map::const_iterator iter = parameters_.find(name); if ( iter == parameters_.end()) { value = 0.0; @@ -65,37 +65,37 @@ namespace ATC } value = iter->second; return true; - } + } /** true if rhs flux is linear (per field) */ - bool linear_flux(FieldName name) const { + bool linear_flux(FieldName name) const { return linearFlux_(name); }; /** true if rhs source is linear (per field) */ - bool linear_source(FieldName name) const { + bool linear_source(FieldName name) const { return linearSource_(name); }; /** true if lhs density is constant (per field) */ - bool constant_density(FieldName name) const { + bool constant_density(FieldName name) const { return constantDensity_(name); }; /** each of these is a field function computed at a set of points */ - /** if there is only one function it is in the base class + /** if there is only one function it is in the base class ** otherwise, a subsidiary class is setup */ /* -----------------------------------------------------------------*/ /** densities */ /* -----------------------------------------------------------------*/ /** thermal energy */ void thermal_energy(const FIELD_MATS & fields, - DENS_MAT & energy) const; + DENS_MAT & energy) const; /** heat capacity */ - void heat_capacity(const FIELD_MATS & fields, + void heat_capacity(const FIELD_MATS & fields, DENS_MAT & capacity) const; /** thermal energy */ - void electron_thermal_energy(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void electron_thermal_energy(const FIELD_MATS & fields, + DENS_MAT & energy) const; /** electron capacities */ void electron_mass_density(const FIELD_MATS &fields, DENS_MAT &density) const; @@ -106,27 +106,27 @@ namespace ATC const GRAD_FIELD_MATS &gradFields, DENS_MAT_VEC &Dcapacity) const; /** kinetic energy */ - void kinetic_energy(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void kinetic_energy(const FIELD_MATS & fields, + DENS_MAT & energy) const; /** mass density */ void mass_density(const FIELD_MATS &fields, DENS_MAT &density) const; /** elastic energy */ - void elastic_energy(const FIELD_MATS & fields, + void elastic_energy(const FIELD_MATS & fields, const GRAD_FIELD_MATS & gradFields, - DENS_MAT & energy) const; + DENS_MAT & energy) const; /** permitivity */ - void permittivity(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void permittivity(const FIELD_MATS & fields, + DENS_MAT & energy) const; /** inverse effective mass */ - void inv_effective_mass(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void inv_effective_mass(const FIELD_MATS & fields, + DENS_MAT & energy) const; /** band-edge potential */ - void band_edge_potential(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void band_edge_potential(const FIELD_MATS & fields, + DENS_MAT & energy) const; /** viscosity */ - void viscosity(const FIELD_MATS & fields, - DENS_MAT & energy) const; + void viscosity(const FIELD_MATS & fields, + DENS_MAT & energy) const; /* -----------------------------------------------------------------*/ /** fluxes */ /* -----------------------------------------------------------------*/ @@ -184,13 +184,13 @@ namespace ATC virtual bool electron_recombination(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &recombination) const; - /** computes drift diffusion charge density */ + /** computes drift diffusion charge density */ virtual bool electron_charge_density(const FIELD_MATS &fields, DENS_MAT &density) const; - virtual void D_electron_charge_density(const FieldName fieldName, + virtual void D_electron_charge_density(const FieldName fieldName, const FIELD_MATS &fields, DENS_MAT &D_density) const; - /** computes momentum source */ + /** computes momentum source */ virtual bool body_force(const FIELD_MATS &fields, DENS_MAT &density) const; diff --git a/lib/atc/Matrix.cpp b/lib/atc/Matrix.cpp index 1b77796b8b..7271232aca 100644 --- a/lib/atc/Matrix.cpp +++ b/lib/atc/Matrix.cpp @@ -11,14 +11,14 @@ namespace ATC_matrix { //* performs a matrix-matrix multiply with optional transposes BLAS version // C = b*C + a*A*B //----------------------------------------------------------------------------- -void MultAB(const MATRIX &A, const MATRIX &B, DENS_MAT &C, +void MultAB(const MATRIX &A, const MATRIX &B, DENS_MAT &C, const bool At, const bool Bt, double a, double b) -{ +{ static char t[2] = {'N','T'}; char *ta=t+At, *tb=t+Bt; int sA[2] = {A.nRows(), A.nCols()}; // sizes of A int sB[2] = {B.nRows(), B.nCols()}; // sizes of B - + GCK(A, B, sA[!At]!=sB[Bt], "MultAB: matrix-matrix multiply"); if (!C.is_size(sA[At],sB[!Bt])) { @@ -33,11 +33,11 @@ void MultAB(const MATRIX &A, const MATRIX &B, DENS_MAT &C, double *pa=A.ptr(), *pb=B.ptr(), *pc=C.ptr(); #ifdef COL_STORAGE - dgemm_(ta, tb, M, N, K, &a, pa, sA, pb, sB, &b, pc, M); + dgemm_(ta, tb, M, N, K, &a, pa, sA, pb, sB, &b, pc, M); #else - dgemm_(tb, ta, N, M, K, &a, pb, sB+1, pa, sA+1, &b, pc, N); + dgemm_(tb, ta, N, M, K, &a, pb, sB+1, pa, sA+1, &b, pc, N); #endif - + } //----------------------------------------------------------------------------- @@ -54,13 +54,13 @@ DenseMatrix inv(const MATRIX& A) int *ipiv = new int[m<<1]; // need 2m storage int *iwork=ipiv+m; - + dgetrf_(&m,&m,invA.ptr(),&m,ipiv,&info); // compute LU factorization GCK(A,A,info<0,"DenseMatrix::inv() dgetrf error: Argument had bad value."); GCK(A,A,info>0,"DenseMatrix::inv() dgetrf error: Matrix not invertible."); if (info > 0) { delete [] ipiv; - invA = 0; + invA = 0; return invA; } @@ -80,9 +80,9 @@ DenseMatrix inv(const MATRIX& A) dgetri_(&m, invA.ptr(), &m, ipiv, work_dummy, &lwork, &info); GCK(A,A,info<0,"DenseMatrix::inv() dgetri error: Argument had bad value."); GCHK(info>0,"DenseMatrix::inv() dgetri error: Matrix not invertible."); - + // Work size query succeeded - lwork = (int)work_dummy[0]; + lwork = (int)work_dummy[0]; double *work = new double[lwork]; // Allocate vector of appropriate size // Compute and store matrix inverse @@ -100,21 +100,21 @@ DenseMatrix inv(const MATRIX& A) //* returns all eigenvalues & e-vectors of a pair of double precision matrices //----------------------------------------------------------------------------- -DenseMatrix eigensystem(const MATRIX& AA, const MATRIX & BB, +DenseMatrix eigensystem(const MATRIX& AA, const MATRIX & BB, DenseMatrix & eVals, bool normalize) { - DENS_MAT A(AA); // Make copy of A - DENS_MAT B(BB); + DENS_MAT A(AA); // Make copy of A + DENS_MAT B(BB); int m = A.nRows(); // size - eVals.resize(m,1); // eigenvectors + eVals.resize(m,1); // eigenvectors //A.print("A"); //B.print("B"); SQCK(A, "DenseMatrix::eigensystem(), matrix not square"); // check matrix is square SQCK(B, "DenseMatrix::eigensystem(), matrix not square"); // check matrix is square SSCK(A, B, "DenseMatrix::eigensystem(), not same size");// check same size - // workspace - int lwork=-1; //1+(NB+6+2*NMAX)*NMAX) + // workspace + int lwork=-1; //1+(NB+6+2*NMAX)*NMAX) double tmp[1]; double *work = tmp; int liwork = -1; // 3+5*NMAX @@ -133,7 +133,7 @@ DenseMatrix eigensystem(const MATRIX& AA, const MATRIX & BB, lwork = int(work[0]); liwork = iwork[0]; work = new double[lwork]; - iwork = new int[liwork]; + iwork = new int[liwork]; dsygvd_(&type,vectors,upper,&m,A.ptr(),&m,B.ptr(),&m, eVals.ptr(),work,&lwork,iwork,&liwork,&info); GCK(A,B,info!=0,"DenseMatrix::eigensystem(), error"); @@ -153,7 +153,7 @@ DenseMatrix eigensystem(const MATRIX& AA, const MATRIX & BB, } } //(A.transpose()).print("normalized e-vectors"); - } + } delete [] work; delete [] iwork; @@ -168,7 +168,7 @@ double condition_number(const MATRIX& AA) { DenseMatrix eVals, I; I.identity(AA.nRows()); - eigensystem(AA, I, eVals); + eigensystem(AA, I, eVals); // [1] William W. Hager, "Condition Estimates," SIAM J. Sci. Stat. Comput. 5, 1984, 311-316, 1984. // [2] Nicholas J. Higham and Françoise Tisseur, "A Block Algorithm for Matrix 1-Norm Estimation with an Application to 1-Norm Pseudospectra, "SIAM J. Matrix Anal. Appl., Vol. 21, 1185-1201, 2000. double max = eVals.maxabs(); @@ -178,23 +178,23 @@ double condition_number(const MATRIX& AA) //----------------------------------------------------------------------------- //* returns polar decomposition of a square double precision matrix via SVD //----------------------------------------------------------------------------- -DenseMatrix polar_decomposition(const MATRIX& AA, +DenseMatrix polar_decomposition(const MATRIX& AA, DenseMatrix & rotation, DenseMatrix & stretch, bool leftRotation) { - DENS_MAT A(AA); // Make copy of A - SQCK(A, "DenseMatrix::polar_decomposition(), matrix not square"); + DENS_MAT A(AA); // Make copy of A + SQCK(A, "DenseMatrix::polar_decomposition(), matrix not square"); int m = A.nRows(); // size - DENS_MAT D(m,1); + DENS_MAT D(m,1); DENS_MAT U(m,m), VT(m,m); // left and right SVD rotations - // workspace - int lwork=-1; + // workspace + int lwork=-1; double tmp[1]; double *work = tmp; - - // calculate singular value decomposition A = U D V^T + + // calculate singular value decomposition A = U D V^T char type[] = "A"; // all columns are returned int info; // query optimal sizes @@ -207,7 +207,7 @@ DenseMatrix polar_decomposition(const MATRIX& AA, dgesvd_(type,type,&m,&m,A.ptr(),&m,D.ptr(), U.ptr(),&m,VT.ptr(),&m, work,&lwork,&info); - + //GCK(A,B,info!=0,"DenseMatrix::polar_decomposition(), error"); GCK(A,A,info!=0,"DenseMatrix::polar_decomposition(), error"); delete [] work; @@ -218,7 +218,7 @@ DenseMatrix polar_decomposition(const MATRIX& AA, // A = R' U' = (U V^T) (V D V^T) stretch.resize(m,m); //if (leftRotation) { stretch = (VT.transpose())*D*VT; } - if (leftRotation) { + if (leftRotation) { DENS_MAT V = VT.transpose(); for (int i = 0; i < m; ++i) { for (int j = 0; j < m; ++j) { @@ -229,7 +229,7 @@ DenseMatrix polar_decomposition(const MATRIX& AA, } // A = V' R' = (U D U^T) (U V^T) //else { stretch = U*D*(U.transpose()); } - else { + else { for (int i = 0; i < m; ++i) { for (int j = 0; j < m; ++j) { stretch(i,j) = U(i,j)*D(j,0); @@ -237,7 +237,7 @@ DenseMatrix polar_decomposition(const MATRIX& AA, } stretch = stretch*(U.transpose()); } - return D; + return D; } //----------------------------------------------------------------------------- //* computes the determinant of a square matrix by LU decomposition (if n>3) @@ -255,7 +255,7 @@ double det(const MATRIX& A) return A(0,0)*(A(1,1)*A(2,2)-A(1,2)*A(2,1)) + A(0,1)*(A(1,2)*A(2,0)-A(1,0)*A(2,2)) + A(0,2)*(A(1,0)*A(2,1)-A(1,1)*A(2,0)); - default: break; + default: break; } // First compute LU factorization int info, *ipiv = new int[m]; @@ -271,12 +271,12 @@ double det(const MATRIX& A) det = PLUA(0,0); OddNumPivots = ipiv[0]!=(1); - for(i=1; i& A) GCK(A,A,!A.is_size(3,3), "max_eigenvalue only implemented for 3x3"); const double c0 = det(A); - const double c1 = A(1,0)*A(0,1) + A(2,0)*A(0,2) + A(1,2)*A(2,1) + const double c1 = A(1,0)*A(0,1) + A(2,0)*A(0,2) + A(1,2)*A(2,1) - A(0,0)*A(1,1) - A(0,0)*A(2,2) - A(1,1)*A(2,2); const double c2 = trace(A); double c[4] = {c0, c1, c2, -1.0}, x[3]; diff --git a/lib/atc/Matrix.h b/lib/atc/Matrix.h index c93576518c..199443facf 100644 --- a/lib/atc/Matrix.h +++ b/lib/atc/Matrix.h @@ -7,7 +7,7 @@ static const int myPrecision = 15; /** * @class Matrix - * @brief Base class for linear algebra subsystem + * @brief Base class for linear algebra subsystem */ template @@ -34,11 +34,11 @@ public: DenseMatrix pow(int n) const; DenseMatrix pow(double n) const; - // functions that return a copy + // functions that return a copy DenseMatrix transpose() const; void row_partition(const std::set & rowsIn, std::set & rows, std::set & colsC, DenseMatrix & A1, DenseMatrix & A2, bool complement=true) const; - std::set row_partition(const std::set & rows, + std::set row_partition(const std::set & rows, DenseMatrix & A1, DenseMatrix & A2) const; void map(const std::set& rows, const std::set& cols, DenseMatrix & A) const; void insert(const std::set& rows, const std::set& cols, const DenseMatrix & A); @@ -70,22 +70,22 @@ public: T col_min (INDEX i=0) const { return column(*this,i).min(); } T col_max (INDEX i=0) const { return column(*this,i).max(); } T col_stdev(INDEX i=0) const { return column(*this,i).stdev(); } - + // pure virtual functions (required to implement these) --------------------- //* reference index operator - virtual T& operator()(INDEX i, INDEX j)=0; + virtual T& operator()(INDEX i, INDEX j)=0; //* value index operator - virtual T operator()(INDEX i, INDEX j)const=0; + virtual T operator()(INDEX i, INDEX j)const=0; //* value flat index operator - virtual T& operator [](INDEX i)=0; + virtual T& operator [](INDEX i)=0; //* reference flat index operator - virtual T operator [](INDEX i) const=0; + virtual T operator [](INDEX i) const=0; //* returns the # of rows - virtual INDEX nRows() const=0; + virtual INDEX nRows() const=0; //* returns the # of columns - virtual INDEX nCols() const=0; + virtual INDEX nCols() const=0; //* returns a pointer to the data (dangerous) - virtual T * ptr() const=0; + virtual T * ptr() const=0; //* resizes the matrix, copy what fits default to OFF virtual void resize(INDEX nRows, INDEX nCols=1, bool copy=false)=0; //* resizes the matrix, zero it out default to ON @@ -93,7 +93,7 @@ public: //* resizes and copies data virtual void copy(const T * ptr, INDEX nRows, INDEX nCols=1)=0; //* create restart file - virtual void write_restart(FILE *f) const=0; + virtual void write_restart(FILE *f) const=0; //* writes a matlab command to recreate this in a variable named s virtual void matlab(std::ostream &o, const std::string &s="M") const; //* writes a mathematica command to recreate this in a variable named s @@ -106,7 +106,7 @@ public: Matrix& operator+=(const Matrix &r); Matrix& operator-=(const Matrix &r); - + Matrix& operator*=(const Matrix& R); Matrix& operator/=(const Matrix& R); Matrix& operator+=(const T v); @@ -116,7 +116,7 @@ public: Matrix& divide_zero_safe(const Matrix& B); Matrix& operator=(const T &v); - Matrix& operator=(const Matrix &c); + Matrix& operator=(const Matrix &c); virtual void set_all_elements_to(const T &v); //* adds a matrix scaled by factor s to this one. void add_scaled(const Matrix &A, const T& s); @@ -148,11 +148,11 @@ protected: virtual void _set_equal(const Matrix &r) = 0; }; -//* Matrix operations +//* Matrix operations //@{ //* Sets C as b*C + a*A[transpose?]*B[transpose?] template -void MultAB(const Matrix &A, const Matrix &B, DenseMatrix &C, +void MultAB(const Matrix &A, const Matrix &B, DenseMatrix &C, bool At=0, bool Bt=0, T a=1, T b=0); //* performs a matrix-vector multiply template @@ -166,7 +166,7 @@ DenseMatrix eigensystem(const Matrix& A, const Matrix& B DenseMatrix polar_decomposition(const Matrix& A, DenseMatrix & rotation, DenseMatrix & stretch, bool leftRotation = true); //* returns the trace of a matrix -template +template T trace(const Matrix& A) { return A.trace(); } //* computes the determinant of a square matrix double det(const Matrix& A); @@ -175,7 +175,7 @@ double max_eigenvalue(const Matrix& A); //@} //----------------------------------------------------------------------------- -// computes the sum of the difference squared of each element. +// computes the sum of the difference squared of each element. //----------------------------------------------------------------------------- template double sum_difference_squared(const Matrix& A, const Matrix &B) @@ -200,21 +200,21 @@ DenseMatrix operator*(const Matrix &A, const Matrix &B) return C; } //----------------------------------------------------------------------------- -//* Multiply a Matrix by a scalar +//* Multiply a Matrix by a scalar //----------------------------------------------------------------------------- template DenseMatrix operator*(const Matrix &M, const T s) { DenseMatrix R(M); - return R*=s; + return R*=s; } //----------------------------------------------------------------------------- -//* Multiply a Matrix by a scalar +//* Multiply a Matrix by a scalar template DenseMatrix operator*(const T s, const Matrix &M) { DenseMatrix R(M); - return R*=s; + return R*=s; } //----------------------------------------------------------------------------- //* inverse scaling operator - must always create memory @@ -247,7 +247,7 @@ DenseMatrix operator-(const Matrix &A, const Matrix &B) //----------------------------------------------------------------------------- //* performs a matrix-matrix multiply with general type implementation template -void MultAB(const Matrix &A, const Matrix &B, DenseMatrix &C, +void MultAB(const Matrix &A, const Matrix &B, DenseMatrix &C, const bool At, const bool Bt, T /* a */, T b) { const INDEX sA[2] = {A.nRows(), A.nCols()}; // m is sA[At] k is sA[!At] @@ -311,16 +311,16 @@ void Matrix::print(std::ostream &o, const std::string &name, int p) const //----------------------------------------------------------------------------- //* print operator, use cout by default template -void Matrix::print() const +void Matrix::print() const { - print(std::cout); + print(std::cout); } //----------------------------------------------------------------------------- //* named print operator, use cout by default template -void Matrix::print(const std::string &name, int p) const +void Matrix::print(const std::string &name, int p) const { - print(std::cout, name, p); + print(std::cout, name, p); } //----------------------------------------------------------------------------- //* element by element division @@ -367,8 +367,8 @@ DenseMatrix Matrix::transpose() const { DenseMatrix t(this->nCols(), this->nRows()); int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) for (INDEX j = 0; j < szj; j++) t(j,i) = (*this)(i,j); return t; @@ -381,14 +381,14 @@ DenseMatrix transpose(const Matrix &A) return A.transpose(); } //----------------------------------------------------------------------------- -//* Returns the sum of all matrix elements +//* Returns the sum of all matrix elements template T Matrix::sum() const { if (!size()) return T(0); T v = (*this)[0]; for (INDEX i=1; isize(); i++) v += (*this)[i]; - return v; + return v; } //----------------------------------------------------------------------------- //* Returns the standard deviation of the matrix @@ -399,12 +399,12 @@ T Matrix::stdev() const T mean = this->mean(); T diff = (*this)[0]-mean; T stdev = diff*diff; - for (INDEX i=1; isize(); i++) + for (INDEX i=1; isize(); i++) { diff = (*this)[i]-mean; stdev += diff*diff; } - return sqrt(stdev/T(this->size()-1)); + return sqrt(stdev/T(this->size()-1)); } //----------------------------------------------------------------------------- //* Returns the maximum of the matrix @@ -414,7 +414,7 @@ T Matrix::max() const GCHK(!this->size(), "Matrix::max() size must be > 0"); T v = (*this)[0]; for (INDEX i=1; isize(); i++) v = std::max(v, (*this)[i]); - return v; + return v; } //----------------------------------------------------------------------------- //* Returns the minimum of the matrix @@ -424,7 +424,7 @@ T Matrix::min() const GCHK(!this->size(), "Matrix::min() size must be > 0"); T v = (*this)[0]; for (INDEX i=1; isize(); i++) v = std::min(v, (*this)[i]); - return v; + return v; } //----------------------------------------------------------------------------- //* Returns the maximum absolute value of the matrix @@ -434,7 +434,7 @@ T Matrix::maxabs() const GCHK(!this->size(), "Matrix::maxabs() size must be > 0"); T v = (*this)[0]; for (INDEX i=1; isize(); i++) v = ATC_Utility::max_abs(v, (*this)[i]); - return v; + return v; } //----------------------------------------------------------------------------- //* Returns the minimum absoute value of the matrix @@ -444,28 +444,28 @@ T Matrix::minabs() const GCHK(!this->size(), "Matrix::minabs() size must be > 0"); T v = (*this)[0]; for (INDEX i=1; isize(); i++) v = ATC_Utility::min_abs(v, (*this)[i]); - return v; + return v; } //----------------------------------------------------------------------------- //* returns the L2 norm of the matrix template -T Matrix::norm() const +T Matrix::norm() const { GCHK(!this->size(), "Matrix::norm() size must be > 0"); - return sqrt(dot(*this)); + return sqrt(dot(*this)); } //----------------------------------------------------------------------------- //* returns the L2 norm of the matrix template -T Matrix::norm_sq() const +T Matrix::norm_sq() const { GCHK(!this->size(), "Matrix::norm() size must be > 0"); - return dot(*this); + return dot(*this); } //----------------------------------------------------------------------------- //* returns the average of the matrix template -T Matrix::mean() const +T Matrix::mean() const { GCHK(!this->size(), "Matrix::mean() size must be > 0"); return sum()/T(this->size()); @@ -497,7 +497,7 @@ T Matrix::trace() const //----------------------------------------------------------------------------- //* Adds a matrix to this one template -Matrix& Matrix::operator+=(const Matrix &r) +Matrix& Matrix::operator+=(const Matrix &r) { SSCK(*this, r, "operator+= or operator +"); int sz=this->size(); for(INDEX i=0; i& Matrix::operator+=(const Matrix &r) // subtracts a matrix from this one //----------------------------------------------------------------------------- template -Matrix& Matrix::operator-=(const Matrix &r) +Matrix& Matrix::operator-=(const Matrix &r) { SSCK(*this, r, "operator-= or operator -"); int sz=this->size(); for(INDEX i=0; i& Matrix::operator*=(const Matrix& R) { if ((R.nCols()==1) && (this->nCols()>1)) { // multiply every entry in a row by the same value int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) for (INDEX j = 0; j < szj; j++) { (*this)(i,j) *= R[i]; } } - else if (((R.nCols()==R.size()) && (R.nRows()==R.size())) && !((this->nCols()==this->size()) && (this->nRows()==this->size()))){ + else if (((R.nCols()==R.size()) && (R.nRows()==R.size())) && !((this->nCols()==this->size()) && (this->nRows()==this->size()))){ int szi = this->nRows(); - int szj = this->nCols(); - for (INDEX i = 0; i < szi; i++) + int szj = this->nCols(); + for (INDEX i = 0; i < szi; i++) for (INDEX j = 0; j < szj; j++) { (*this)(i,j) *= R[i]; } - } + } else { // multiply each entry by a different value int sz = this->size(); - for (INDEX i = 0; i < sz; i++) + for (INDEX i = 0; i < sz; i++) { - (*this)[i] *= R[i]; + (*this)[i] *= R[i]; } } return *this; @@ -566,10 +566,10 @@ Matrix& Matrix::operator/=(const Matrix& R) else { // divide each entry by a different value SSCK(*this, R, "operator/= or operator/"); int sz = this->size(); - for(INDEX i = 0; i < sz; i++) + for(INDEX i = 0; i < sz; i++) { - GCHK(fabs(R[i])==0,"Operator/: division by zero"); - (*this)[i] /= R[i]; + GCHK(fabs(R[i])==0,"Operator/: division by zero"); + (*this)[i] /= R[i]; } } return *this; @@ -594,10 +594,10 @@ Matrix& Matrix::divide_zero_safe(const Matrix& R) else { // divide each entry by a different value SSCK(*this, R, "operator/= or operator/"); int sz = this->size(); - for(INDEX i = 0; i < sz; i++) + for(INDEX i = 0; i < sz; i++) { if(fabs(R[i])!=0) { - (*this)[i] /= R[i]; + (*this)[i] /= R[i]; } } } @@ -607,33 +607,33 @@ Matrix& Matrix::divide_zero_safe(const Matrix& R) // scales this matrix by a constant //----------------------------------------------------------------------------- template -Matrix& Matrix::operator*=(const T v) +Matrix& Matrix::operator*=(const T v) { - int sz=this->size(); for(INDEX i=0; isize(); for(INDEX i=0; i -Matrix& Matrix::operator+=(const T v) +Matrix& Matrix::operator+=(const T v) { - int sz=this->size(); for(INDEX i=0; isize(); for(INDEX i=0; i -Matrix& Matrix::operator-=(const T v) +Matrix& Matrix::operator-=(const T v) { - int sz=this->size(); for(INDEX i=0; isize(); for(INDEX i=0; i -Matrix& Matrix::operator/=(T v) +Matrix& Matrix::operator/=(T v) { return (*this)*=(1.0/v); } @@ -650,15 +650,15 @@ Matrix& Matrix::operator=(const Matrix &r) //----------------------------------------------------------------------------- //* sets all elements to a constant template -inline Matrix& Matrix::operator=(const T &v) +inline Matrix& Matrix::operator=(const T &v) { - set_all_elements_to(v); + set_all_elements_to(v); return *this; } //----------------------------------------------------------------------------- //* sets all elements to a constant template -void Matrix::set_all_elements_to(const T &v) +void Matrix::set_all_elements_to(const T &v) { int sz=this->size(); for(INDEX i=0; i::add_scaled(const Matrix &A, const T& s) //----------------------------------------------------------------------------- //* writes a matlab command to the console template -void Matrix::matlab(const std::string &s) const +void Matrix::matlab(const std::string &s) const { - this->matlab(std::cout, s); + this->matlab(std::cout, s); } //----------------------------------------------------------------------------- //* Writes a matlab script defining the vector to the stream @@ -685,17 +685,17 @@ void Matrix::matlab(std::ostream &o, const std::string &s) const { o << s <<"=zeros(" << nRows() << ","<nRows(); - int szj = this->nCols(); + int szj = this->nCols(); for (INDEX i = 0; i < szi; i++) - for (INDEX j = 0; j < szj; j++) + for (INDEX j = 0; j < szj; j++) o << s << "("< -void Matrix::mathematica(const std::string &s) const +void Matrix::mathematica(const std::string &s) const { - this->mathematica(std::cout, s); + this->mathematica(std::cout, s); } //----------------------------------------------------------------------------- //* Writes a mathematica script defining the vector to the stream @@ -710,7 +710,7 @@ void Matrix::mathematica(std::ostream &o, const std::string &s) const for(INDEX j=1; j< nCols(); j++) o << ", " << (*this)(i,j); if (i+1 == nRows()) { o <<" } \n"; } else { o <<" }, \n"; } - + } o << "};\n"; o << std::scientific; @@ -718,16 +718,16 @@ void Matrix::mathematica(std::ostream &o, const std::string &s) const //----------------------------------------------------------------------------- //* sets all matrix elements to zero template -inline Matrix& Matrix::zero() -{ +inline Matrix& Matrix::zero() +{ set_all_elements_to(T(0)); return *this; } //----------------------------------------------------------------------------- //* sets to identity template -inline Matrix& Matrix::identity(int nrows) -{ +inline Matrix& Matrix::identity(int nrows) +{ if (nrows == 0) { SQCK(*this, "DenseMatrix::inv(), matrix not square"); // check matrix is square nrows = nRows(); @@ -739,30 +739,30 @@ inline Matrix& Matrix::identity(int nrows) //----------------------------------------------------------------------------- //* returns the total number of elements template -inline INDEX Matrix::size() const -{ - return nRows()*nCols(); +inline INDEX Matrix::size() const +{ + return nRows()*nCols(); } //----------------------------------------------------------------------------- //* returns true if (i,j) is within the range of the matrix template inline bool Matrix::in_range(INDEX i, INDEX j) const -{ - return i inline bool Matrix::is_size(INDEX rs, INDEX cs) const -{ - return nRows()==rs && nCols()==cs; +{ + return nRows()==rs && nCols()==cs; } //----------------------------------------------------------------------------- //* returns true if the matrix is square and not empty template inline bool Matrix::is_square() const -{ - return nRows()==nCols() && nRows(); +{ + return nRows()==nCols() && nRows(); } //----------------------------------------------------------------------------- //* returns true if Matrix, m, is the same size as this @@ -776,14 +776,14 @@ inline bool Matrix::same_size(const Matrix &m) const template inline bool Matrix::same_size(const Matrix &a, const Matrix &b) { - return a.same_size(b); + return a.same_size(b); } //----------------------------------------------------------------------------- //* returns true if Matrix a rows = Matrix b cols template inline bool Matrix::cols_equals_rows(const Matrix &a, const Matrix &b) { - return a.nCols() == b.nRows(); + return a.nCols() == b.nRows(); } //----------------------------------------------------------------------------- //* returns true if no value is outside of the range @@ -842,7 +842,7 @@ void merror(const Matrix &a, const Matrix &b, const std::string m) //* rows is the map for A1, (rows,colsC) is the map for A2 template -void Matrix::row_partition(const std::set & rowsIn, +void Matrix::row_partition(const std::set & rowsIn, std::set & rows, std::set & colsC, DenseMatrix & A1, DenseMatrix & A2, bool complement) const { @@ -890,7 +890,7 @@ DenseMatrix & A1, DenseMatrix & A2, bool complement) const } template -std::set Matrix::row_partition(const std::set & rows, +std::set Matrix::row_partition(const std::set & rows, DenseMatrix & A1, DenseMatrix & A2) const { // complement of set "rows" in set of this.cols is "cols" @@ -935,7 +935,7 @@ DenseMatrix & A1, DenseMatrix & A2) const //----------------------------------------------------------------------------- //* returns row & column mapped matrix template -void Matrix::map(const std::set & rows, const std::set & cols, +void Matrix::map(const std::set & rows, const std::set & cols, DenseMatrix & A ) const { if (rows.size() == 0 || cols.size() == 0 ) { @@ -957,10 +957,10 @@ DenseMatrix & A ) const } } //----------------------------------------------------------------------------- -//* inserts elements from a smaller matrix +//* inserts elements from a smaller matrix template -void Matrix::insert(const std::set & rows, const std::set & cols, -const DenseMatrix & A ) +void Matrix::insert(const std::set & rows, const std::set & cols, +const DenseMatrix & A ) { if (rows.size() == 0 || cols.size() == 0 ) return; std::set::const_iterator itrI, itrJ; @@ -976,10 +976,10 @@ const DenseMatrix & A ) } } //----------------------------------------------------------------------------- -//* assemble elements from a smaller matrix +//* assemble elements from a smaller matrix template -void Matrix::assemble(const std::set & rows, const std::set & cols, -const DenseMatrix & A ) +void Matrix::assemble(const std::set & rows, const std::set & cols, +const DenseMatrix & A ) { if (rows.size() == 0 || cols.size() == 0 ) return; std::set::const_iterator itrI, itrJ; diff --git a/lib/atc/MatrixDef.h b/lib/atc/MatrixDef.h index 7ac3e3dc5f..9e8e75f819 100644 --- a/lib/atc/MatrixDef.h +++ b/lib/atc/MatrixDef.h @@ -1,9 +1,9 @@ -#ifndef MATRIXDEF_H +#ifndef MATRIXDEF_H #define MATRIXDEF_H /****************************************************************************** * Common definitions for Matrix and Vector classes -* This header file contains macros and inline functions needed for the matrix +* This header file contains macros and inline functions needed for the matrix * classes. All error checking should be defined here as a macro so that it is * neatly disabled when ATC_PRINT_DEBUGGING is not defined ******************************************************************************/ @@ -37,7 +37,7 @@ typedef int INDEX; enum CLONE_TYPE { CLONE_ROW=0, CLONE_COL=1, CLONE_DIAG=2 }; //* @struct TRIPLET //* @brief Triplet output entity -template +template struct TRIPLET { TRIPLET(int _i=0, int _j=0, T _v=T(0)) : i(_i), j(_j), v(_v) {} INDEX i, j; T v; }; @@ -139,22 +139,22 @@ template T dot(const SparseVector &a, const SparseVector &b); //@} template CloneVector column(Matrix &c, INDEX i) { - return CloneVector(c, CLONE_COL, i); + return CloneVector(c, CLONE_COL, i); } template CloneVector row(Matrix &c, INDEX i) { return CloneVector(c, CLONE_ROW, i); } template CloneVector diagonal(Matrix &c) { - return CloneVector(c, CLONE_DIAG); + return CloneVector(c, CLONE_DIAG); } template const CloneVector column(const Matrix &c, INDEX i) { - return CloneVector(c, CLONE_COL, i); + return CloneVector(c, CLONE_COL, i); } template const CloneVector row(const Matrix &c, INDEX i) { - return CloneVector(c, CLONE_ROW, i); + return CloneVector(c, CLONE_ROW, i); } -template const CloneVector diagonal(const Matrix &c) { - return CloneVector(c, CLONE_DIAG); +template const CloneVector diagonal(const Matrix &c) { + return CloneVector(c, CLONE_DIAG); } template const SparseMatrix *sparse_cast(const Matrix *m); template const DiagonalMatrix *diag_cast(const Matrix *m); diff --git a/lib/atc/MatrixLibrary.h b/lib/atc/MatrixLibrary.h index 7cd23a28fd..cccb37cbbc 100644 --- a/lib/atc/MatrixLibrary.h +++ b/lib/atc/MatrixLibrary.h @@ -14,9 +14,9 @@ namespace ATC_matrix { template -const SparseMatrix *sparse_cast(const Matrix *m) +const SparseMatrix *sparse_cast(const Matrix *m) { - return dynamic_cast*>(m); + return dynamic_cast*>(m); } template @@ -27,7 +27,7 @@ void copy_sparse_to_matrix(const SparseMatrix *s, Matrix &m) for (INDEX i=0; isize(); i++) { triplet = s->triplet(i); - m(triplet.i, triplet.j) = triplet.v; + m(triplet.i, triplet.j) = triplet.v; } } diff --git a/lib/atc/MeshReader.cpp b/lib/atc/MeshReader.cpp index c4896ec727..fb870985a3 100644 --- a/lib/atc/MeshReader.cpp +++ b/lib/atc/MeshReader.cpp @@ -2,8 +2,8 @@ #include "LammpsInterface.h" #include "Utility.h" #ifdef HAS_EXODUS -//#include -//#include "netcdf.h" +//#include +//#include "netcdf.h" #include "exodusII.h" #endif @@ -18,8 +18,8 @@ using std::string; namespace ATC { /** constructor, takes a filename */ - MeshReader::MeshReader(string filename, - Array periodicity, + MeshReader::MeshReader(string filename, + Array periodicity, double /* tol */) : meshfile_(filename), periodicity_(periodicity), @@ -36,7 +36,7 @@ namespace ATC { } string ext = filename.substr(idx+1); - + if (ext == "mesh"){ read_mesh_file(); } else { throw ATC_Error("mesh file is of unknown type."); } } @@ -66,7 +66,7 @@ namespace ATC { for (unsigned int i=0; i < str.size(); i++) { if (isdigit(str[i])) { for (unsigned int a=i; a 0) { throw ATC_Error("problem with init "+meshfile_+" "+title); } - // coordinates + // coordinates float x[nNodes_], y[nNodes_], z[nNodes_]; error = ex_get_coord (exoid, x, y, z); if (error > 0) { throw ATC_Error("problem with getting coordinates "+meshfile_); } nodeCoords_->reset(nsd,nNodes_); DENS_MAT & nodes = *nodeCoords_; for (int i = 0; i < nNodes_; ++i) { - nodes(0,i) = x[i]; // this is a float to double conversion - nodes(1,i) = y[i]; // this is a float to double conversion - nodes(2,i) = z[i]; // this is a float to double conversion + nodes(0,i) = x[i]; // this is a float to double conversion + nodes(1,i) = y[i]; // this is a float to double conversion + nodes(2,i) = z[i]; // this is a float to double conversion } ATC::LammpsInterface::instance()->print_msg_once("read "+to_string(nNodes_)+ " nodes"); @@ -181,7 +181,7 @@ namespace ATC { error = ex_get_elem_blk_ids(exoid, blkIds); char etype[MAX_STR_LENGTH+1]; string lastType; - for (int i=0; ireset(nVerts, nElements_); int n = 0; - for (int i=0; i > >(); nodeSets_->reset(nNodeSets_); - for (int i=0; iint_allmin(&lo,&globalLo); lammps_->int_allmax(&hi,&globalHi); if (globalLo == lammps_->natoms()) throw ATC_Error("MoleculeSet:initialize - no molecules correspond to the group"); - + // molmap = vector of length nlen // set to 1 for IDs that appear in group across all procs, else 0 int nlen = globalHi-globalLo+1; int * localCount = new int[nlen]; for (i = 0; i < nlen; i++) localCount[i] = 0; - + for (i = 0; i < nlocal; i++) if (mask[i] & groupBit_) localCount[molecule[i]-globalLo]++; - + int * globalCount = new int[nlen]; lammps_->int_allsum(localCount,globalCount,nlen); - + // nmolecules = # of non-zero IDs in molmap // molmap[i] = index of molecule, skipping molecules not in group with -1 - + nMoleculesTotal_ = 0; for (i = 0; i < nlen; i++) if (globalCount[i]) nMoleculesTotal_++; @@ -209,7 +209,7 @@ namespace ATC { lammps_->forward_comm_fix(); int * numBond = lammps_->num_bond(); int ** bondAtom = lammps_->bond_atom(); - + // add in real atoms for molecules int *molecule = lammps_->atom_to_molecule(); const int *mask = lammps_->atom_mask(); @@ -217,7 +217,7 @@ namespace ATC { _atomFound_.resize(atc_->nproc_ghost()); _atomFound_ = false; int nmol = 0; - + for (int i = 0; i < nlocal; i++) { queue myQueue; if ((mask[i] & groupBit_) && !_atomFound_(i)) { @@ -245,7 +245,7 @@ namespace ATC { } nmol++; moleculeToAtoms_.insert(pair >(molecule[i],myAtoms)); - } + } } // set local molecule order MoleculeSet::set_local_molecules_to_atoms(); diff --git a/lib/atc/MoleculeSet.h b/lib/atc/MoleculeSet.h index 763f08ef4d..677f907460 100644 --- a/lib/atc/MoleculeSet.h +++ b/lib/atc/MoleculeSet.h @@ -112,7 +112,7 @@ namespace ATC { PerAtomQuantity * numBond = nullptr); virtual ~SmallMoleculeSet(); - + /** reset all data */ virtual void clear(); diff --git a/lib/atc/NonLinearSolver.cpp b/lib/atc/NonLinearSolver.cpp index c11ca9474d..a58f615e4a 100644 --- a/lib/atc/NonLinearSolver.cpp +++ b/lib/atc/NonLinearSolver.cpp @@ -1,4 +1,4 @@ -// ATC headers +// ATC headers #include "NonLinearSolver.h" #include "LinearSolver.h" #include "ATC_Error.h" @@ -32,7 +32,7 @@ namespace ATC { //-------------------------------------------------------------------- double NonLinearSolver::residual_norm(VECTOR & r) { - + if (bcs_) { DENS_VEC R = r; BC_SET::const_iterator itr; @@ -54,10 +54,10 @@ namespace ATC { } if (rNorm0_ == 0.0) rNorm0_ = 1.0; if (rNorm0_ < tol0_ ) rNorm0_ = rNorm0P_; - if (rNorm0P_ == 1.0) rNorm0P_ = rNorm0_; + if (rNorm0P_ == 1.0) rNorm0P_ = rNorm0_; rNormP_ = rNorm0_; dx_.reset(r_.nRows()); // needs to be sized for linear solver - // newton's method + // newton's method for (int iter = 0; iter < maxIterations_ ; iter++ ) { // compute tangent f_->tangent(x, r_, A_); @@ -66,7 +66,7 @@ namespace ATC { if (rNorm_ < tol_) { return true; } - SPAR_MAT Asparse(A_); + SPAR_MAT Asparse(A_); LinearSolver linearSolver(Asparse, LinearSolver::AUTO_SOLVE, parallel_); if (bcs_) { linearSolver.allow_reinitialization(); @@ -74,7 +74,7 @@ namespace ATC { if (iter > 0) linearSolver.set_homogeneous_bcs(); else { x.zero(); } // linear solve w/ bcs will replace guess } - r_ *= -1; + r_ *= -1; linearSolver.solve(dx_,r_); if (iter > 0 && rNorm_ > rNormP_) { @@ -97,9 +97,9 @@ namespace ATC { - bool NonLinearSolver::line_search(VECTOR & x) + bool NonLinearSolver::line_search(VECTOR & x) { - double rNormP = rNormP_; + double rNormP = rNormP_; double dxnorm = dx_.norm(); while ( dxnorm > tolx_) { dx_ *= 0.5; // bisection diff --git a/lib/atc/NonLinearSolver.h b/lib/atc/NonLinearSolver.h index 299408c4c3..fa41af6331 100644 --- a/lib/atc/NonLinearSolver.h +++ b/lib/atc/NonLinearSolver.h @@ -29,7 +29,7 @@ class TangentOperator { /** * @class NonLinearSolver * @brief a class to solve a system of non-linear equations - * f(x) = 0 + * f(x) = 0 */ @@ -41,7 +41,7 @@ class NonLinearSolver { }; /** Constructor */ - NonLinearSolver( + NonLinearSolver( TangentOperator * f, // provides f and f' at x, pointer for polymorphism const BC_SET * bcs = nullptr, const int dof = 0, @@ -52,7 +52,7 @@ class NonLinearSolver { virtual ~NonLinearSolver() {}; /** residual norm */ - double residual_norm(VECTOR & x); + double residual_norm(VECTOR & x); /** solve */ bool solve(VECTOR & x); // incoming: initial guess, outgoing: solution @@ -60,7 +60,7 @@ class NonLinearSolver { /** line search */ bool line_search(VECTOR & x); - + /** access to current state */ DENS_MAT & tangent() { return A_;} DENS_VEC & residual() { return r_;} @@ -87,7 +87,7 @@ class NonLinearSolver { /** flavors */ int solverType_; - /** state */ + /** state */ double rNorm0_, rNorm0P_, rNorm_, rNormP_; /** parameters & tolerances */ diff --git a/lib/atc/OutputManager.cpp b/lib/atc/OutputManager.cpp index 83257a3d21..d66fb0e8dd 100644 --- a/lib/atc/OutputManager.cpp +++ b/lib/atc/OutputManager.cpp @@ -22,11 +22,11 @@ static const int kFieldWidth = kFieldPrecison + 6; static const int kFileNameSize = 26; // HERE <<<< static string tensor_component_names[9] = {"11","12","13", - "21","22","23", - "31","32","33"}; -static string sym_tensor_component_names[6] = {"11","22","33","12","13","23"}; -static string vector_component_names[3] = {"_X","_Y","_Z"}; -static string list_component_names[26] = {"_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","_r","_s","_t","_u","_v","_w","_x","_y","_z"}; + "21","22","23", + "31","32","33"}; +static string sym_tensor_component_names[6] = {"11","22","33","12","13","23"}; +static string vector_component_names[3] = {"_X","_Y","_Z"}; +static string list_component_names[26] = {"_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","_r","_s","_t","_u","_v","_w","_x","_y","_z"}; string* get_component_names(int type) { // HERE <<<< string* componentNames = list_component_names; @@ -39,7 +39,7 @@ string* get_component_names(int type) { // HERE <<<< return componentNames; } - + //----------------------------------------------------------------------------- //* //----------------------------------------------------------------------------- @@ -95,8 +95,8 @@ void OutputManager::set_option(OutputOption option, bool value) { //----------------------------------------------------------------------------- //* //----------------------------------------------------------------------------- -void OutputManager::initialize(string outputPrefix, set & otypes) -{ +void OutputManager::initialize(string outputPrefix, set & otypes) +{ if (outputPrefix_ != outputPrefix ) { // new stream with existing object outputPrefix_ = outputPrefix; initialized_ = false; @@ -162,8 +162,8 @@ void OutputManager::read_restart_file(string fileName, RESTART_LIST *data) for (int j = 0; j < field_data->nCols(); ++j) { double myVal; if (fread(&myVal,sizeof(double),1,fp) == 1) - (*field_data)(i,j) = myVal; - + (*field_data)(i,j) = myVal; + } } } @@ -172,7 +172,7 @@ void OutputManager::read_restart_file(string fileName, RESTART_LIST *data) //----------------------------------------------------------------------------- //* //----------------------------------------------------------------------------- -void OutputManager::write_globals(void) +void OutputManager::write_globals(void) { if ( outputPrefix_ == "NULL") return; string file = outputPrefix_ + ".GLOBALS"; @@ -186,10 +186,10 @@ void OutputManager::write_globals(void) if ( firstStep_ || writeGlobalsHeader_) { text << "# time:1 "; int index = 2; - for (iter = globalData_.begin(); iter != globalData_.end(); iter++) + for (iter = globalData_.begin(); iter != globalData_.end(); iter++) { string name = iter->first; - string str; stringstream out; out << ":" << index++; + string str; stringstream out; out << ":" << index++; str = out.str(); name.append(str); text.width(kFieldWidth); text << name << " "; @@ -199,7 +199,7 @@ void OutputManager::write_globals(void) writeGlobalsHeader_ = false; // data text.width(kFieldWidth); text << outputTimes_[outputTimes_.size()-1] << " "; - for (iter = globalData_.begin(); + for (iter = globalData_.begin(); iter != globalData_.end(); iter++) { double value = iter->second; text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << value << " "; @@ -207,13 +207,13 @@ void OutputManager::write_globals(void) text << "\n"; } //----------------------------------------------------------------------------- -//* +//* //----------------------------------------------------------------------------- -void OutputManager::write_geometry(const MATRIX *coordinates, +void OutputManager::write_geometry(const MATRIX *coordinates, const Array2D *connectivities) { - if ( outputPrefix_ == "NULL") throw ATC_Error( "No outputPrefix given."); - + if ( outputPrefix_ == "NULL") throw ATC_Error( "No outputPrefix given."); + number_of_nodes_ = coordinates->nCols(); coordinates_ = coordinates; connectivities_ = connectivities; @@ -222,7 +222,7 @@ void OutputManager::write_geometry(const MATRIX *coordinates, initialized_ = true; } //----------------------------------------------------------------------------- -//* +//* //----------------------------------------------------------------------------- void OutputManager::write_geometry_ensight(void) { @@ -268,14 +268,14 @@ void OutputManager::write_geometry_ensight(void) strcpy(buffer,"coordinates"); fwrite(buffer,sizeof(char),80,fp); fwrite(&number_of_nodes_,sizeof(int),1,fp); - + int number_of_spatial_dimensions = coordinates.nRows(); - if (number_of_spatial_dimensions != 3) + if (number_of_spatial_dimensions != 3) throw ATC_Error("Ensight writer needs a 3D geometry"); - for (int i = 0; i < number_of_spatial_dimensions; ++i) + for (int i = 0; i < number_of_spatial_dimensions; ++i) { - for (int j = 0; j < number_of_nodes_; ++j) + for (int j = 0; j < number_of_nodes_; ++j) { float x = (float) coordinates(i,j); fwrite(&x,sizeof(float),1,fp); @@ -283,36 +283,36 @@ void OutputManager::write_geometry_ensight(void) } // write mesh connectivities or point "connectivities" - if (connectivities_) - { + if (connectivities_) + { dataType_ = MESH; int nodes_per_element = connectivities_->nRows(); if (nodes_per_element == 4) { strcpy(buffer,"tetra4"); } else if (nodes_per_element == 8) { strcpy(buffer,"hexa8"); } else if (nodes_per_element == 20) { strcpy(buffer,"hexa20"); } else if (nodes_per_element == 27) { strcpy(buffer,"hexa27"); } - else + else throw ATC_Error("Ensight writer does not recoginize element type"); fwrite(buffer,sizeof(char),80,fp); int number_of_elements = connectivities_->nCols(); fwrite(&number_of_elements,sizeof(int),1,fp); int number_of_nodes_per_element = connectivities_->nRows(); - for (int j = 0; j < number_of_elements; ++j) + for (int j = 0; j < number_of_elements; ++j) { - for (int i = 0; i < number_of_nodes_per_element; ++i) + for (int i = 0; i < number_of_nodes_per_element; ++i) { int inode = (*connectivities_)(i,j) +1; // 1 based numbering fwrite(&inode,sizeof(int),1,fp); } } - } - else + } + else { strcpy(buffer,"point"); fwrite(buffer,sizeof(char),80,fp); int number_of_elements = number_of_nodes_; fwrite(&number_of_elements,sizeof(int),1,fp); - for (int j = 0; j < number_of_elements; ++j) + for (int j = 0; j < number_of_elements; ++j) { int inode = j +1; // 1 based numbering fwrite(&inode,sizeof(int),1,fp); @@ -325,7 +325,7 @@ void OutputManager::write_geometry_ensight(void) fclose(fp); } //----------------------------------------------------------------------------- -//* +//* //----------------------------------------------------------------------------- void OutputManager::write_geometry_text(void) { @@ -336,14 +336,14 @@ void OutputManager::write_geometry_text(void) // open file ofstream text; text.open(geom_file_text.c_str(),ios_base::out); - if (connectivities_) - { + if (connectivities_) + { int number_of_elements = connectivities_->nCols(); int number_of_nodes_per_element = connectivities_->nRows(); - for (int j = 0; j < number_of_elements; ++j) + for (int j = 0; j < number_of_elements; ++j) { text << "#"; - for (int i = 0; i < number_of_nodes_per_element; ++i) + for (int i = 0; i < number_of_nodes_per_element; ++i) { int inode = (*connectivities_)(i,j) +1; // 1 based numbering text << setw(6) << inode; @@ -354,10 +354,10 @@ void OutputManager::write_geometry_text(void) const MATRIX & coordinates = *coordinates_; int number_of_spatial_dimensions = coordinates.nRows(); - for (int j = 0; j < number_of_nodes_; ++j) + for (int j = 0; j < number_of_nodes_; ++j) { text << setw(6) << j+1 << " "; - for (int i = 0; i < number_of_spatial_dimensions; ++i) + for (int i = 0; i < number_of_spatial_dimensions; ++i) { text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << coordinates(i,j) << " "; } @@ -368,25 +368,25 @@ void OutputManager::write_geometry_text(void) //----------------------------------------------------------------------------- /** pack "soln" into data */ //----------------------------------------------------------------------------- -void OutputManager::write_data(double time, FIELDS *soln, OUTPUT_LIST *data, const int *node_map) +void OutputManager::write_data(double time, FIELDS *soln, OUTPUT_LIST *data, const int *node_map) { // pack - OUTPUT_LIST combined_data; - if (soln) + OUTPUT_LIST combined_data; + if (soln) { FIELDS::iterator iter; - for (iter = soln->begin(); iter != soln->end(); iter++) + for (iter = soln->begin(); iter != soln->end(); iter++) { FieldName field_index = iter->first; - MATRIX* field_data = &((iter->second).set_quantity()); + MATRIX* field_data = &((iter->second).set_quantity()); string field_name = field_to_string(field_index); combined_data[field_name] = field_data; } } - if (data) + if (data) { OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { string field_name = iter->first; const MATRIX* field_data = iter->second; @@ -410,7 +410,7 @@ void OutputManager::write_data(double time, OUTPUT_LIST *data, const int *node_m if (ensightOutput_) { // write data OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { string field_name = iter->first; const MATRIX* field_data = iter->second; @@ -422,7 +422,7 @@ void OutputManager::write_data(double time, OUTPUT_LIST *data, const int *node_m // write text dump if (textOutput_) { - write_data_text(data); + write_data_text(data); if (firstStep_ && node_map) { string map_file_text = outputPrefix_ + ".MAP"; ofstream text; @@ -434,10 +434,10 @@ void OutputManager::write_data(double time, OUTPUT_LIST *data, const int *node_m } } else if (fullTextOutput_) { - write_data_text(data,node_map); + write_data_text(data,node_map); } if (vtkOutput_) { - write_data_vtk(data); + write_data_vtk(data); } // global variables @@ -471,7 +471,7 @@ void OutputManager::write_data_ensight(string field_name, const MATRIX *field_da nfiles = kFileNameSize; } string* component_names = get_component_names(type); - for (int ifile = 0; ifile < nfiles; ++ifile) + for (int ifile = 0; ifile < nfiles; ++ifile) { string comp_name; if (! custom_name(field_name,ifile,comp_name)) @@ -480,15 +480,15 @@ void OutputManager::write_data_ensight(string field_name, const MATRIX *field_da } } - for (int ifile = 0; ifile < nfiles; ++ifile) + for (int ifile = 0; ifile < nfiles; ++ifile) { // for vector/tensor to components - if ( nfiles > 1 ) - { - col_start = ifile; - col_end = ifile+1; + if ( nfiles > 1 ) + { + col_start = ifile; + col_end = ifile+1; } - + // open or append data file string data_file_name = filenames[ifile]; FILE * fp=nullptr; @@ -501,12 +501,12 @@ void OutputManager::write_data_ensight(string field_name, const MATRIX *field_da if (fp == nullptr) { throw ATC_Error("can not create Ensight data file: "+data_file_name); } - + // write data char buffer[80]; strcpy(buffer,"BEGIN TIME STEP"); fwrite(buffer,sizeof(char),80,fp); - strcpy(buffer,"field name"); + strcpy(buffer,"field name"); fwrite(buffer,sizeof(char),80,fp); // per part @@ -516,23 +516,23 @@ void OutputManager::write_data_ensight(string field_name, const MATRIX *field_da fwrite(&part_number,sizeof(int),1,fp); strcpy(buffer,"coordinates"); fwrite(buffer,sizeof(char),80,fp); - if (node_map) + if (node_map) { - for (int j = col_start; j < col_end; ++j) + for (int j = col_start; j < col_end; ++j) { - for (int i = 0; i < number_of_nodes_; ++i) + for (int i = 0; i < number_of_nodes_; ++i) { int inode = node_map[i]; float x = (float) (*field_data)(inode,j); fwrite(&x,sizeof(float),1,fp); } } - } - else + } + else { - for (int j = col_start; j < col_end; ++j) + for (int j = col_start; j < col_end; ++j) { - for (int i = 0; i < field_data->nRows(); ++i) + for (int i = 0; i < field_data->nRows(); ++i) { float x = (float) (*field_data)(i,j); fwrite(&x,sizeof(float),1,fp); @@ -552,10 +552,10 @@ void OutputManager::write_data_ensight(string field_name, const MATRIX *field_da //----------------------------------------------------------------------------- void OutputManager::write_text_data_header(OUTPUT_LIST *data, ofstream & text, int k) { - if (data) + if (data) { OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { string field_name = iter->first; int nrows = iter->second->nRows(); @@ -584,7 +584,7 @@ void OutputManager::write_text_data_header(OUTPUT_LIST *data, ofstream & text, i else { for (int i = 1; i <= ncols; i++) { string name = field_name; - string str; stringstream out; + string str; stringstream out; if (! custom_name(field_name,i-1,name)) { out <<"_"<begin(); @@ -624,19 +624,19 @@ void OutputManager::write_data_text(OUTPUT_LIST *data) const MATRIX* field_data = iter->second; nrows = field_data->nRows(); - for (int i = 0; i < nrows; ++i) + for (int i = 0; i < nrows; ++i) { text.width(6); text << i << " "; // give an ordinate for gnuplot - text.width(10); text << outputTimes_.size() << " "; + text.width(10); text << outputTimes_.size() << " "; OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { const MATRIX* field_data = iter->second; int ncols = field_data->nCols(); if (ncols > kFileNameSize) { ncols = kFileNameSize;} - for (int j = 0; j < ncols; ++j) + for (int j = 0; j < ncols; ++j) { - text.width(kFieldWidth); + text.width(kFieldWidth); text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << (*field_data)(i,j) << " "; } } @@ -656,26 +656,26 @@ void OutputManager::write_data_text(OUTPUT_LIST *data, const int *node_map) else text.open(data_file_text.c_str(),ios_base::app); // write data label header - if (firstStep_) + if (firstStep_) { - text.width(6); text << "# index:1" << " "; - text.width(6); text << " id:2" << " "; - text.width(10); text << " step:3" << " "; - text.width(4); text << " x:4" << " "; - text.width(4); text << " y:5" << " "; - text.width(4); text << " z:6" << " "; + text.width(6); text << "# index:1" << " "; + text.width(6); text << " id:2" << " "; + text.width(10); text << " step:3" << " "; + text.width(4); text << " x:4" << " "; + text.width(4); text << " y:5" << " "; + text.width(4); text << " z:6" << " "; write_text_data_header(data,text,7); - if (connectivities_) - { + if (connectivities_) + { int number_of_elements = connectivities_->nCols(); int number_of_nodes_per_element = connectivities_->nRows(); - text << "# connectivities number_of_elements: " << number_of_elements - << " nodes_per_element: " << number_of_nodes_per_element << "\n"; - for (int j = 0; j < number_of_elements; ++j) + text << "# connectivities number_of_elements: " << number_of_elements + << " nodes_per_element: " << number_of_nodes_per_element << "\n"; + for (int j = 0; j < number_of_elements; ++j) { text << "#"; - for (int i = 0; i < number_of_nodes_per_element; ++i) + for (int i = 0; i < number_of_nodes_per_element; ++i) { int inode = (*connectivities_)(i,j) +1; // 1 based numbering text << setw(6) << inode; @@ -686,34 +686,34 @@ void OutputManager::write_data_text(OUTPUT_LIST *data, const int *node_map) } text << "# timestep " << outputTimes_.size() << " : " << outputTimes_[outputTimes_.size()-1] << "\n"; - + OUTPUT_LIST::iterator iter; iter = data->begin(); if (iter == data->end()) { throw ATC_Error(" no data in output");} int nnodes = coordinates_->nCols(); - for (int i = 0; i < nnodes; ++i) + for (int i = 0; i < nnodes; ++i) { int unode = i; if (node_map) unode = node_map[i]; - text.width(6); text << i << " "; - text.width(6); text << unode << " "; - text.width(10); text << outputTimes_.size() << " "; + text.width(6); text << i << " "; + text.width(6); text << unode << " "; + text.width(10); text << outputTimes_.size() << " "; // coordinates for (int j = 0; j < coordinates_->nRows(); ++j) { - text.width(kFieldWidth); + text.width(kFieldWidth); text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << (*coordinates_)(j,i) << " "; } // data OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { const MATRIX* field_data = iter->second; int ncols = field_data->nCols(); if (ncols > kFileNameSize) { ncols = kFileNameSize; } - for (int j = 0; j < ncols; ++j) + for (int j = 0; j < ncols; ++j) { - text.width(kFieldWidth); + text.width(kFieldWidth); text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << (*field_data)(unode,j) << " "; } } @@ -740,7 +740,7 @@ void OutputManager::write_data_vtk(OUTPUT_LIST *data) text << "POINTS " << nnodes << " float\n"; for (int i = 0; i < nnodes; ++i) { for (int j = 0; j < coordinates_->nRows(); ++j) { - text.width(kFieldWidth); + text.width(kFieldWidth); text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << (*coordinates_)(j,i) << " "; } text << "\n"; @@ -758,7 +758,7 @@ void OutputManager::write_data_vtk(OUTPUT_LIST *data) text << "\n"; } text << "\n"; - int cell_type = 4 ; + int cell_type = 4 ; text << "CELL_TYPES " << nelems << "\n"; for (int j = 0; j < nelems; ++j) { text << cell_type << "\n"; @@ -768,12 +768,12 @@ void OutputManager::write_data_vtk(OUTPUT_LIST *data) text << "POINT_DATA " << nnodes << "\n"; text << "\n"; OUTPUT_LIST::iterator iter; - for (iter = data->begin(); iter != data->end(); iter++) + for (iter = data->begin(); iter != data->end(); iter++) { string field_name = iter->first; const MATRIX* field_data = iter->second; int ncols = field_data->nCols(); - if (ncols == 1) { + if (ncols == 1) { text << "SCALARS " << field_name << " float\n"; text << "LOOKUP_TABLE default\n"; } @@ -782,7 +782,7 @@ void OutputManager::write_data_vtk(OUTPUT_LIST *data) } for (int i = 0; i < nnodes; ++i) { for (int j = 0; j < ncols; ++j) { - text.width(kFieldWidth); + text.width(kFieldWidth); text << setw(kFieldWidth) << std::scientific << std::setprecision(kFieldPrecison) << (*field_data)(i,j) << " "; } text <<"\n"; @@ -797,10 +797,10 @@ void OutputManager::write_dictionary(double /* time */, OUTPUT_LIST *data) // file names string dict_file_name = outputPrefix_ + ".case"; string geom_file_name = outputPrefix_ + ".geo"; - + // open file FILE * fp=nullptr; - if ((fp=fopen(dict_file_name.c_str(),"w")) == nullptr) + if ((fp=fopen(dict_file_name.c_str(),"w")) == nullptr) { throw ATC_Error("can not create Ensight case file"); } @@ -831,7 +831,7 @@ void OutputManager::write_dictionary(double /* time */, OUTPUT_LIST *data) string* component_names = get_component_names(type); int ndof = fieldCols; if (ndof > kFileNameSize) ndof = kFileNameSize; - for (int j = 0; j < ndof; ++j) + for (int j = 0; j < ndof; ++j) { string comp_name; if (! custom_name(field_name,j,comp_name)) @@ -844,15 +844,15 @@ void OutputManager::write_dictionary(double /* time */, OUTPUT_LIST *data) else if (type == VECTOR_OUTPUT) { fprintf(fp,"vector per node: 1 1 %s %s\n", field_name.c_str(),field_file.c_str()); - } + } else if (type == SYM_TENSOR_OUTPUT) { fprintf(fp,"tensor symm per node: 1 1 %s %s\n", field_name.c_str(),field_file.c_str()); - } + } else if (type == TENSOR_OUTPUT) { fprintf(fp,"tensor asymm per node: 1 1 %s %s\n", field_name.c_str(),field_file.c_str()); - } + } else { fprintf(fp,"scalar per node: 1 1 %s %s\n", field_name.c_str(),field_file.c_str()); diff --git a/lib/atc/OutputManager.h b/lib/atc/OutputManager.h index 4454d65265..9f16f7ecd3 100644 --- a/lib/atc/OutputManager.h +++ b/lib/atc/OutputManager.h @@ -18,13 +18,13 @@ namespace ATC { enum OutputType { ENSIGHT=0, GNUPLOT, FULL_GNUPLOT, VTK }; enum OutputDataType { POINT=0, MESH }; - enum OutputDataCardinality { SCALAR_OUTPUT=0, VECTOR_OUTPUT, TENSOR_OUTPUT, + enum OutputDataCardinality { SCALAR_OUTPUT=0, VECTOR_OUTPUT, TENSOR_OUTPUT, SYM_TENSOR_OUTPUT, LIST_OUTPUT }; enum OutputOption { OUTPUT_VECTOR_COMPONENTS=0, OUTPUT_TENSOR_COMPONENTS}; /** - * @class OutputManager - * @brief Base class for handling output desired from an AtC computation + * @class OutputManager + * @brief Base class for handling output desired from an AtC computation */ class OutputManager{ @@ -38,7 +38,7 @@ namespace ATC { void initialize(std::string outputPrefix, std::set &otypes); /** set output options */ - void set_option(OutputOption option, bool value); + void set_option(OutputOption option, bool value); // Dump text-based field info to disk for later restart void write_restart_file(std::string fileName, RESTART_LIST *data); @@ -47,9 +47,9 @@ namespace ATC { void read_restart_file(std::string fileName, RESTART_LIST *data); /** write initial/reference geometry - default is to write point data, - if connectivities are given then mesh data will be output - coordinates : num _total_ points/nodes X num spatial dim + default is to write point data, + if connectivities are given then mesh data will be output + coordinates : num _total_ points/nodes X num spatial dim connectivities : num elements X num nodes per element*/ void write_geometry(const MATRIX *coordinates, const Array2D *connectivity=nullptr); @@ -57,7 +57,7 @@ namespace ATC { /** write data from a time step specify node_map to handle periodic soln & data */ void write_data(double time, OUTPUT_LIST *data, const int *node_map=nullptr); - void write_data(double time, FIELDS *soln, OUTPUT_LIST *data, + void write_data(double time, FIELDS *soln, OUTPUT_LIST *data, const int *node_map=nullptr); /** add custom names for any field */ @@ -85,11 +85,11 @@ namespace ATC { else return LIST_OUTPUT; } bool use_component_names(int type) const { - if ( (type==LIST_OUTPUT) || + if ( (type==LIST_OUTPUT) || ((type==SYM_TENSOR_OUTPUT || type==TENSOR_OUTPUT) && tensorToComponents_) - || (type==VECTOR_OUTPUT && vectorToComponents_) ) + || (type==VECTOR_OUTPUT && vectorToComponents_) ) return true; - else + else return false; } bool custom_name(const std::string field, const int index, std::string & name) const { @@ -99,7 +99,7 @@ namespace ATC { name = names[index]; return true; } - void print_custom_names(); + void print_custom_names(); private: @@ -124,8 +124,8 @@ namespace ATC { const Array2D * connectivities_; /** number of columns of data */ int nDataCols_; - /** number of nodes */ - int number_of_nodes_; + /** number of nodes */ + int number_of_nodes_; /** data type */ int dataType_; /** base name for output files */ diff --git a/lib/atc/ParDenseMatrix.h b/lib/atc/ParDenseMatrix.h index 873bf0f410..d5d3d8ac95 100644 --- a/lib/atc/ParDenseMatrix.h +++ b/lib/atc/ParDenseMatrix.h @@ -15,7 +15,7 @@ using ATC::ATC_Error; namespace ATC_matrix { /** - * @class ParDenseMatrix + * @class ParDenseMatrix * @brief Parallelized version of DenseMatrix class. */ diff --git a/lib/atc/ParDiagonalMatrix.cpp b/lib/atc/ParDiagonalMatrix.cpp index 5888bedc04..bbbc5ab29e 100644 --- a/lib/atc/ParDiagonalMatrix.cpp +++ b/lib/atc/ParDiagonalMatrix.cpp @@ -5,7 +5,7 @@ using MPI_Wrappers::allgatherv; namespace ATC_matrix { // template<> - // void ParDiagonalMatrix::MultAB(const Matrix &B, DenseMatrix &C) const + // void ParDiagonalMatrix::MultAB(const Matrix &B, DenseMatrix &C) const // { // //SparseMatrix::compress(*this); // GCK(*this, B, this->nCols()!=B.nRows(), "ParDiagonalMatrix * Matrix"); @@ -19,7 +19,7 @@ namespace ATC_matrix { // INDEX startIndex = (myRank * nRows) / nProcs; // INDEX endIndex = ((myRank + 1) * nRows) / nProcs; - + // // Calculate the scaled rows associated with this processor // for (INDEX i = startIndex; i < endIndex; i++) { // double value = (*this)[i]; @@ -28,13 +28,13 @@ namespace ATC_matrix { // } // // Collect results on all processors - + // // consider sending only owned rows from each processor // allsum(_comm, MPI_IN_PLACE, C.ptr(), C.size()); // } template<> - void ParDiagonalMatrix::MultAB(const Matrix &B, DenseMatrix &C) const + void ParDiagonalMatrix::MultAB(const Matrix &B, DenseMatrix &C) const { //SparseMatrix::compress(*this); GCK(*this, B, this->nCols()!=B.nRows(), "ParDiagonalMatrix * Matrix"); @@ -52,7 +52,7 @@ namespace ATC_matrix { int nMajor = nRows; int nMinor = nCols; #endif - + int *majorCounts = new int[nProcs]; int *majorOffsets = new int[nProcs]; @@ -64,7 +64,7 @@ namespace ATC_matrix { INDEX myNMajor = majorCounts[myRank]; INDEX myMajorOffset = majorOffsets[myRank]; - + // Calculate the scaled values associated with this processor, in row chunks #ifdef COL_STORAGE // Column-major storage diff --git a/lib/atc/ParDiagonalMatrix.h b/lib/atc/ParDiagonalMatrix.h index 89f22b783f..dfafee6e2c 100644 --- a/lib/atc/ParDiagonalMatrix.h +++ b/lib/atc/ParDiagonalMatrix.h @@ -10,7 +10,7 @@ namespace ATC_matrix { /** - * @class ParDiagonalMatrix + * @class ParDiagonalMatrix * @brief Parallelized version of DiagonalMatrix class. */ diff --git a/lib/atc/ParSparseMatrix.cpp b/lib/atc/ParSparseMatrix.cpp index 77c8eb33d5..0365a35641 100644 --- a/lib/atc/ParSparseMatrix.cpp +++ b/lib/atc/ParSparseMatrix.cpp @@ -33,7 +33,7 @@ void ParSparseMatrix::MultMv(const Vector& v, #ifdef DISABLE_PAR_HEURISTICS // Use much more lenient heuristics to exercise parallel code if (numProcs == 1 || _size < 300) { -#else +#else // These are simple heuristics to perform multiplication in serial if // parallel will be slower. They were determined experimentally. if ( numProcs == 1 || @@ -45,7 +45,7 @@ void ParSparseMatrix::MultMv(const Vector& v, SparseMatrix::MultMv(v, c); return; } - + SparseMatrix::compress(*this); GCK(*this, v, this->nCols() != v.size(), "ParSparseMatrix * Vector") diff --git a/lib/atc/ParSparseMatrix.h b/lib/atc/ParSparseMatrix.h index b2642e87be..3b21a1c70f 100644 --- a/lib/atc/ParSparseMatrix.h +++ b/lib/atc/ParSparseMatrix.h @@ -10,13 +10,13 @@ namespace ATC_matrix { /** - * @class ParSparseMatrix + * @class ParSparseMatrix * @brief Parallelized version of SparseMatrix class. - * + * * ParSparseMatrix::MultMv is used in LinearSolver, which is then * used in NonLinearSolver, PoissonSolver, and SchrodingerSolver. These * parallelized solvers are used in the following locations: - * + * * - LinearSolver * - ExtrinsicModelDriftDiffusion.cpp (lines 511 and 522) * - AtomicRegulator.cpp (line 926) @@ -55,7 +55,7 @@ namespace ATC_matrix { template friend void ParMultAB(MPI_Comm comm, const SparseMatrix& A, const Matrix& B, DenseMatrix& C); - + private: MPI_Comm _comm; }; @@ -99,7 +99,7 @@ namespace ATC_matrix { void ParMultAB(MPI_Comm comm, const SparseMatrix& A, const Matrix& B, DenseMatrix& C) { SparseMatrix::compress(A); - + INDEX M = A.nRows(), N = B.nCols(); if (!C.is_size(M, N)) { diff --git a/lib/atc/PerAtomQuantity-inl.h b/lib/atc/PerAtomQuantity-inl.h index b570e7645b..b7c16e2348 100644 --- a/lib/atc/PerAtomQuantity-inl.h +++ b/lib/atc/PerAtomQuantity-inl.h @@ -49,17 +49,17 @@ namespace ATC { const DenseMatrix & myQuantity(this->quantity_); // necessary to access quantity_ this way because of templating if (myQuantity.nRows()>0) { // full matrix copy - + if (atomType_ == ALL || atomType_ == PROC_GHOST) { if (nCols_==1) { // scalar T * lammpsQuantity = this->lammps_scalar(); - + for (int i = 0; i < atc_.nlocal_total(); i++) lammpsQuantity[i] = myQuantity(i,0); } else{ // vector T ** lammpsQuantity = this->lammps_vector(); - + for (int i = 0; i < atc_.nlocal_total(); i++) for (int j = 0; j < nCols_; j++) lammpsQuantity[i][j] = myQuantity(i,j); @@ -119,7 +119,7 @@ namespace ATC { else { const Array & quantityToLammps = atc_.atc_to_lammps_map(); int atomIndex; - + if (nCols_==1) { // scalar const T * lammpsQuantity = this->lammps_scalar(); for (int i = 0; i < myQuantity.nRows(); i++) { @@ -141,7 +141,7 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for exchange with another proc + // pack values in local atom-based arrays for exchange with another proc //----------------------------------------------------------------- template int PerAtomQuantity::pack_exchange(int i, double *buffer) @@ -157,7 +157,7 @@ namespace ATC { } //----------------------------------------------------------------- - // unpack values in local atom-based arrays from exchange with another proc + // unpack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- template int PerAtomQuantity::unpack_exchange(int i, double *buffer) @@ -173,10 +173,10 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for passing to ghosts on another proc + // pack values in local atom-based arrays for passing to ghosts on another proc //----------------------------------------------------------------- template - int PerAtomQuantity::pack_comm(int index, double *buf, + int PerAtomQuantity::pack_comm(int index, double *buf, int /* pbc_flag */, int * /* pbc */) { if (this->need_reset()) this->reset(); @@ -202,12 +202,12 @@ namespace ATC { } //----------------------------------------------------------------- - // allocate local atom-based arrays + // allocate local atom-based arrays //----------------------------------------------------------------- template void PerAtomQuantity::grow_lammps_array(int nmax, const std::string & tag) { - + if (nCols_ == 1) this->lammpsScalar_ = lammpsInterface_->grow_array(this->lammpsScalar_,nmax,tag.c_str()); else @@ -215,7 +215,7 @@ namespace ATC { } //----------------------------------------------------------------- - // copy values within local atom-based arrays + // copy values within local atom-based arrays //----------------------------------------------------------------- template void PerAtomQuantity::copy_lammps_array(int i, int j) @@ -252,10 +252,10 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for passing to ghosts on another proc + // pack values in local atom-based arrays for passing to ghosts on another proc //----------------------------------------------------------------- template - int LammpsAtomQuantity::pack_comm(int index, double *buf, + int LammpsAtomQuantity::pack_comm(int index, double *buf, int /* pbc_flag */, int * /* pbc */) { if (this->need_reset()) this->reset(); @@ -294,7 +294,7 @@ namespace ATC { lammpsQuantity[index][k] = myQuantity(index,k); } } - + this->propagate_reset(); return bufIdx; } @@ -317,11 +317,11 @@ namespace ATC { const INT_ARRAY & atomMap(atomMap_->quantity()); if (myQuantity.nRows()>0) { // full matrix copy - + if (PerAtomQuantity::atomType_ == ALL || PerAtomQuantity::atomType_ == PROC_GHOST) { if (nCols==1) { // scalar T * lammpsQuantity = ProtectedAtomQuantity::lammps_scalar(); - + for (int i = 0; i < PerAtomQuantity::atc_.nlocal_total(); i++) { int idx = atomMap(i,0); if (idx > -1) { @@ -331,7 +331,7 @@ namespace ATC { } else{ // vector T ** lammpsQuantity = ProtectedAtomQuantity::lammps_vector(); - + for (int i = 0; i < PerAtomQuantity::atc_.nlocal_total(); i++) { int idx = atomMap(i,0); if (idx > -1) { @@ -475,10 +475,10 @@ namespace ATC { const DiagonalMatrix & myQuantity(this->quantity_); // necessary to access quantity_ this way because of templating if (myQuantity.size()>0) { // full matrix copy - + if (atomType_ == ALL || atomType_ == PROC_GHOST) { T * lammpsQuantity = this->lammps_scalar(); - + for (int i = 0; i < atc_.nlocal_total(); i++) { lammpsQuantity[i] = myQuantity(i,i); } @@ -526,7 +526,7 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for exchange with another proc + // pack values in local atom-based arrays for exchange with another proc //----------------------------------------------------------------- template int PerAtomDiagonalMatrix::pack_exchange(int i, double *buffer) @@ -536,7 +536,7 @@ namespace ATC { } //----------------------------------------------------------------- - // unpack values in local atom-based arrays from exchange with another proc + // unpack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- template int PerAtomDiagonalMatrix::unpack_exchange(int i, double *buffer) @@ -546,10 +546,10 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for passing to ghosts on another proc + // pack values in local atom-based arrays for passing to ghosts on another proc //----------------------------------------------------------------- template - int PerAtomDiagonalMatrix::pack_comm(int index, double *buf, + int PerAtomDiagonalMatrix::pack_comm(int index, double *buf, int /* pbc_flag */, int * /* pbc */) { if (this->need_reset()) this->reset(); @@ -571,7 +571,7 @@ namespace ATC { } //----------------------------------------------------------------- - // allocate local atom-based arrays + // allocate local atom-based arrays //----------------------------------------------------------------- template void PerAtomDiagonalMatrix::grow_lammps_array(int nmax, const std::string & tag) @@ -580,7 +580,7 @@ namespace ATC { } //----------------------------------------------------------------- - // copy values within local atom-based arrays + // copy values within local atom-based arrays //----------------------------------------------------------------- template void PerAtomDiagonalMatrix::copy_lammps_array(int i, int j) @@ -636,10 +636,10 @@ namespace ATC { if (myQuantity.nRows()>0) { // full matrix copy if (atomType_ == ALL || atomType_ == PROC_GHOST) { - + T ** lammpsQuantity = this->lammps_vector(); int ** lammpsColIndices = this->lammps_column_indices(); - + for (int i = 0; i < atc_.nlocal_total(); i++) { myQuantity.row(i,_values_,_colIndices_); for (int j = 0; j < _values_.size(); j++) { @@ -717,7 +717,7 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for exchange with another proc + // pack values in local atom-based arrays for exchange with another proc //----------------------------------------------------------------- template int PerAtomSparseMatrix::pack_exchange(int i, double *buffer) @@ -735,7 +735,7 @@ namespace ATC { } //----------------------------------------------------------------- - // unpack values in local atom-based arrays from exchange with another proc + // unpack values in local atom-based arrays from exchange with another proc //----------------------------------------------------------------- template int PerAtomSparseMatrix::unpack_exchange(int i, double *buffer) @@ -753,10 +753,10 @@ namespace ATC { } //----------------------------------------------------------------- - // pack values in local atom-based arrays for passing to ghosts on another proc + // pack values in local atom-based arrays for passing to ghosts on another proc //----------------------------------------------------------------- template - int PerAtomSparseMatrix::pack_comm(int /* index */, double * /* buf */, + int PerAtomSparseMatrix::pack_comm(int /* index */, double * /* buf */, int /* pbc_flag */, int */* pbc */) { return 0; @@ -772,19 +772,19 @@ namespace ATC { } //----------------------------------------------------------------- - // allocate local atom-based arrays + // allocate local atom-based arrays //----------------------------------------------------------------- template void PerAtomSparseMatrix::grow_lammps_array(int nmax, const std::string & tag) { - + this->lammpsVector_ = lammpsInterface_->grow_array(this->lammpsVector_,nmax,maxEntriesPerRow_,tag.c_str()); std::string myString(tag+std::string("Columns")); this->lammpsColIndices_ = lammpsInterface_->grow_array(this->lammpsColIndices_,nmax,maxEntriesPerRow_,myString.c_str()); } //----------------------------------------------------------------- - // copy values within local atom-based arrays + // copy values within local atom-based arrays //----------------------------------------------------------------- template void PerAtomSparseMatrix::copy_lammps_array(int i, int j) diff --git a/lib/atc/PerAtomQuantity.h b/lib/atc/PerAtomQuantity.h index a822b6a9b6..3b72431560 100644 --- a/lib/atc/PerAtomQuantity.h +++ b/lib/atc/PerAtomQuantity.h @@ -18,17 +18,17 @@ namespace ATC { template class ClonedAtomQuantity; /** - * @class PerAtomQuantity + * @class PerAtomQuantity * @brief Base class for objects that manage atomic quantities and their AtC interface */ template class PerAtomQuantity : public MatrixDependencyManager { public: - + // constructor PerAtomQuantity(ATC_Method * atc, int nCols = 1, AtomType atomType = INTERNAL); - + // destructor virtual ~PerAtomQuantity(); @@ -75,7 +75,7 @@ namespace ATC { /** resets AtC local quantity after exchange */ virtual void post_exchange() {(this->quantity_).resize(atc_.nlocal(),nCols_); this->set_quantity_to_lammps();}; - + /** returns how much lammps memory is used in this function */ virtual int memory_usage() const {return nCols_;}; @@ -112,7 +112,7 @@ namespace ATC { virtual void reset_nlocal() { this->force_reset();} protected: - + /** utility object to access ATC methods */ PaqAtcUtility atc_; @@ -137,7 +137,7 @@ namespace ATC { /** sets the quantity based on a lammps pointer */ virtual void set_quantity_to_lammps() const; - + /** gets appropriate data for lammps pointer */ virtual T * lammps_scalar() const = 0; @@ -151,17 +151,17 @@ namespace ATC { T ** lammpsVector_; private: - + // do not define PerAtomQuantity(); - + }; //-------------------------------------------------------- //-------------------------------------------------------- // Class LammpsAtomQuantity // A base class for defining objects that manage - // quantities but the lammps data forms the + // quantities but the lammps data forms the // absolute definition for the contained data. //-------------------------------------------------------- //-------------------------------------------------------- @@ -235,7 +235,7 @@ namespace ATC { virtual void reset() const; - + /** gets appropriate data for lammps pointer */ virtual T * lammps_scalar() const = 0; @@ -280,7 +280,7 @@ namespace ATC { virtual int unpack_exchange(int /* i */, double * /* buffer */) {return 0;}; /** packs up data for parallel transfer to ghost atoms on other processors */ - virtual int pack_comm(int /* index */, double * /* buf */, + virtual int pack_comm(int /* index */, double * /* buf */, int /* pbc_flag */, int * /* pbc */) {return 0;}; /** unpacks data after parallel transfer to ghost atoms on other processors */ @@ -309,11 +309,11 @@ namespace ATC { //-------------------------------------------------------- // Class ClonedLammpsAtomQuantity // A base class for defining objects that manage - // quantities defined at atoms based on data in + // quantities defined at atoms based on data in // a LammpsAtomQuantity //-------------------------------------------------------- //-------------------------------------------------------- - + template class ClonedAtomQuantity : public ShallowAtomQuantity { @@ -372,11 +372,11 @@ namespace ATC { //-------------------------------------------------------- // Class ProtectedClonedAtomQuantity // A base class for defining objects that manage - // quantities defined at atoms based on data in + // quantities defined at atoms based on data in // a pointer managed in the standard lammps way. //-------------------------------------------------------- //-------------------------------------------------------- - + template class ProtectedClonedAtomQuantity : public ShallowAtomQuantity { @@ -456,8 +456,8 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- // Class AtcAtomQuantity - // A funcational base class for defining objects that - // manage quantities defined at atoms and their AtC + // A funcational base class for defining objects that + // manage quantities defined at atoms and their AtC // interface that are defined by AtC classes //-------------------------------------------------------- //-------------------------------------------------------- @@ -843,7 +843,7 @@ namespace ATC { quantity1_->register_dependence(this); quantity2_->register_dependence(this); }; - + // destructor virtual ~SummedAtomicQuantity() { @@ -880,17 +880,17 @@ namespace ATC { }; /** - * @class PerAtomDiagonalMatrix + * @class PerAtomDiagonalMatrix * @brief Base class for objects that manage atomic diagonal matrices and their AtC interface */ template class PerAtomDiagonalMatrix : public MatrixDependencyManager { public: - + // constructor PerAtomDiagonalMatrix(ATC_Method * atc, AtomType atomType = INTERNAL); - + // destructor virtual ~PerAtomDiagonalMatrix(); @@ -934,7 +934,7 @@ namespace ATC { /** resets AtC local quantity after exchange */ virtual void post_exchange() {(this->quantity_).resize(atc_.nlocal()); this->set_quantity_to_lammps();}; - + /** returns how much lammps memory is used in this function */ virtual int memory_usage() const {return 1;}; @@ -971,7 +971,7 @@ namespace ATC { virtual void reset_nlocal() { this->force_reset();} protected: - + /** utility object to access ATC methods */ PaqAtcUtility atc_; @@ -993,7 +993,7 @@ namespace ATC { /** sets the quantity based on a lammps pointer */ virtual void set_quantity_to_lammps() const; - + /** gets appropriate data for lammps pointer */ virtual T * lammps_scalar() const = 0; @@ -1001,17 +1001,17 @@ namespace ATC { T * lammpsScalar_; private: - + // do not define PerAtomDiagonalMatrix(); - + }; //-------------------------------------------------------- //-------------------------------------------------------- // Class AtcAtomDiagonalMatrix - // A funcational base class for defining objects that - // manage diagonal matrices defined at atoms and their + // A funcational base class for defining objects that + // manage diagonal matrices defined at atoms and their // AtC interface that are defined by AtC classes //-------------------------------------------------------- //-------------------------------------------------------- @@ -1044,7 +1044,7 @@ namespace ATC { //-------------------------------------------------------- // Class ProtectedAtomDiagonalMatrix // A base class for defining objects that manage - // diagonal matrixes defined at atoms internally and + // diagonal matrixes defined at atoms internally and // do not allow for reset externally //-------------------------------------------------------- //-------------------------------------------------------- @@ -1128,10 +1128,10 @@ namespace ATC { class PerAtomSparseMatrix : public MatrixDependencyManager { public: - + // constructor PerAtomSparseMatrix(ATC_Method * atc, int nCols = 1, int maxEntriesPerRow = 1, AtomType atomType = INTERNAL); - + // destructor virtual ~PerAtomSparseMatrix(); @@ -1178,7 +1178,7 @@ namespace ATC { /** resets AtC local quantity after exchange */ virtual void post_exchange() {(this->quantity_).reset(atc_.nlocal(),nCols_); this->set_quantity_to_lammps();}; - + /** returns how much lammps memory is used in this function */ virtual int memory_usage() const {return 2*maxEntriesPerRow_;}; @@ -1215,7 +1215,7 @@ namespace ATC { virtual void reset_nlocal() { this->set_reset();}; protected: - + /** utility object to access ATC methods */ PaqAtcUtility atc_; @@ -1243,7 +1243,7 @@ namespace ATC { /** sets the quantity based on a lammps pointer */ virtual void set_quantity_to_lammps() const; - + /** gets appropriate data for lammps pointer */ virtual T ** lammps_vector() const = 0; @@ -1261,17 +1261,17 @@ namespace ATC { mutable DenseVector _colIndices_; private: - + // do not define PerAtomSparseMatrix(); - + }; //-------------------------------------------------------- //-------------------------------------------------------- // Class AtcAtomSparseMatrix - // A funcational base class for defining objects that - // manage sparse matrices defined at atoms and their + // A funcational base class for defining objects that + // manage sparse matrices defined at atoms and their // AtC interface that are defined by AtC classes //-------------------------------------------------------- //-------------------------------------------------------- @@ -1283,7 +1283,7 @@ namespace ATC { // constructor AtcAtomSparseMatrix(ATC_Method * atc, int nCols = 1, int maxEntriesPerRow = 1, - AtomType atomType = INTERNAL) : + AtomType atomType = INTERNAL) : PerAtomSparseMatrix(atc,nCols,maxEntriesPerRow,atomType) {}; // destructor @@ -1308,7 +1308,7 @@ namespace ATC { //-------------------------------------------------------- // Class ProtectedAtomSparseMatrix // A base class for defining objects that manage - // sparse matrixes defined at atoms internally and + // sparse matrixes defined at atoms internally and // do not allow for reset externally //-------------------------------------------------------- //-------------------------------------------------------- @@ -1389,7 +1389,7 @@ namespace ATC { //-------------------------------------------------------- // Class ProtectedMappedSparseMatrix // A base class for defining objects that manage - // sparse matrices defined at atoms internally and do + // sparse matrices defined at atoms internally and do // not allow for reset externally, but are mapped in // at least one of their dimensions //-------------------------------------------------------- @@ -1415,7 +1415,7 @@ namespace ATC { /** resets AtC local quantity after exchange */ virtual void post_exchange() {this->set_reset();}; - + /** returns how much lammps memory is used in this function */ virtual int memory_usage() const {return 0;}; diff --git a/lib/atc/PerAtomQuantityLibrary.cpp b/lib/atc/PerAtomQuantityLibrary.cpp index 7f8a9b879a..917e6b51ea 100644 --- a/lib/atc/PerAtomQuantityLibrary.cpp +++ b/lib/atc/PerAtomQuantityLibrary.cpp @@ -82,13 +82,13 @@ namespace ATC { AtomInElementSet::AtomInElementSet(ATC_Method * atc, PerAtomQuantity * map, ESET eset, int type): - atc_(atc,INTERNAL), + atc_(atc,INTERNAL), map_(map),eset_(eset),type_(type), quantityToLammps_(atc_.atc_to_lammps_map()) { map_->register_dependence(this); needReset_ = true; - + } //-------------------------------------------------------- // destructor @@ -100,12 +100,12 @@ namespace ATC { //-------------------------------------------------------- // reset //-------------------------------------------------------- - void AtomInElementSet::reset() + void AtomInElementSet::reset() { if (map_->need_reset() || needReset_) { list_.clear(); INT_ARRAY map = map_->quantity(); - int * type = ATC::LammpsInterface::instance()->atom_type(); + int * type = ATC::LammpsInterface::instance()->atom_type(); ESET::const_iterator itr; const Array & quantityToLammps = atc_.atc_to_lammps_map(); for (int i = 0; i < map.size(); i++) { @@ -113,7 +113,7 @@ namespace ATC { if (map(i,0) == *itr) { int a = quantityToLammps(i); if (type[a] == type_) { - list_.push_back(ID_PAIR(i,a)); + list_.push_back(ID_PAIR(i,a)); break; } } @@ -150,7 +150,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // reset //-------------------------------------------------------- @@ -196,18 +196,18 @@ namespace ATC { int ngroup = lammpsInterface_->ngroup(); const int *mask = lammpsInterface_->atom_mask(); double * bounds; - + bounds = new double[6]; for (int i = 0; i < ngroup; ++i) { lammpsInterface_->group_bounds(i, bounds); - atomGroupVolume_[lammpsInterface_->group_bit(i)] = + atomGroupVolume_[lammpsInterface_->group_bit(i)] = (bounds[1]-bounds[0])*(bounds[3]-bounds[2])*(bounds[5]-bounds[4]); } delete [] bounds; - + INT_VECTOR localCount(ngroup); INT_VECTOR globalCount(ngroup); - + // loop over atoms localCount = 0; for (int i = 0; i < atcToLammps_.size(); ++i) { @@ -216,13 +216,13 @@ namespace ATC { localCount(j)++; } } - + // communication to get total atom counts per group lammpsInterface_->int_allsum(localCount.ptr(), globalCount.ptr(),ngroup); - + for (int i = 0; i < ngroup; ++i) { - int iGroupBit = lammpsInterface_->group_bit(i); + int iGroupBit = lammpsInterface_->group_bit(i); if (globalCount(i) > 0) atomGroupVolume_[iGroupBit] /= globalCount(i); else @@ -257,13 +257,13 @@ namespace ATC { quantity_ = lammpsInterface_->volume_per_atom(); } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class AtomVolumeElement //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -303,19 +303,19 @@ namespace ATC { _elementAtomCount_.resize(nElts); const INT_ARRAY & atomElement(atomElement_->quantity()); _elementAtomVolume_.resize(nElts); - + // determine number of atoms in each element, partial sum for (int i = 0; i < nLocal; ++i) { _elementAtomCountLocal_(atomElement(i,0)) += 1; } - + // mpi to determine total atoms lammpsInterface_->int_allsum(_elementAtomCountLocal_.ptr(),_elementAtomCount_.ptr(),nElts); - + // divide element volume by total atoms to get atomic volume if (nLocal>0) { for (int i = 0; i < nElts; ++i) { - + double minx, maxx, miny, maxy, minz, maxz; feMesh_->element_coordinates(i,_nodalCoordinates_); minx = _nodalCoordinates_(0,0); maxx = _nodalCoordinates_(0,0); @@ -333,7 +333,7 @@ namespace ATC { if (eltVol<0) eltVol *= -1.; _elementAtomVolume_(i) = eltVol/_elementAtomCount_(i); } - + for (int i = 0; i < nLocal; ++i) quantity_(i,i) = _elementAtomVolume_(atomElement(i,0)); } @@ -364,16 +364,16 @@ namespace ATC { // compute volumes and atom counts in each region int nregion = lammpsInterface_->nregion(); regionalAtomVolume_.resize(nregion); - + for (int i = 0; i < nregion; ++i) { - regionalAtomVolume_(i) = + regionalAtomVolume_(i) = (lammpsInterface_->region_xhi(i)-lammpsInterface_->region_xlo(i)) *(lammpsInterface_->region_yhi(i)-lammpsInterface_->region_ylo(i)) *(lammpsInterface_->region_zhi(i)-lammpsInterface_->region_zlo(i)); } - + INT_VECTOR localCount(nregion); - INT_VECTOR globalCount(nregion); + INT_VECTOR globalCount(nregion); // loop over atoms localCount = 0; const DENS_MAT atomicCoordinates(atomCoarseGrainingPositions->quantity()); @@ -390,7 +390,7 @@ namespace ATC { // communication to get total atom counts per group lammpsInterface_->int_allsum(localCount.ptr(), globalCount.ptr(),nregion); - + for (int i = 0; i < nregion; ++i) { if (globalCount(i) > 0) regionalAtomVolume_(i) /= globalCount(i); @@ -414,7 +414,7 @@ namespace ATC { { if (need_reset()) { PerAtomDiagonalMatrix::reset(); - const DENS_MAT & atomicCoordinates(atomCoarseGrainingPositions_->quantity()); + const DENS_MAT & atomicCoordinates(atomCoarseGrainingPositions_->quantity()); for (int i = 0; i < quantity_.nRows(); i++) { for (int iregion = 0; iregion < lammpsInterface_->nregion(); iregion++) { if (lammpsInterface_->region_match(iregion, @@ -457,7 +457,7 @@ namespace ATC { ifstream in; const int lineSize = 256; char line[lineSize]; - const char* fname = &atomVolumeFile_[0]; + const char* fname = &atomVolumeFile_[0]; // create tag to local id map for this processor map tag2id; @@ -477,13 +477,13 @@ namespace ATC { if (! in.good()) throw ATC_Error(msg); in.getline(line,lineSize); // header in.getline(line,lineSize); // blank line - in.getline(line,lineSize); // number of atoms + in.getline(line,lineSize); // number of atoms stringstream inss (line,stringstream::in | stringstream::out); inss >> natoms; // number of atoms - stringstream ss; + stringstream ss; ss << " found " << natoms << " atoms in atomic weights file"; lammpsInterface_->print_msg(ss.str()); - if (natoms != lammpsInterface_->natoms()) { + if (natoms != lammpsInterface_->natoms()) { throw ATC_Error("Incorrect number of atomic weights read-in!"); } in.getline(line,lineSize); // blank line @@ -496,7 +496,7 @@ namespace ATC { if (ATC::LammpsInterface::instance()->rank_zero()) { in.getline(line,lineSize); stringstream ss (line,stringstream::in | stringstream::out); - ss >> tag >> atomic_weight; + ss >> tag >> atomic_weight; nread++; } lammpsInterface_->int_broadcast(&nread); @@ -511,11 +511,11 @@ namespace ATC { } if (lammpsInterface_->rank_zero()) { in.close(); - stringstream ss; + stringstream ss; ss << " read " << nread << " atomic weights"; lammpsInterface_->print_msg(ss.str()); } - if (count != nlocal) + if (count != nlocal) throw ATC_Error("reset "+to_string(count)+" atoms vs "+to_string(nlocal)); } } @@ -532,7 +532,7 @@ namespace ATC { //-------------------------------------------------------- AtomNumber::AtomNumber(ATC_Method * atc, AtomType atomType) : ProtectedAtomQuantity(atc,1,atomType), - atc_(atc) + atc_(atc) { } @@ -552,32 +552,32 @@ namespace ATC { //-------------------------------------------------------- // constructor //-------------------------------------------------------- - AtomTypeVector::AtomTypeVector(ATC_Method * atc, + AtomTypeVector::AtomTypeVector(ATC_Method * atc, vector typeList, AtomType atomType) : ProtectedAtomQuantity(atc, typeList.size(), atomType), atc_(atc), ntypes_(ATC::LammpsInterface::instance()->ntypes()), - typeList_(typeList) + typeList_(typeList) { if (typeList_.size() == 0) throw ATC_Error("type list is empty"); - index_.resize(ntypes_,-1); + index_.resize(ntypes_,-1); for (unsigned int i = 0; i < typeList_.size(); i++) { index_[typeList_[i]] = i; } } - AtomTypeVector::AtomTypeVector(ATC_Method * atc, + AtomTypeVector::AtomTypeVector(ATC_Method * atc, vector typeList, vector groupList, AtomType atomType) : ProtectedAtomQuantity(atc, typeList.size()+groupList.size(), atomType), atc_(atc), ntypes_(ATC::LammpsInterface::instance()->ntypes()), typeList_(typeList), - groupList_(groupList) + groupList_(groupList) { if ((typeList_.size() == 0) && (groupList_.size() == 0)) throw ATC_Error("type/group lists are empty"); // reverse map - index_.resize(ntypes_,-1); + index_.resize(ntypes_,-1); for (unsigned int i = 0; i < typeList_.size(); i++) { index_[typeList_[i]-1] = i; } @@ -590,16 +590,16 @@ namespace ATC { int nlocal = atc_->nlocal(); quantity_.reset(nlocal,typeList_.size()+groupList_.size()); const Array & quantityToLammps = (PerAtomQuantity::atc_).atc_to_lammps_map(); - if (typeList_.size()) { - int * type = ATC::LammpsInterface::instance()->atom_type(); + if (typeList_.size()) { + int * type = ATC::LammpsInterface::instance()->atom_type(); for (int i = 0; i < nlocal; i++) { - int a = quantityToLammps(i); + int a = quantityToLammps(i); int index = index_[type[a]-1]; if (index > -1) quantity_(i,index) = 1; } } int index = typeList_.size(); - if (groupList_.size()) { + if (groupList_.size()) { const int * mask = ATC::LammpsInterface::instance()->atom_mask(); for (unsigned int j = 0; j < groupList_.size(); j++) { int group = groupList_[j]; @@ -618,7 +618,7 @@ namespace ATC { // Class XrefWrapper //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // constructor //-------------------------------------------------------- @@ -686,7 +686,7 @@ namespace ATC { //-------------------------------------------------------- void AtomicMassWeightedDisplacement::reset() const { - if (need_reset()) { + if (need_reset()) { PerAtomQuantity::reset(); const DENS_MAT & position(atomPositions_->quantity()); const DENS_MAT & mass(atomMasses_->quantity()); @@ -749,7 +749,7 @@ namespace ATC { // q = m * v quantity_ = velocity; - quantity_ *= mass; + quantity_ *= mass; } } @@ -800,7 +800,7 @@ namespace ATC { PerAtomQuantity::reset(); const DENS_MAT & mass(atomMasses_->quantity()); const DENS_MAT & velocity(atomVelocities_->quantity()); - + // q = m * (v dot v) for (int i = 0; i < quantity_.nRows(); i++) { quantity_(i,0) = velocity(i,0)*velocity(i,0); @@ -860,7 +860,7 @@ namespace ATC { PerAtomQuantity::reset(); const DENS_MAT & velocity(atomVelocities_->quantity()); const DENS_MAT & meanVelocity(atomMeanVelocities_->quantity()); - + // q = m * (v dot v) for (int i = 0; i < quantity_.nRows(); i++) { for (int j = 0; j < velocity.nCols(); j++) { @@ -969,7 +969,7 @@ namespace ATC { PerAtomQuantity::reset(); const DENS_MAT & velocity(fluctuatingVelocities_->quantity()); const DENS_MAT & tv(atomTypeVector_->quantity()); - + for (int i = 0; i < quantity_.nRows(); i++) { int m = 0; for (int j = 0; j < velocity.nCols(); j++) { @@ -1038,7 +1038,7 @@ namespace ATC { const DENS_MAT & mass(atomMasses_->quantity()); const DENS_MAT & velocity(atomVelocities_->quantity()); const DENS_MAT & meanVelocity(atomMeanVelocities_->quantity()); - + // q = m * (v dot v) double vRel; for (int i = 0; i < quantity_.nRows(); i++) { @@ -1102,7 +1102,7 @@ namespace ATC { PerAtomQuantity::reset(); const DENS_MAT & mass(atomMasses_->quantity()); const DENS_MAT & velocity(atomVelocities_->quantity()); - + // K = m * (v \otimes v) for (int i = 0; i < quantity_.nRows(); i++) { double m = mass(i,0); @@ -1173,7 +1173,7 @@ namespace ATC { const DENS_MAT & mass(atomMasses_->quantity()); const DENS_MAT & velocity(atomVelocities_->quantity()); const DENS_MAT & meanVelocity(atomMeanVelocities_->quantity()); - + // K = m * (v \otimes v) for (int i = 0; i < quantity_.nRows(); i++) { double m = mass(i,0); @@ -1324,7 +1324,7 @@ namespace ATC { if (!referencePotential_) { referencePotential_ = interscaleManager.per_atom_quantity("AtomicReferencePotential"); } - + potentialEnergy_->register_dependence(this); referencePotential_->register_dependence(this); } @@ -1539,7 +1539,7 @@ namespace ATC { type_(type) { // DO NOTHING - + } //-------------------------------------------------------- @@ -1580,7 +1580,7 @@ namespace ATC { group_(group) { // DO NOTHING - + } //-------------------------------------------------------- @@ -1641,7 +1641,7 @@ namespace ATC { //-------------------------------------------------------- void AtomToNodeset::reset() const { - + //so it has been commented out. /* if (need_reset()) { @@ -1761,7 +1761,7 @@ namespace ATC { const DENS_MAT & source(source_->quantity()); const INT_ARRAY & map(map_->quantity()); quantity_.resize(map_->size(),source.nCols()); - + for (int i = 0; i < source.nRows(); i++) { int idx = map(i,0); if (idx > -1) { @@ -1901,7 +1901,7 @@ namespace ATC { // computes the classical atomic heat capacity //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // constructor //-------------------------------------------------------- @@ -2114,7 +2114,7 @@ namespace ATC { atomVelocities_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_VELOCITY, atomType); } - + atomLambdas_->register_dependence(this); atomVelocities_->register_dependence(this); } @@ -2137,7 +2137,7 @@ namespace ATC { PerAtomQuantity::reset(); const DENS_MAT & v(atomVelocities_->quantity()); const DENS_MAT & lambda(atomLambdas_->quantity()); - + // force = -lambda*v quantity_ = v; quantity_ *= lambda; @@ -2170,7 +2170,7 @@ namespace ATC { atomMass_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_MASS, atomType); } - + atomLambda_->register_dependence(this); atomMass_->register_dependence(this); } @@ -2194,7 +2194,7 @@ namespace ATC { const DENS_MAT & m(atomMass_->quantity()); const DENS_MAT & lambda(atomLambda_->quantity()); double timeFactor = time_step_factor(0.5*atc_.dt()); - + //force = -lambda*m*(timestep factor) quantity_ = lambda; quantity_ *= m; @@ -2221,7 +2221,7 @@ namespace ATC { if (!atomLambda_) { atomLambda_ = interscaleManager.per_atom_quantity("AtomLambdaMomentum"); } - + atomLambda_->register_dependence(this); } @@ -2241,7 +2241,7 @@ namespace ATC { if (need_reset()) { PerAtomQuantity::reset(); const DENS_MAT & lambda(atomLambda_->quantity()); - + // force = -lambda quantity_ = lambda; quantity_ *= -1.; @@ -2372,7 +2372,7 @@ namespace ATC { if (!nodeToOverlapMap_) { nodeToOverlapMap_ = (atc->interscale_manager()).dense_matrix_int("NodeToOverlapMap"); } - + shapeFunction_->register_dependence(this); nodeToOverlapMap_->register_dependence(this); } @@ -2388,7 +2388,7 @@ namespace ATC { const SPAR_MAT & shapeFunction(shapeFunction_->quantity()); quantity_.reset(shapeFunction.nRows(),nNodeOverlap); // number of atoms X number of nodes overlapping MD region const INT_ARRAY nodeToOverlapMap(nodeToOverlapMap_->quantity()); - + for (int i = 0; i < shapeFunction.size(); ++i) { TRIPLET myTriplet = shapeFunction.triplet(i); int myCol = nodeToOverlapMap(myTriplet.j,0); @@ -2418,7 +2418,7 @@ namespace ATC { if (!lambdaAtomMap_) { lambdaAtomMap_ = (atc->interscale_manager()).dense_matrix_int("LambdaAtomMap"); } - + lambdaAtomMap_->register_dependence(this); } @@ -2436,7 +2436,7 @@ namespace ATC { const SPAR_MAT & shapeFunction(shapeFunction_->quantity()); const INT_ARRAY nodeToOverlapMap(nodeToOverlapMap_->quantity()); const INT_ARRAY lambdaAtomMap(lambdaAtomMap_->quantity()); - + for (int i = 0; i < shapeFunction.size(); ++i) { TRIPLET myTriplet = shapeFunction.triplet(i); int myRow = lambdaAtomMap(myTriplet.i,0); @@ -2488,7 +2488,7 @@ namespace ATC { } } quantity_.compress(); - + //int nNodes = nodeToOverlapMap_->nRows(); _activeNodes_.reset(nNodes); for (int i = 0; i < nNodes; ++i) { diff --git a/lib/atc/PerAtomQuantityLibrary.h b/lib/atc/PerAtomQuantityLibrary.h index 3e3cb78e95..2229645531 100644 --- a/lib/atc/PerAtomQuantityLibrary.h +++ b/lib/atc/PerAtomQuantityLibrary.h @@ -33,7 +33,7 @@ namespace ATC { // destructor virtual ~AtomNumber() {}; - + /** reset the quantity */ virtual void reset() const; @@ -65,7 +65,7 @@ namespace ATC { // destructor virtual ~AtomTypeVector() {}; - + /** reset the quantity */ virtual void reset() const; @@ -73,14 +73,14 @@ namespace ATC { ATC_Method * atc_; int ntypes_; std::vector typeList_,index_; // lammps->atc & atc->lammps - std::vector groupList_; + std::vector groupList_; private: AtomTypeVector(); // do not define }; - + // inherited classes are used for this task because // lammps changes pointer location so it can only be // accessed by functions @@ -88,32 +88,32 @@ namespace ATC { * @class XrefWrapper * @brief Class for wrapping the xref_ array */ - + class XrefWrapper : public ProtectedClonedAtomQuantity { - + public: - + // constructor XrefWrapper(ATC_Method * atc, AtomType atomType=INTERNAL); - + // destructor virtual ~XrefWrapper() {}; - + protected: - + /** pointer to atc to access raw pointer */ ATC_Method * atc_; /** gets appropriate pointer for lammps data */ double ** lammps_vector() const; - + private: // do not define XrefWrapper(); - + }; - + /** * @class AtomToElementMap * @brief Class for identifying the element associated with an atom @@ -158,13 +158,13 @@ namespace ATC { // constructor AtomInElementSet(ATC_Method * atc, PerAtomQuantity * map, - ESET eset, int type); + ESET eset, int type); // destructor virtual ~AtomInElementSet(); // accessors - virtual const ID_LIST & quantity(); + virtual const ID_LIST & quantity(); virtual ID_LIST & set_quantity() {return list_;} int size() {if (needReset_) reset(); return list_.size(); } ID_PAIR item(int i) {if (needReset_) reset(); return list_[i]; } @@ -251,7 +251,7 @@ namespace ATC { /** pointer to lammps interface */ const LammpsInterface * lammpsInterface_; - + /** reference to array mapping atc indices to lammps indices */ const Array & atcToLammps_; @@ -415,7 +415,7 @@ namespace ATC { * @class AtomicMassWeightedDisplacement * @brief Class for computing the precursor atomic quantity m*(x - x_ref) */ - + class AtomicMassWeightedDisplacement : public ProtectedAtomQuantity { public: @@ -437,7 +437,7 @@ namespace ATC { /** atomic positions */ PerAtomQuantity * atomPositions_; - + /** atomic masses */ PerAtomQuantity * atomMasses_; @@ -445,17 +445,17 @@ namespace ATC { PerAtomQuantity * atomReferencePositions_; private: - + // do not define AtomicMassWeightedDisplacement(); }; /** - * @class FluctuatingVelocity + * @class FluctuatingVelocity * @brief Class for computing the atomic quantity v - bar{v} */ - + class FluctuatingVelocity : public ProtectedAtomQuantity { public: @@ -480,7 +480,7 @@ namespace ATC { /** atomic mean velocities */ PerAtomQuantity * atomMeanVelocities_; private: - + // do not define FluctuatingVelocity(); @@ -490,7 +490,7 @@ namespace ATC { * @class ChargeVelcity * @brief Class for computing the atomic quantity q v' */ - + class ChargeVelocity : public ProtectedAtomQuantity { public: @@ -515,7 +515,7 @@ namespace ATC { /** atomic mean velocities */ FundamentalAtomQuantity * atomCharge_; private: - + // do not define ChargeVelocity(); @@ -525,7 +525,7 @@ namespace ATC { * @class SpeciesVelcity * @brief Class for computing the atomic quantity m^(a) v' */ - + class SpeciesVelocity : public ProtectedAtomQuantity { public: @@ -550,7 +550,7 @@ namespace ATC { /** atomic mean velocities */ PerAtomQuantity * atomTypeVector_; private: - + // do not define SpeciesVelocity(); @@ -560,7 +560,7 @@ namespace ATC { * @class AtomicMomentum * @brief Class for computing the precursor atomic quantity m*v */ - + class AtomicMomentum : public ProtectedAtomQuantity { public: @@ -586,17 +586,17 @@ namespace ATC { PerAtomQuantity * atomMasses_; private: - + // do not define AtomicMomentum(); }; /** - * @class AtomicEnergyForTemperature - * @brief Base class for accessing quantities needed for computing temperature + * @class AtomicEnergyForTemperature + * @brief Base class for accessing quantities needed for computing temperature */ - + class AtomicEnergyForTemperature : public ProtectedAtomQuantity { public: @@ -613,18 +613,18 @@ namespace ATC { virtual double kinetic_energy_multiplier() const = 0; private: - + // do not define AtomicEnergyForTemperature(); }; /** - * @class TwiceKineticEnergy - * @brief Class for computing the precursor atomic quantity m*v*v + * @class TwiceKineticEnergy + * @brief Class for computing the precursor atomic quantity m*v*v * (used when the kinetic definition of temperature is required) */ - + class TwiceKineticEnergy : public AtomicEnergyForTemperature { public: @@ -653,17 +653,17 @@ namespace ATC { PerAtomQuantity * atomMasses_; private: - + // do not define TwiceKineticEnergy(); }; /** - * @class KineticTensor - * @brief Class for computing the atomic quantity m v (x) v + * @class KineticTensor + * @brief Class for computing the atomic quantity m v (x) v */ - + class KineticTensor : public ProtectedAtomQuantity { public: @@ -689,7 +689,7 @@ namespace ATC { PerAtomQuantity * atomMasses_; private: - + // do not define KineticTensor(); @@ -697,10 +697,10 @@ namespace ATC { /** - * @class FluctuatingKineticTensor - * @brief Class for computing the atomic quantity m v (x) v + * @class FluctuatingKineticTensor + * @brief Class for computing the atomic quantity m v (x) v */ - + class FluctuatingKineticTensor : public ProtectedAtomQuantity { public: @@ -729,18 +729,18 @@ namespace ATC { /** atomic mean velocities */ PerAtomQuantity * atomMeanVelocities_; private: - + // do not define FluctuatingKineticTensor(); }; /** - * @class TwiceFluctuatingKineticEnergy - * @brief Class for computing the precursor atomic quantity m*(v-vr)*(v-vr) + * @class TwiceFluctuatingKineticEnergy + * @brief Class for computing the precursor atomic quantity m*(v-vr)*(v-vr) * (used when the kinetic definition of temperature is required) */ - + class TwiceFluctuatingKineticEnergy : public AtomicEnergyForTemperature { public: @@ -773,7 +773,7 @@ namespace ATC { PerAtomQuantity * atomMeanVelocities_; private: - + // do not define TwiceFluctuatingKineticEnergy(); @@ -781,10 +781,10 @@ namespace ATC { /** * @class MixedKePeEnergy - * @brief Class for computing the precursor atomic quantity for + * @brief Class for computing the precursor atomic quantity for * a mixed temperature definition involving both KE and PE */ - + class MixedKePeEnergy : public AtomicEnergyForTemperature { public: @@ -821,7 +821,7 @@ namespace ATC { PerAtomQuantity * potentialEnergy_; private: - + // do not define MixedKePeEnergy(); @@ -831,7 +831,7 @@ namespace ATC { * @class TotalEnergy * @brief Class for the atomic total energy */ - + class TotalEnergy : public ProtectedAtomQuantity { public: @@ -861,10 +861,10 @@ namespace ATC { /** * @class FluctuatingPotentialEnergy - * @brief Class for computing the precursor atomic quantity for + * @brief Class for computing the precursor atomic quantity for * a configurational (PE-based) temperature */ - + class FluctuatingPotentialEnergy : public AtomicEnergyForTemperature { public: @@ -893,18 +893,18 @@ namespace ATC { PerAtomQuantity * referencePotential_; private: - + // do not define FluctuatingPotentialEnergy(); }; /** - * @class DotTwiceKineticEnergy - * @brief Class for computing the precursor atomic power 2*v*f + * @class DotTwiceKineticEnergy + * @brief Class for computing the precursor atomic power 2*v*f * (used when the kinetic definition of temperature is required) */ - + class DotTwiceKineticEnergy : public ProtectedAtomQuantity { public: @@ -930,7 +930,7 @@ namespace ATC { PerAtomQuantity * atomVelocities_; private: - + // do not define DotTwiceKineticEnergy(); @@ -941,7 +941,7 @@ namespace ATC { * @brief Class for computing the quantity |v|^2 * (used for weights in the thermostat) */ - + class VelocitySquared : public ProtectedAtomQuantity { public: @@ -974,7 +974,7 @@ namespace ATC { * @brief Class for computing the 2nd order RHS fractional step * contribution to the equation for lambda, with appropriate weights */ - + class LambdaSquared : public ProtectedAtomQuantity { public: @@ -1020,12 +1020,12 @@ namespace ATC { class LargeToSmallAtomMap : public ProtectedAtomQuantity { public: - + // constructor LargeToSmallAtomMap(ATC_Method * atc, AtomType atomType = INTERNAL) : ProtectedAtomQuantity(atc,1,atomType), size_(0) {}; - + // destructor virtual ~LargeToSmallAtomMap() {}; @@ -1051,7 +1051,7 @@ namespace ATC { virtual int unpack_exchange(int /* i */, double * /* buffer */) {return 0;}; /** packs up data for parallel transfer to ghost atoms on other processors */ - virtual int pack_comm(int /* index */, double * /* buf */, + virtual int pack_comm(int /* index */, double * /* buf */, int /* pbc_flag */, int * /* pbc */) {return 0;}; /** unpacks data after parallel transfer to ghost atoms on other processors */ @@ -1081,12 +1081,12 @@ namespace ATC { class AtomToType : public LargeToSmallAtomMap { public: - + // constructor AtomToType(ATC_Method * atc, int type, AtomType atomType = INTERNAL); - + // destructor virtual ~AtomToType() {}; @@ -1113,12 +1113,12 @@ namespace ATC { class AtomToGroup : public LargeToSmallAtomMap { public: - + // constructor AtomToGroup(ATC_Method * atc, int group, AtomType atomType = INTERNAL); - + // destructor virtual ~AtomToGroup() {}; @@ -1145,13 +1145,13 @@ namespace ATC { class AtomToNodeset : public LargeToSmallAtomMap { public: - + // constructor AtomToNodeset(ATC_Method * atc, SetDependencyManager * subsetNodes, PerAtomQuantity * atomElement = nullptr, AtomType atomType = INTERNAL); - + // destructor virtual ~AtomToNodeset() { atomElement_->remove_dependence(this); @@ -1190,13 +1190,13 @@ namespace ATC { class AtomToElementset : public LargeToSmallAtomMap { public: - + // constructor AtomToElementset(ATC_Method * atc, MatrixDependencyManager * elementMask, PerAtomQuantity * atomElement = nullptr, AtomType atomType = INTERNAL); - + // destructor virtual ~AtomToElementset(); @@ -1225,17 +1225,17 @@ namespace ATC { * @class MappedAtomQuantity * @brief generic reduced mapping */ - + class MappedAtomQuantity : public ProtectedMappedAtomQuantity { public: - + // constructor MappedAtomQuantity(ATC_Method * atc, PerAtomQuantity * source, LargeToSmallAtomMap * map, AtomType atomType = INTERNAL); - + // destructor virtual ~MappedAtomQuantity() { source_->remove_dependence(this); @@ -1265,7 +1265,7 @@ namespace ATC { * @brief Class for computing the quantity |v|^2 on a subset of atoms * (used for weights in the thermostat) */ - + class VelocitySquaredMapped : public ProtectedMappedAtomQuantity { public: @@ -1299,7 +1299,7 @@ namespace ATC { * @brief Class for computing the 2nd order RHS fractional step * contribution to the equation for lambda, with appropriate weights */ - + class LambdaSquaredMapped : public ProtectedMappedAtomQuantity { public: @@ -1337,10 +1337,10 @@ namespace ATC { }; /** - * @class HeatCapacity - * @brief Class for the classical atomic heat capacity + * @class HeatCapacity + * @brief Class for the classical atomic heat capacity */ - + class HeatCapacity : public ConstantQuantity { public: @@ -1354,17 +1354,17 @@ namespace ATC { protected: private: - + // do not define HeatCapacity(); }; /** - * @class AtomicVelocityRescaleFactor - * @brief Class for computing the atomic rescaling induced by the rescaling thermostat + * @class AtomicVelocityRescaleFactor + * @brief Class for computing the atomic rescaling induced by the rescaling thermostat */ - + class AtomicVelocityRescaleFactor : public ProtectedAtomQuantity { public: @@ -1386,17 +1386,17 @@ namespace ATC { PerAtomQuantity * atomLambdas_; private: - + // do not define AtomicVelocityRescaleFactor(); }; /** - * @class AtomicFluctuatingVelocityRescaled - * @brief Class for computing the atomic rescaling of the velocity fluctuations by the rescaling thermostat + * @class AtomicFluctuatingVelocityRescaled + * @brief Class for computing the atomic rescaling of the velocity fluctuations by the rescaling thermostat */ - + class AtomicFluctuatingVelocityRescaled : public ProtectedAtomQuantity { public: @@ -1422,17 +1422,17 @@ namespace ATC { PerAtomQuantity * atomFluctuatingVelocity_; private: - + // do not define AtomicFluctuatingVelocityRescaled(); }; /** - * @class AtomicCombinedRescaleThermostatError - * @brief Class for computing the atomic error in the rescaling thermostat when used in combination with a specified streaming velocity + * @class AtomicCombinedRescaleThermostatError + * @brief Class for computing the atomic error in the rescaling thermostat when used in combination with a specified streaming velocity */ - + class AtomicCombinedRescaleThermostatError : public ProtectedAtomQuantity { public: @@ -1466,17 +1466,17 @@ namespace ATC { PerAtomQuantity * atomMass_; private: - + // do not define AtomicCombinedRescaleThermostatError(); }; /** - * @class AtomicThermostatForce - * @brief Class for computing the atomic force induced by the GLC-based thermostats + * @class AtomicThermostatForce + * @brief Class for computing the atomic force induced by the GLC-based thermostats */ - + class AtomicThermostatForce : public ProtectedAtomQuantity { public: @@ -1502,17 +1502,17 @@ namespace ATC { PerAtomQuantity * atomVelocities_; private: - + // do not define AtomicThermostatForce(); }; /** - * @class AtomicKinetostatForceDisplacement - * @brief Class for computing the atomic force induced by the GLC-based kinetostats + * @class AtomicKinetostatForceDisplacement + * @brief Class for computing the atomic force induced by the GLC-based kinetostats */ - + class AtomicKinetostatForceDisplacement : public ProtectedAtomQuantity { public: @@ -1541,7 +1541,7 @@ namespace ATC { PerAtomQuantity * atomMass_; private: - + // do not define AtomicKinetostatForceDisplacement(); @@ -1549,9 +1549,9 @@ namespace ATC { /** * @class AtomicKinetostatForceVelocity - * @brief Class for computing the atomic force induced by the GLC-based kinetostats + * @brief Class for computing the atomic force induced by the GLC-based kinetostats */ - + class AtomicKinetostatForceVelocity : public AtomicKinetostatForceDisplacement { public: @@ -1580,9 +1580,9 @@ namespace ATC { /** * @class AtomicKinetostatForceStress - * @brief Class for computing the atomic force induced by the stress-based kinetostats + * @brief Class for computing the atomic force induced by the stress-based kinetostats */ - + class AtomicKinetostatForceStress : public ProtectedAtomQuantity { public: @@ -1604,7 +1604,7 @@ namespace ATC { PerAtomQuantity * atomLambda_; private: - + // do not define AtomicKinetostatForceStress(); @@ -1614,7 +1614,7 @@ namespace ATC { * @class PerAtomKernelFunction * @brief Class for computing the kernel function at each atom location */ - + class PerAtomKernelFunction : public ProtectedAtomSparseMatrix { public: @@ -1639,7 +1639,7 @@ namespace ATC { const FE_Engine * feEngine_; private: - + // do not define PerAtomKernelFunction(); @@ -1649,7 +1649,7 @@ namespace ATC { * @class PerAtomShapeFunction * @brief Class for computing the shape function at each atom location */ - + class PerAtomShapeFunction : public ProtectedAtomSparseMatrix { public: @@ -1678,7 +1678,7 @@ namespace ATC { const FE_Engine * feEngine_; private: - + // do not define PerAtomShapeFunction(); @@ -1688,7 +1688,7 @@ namespace ATC { * @class LambdaCouplingMatrix * @brief constructs the coupling matrix needed to solve for lambda, i.e. N in N^T w N L = b */ - + class LambdaCouplingMatrix : public ProtectedMappedAtomSparseMatrix { public: @@ -1697,7 +1697,7 @@ namespace ATC { LambdaCouplingMatrix(ATC_Method * atc, MatrixDependencyManager * nodeToOverlapMap = nullptr, SPAR_MAN * shapeFunction = nullptr); - + // destructor virtual ~LambdaCouplingMatrix() { shapeFunction_->remove_dependence(this); @@ -1727,7 +1727,7 @@ namespace ATC { * @brief constructs the coupling matrix needed to solve for lambda, i.e. N in N^T w N L = b * when localization is being used for the constraint */ - + class LocalLambdaCouplingMatrix : public LambdaCouplingMatrix { public: @@ -1737,7 +1737,7 @@ namespace ATC { MatrixDependencyManager * lambdaAtomMap = nullptr, MatrixDependencyManager * nodeToOverlapMap = nullptr, SPAR_MAN * shapeFunction = nullptr); - + // destructor virtual ~LocalLambdaCouplingMatrix() { lambdaAtomMap_->remove_dependence(this); @@ -1762,7 +1762,7 @@ namespace ATC { * @class GhostCouplingMatrix * @brief constructs the modified shape functions used to compute the total forces between ghost and internal atoms */ - + class GhostCouplingMatrix : public LambdaCouplingMatrix { public: @@ -1772,7 +1772,7 @@ namespace ATC { SPAR_MAN * shapeFunction, SetDependencyManager * subsetNodes, MatrixDependencyManager * nodeToOverlapMap = nullptr); - + // destructor virtual ~GhostCouplingMatrix() { subsetNodes_->remove_dependence(this); diff --git a/lib/atc/PerPairQuantity.cpp b/lib/atc/PerPairQuantity.cpp index 01308e4b39..164c387643 100644 --- a/lib/atc/PerPairQuantity.cpp +++ b/lib/atc/PerPairQuantity.cpp @@ -27,7 +27,7 @@ PairMapNeighbor::PairMapNeighbor(LammpsInterface * lammpsInterface, int groupbit { }; -void PairMapNeighbor::reset(void) const +void PairMapNeighbor::reset(void) const { int inum = lammpsInterface_->neighbor_list_inum(); int *ilist = lammpsInterface_->neighbor_list_ilist(); @@ -35,16 +35,16 @@ void PairMapNeighbor::reset(void) const int **firstneigh = lammpsInterface_->neighbor_list_firstneigh(); const int * mask = lammpsInterface_->atom_mask(); - pairMap_.clear(); + pairMap_.clear(); int pairIndex = nBonds_; std::pair< int,int > pair_ij; - for (int i = 0; i < inum; i++) { + for (int i = 0; i < inum; i++) { int lammps_i = ilist[i]; if (mask[lammps_i] & groupbit_) { for (int j = 0; j < numneigh[lammps_i]; j++) { int lammps_j = firstneigh[lammps_i][j]; lammpsInterface_->neighbor_remap(lammps_j); - pair_ij.first = lammps_i; // alpha + pair_ij.first = lammps_i; // alpha pair_ij.second = lammps_j; // beta pairMap_[pair_ij] = pairIndex; pairIndex++; @@ -67,7 +67,7 @@ PairMapBoth::PairMapBoth(LammpsInterface * lammpsInterface, int groupbit): { }; //========================================================== -DensePerPairMatrix::DensePerPairMatrix(LammpsInterface * lammpsInterface, +DensePerPairMatrix::DensePerPairMatrix(LammpsInterface * lammpsInterface, const PairMap & pairMap, int nCols): lammpsInterface_(lammpsInterface), @@ -77,20 +77,20 @@ DensePerPairMatrix::DensePerPairMatrix(LammpsInterface * lammpsInterface, }; //========================================================== -PairVirial::PairVirial(LammpsInterface * lammpsInterface, +PairVirial::PairVirial(LammpsInterface * lammpsInterface, const PairMap & pairMap, int nCols): DensePerPairMatrix(lammpsInterface,pairMap,nCols) { }; //========================================================== -PairVirialEulerian::PairVirialEulerian(LammpsInterface * lammpsInterface, +PairVirialEulerian::PairVirialEulerian(LammpsInterface * lammpsInterface, const PairMap & pairMap): PairVirial(lammpsInterface,pairMap,6) { }; -void PairVirialEulerian::reset(void) const +void PairVirialEulerian::reset(void) const { int nPairs = pairMap_.size(); quantity_.reset(nPairs,nCols_); @@ -108,7 +108,7 @@ void PairVirialEulerian::reset(void) const double delz = xa[2] - xb[2]; double rsq = delx*delx + dely*dely + delz*delz; double fforce = 0; - lammpsInterface_->pair_force(apair,rsq,fforce); + lammpsInterface_->pair_force(apair,rsq,fforce); quantity_(pairIndex,0)=-delx*delx*fforce; quantity_(pairIndex,1)=-dely*dely*fforce; quantity_(pairIndex,2)=-delz*delz*fforce; @@ -118,25 +118,25 @@ void PairVirialEulerian::reset(void) const } } //========================================================== -PairVirialLagrangian::PairVirialLagrangian(LammpsInterface * lammpsInterface, - const PairMap & pairMap, +PairVirialLagrangian::PairVirialLagrangian(LammpsInterface * lammpsInterface, + const PairMap & pairMap, double ** xRef): // const PerAtomQuantity * xRef): PairVirial(lammpsInterface,pairMap,9), xRef_(xRef) { - + }; -void PairVirialLagrangian::reset(void) const +void PairVirialLagrangian::reset(void) const { int nPairs = pairMap_.size(); quantity_.reset(nPairs,nCols_); - double **xatom = lammpsInterface_->xatom(); + double **xatom = lammpsInterface_->xatom(); - double ** xref = xRef_; + double ** xref = xRef_; for (ATOM_PAIR apair = pairMap_.start(); ! pairMap_.finished(); apair=pairMap_++){ @@ -150,12 +150,12 @@ void PairVirialLagrangian::reset(void) const double delz = xa[2] - xb[2]; double * Xa = xref[lammps_a]; double * Xb = xref[lammps_b]; - double delX = Xa[0] - Xb[0]; - double delY = Xa[1] - Xb[1]; - double delZ = Xa[2] - Xb[2]; + double delX = Xa[0] - Xb[0]; + double delY = Xa[1] - Xb[1]; + double delZ = Xa[2] - Xb[2]; double rsq = delx*delx + dely*dely + delz*delz; double fforce = 0; - lammpsInterface_->pair_force(apair,rsq,fforce); + lammpsInterface_->pair_force(apair,rsq,fforce); quantity_(pairIndex,0)=-delx*fforce*delX; quantity_(pairIndex,1)=-delx*fforce*delY; quantity_(pairIndex,2)=-delx*fforce*delZ; @@ -168,26 +168,26 @@ void PairVirialLagrangian::reset(void) const } } //========================================================== -PairPotentialHeatFlux::PairPotentialHeatFlux(LammpsInterface * lammpsInterface, +PairPotentialHeatFlux::PairPotentialHeatFlux(LammpsInterface * lammpsInterface, const PairMap & pairMap): DensePerPairMatrix(lammpsInterface,pairMap,3) { }; //========================================================== -PairPotentialHeatFluxEulerian::PairPotentialHeatFluxEulerian(LammpsInterface * lammpsInterface, - const PairMap & pairMap): +PairPotentialHeatFluxEulerian::PairPotentialHeatFluxEulerian(LammpsInterface * lammpsInterface, + const PairMap & pairMap): PairPotentialHeatFlux(lammpsInterface,pairMap) { - + }; -void PairPotentialHeatFluxEulerian::reset(void) const +void PairPotentialHeatFluxEulerian::reset(void) const { int nPairs = pairMap_.size(); quantity_.reset(nPairs,nCols_); - double **xatom = lammpsInterface_->xatom(); - double **vatom = lammpsInterface_->vatom(); + double **xatom = lammpsInterface_->xatom(); + double **vatom = lammpsInterface_->vatom(); for (ATOM_PAIR apair = pairMap_.start(); ! pairMap_.finished(); apair=pairMap_++){ int lammps_a = (apair.first).first ; @@ -200,7 +200,7 @@ void PairPotentialHeatFluxEulerian::reset(void) const double delz = xa[2] - xb[2]; double rsq = delx*delx + dely*dely + delz*delz; double fforce = 0; - lammpsInterface_->pair_force(apair,rsq,fforce); + lammpsInterface_->pair_force(apair,rsq,fforce); double* v = vatom[lammps_a]; fforce *=delx*v[0] + dely*v[1] + delz*v[2]; quantity_(pairIndex,0)=fforce*delx; @@ -209,21 +209,21 @@ void PairPotentialHeatFluxEulerian::reset(void) const } } //========================================================== -PairPotentialHeatFluxLagrangian::PairPotentialHeatFluxLagrangian(LammpsInterface * lammpsInterface, +PairPotentialHeatFluxLagrangian::PairPotentialHeatFluxLagrangian(LammpsInterface * lammpsInterface, const PairMap & pairMap, double ** xRef): PairPotentialHeatFlux(lammpsInterface,pairMap), xRef_(xRef) { - + }; -void PairPotentialHeatFluxLagrangian::reset(void) const +void PairPotentialHeatFluxLagrangian::reset(void) const { int nPairs = pairMap_.size(); quantity_.reset(nPairs,nCols_); - double **xatom = lammpsInterface_->xatom(); - double **vatom = lammpsInterface_->vatom(); + double **xatom = lammpsInterface_->xatom(); + double **vatom = lammpsInterface_->vatom(); for (ATOM_PAIR apair = pairMap_.start(); ! pairMap_.finished(); apair=pairMap_++){ @@ -237,12 +237,12 @@ void PairPotentialHeatFluxLagrangian::reset(void) const double delz = xa[2] - xb[2]; double * Xa = xRef_[lammps_a]; double * Xb = xRef_[lammps_b]; - double delX = Xa[0] - Xb[0]; - double delY = Xa[1] - Xb[1]; - double delZ = Xa[2] - Xb[2]; + double delX = Xa[0] - Xb[0]; + double delY = Xa[1] - Xb[1]; + double delZ = Xa[2] - Xb[2]; double rsq = delx*delx + dely*dely + delz*delz; double fforce = 0; - lammpsInterface_->pair_force(apair,rsq,fforce); + lammpsInterface_->pair_force(apair,rsq,fforce); double* v = vatom[lammps_a]; fforce *=delx*v[0] + dely*v[1] + delz*v[2]; quantity_(pairIndex,0)=fforce*delX; @@ -251,21 +251,21 @@ void PairPotentialHeatFluxLagrangian::reset(void) const } } //========================================================== -SparsePerPairMatrix::SparsePerPairMatrix(LammpsInterface * lammpsInterface, +SparsePerPairMatrix::SparsePerPairMatrix(LammpsInterface * lammpsInterface, const PairMap & pairMap): lammpsInterface_(lammpsInterface), pairMap_(pairMap) { }; //========================================================== -BondMatrix::BondMatrix(LammpsInterface * lammpsInterface, +BondMatrix::BondMatrix(LammpsInterface * lammpsInterface, const PairMap & pairMap, double ** x, const FE_Mesh * feMesh): SparsePerPairMatrix(lammpsInterface,pairMap), x_(x), feMesh_(feMesh) { }; //========================================================== -BondMatrixKernel::BondMatrixKernel(LammpsInterface * lammpsInterface, - const PairMap & pairMap, +BondMatrixKernel::BondMatrixKernel(LammpsInterface * lammpsInterface, + const PairMap & pairMap, double ** x, const FE_Mesh * feMesh, const KernelFunction * kernelFunction): @@ -278,7 +278,7 @@ BondMatrixKernel::BondMatrixKernel(LammpsInterface * lammpsInterface, void BondMatrixKernel::reset(void) const { int nPairs = pairMap_.size(); // needs to come after quantity for reset - int nNodes = feMesh_->num_nodes_unique(); + int nNodes = feMesh_->num_nodes_unique(); quantity_.reset(nNodes,nPairs); double lam1,lam2; int heartbeatFreq = (nNodes <= 10 ? 1 : (int) nNodes / 10); @@ -302,7 +302,7 @@ void BondMatrixKernel::reset(void) const xbI = xba + xaI; kernelFunction_->bond_intercepts(xaI,xbI,lam1,lam2); if (lam1 < lam2) { - double bondValue = invVol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); + double bondValue = invVol*(kernelFunction_->bond(xaI,xbI,lam1,lam2)); int pairIndex = apair.second; quantity_.add(I,pairIndex,bondValue); } // if lam1 < lam2 @@ -312,8 +312,8 @@ void BondMatrixKernel::reset(void) const beat.finish(); } //========================================================== -BondMatrixPartitionOfUnity::BondMatrixPartitionOfUnity(LammpsInterface * lammpsInterface, - const PairMap & pairMap, double ** x, const FE_Mesh * feMesh, +BondMatrixPartitionOfUnity::BondMatrixPartitionOfUnity(LammpsInterface * lammpsInterface, + const PairMap & pairMap, double ** x, const FE_Mesh * feMesh, const DIAG_MAN * invVols): BondMatrix(lammpsInterface,pairMap,x,feMesh), invVols_(invVols) @@ -330,11 +330,11 @@ BondMatrixPartitionOfUnity::BondMatrixPartitionOfUnity(LammpsInterface * lammpsI }; void BondMatrixPartitionOfUnity::reset(void) const { - int nNodes = feMesh_->num_nodes_unique(); - int nPairs = pairMap_.size(); + int nNodes = feMesh_->num_nodes_unique(); + int nPairs = pairMap_.size(); quantity_.reset(nNodes,nPairs); - int nodes_per_element = feMesh_->num_nodes_per_element(); - Array node_list(nodes_per_element); + int nodes_per_element = feMesh_->num_nodes_per_element(); + Array node_list(nodes_per_element); DENS_VEC shp(nodes_per_element); int heartbeatFreq = (int) nPairs / 10; HeartBeat beat("computing bond matrix ",heartbeatFreq); diff --git a/lib/atc/PerPairQuantity.h b/lib/atc/PerPairQuantity.h index 2c391f99a8..a1d507a592 100644 --- a/lib/atc/PerPairQuantity.h +++ b/lib/atc/PerPairQuantity.h @@ -18,7 +18,7 @@ namespace ATC { typedef std::pair< std::pair< int,int >,int > ATOM_PAIR; /** - * @class PairMap + * @class PairMap * @brief Base class maps of pair indices to a single index */ @@ -28,7 +28,7 @@ namespace ATC { virtual ~PairMap(void); virtual void reset(void) const = 0; - void quantity() {}; + void quantity() {}; void set_quantity() { throw ATC_Error("inappropriate access to pair map");} // lammps communication @@ -36,9 +36,9 @@ namespace ATC { virtual void rest_nlocal() {this->force_reset();}; // iterator interface - int size(void) const { - if (this->need_reset()) reset(); - return nPairs_+nBonds_; + int size(void) const { + if (this->need_reset()) reset(); + return nPairs_+nBonds_; } int num_bonds(void) const { return nBonds_; } virtual ATOM_PAIR start() const = 0; // const reset / non-const call propagte reset @@ -66,10 +66,10 @@ namespace ATC { iterator_ = pairMap_.begin(); return *iterator_;} virtual ATOM_PAIR next(void) const { iterator_++; return *iterator_;} - virtual bool finished() const { + virtual bool finished() const { return (iterator_==pairMap_.end());} protected: - mutable PAIR_MAP pairMap_; + mutable PAIR_MAP pairMap_; private: mutable PAIR_MAP_ITERATOR iterator_; PairMapNeighbor();// do not define @@ -79,12 +79,12 @@ namespace ATC { public: PairMapBond(LammpsInterface * lammpsInterface, int groupbit); virtual ~PairMapBond(void) {}; - virtual bool need_reset(void) const { return true;} + virtual bool need_reset(void) const { return true;} virtual void reset(void) const {nBonds_ = lammpsInterface_->bond_list_length(); }; ATOM_PAIR start() const { reset(); // if (needs_reset()) propagate_reset() - index_ = 0; return atom_pair(index_);} + index_ = 0; return atom_pair(index_);} ATOM_PAIR next() const {return atom_pair(++index_);} bool finished() const { return index_==nBonds_; } ATOM_PAIR atom_pair(int n) const { @@ -94,7 +94,7 @@ namespace ATC { return p; } int * bond = (lammpsInterface_->bond_list())[n]; - std::pair pair_ij(bond[0],bond[1]); + std::pair pair_ij(bond[0],bond[1]); ATOM_PAIR p(pair_ij,n); return p; } @@ -108,31 +108,31 @@ namespace ATC { PairMapBoth(LammpsInterface * lammpsInterface, int groupbit); virtual ~PairMapBoth(void) {}; virtual bool need_reset(void) const { - nBonds_ = lammpsInterface_->bond_list_length(); + nBonds_ = lammpsInterface_->bond_list_length(); return PairMapNeighbor::need_reset(); } - virtual void reset(void) const { - nBonds_ = lammpsInterface_->bond_list_length(); + virtual void reset(void) const { + nBonds_ = lammpsInterface_->bond_list_length(); PairMapNeighbor::reset(); } virtual ATOM_PAIR start(void) const { if (need_reset()) reset(); index_ = 0; - iterator_ = pairMap_.begin(); + iterator_ = pairMap_.begin(); return atom_pair(index_); // start with bonds } virtual ATOM_PAIR next(void) const { ++index_; - if (index_ < nBonds_) { return atom_pair(index_);} + if (index_ < nBonds_) { return atom_pair(index_);} else { if (index_>nBonds_) iterator_++; return *iterator_; } } ATOM_PAIR atom_pair(int n) const { int * bond = (lammpsInterface_->bond_list())[n]; - std::pair pair_ij(bond[0],bond[1]); + std::pair pair_ij(bond[0],bond[1]); ATOM_PAIR p(pair_ij,n); return p; } - virtual bool finished() const { + virtual bool finished() const { return (iterator_==pairMap_.end());} private: mutable int index_; @@ -141,18 +141,18 @@ namespace ATC { }; /** - * @class DensePerPairQuantity - * @brief Base class for objects that manage pair/bond quantities + * @class DensePerPairQuantity + * @brief Base class for objects that manage pair/bond quantities */ class DensePerPairMatrix : public MatrixDependencyManager { public: - + // constructor - DensePerPairMatrix(LammpsInterface * lammpsInterface, - const PairMap & pairMap, + DensePerPairMatrix(LammpsInterface * lammpsInterface, + const PairMap & pairMap, int nCols = 1); - + // destructor virtual ~DensePerPairMatrix(){}; @@ -171,7 +171,7 @@ namespace ATC { virtual void reset() const = 0; protected: - + /** pointer to access Lammps data */ LammpsInterface * lammpsInterface_; @@ -186,7 +186,7 @@ namespace ATC { }; /** - * @class PairVirial + * @class PairVirial * @brief f_ab (x) x_ab where (ab) -> p */ class PairVirial : public DensePerPairMatrix { @@ -201,12 +201,12 @@ namespace ATC { /** resets data, if necessary */ virtual void reset() const = 0; - + private: PairVirial(void); // do not define }; /** - * @class PairVirial + * @class PairVirial * @brief f_ab (x) x_ab where (ab) -> p */ class PairVirialEulerian : public PairVirial { @@ -221,7 +221,7 @@ namespace ATC { /** resets data, if necessary */ virtual void reset() const; - + private: PairVirialEulerian(void); // do not define }; @@ -230,7 +230,7 @@ namespace ATC { public: // constructor PairVirialLagrangian(LammpsInterface * lammpsInterface, - const PairMap & pairMap, + const PairMap & pairMap, double ** xRef); // const PerAtomQuantity * x0); @@ -242,13 +242,13 @@ namespace ATC { protected: double ** xRef_; // note difficult to make a ** const // const PerAtomQuantity * xRef_; - + private: PairVirialLagrangian(void); // do not define }; /**` - * @class PairPotentialHeatFlux + * @class PairPotentialHeatFlux * @brief f_ab v_b where (ab) -> p */ class PairPotentialHeatFlux : public DensePerPairMatrix { @@ -263,7 +263,7 @@ namespace ATC { /** resets data, if necessary */ virtual void reset() const =0; - + private: PairPotentialHeatFlux(void); // do not define }; @@ -279,7 +279,7 @@ namespace ATC { /** resets data, if necessary */ virtual void reset() const; - + private: PairPotentialHeatFluxEulerian(void); // do not define }; @@ -299,23 +299,23 @@ namespace ATC { protected: double ** xRef_; // note difficult to make a ** const //const PerAtomQuantity * x0_; - + private: PairPotentialHeatFluxLagrangian(void); // do not define }; /** - * @class SparsePerPairMatrix - * @brief Base class for objects that manage pair/bond quantities + * @class SparsePerPairMatrix + * @brief Base class for objects that manage pair/bond quantities */ class SparsePerPairMatrix : public MatrixDependencyManager { public: - + // constructor - SparsePerPairMatrix(LammpsInterface * lammpsInterface, - const PairMap & pairMap); - + SparsePerPairMatrix(LammpsInterface * lammpsInterface, + const PairMap & pairMap); + // destructor virtual ~SparsePerPairMatrix(){}; @@ -331,7 +331,7 @@ namespace ATC { virtual void reset() const = 0; protected: - + /** pointer to access Lammps data */ LammpsInterface * lammpsInterface_; @@ -362,7 +362,7 @@ namespace ATC { protected: double ** x_; const class FE_Mesh * feMesh_; - + private: BondMatrix(void); // do not define }; @@ -376,7 +376,7 @@ namespace ATC { public: // constructor BondMatrixKernel(LammpsInterface * lammpsInterface, - const PairMap & pairMap, + const PairMap & pairMap, double ** x, const class FE_Mesh * feMesh, const class KernelFunction * kernelFunction); @@ -389,7 +389,7 @@ namespace ATC { protected: const class KernelFunction * kernelFunction_; - + private: BondMatrixKernel(void); // do not define }; @@ -403,7 +403,7 @@ namespace ATC { public: // constructor BondMatrixPartitionOfUnity(LammpsInterface * lammpsInterface, - const PairMap & pairMap, + const PairMap & pairMap, double ** x, const class FE_Mesh * feMesh, const DIAG_MAN * invVol); diff --git a/lib/atc/PhysicsModel.cpp b/lib/atc/PhysicsModel.cpp index f5c342c5a0..0cef920e88 100644 --- a/lib/atc/PhysicsModel.cpp +++ b/lib/atc/PhysicsModel.cpp @@ -79,19 +79,19 @@ void PhysicsModel::parse_material_file(string fileName) stringstream ss; ss << "WARNING: material units " << units << " do not match lammps"; if (units == "SI") { - if (lammpsUnits != LammpsInterface::SI) + if (lammpsUnits != LammpsInterface::SI) ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } else if (units == "real") { - if (lammpsUnits != LammpsInterface::REAL ) + if (lammpsUnits != LammpsInterface::REAL ) ATC::LammpsInterface::instance()->print_msg_once(ss.str()); } else if (units == "metal") { - if (lammpsUnits != LammpsInterface::METAL ) + if (lammpsUnits != LammpsInterface::METAL ) ATC::LammpsInterface::instance()->print_msg_once(ss.str()); - } + } else { - throw ATC_Error("unknown units in material file"); + throw ATC_Error("unknown units in material file"); } } else { @@ -126,7 +126,7 @@ void PhysicsModel::initialize(void) for (weak = weakEqns_.begin(); weak!=weakEqns_.end(); weak++) { FieldName fieldName = weak->first; WeakEquation * weakEq = weak->second; - set needs= weakEq->needs_material_functions(); + set needs= weakEq->needs_material_functions(); vector< Material* >::iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; @@ -136,11 +136,11 @@ void PhysicsModel::initialize(void) null_(fieldName,matId) = true; stringstream ss; ss << "WARNING: physics model: [" << type_ << "], material: [" << tag - << "] does not provide all interfaces for <" - << field_to_string(fieldName) + << "] does not provide all interfaces for <" + << field_to_string(fieldName) << "> physics and will be treated as null "; ATC::LammpsInterface::instance()->print_msg_once(ss.str()); - // if (noNull_) + // if (noNull_) //throw ATC_Error("material does not provide all interfaces for physics"); } } @@ -186,7 +186,7 @@ void PhysicsModel::num_fields(map & fieldSizes, fieldSizes[field] = size; rhsMask(field,FLUX) = weakEq->has_B_integrand(); rhsMask(field,SOURCE) = weakEq->has_N_integrand(); - } + } } //--------------------------------------------------------------------- @@ -362,7 +362,7 @@ PhysicsModelDriftDiffusionConvectionSchrodinger::PhysicsModelDriftDiffusionConve // PhysicsModelElectrostatic //--------------------------------------------------------------------- PhysicsModelElectrostatic::PhysicsModelElectrostatic(string filename): - PhysicsModel(filename) + PhysicsModel(filename) { PhysicsModel::type_ = "electrostatic"; weakEqns_[VELOCITY] = new WeakEquationMomentumElectrostatic(); @@ -373,7 +373,7 @@ PhysicsModelElectrostatic::PhysicsModelElectrostatic(string filename): // PhysicsModelElectrostaticEquilibrium //--------------------------------------------------------------------- PhysicsModelElectrostaticEquilibrium::PhysicsModelElectrostaticEquilibrium(string filename): - PhysicsModel(filename) + PhysicsModel(filename) { PhysicsModel::type_ = "equilibrium electrostatic"; weakEqns_[VELOCITY] = new WeakEquationMomentumElectrostatic(); @@ -424,20 +424,20 @@ PhysicsModelTangentOperator::PhysicsModelTangentOperator(ATC_Coupling * atc, void PhysicsModelTangentOperator::function(const VECTOR & x, DENS_VEC & r) { - CLON_VEC f = column(fields_[fieldName_].set_quantity(),dof_); + CLON_VEC f = column(fields_[fieldName_].set_quantity(),dof_); f = x; atc_->compute_rhs_vector(rhsMask_, fields_, rhs_, integrationType_, physicsModel_); CLON_VEC rhsv = column(rhs_[fieldName_].quantity(),dof_); r = rhsv; } -void PhysicsModelTangentOperator::tangent(const VECTOR & x, DENS_VEC & r, +void PhysicsModelTangentOperator::tangent(const VECTOR & x, DENS_VEC & r, MATRIX & K) { function(x,r); pair row_col(fieldName_,fieldName_); const FIELDS & fields = fields_; atc_->compute_rhs_tangent(row_col, rhsMask_, fields , stiffness_, integrationType_, physicsModel_); - K = stiffness_.dense_copy(); + K = stiffness_.dense_copy(); } }; // end namespace diff --git a/lib/atc/PhysicsModel.h b/lib/atc/PhysicsModel.h index 8479727a89..7c1108e7f7 100644 --- a/lib/atc/PhysicsModel.h +++ b/lib/atc/PhysicsModel.h @@ -13,28 +13,28 @@ #include "ATC_TypeDefs.h" #include "Utility.h" -namespace ATC +namespace ATC { class ATC_Coupling; //------------------------------------------------------------------- // @class PhysicsModel //------------------------------------------------------------------- /** - * @brief An adaptor for the FE_Engine of the specific weak form of + * @brief An adaptor for the FE_Engine of the specific weak form of * the continuum PDE for the FE_Engine. * It is assumed that the PDE fits this template: - * DENSITY(FIELDS) FIELD_RATE + * DENSITY(FIELDS) FIELD_RATE * = DIV FLUX(FIELDS, GRAD_FIELDS) + SOURCE(FIELDS,GRAD_FIELDS) * + PRESCRIBED_SOURCE(X,t) + EXTRINSIC_SOURCE(FIELDS,GRAD_FIELDS) * Also it is important to understand that the physics model only handles * extrinsic fields or surrogates of intrinsic fields */ - class PhysicsModel + class PhysicsModel { public: - // constructor + // constructor PhysicsModel(std::string fileName); // destructor @@ -44,7 +44,7 @@ namespace ATC void parse_material_file(std::string fileName); /** initialize */ - void initialize(void); + void initialize(void); // set timescale parameters based on a given lengthscale virtual void set_timescales(const double /* lengthscale */) {}; @@ -59,20 +59,20 @@ namespace ATC const Material * material(const int index) const {return materials_[index];} /** access to parameter values */ - bool parameter_value(const std::string& name, double& value, + bool parameter_value(const std::string& name, double& value, const int imat = 0) const ; /** return fields ids and length */ - void num_fields(std::map & fieldSizes, + void num_fields(std::map & fieldSizes, Array2D & rhsMask) const; /** is the material model linear */ - bool is_linear(FieldName name) const { + bool is_linear(FieldName name) const { std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; - bool linear = mat->linear_flux(name) - && mat->linear_source(name) + bool linear = mat->linear_flux(name) + && mat->linear_source(name) && mat->constant_density(name); if (! linear) return linear; } @@ -80,7 +80,7 @@ namespace ATC } /** is rhs linear */ - bool has_linear_rhs(FieldName name) const { + bool has_linear_rhs(FieldName name) const { std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; @@ -91,7 +91,7 @@ namespace ATC } /** is mass matrix constant */ - bool has_constant_mass(FieldName name) const { + bool has_constant_mass(FieldName name) const { std::vector< Material* >::const_iterator iter; for (iter = materials_.begin(); iter != materials_.end(); iter++) { Material * mat = *iter; @@ -103,21 +103,21 @@ namespace ATC /** access to weak equations */ const WeakEquation * weak_equation(FieldName field) const - { + { std::map::const_iterator itr = weakEqns_.find(field); if (itr == weakEqns_.end()) return nullptr; return (weakEqns_.find(field))->second; } /** requires ics */ - bool is_dynamic(FieldName field) const + bool is_dynamic(FieldName field) const { return (weak_equation(field)->type() == WeakEquation::DYNAMIC_PDE); } /** query null weak equations per material */ bool null(FieldName field, int matID) const - { + { return null_(field,matID); } @@ -126,7 +126,7 @@ namespace ATC std::map parameterValues_; /** material models */ - std::vector materials_; + std::vector materials_; std::map materialNameToIndexMap_;// maps tag to index /** weak equations */ @@ -149,7 +149,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelThermal : public PhysicsModel { - public: + public: PhysicsModelThermal(std::string filename); }; //------------------------------------------------------------------- @@ -157,7 +157,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelElastic : public PhysicsModel { - public: + public: PhysicsModelElastic(std::string filename); }; //------------------------------------------------------------------- @@ -165,16 +165,16 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelThermoElastic : public PhysicsModel { - public: + public: PhysicsModelThermoElastic(std::string filename); }; - + //------------------------------------------------------------------- // @class PhysicsModelShear //------------------------------------------------------------------- class PhysicsModelShear : public PhysicsModel { - public: + public: PhysicsModelShear(std::string filename); }; //------------------------------------------------------------------- @@ -182,7 +182,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelThermoShear : public PhysicsModel { - public: + public: PhysicsModelThermoShear(std::string filename); }; //------------------------------------------------------------------- @@ -190,7 +190,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelSpecies : public PhysicsModel { - public: + public: PhysicsModelSpecies(std::string filename); }; //------------------------------------------------------------------- @@ -198,7 +198,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelTwoTemperature : public PhysicsModel { - public: + public: PhysicsModelTwoTemperature(std::string filename); }; //------------------------------------------------------------------- @@ -206,7 +206,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusion : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusion(std::string filename); }; //------------------------------------------------------------------- @@ -214,7 +214,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionEquilibrium : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionEquilibrium(std::string filename); }; //------------------------------------------------------------------- @@ -222,7 +222,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionSchrodinger : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionSchrodinger(std::string filename); }; //------------------------------------------------------------------- @@ -230,7 +230,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionConvection : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionConvection(std::string filename); }; //------------------------------------------------------------------- @@ -238,7 +238,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionConvectionEquilibrium : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionConvectionEquilibrium(std::string filename); }; //------------------------------------------------------------------- @@ -246,7 +246,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionConvectionSchrodinger : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionConvectionSchrodinger(std::string filename); }; //------------------------------------------------------------------- @@ -254,7 +254,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelDriftDiffusionSchrodingerSlice : public PhysicsModel { - public: + public: PhysicsModelDriftDiffusionSchrodingerSlice(std::string filename); }; //------------------------------------------------------------------- @@ -262,7 +262,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelElectrostatic : public PhysicsModel { - public: + public: PhysicsModelElectrostatic(std::string filename); }; //------------------------------------------------------------------- @@ -270,7 +270,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelElectrostaticEquilibrium : public PhysicsModel { - public: + public: PhysicsModelElectrostaticEquilibrium(std::string filename); }; //------------------------------------------------------------------- @@ -278,7 +278,7 @@ namespace ATC //------------------------------------------------------------------- class PhysicsModelSpeciesElectrostatic : public PhysicsModel { - public: + public: PhysicsModelSpeciesElectrostatic(std::string filename); }; //------------------------------------------------------------------- @@ -314,7 +314,7 @@ namespace ATC FIELDS & fields_; FieldName fieldName_; int dof_; - SPAR_MAT stiffness_; + SPAR_MAT stiffness_; }; } diff --git a/lib/atc/PoissonSolver.cpp b/lib/atc/PoissonSolver.cpp index 52909fc454..3d644e6c58 100644 --- a/lib/atc/PoissonSolver.cpp +++ b/lib/atc/PoissonSolver.cpp @@ -44,24 +44,24 @@ PoissonSolver::PoissonSolver( { if (physicsModel_->has_linear_rhs(fieldName)) { linear_ = true; - rhsMask_(fieldName,FLUX) = false; + rhsMask_(fieldName,FLUX) = false; } else { - rhsMask_(fieldName,FLUX) = true; - rhsMask_(fieldName,SOURCE) = true; + rhsMask_(fieldName,FLUX) = true; + rhsMask_(fieldName,SOURCE) = true; } - + if (prescribedDataMgr_->has_robin_source(fieldName)) { - - - + + + rhsMask_(fieldName,ROBIN_SOURCE) = true; } } // -------------------------------------------------------------------- -PoissonSolver::~PoissonSolver() -{ +PoissonSolver::~PoissonSolver() +{ if (tangent_) delete tangent_; if (solverNL_) delete solverNL_; if (solver_) delete solver_; @@ -74,9 +74,9 @@ PoissonSolver::~PoissonSolver() bool PoissonSolver::modify(int /* narg */, char **arg) { bool match = false; - /*! \page man_poisson_solver fix_modify AtC poisson_solver + /*! \page man_poisson_solver fix_modify AtC poisson_solver \section syntax - fix_modify AtC poisson_solver mesh create + fix_modify AtC poisson_solver mesh create - nx ny nz = number of elements in x, y, z - region-id = id of region that is to be meshed @@ -105,7 +105,7 @@ PoissonSolver::~PoissonSolver() // feEngine_->modify(narg,arg); } - } + } return match; } // -------------------------------------------------------------------- @@ -115,16 +115,16 @@ void PoissonSolver::initialize(void) { nNodes_ = feEngine_->num_nodes(); - if (atc_->source_atomic_quadrature(fieldName_)) + if (atc_->source_atomic_quadrature(fieldName_)) integrationType_ = FULL_DOMAIN_ATOMIC_QUADRATURE_SOURCE; // compute penalty for Dirichlet boundaries - if (prescribedDataMgr_->none_fixed(fieldName_)) + if (prescribedDataMgr_->none_fixed(fieldName_)) throw ATC_Error("Poisson solver needs Dirichlet data"); const BC_SET & bcs = (prescribedDataMgr_->bcs(fieldName_))[0]; - if (linear_) { // constant rhs + if (linear_) { // constant rhs if (! solver_ ) { pair row_col(fieldName_,fieldName_); Array2D rhsMask(NUM_FIELDS,NUM_FLUX); @@ -151,10 +151,10 @@ void PoissonSolver::initialize(void) else { // print_mask(rhsMask_); if ( solverNL_ ) delete solverNL_; - tangent_ = new PhysicsModelTangentOperator(atc_,physicsModel_, rhsMask_, integrationType_, fieldName_); + tangent_ = new PhysicsModelTangentOperator(atc_,physicsModel_, rhsMask_, integrationType_, fieldName_); solverNL_ = new NonLinearSolver(tangent_,&bcs,0,parallel_); - + if (solverTol_) solverNL_->set_residual_tolerance(solverTol_); if (solverMaxIter_) solverNL_->set_max_iterations(solverMaxIter_); } @@ -173,11 +173,11 @@ bool PoissonSolver::solve(FIELDS & fields, FIELDS & rhs) if (linear_) {converged = solver_->solve(f,r);} else {converged = solverNL_->solve(f);} - if (atc_->source_atomic_quadrature(fieldName_) + if (atc_->source_atomic_quadrature(fieldName_) && LammpsInterface::instance()->atom_charge() ) set_charges(fields); return converged; } -bool PoissonSolver::solve(DENS_MAT & field, const DENS_MAT & rhs) +bool PoissonSolver::solve(DENS_MAT & field, const DENS_MAT & rhs) { CLON_VEC f = column(field,0); @@ -186,7 +186,7 @@ bool PoissonSolver::solve(DENS_MAT & field, const DENS_MAT & rhs) if (linear_) {converged = solver_->solve(f,r);} else {converged = solverNL_->solve(f);} - if (atc_->source_atomic_quadrature(fieldName_) + if (atc_->source_atomic_quadrature(fieldName_) && LammpsInterface::instance()->atom_charge() ) set_charges(atc_->fields()); return converged; } @@ -197,7 +197,7 @@ bool PoissonSolver::solve(DENS_MAT & field, const DENS_MAT & rhs) void PoissonSolver::set_charges(FIELDS & fields) { FIELD_MATS sources; - + atc_->compute_sources_at_atoms(rhsMask_, fields, physicsModel_,sources); FIELD_MATS::const_iterator nField = sources.find(fieldName_); if (nField != sources.end()) { diff --git a/lib/atc/PoissonSolver.h b/lib/atc/PoissonSolver.h index 8913c62134..cc176ee042 100644 --- a/lib/atc/PoissonSolver.h +++ b/lib/atc/PoissonSolver.h @@ -43,7 +43,7 @@ class PoissonSolver { ~PoissonSolver(); /** parser */ - bool modify(int narg, char **arg); + bool modify(int narg, char **arg); /** initialize */ void initialize(void); @@ -62,19 +62,19 @@ class PoissonSolver { } /** access to penalty coefficient */ - double penalty_coefficient() const + double penalty_coefficient() const { return solver_->penalty_coefficient(); } /** set tolerance for underlying solver */ - void set_tolerance(double tol) + void set_tolerance(double tol) { solverTol_ = tol; } /** set max iterations for underlying solver */ - void set_max_iterations(int maxIter) + void set_max_iterations(int maxIter) { solverMaxIter_ = maxIter; } @@ -83,7 +83,7 @@ class PoissonSolver { /** set atomic charges from electron model */ void set_charges(FIELDS & fields); - + /** Pointer to ATC_Tranfer */ ATC_Coupling * atc_; @@ -113,7 +113,7 @@ class PoissonSolver { /** solver */ LinearSolver * solver_; - NonLinearSolver *solverNL_; + NonLinearSolver *solverNL_; PhysicsModelTangentOperator * tangent_; int solverType_; double solverTol_; diff --git a/lib/atc/PolynomialSolver.cpp b/lib/atc/PolynomialSolver.cpp index b498b3b5bb..fc311f1e0b 100644 --- a/lib/atc/PolynomialSolver.cpp +++ b/lib/atc/PolynomialSolver.cpp @@ -59,12 +59,12 @@ namespace ATC { const double A = c[2] * c3inv; const double B = c[1] * c3inv; const double C = c[0] * c3inv; - + // substitute x = t - A/3 so t^3 + pt + q = 0 const double A2 = A*A; const double p = (1.0/3.0)*((-1.0/3.0)*A2 + B); const double q = 0.5*((2.0/27.0)*A*A2 - (1.0/3.0)*A*B + C); - + // Cardano's fomula const double p3 = p*p*p; const double D = q*q + p3; @@ -103,13 +103,13 @@ namespace ATC { } // solve ode with polynomial source : y'n + a_n-1 y'n-1 + ... = b_n x^n +... - void integrate_ode(double x, + void integrate_ode(double x, int na, double * a, double * y0, double * y, int nb, double * /* b */ ) { if (na == 2) { // particular if ( a[1] == 0) { - if ( a[0] == 0) { + if ( a[0] == 0) { y[0] = y0[0]+y0[1]*x; y[1] = y0[1]; } @@ -132,7 +132,7 @@ namespace ATC { c /= j; z *= x; y[0] += c*z; - } + } } else throw ATC_Error("can only integrate 2nd order ODEs currently"); } diff --git a/lib/atc/PrescribedDataManager.cpp b/lib/atc/PrescribedDataManager.cpp index 947191a0e4..72f6c75e79 100644 --- a/lib/atc/PrescribedDataManager.cpp +++ b/lib/atc/PrescribedDataManager.cpp @@ -18,7 +18,7 @@ namespace ATC { // PrescribedDataManager //------------------------------------------------------------------------- PrescribedDataManager::PrescribedDataManager - (FE_Engine * feEngine, + (FE_Engine * feEngine, const map & fieldSize) : fieldSizes_(fieldSize), feEngine_(feEngine) { @@ -34,8 +34,8 @@ namespace ATC { bcs_[thisField].reset(nNodes_,thisSize); for (int inode = 0; inode < nNodes_ ; ++inode) { for (int idof = 0; idof < thisSize ; ++idof) { - ics_[thisField](inode,idof) = nullptr; - bcs_[thisField](inode,idof) = nullptr; + ics_[thisField](inode,idof) = nullptr; + bcs_[thisField](inode,idof) = nullptr; } } // compact inode, value lists @@ -44,7 +44,7 @@ namespace ATC { elementSources_[thisField].reset(nElems_,thisSize); for (int ielem = 0; ielem < nElems_ ; ++ielem) { for (int idof = 0; idof < thisSize ; ++idof) { - elementSources_[thisField](ielem,idof) = nullptr; + elementSources_[thisField](ielem,idof) = nullptr; } } // node based sources @@ -70,14 +70,14 @@ namespace ATC { // construct & initialize internal data nNodes_ = feEngine_->num_nodes(); nElems_ = feEngine_->num_elements(); - + // nodal ics & essential bcs ics_[fieldName].reset(nNodes_,size); bcs_[fieldName].reset(nNodes_,size); for (int inode = 0; inode < nNodes_ ; ++inode) { for (int idof = 0; idof < size ; ++idof) { - ics_[fieldName](inode,idof) = nullptr; - bcs_[fieldName](inode,idof) = nullptr; + ics_[fieldName](inode,idof) = nullptr; + bcs_[fieldName](inode,idof) = nullptr; } } @@ -85,7 +85,7 @@ namespace ATC { elementSources_[fieldName].reset(nElems_,size); for (int ielem = 0; ielem < nElems_ ; ++ielem) { for (int idof = 0; idof < size ; ++idof) { - elementSources_[fieldName](ielem,idof) = nullptr; + elementSources_[fieldName](ielem,idof) = nullptr; } } } @@ -98,7 +98,7 @@ namespace ATC { // check to see if field exists if (fieldSizes_.find(fieldName) == fieldSizes_.end()) return; - + // delete field in maps fieldSizes_.erase(fieldName); ics_.erase(fieldName); @@ -110,28 +110,28 @@ namespace ATC { // fix_initial_field //------------------------------------------------------------------------- void PrescribedDataManager::fix_initial_field - (const string nodesetName, - const FieldName thisField, - const int thisIndex, + (const string nodesetName, + const FieldName thisField, + const int thisIndex, const XT_Function * f) { set nodeSet = (feEngine_->fe_mesh())->nodeset(nodesetName); set::const_iterator iset; for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { int inode = *iset; - ics_[thisField](inode,thisIndex) = (XT_Function*) f; + ics_[thisField](inode,thisIndex) = (XT_Function*) f; } } //------------------------------------------------------------------------- // fix_field //------------------------------------------------------------------------- void PrescribedDataManager::fix_field - (const std::set nodeSet, - const FieldName thisField, - const int thisIndex, + (const std::set nodeSet, + const FieldName thisField, + const int thisIndex, const XT_Function * f) { - // fix fields + // fix fields set::const_iterator iset; for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { int inode = *iset; @@ -139,9 +139,9 @@ namespace ATC { } } void PrescribedDataManager::fix_field - (const string nodesetName, - const FieldName thisField, - const int thisIndex, + (const string nodesetName, + const FieldName thisField, + const int thisIndex, const XT_Function * f) { set nodeSet = (feEngine_->fe_mesh())->nodeset(nodesetName); @@ -151,8 +151,8 @@ namespace ATC { // unfix_field //------------------------------------------------------------------------- void PrescribedDataManager::unfix_field - (const string nodesetName, - const FieldName thisField, + (const string nodesetName, + const FieldName thisField, const int thisIndex) { set nodeSet = (feEngine_->fe_mesh())->nodeset(nodesetName); @@ -167,9 +167,9 @@ namespace ATC { // fix_field //------------------------------------------------------------------------- void PrescribedDataManager::fix_field - (const int nodeId, - const FieldName thisField, - const int thisIndex, + (const int nodeId, + const FieldName thisField, + const int thisIndex, const XT_Function * f) { bcs_[thisField](nodeId,thisIndex) = (XT_Function*) f; @@ -178,8 +178,8 @@ namespace ATC { // unfix_field //------------------------------------------------------------------------- void PrescribedDataManager::unfix_field - (const int nodeId, - const FieldName thisField, + (const int nodeId, + const FieldName thisField, const int thisIndex) { bcs_[thisField](nodeId,thisIndex) = nullptr; @@ -188,12 +188,12 @@ namespace ATC { // fix_flux //------------------------------------------------------------------------- void PrescribedDataManager::fix_flux - (const string facesetName, - const FieldName thisField, - const int thisIndex, + (const string facesetName, + const FieldName thisField, + const int thisIndex, const XT_Function * f) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -203,7 +203,7 @@ namespace ATC { if (dof.size() == 0) { int ndof = (fieldSizes_.find(thisField))->second; dof.reset(ndof); - for(int i = 0; i < ndof; i++) dof(i) = nullptr; + for(int i = 0; i < ndof; i++) dof(i) = nullptr; } dof(thisIndex) = (XT_Function*) f; } @@ -212,11 +212,11 @@ namespace ATC { // unfix_flux //------------------------------------------------------------------------- void PrescribedDataManager::unfix_flux - (const string facesetName, - const FieldName thisField, - const int thisIndex) + (const string facesetName, + const FieldName thisField, + const int thisIndex) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -229,12 +229,12 @@ namespace ATC { // fix_robin //------------------------------------------------------------------------- void PrescribedDataManager::fix_robin - (const string facesetName, - const FieldName thisField, - const int thisIndex, + (const string facesetName, + const FieldName thisField, + const int thisIndex, const UXT_Function * f) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -244,7 +244,7 @@ namespace ATC { if (dof.size() == 0) { int ndof = (fieldSizes_.find(thisField))->second; dof.reset(ndof); - for(int i = 0; i < ndof; i++) dof(i) = nullptr; + for(int i = 0; i < ndof; i++) dof(i) = nullptr; } dof(thisIndex) = (UXT_Function*) f; } @@ -253,11 +253,11 @@ namespace ATC { // unfix_robin //------------------------------------------------------------------------- void PrescribedDataManager::unfix_robin - (const string facesetName, - const FieldName thisField, - const int thisIndex) + (const string facesetName, + const FieldName thisField, + const int thisIndex) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -270,10 +270,10 @@ namespace ATC { // fix_open //------------------------------------------------------------------------- void PrescribedDataManager::fix_open - (const string facesetName, + (const string facesetName, const FieldName thisField) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -285,10 +285,10 @@ namespace ATC { // unfix_open //------------------------------------------------------------------------- void PrescribedDataManager::unfix_open - (const string facesetName, - const FieldName thisField) + (const string facesetName, + const FieldName thisField) { - const set< pair > * fset + const set< pair > * fset = & ( (feEngine_->fe_mesh())->faceset(facesetName)); set< pair >::const_iterator iset; for (iset = fset->begin(); iset != fset->end(); iset++) { @@ -300,9 +300,9 @@ namespace ATC { // fix_source //------------------------------------------------------------------------- void PrescribedDataManager::fix_source - (const string elemsetName, - const FieldName thisField, - const int thisIndex, + (const string elemsetName, + const FieldName thisField, + const int thisIndex, const XT_Function *f) { set elemSet = (feEngine_->fe_mesh())->elementset(elemsetName); @@ -317,8 +317,8 @@ namespace ATC { // fix_source //------------------------------------------------------------------------- void PrescribedDataManager::fix_source - (const FieldName thisField, - const int thisIndex, + (const FieldName thisField, + const int thisIndex, const set > & s) { set >::const_iterator iset; @@ -334,8 +334,8 @@ namespace ATC { // unfix_source //------------------------------------------------------------------------- void PrescribedDataManager::unfix_source - (const string elemsetName, - const FieldName thisField, + (const string elemsetName, + const FieldName thisField, const int thisIndex) { set elemSet = (feEngine_->fe_mesh())->elementset(elemsetName); @@ -348,7 +348,7 @@ namespace ATC { //------------------------------------------------------------------------- // set_initial_conditions //------------------------------------------------------------------------- - void PrescribedDataManager::set_initial_conditions(const double t, + void PrescribedDataManager::set_initial_conditions(const double t, FIELDS &fields, FIELDS &dot_fields, FIELDS &ddot_fields, @@ -367,15 +367,15 @@ namespace ATC { for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { XT_Function *f = ics_[thisField](inode,thisIndex); if (!f) f = bcs_[thisField](inode,thisIndex); - if (f) + if (f) { - DENS_VEC coords(3); + DENS_VEC coords(3); coords = (feEngine_->fe_mesh())->nodal_coordinates(inode); double *x = coords.ptr(); myField(inode,thisIndex) = f->f(x,t); - myDotField(inode,thisIndex) = f->dfdt(x,t); - myDDotField(inode,thisIndex) = f->ddfdt(x,t); - myDDDotField(inode,thisIndex) = f->dddfdt(x,t); + myDotField(inode,thisIndex) = f->dfdt(x,t); + myDDotField(inode,thisIndex) = f->ddfdt(x,t); + myDDDotField(inode,thisIndex) = f->dddfdt(x,t); } else { myField(inode,thisIndex) = 0; @@ -397,7 +397,7 @@ namespace ATC { //------------------------------------------------------------------------- // set_fixed_fields //------------------------------------------------------------------------- - void PrescribedDataManager::set_fixed_fields(const double t, + void PrescribedDataManager::set_fixed_fields(const double t, FIELDS &fields, FIELDS &dot_fields, FIELDS &ddot_fields, @@ -408,20 +408,20 @@ namespace ATC { FieldName thisField = field->first; int thisSize = field->second; for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { - BC_SET & bcs = (bcValues_[thisField])[thisIndex]; + BC_SET & bcs = (bcValues_[thisField])[thisIndex]; bcs.clear(); for (int inode = 0; inode < nNodes_ ; ++inode) { XT_Function * f = bcs_[thisField](inode,thisIndex); if (f) { - DENS_VEC coords(3); + DENS_VEC coords(3); coords = (feEngine_->fe_mesh())->nodal_coordinates(inode); double * x = coords.ptr(); double val = f->f(x,t); - + (fields [thisField].set_quantity())(inode,thisIndex) = val; - (dot_fields [thisField].set_quantity())(inode,thisIndex) = f->dfdt(x,t); - (ddot_fields [thisField].set_quantity())(inode,thisIndex) = f->ddfdt(x,t); - (dddot_fields[thisField].set_quantity())(inode,thisIndex) = f->dddfdt(x,t); + (dot_fields [thisField].set_quantity())(inode,thisIndex) = f->dfdt(x,t); + (ddot_fields [thisField].set_quantity())(inode,thisIndex) = f->ddfdt(x,t); + (dddot_fields[thisField].set_quantity())(inode,thisIndex) = f->dddfdt(x,t); // compact set pair bc = make_pair(inode,val); bcs.insert(bc); @@ -434,7 +434,7 @@ namespace ATC { // set_fixed_field //------------------------------------------------------------------------- void PrescribedDataManager::set_fixed_field( - const double t, + const double t, const FieldName & fieldName, DENS_MAT & fieldMatrix) { @@ -447,7 +447,7 @@ namespace ATC { for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { XT_Function * f = bcs_[fieldName](inode,thisIndex); if (f) { - DENS_VEC coords(3); + DENS_VEC coords(3); coords = (feEngine_->fe_mesh())->nodal_coordinates(inode); fieldMatrix(inode,thisIndex) = f->f(coords.ptr(),t); } @@ -458,7 +458,7 @@ namespace ATC { // set_fixed_dfield //------------------------------------------------------------------------- void PrescribedDataManager::set_fixed_dfield( - const double t, + const double t, const FieldName & fieldName, DENS_MAT & dfieldMatrix) { @@ -471,7 +471,7 @@ namespace ATC { for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { XT_Function * f = bcs_[fieldName](inode,thisIndex); if (f) { - DENS_VEC coords(3); + DENS_VEC coords(3); coords = (feEngine_->fe_mesh())->nodal_coordinates(inode); dfieldMatrix(inode,thisIndex) = f->dfdt(coords.ptr(),t); } @@ -482,7 +482,7 @@ namespace ATC { // set_sources //------------------------------------------------------------------------- void PrescribedDataManager::set_sources - (double t, + (double t, FIELDS & sources) { // zero @@ -497,7 +497,7 @@ namespace ATC { } // compute boundary fluxes feEngine_->add_fluxes(fieldMask,t,faceSources_,sources); - + // compute internal sources feEngine_->add_sources(fieldMask,t,elementSources_,sources); feEngine_->add_sources(fieldMask,t,nodalSources_,sources); @@ -510,20 +510,20 @@ namespace ATC { for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { XT_Function * f = bcs_[thisField](inode,thisIndex); if (f) { - + (sources[thisField].set_quantity())(inode,thisIndex) = 0.0; } } } } - + } //------------------------------------------------------------------------- // print //------------------------------------------------------------------------- - void PrescribedDataManager::print(void) + void PrescribedDataManager::print(void) { // print and check consistency enum dataType {FREE=0,FIELD,SOURCE}; @@ -548,17 +548,17 @@ namespace ATC { for (int ielem = 0; ielem < nElems_ ; ++ielem) { for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { f = elementSources_[thisField](ielem,thisIndex); - if (f) { + if (f) { feEngine_->element_connectivity(ielem,conn); for (int i = 0; i < conn.size() ; ++i) { int inode = conn(i); - if (bcTypes(inode,thisIndex) != FIELD) + if (bcTypes(inode,thisIndex) != FIELD) { bcTypes(inode,thisIndex) = SOURCE; } } } } } - map < pair, Array < XT_Function * > > & fset + map < pair, Array < XT_Function * > > & fset = faceSources_[thisField]; map < pair, Array < XT_Function * > > ::const_iterator iset; for (iset = fset.begin(); iset != fset.end(); iset++) { @@ -566,11 +566,11 @@ namespace ATC { Array < XT_Function * > fs = iset->second; for (int thisIndex = 0; thisIndex < thisSize ; ++thisIndex) { f = fs(thisIndex); - if (f) { + if (f) { feEngine_->face_connectivity(face,conn); for (int i = 0; i < conn.size() ; ++i) { int inode = conn(i); - if (bcTypes(inode,thisIndex) != FIELD) + if (bcTypes(inode,thisIndex) != FIELD) { bcTypes(inode,thisIndex) = SOURCE; } } } @@ -603,7 +603,7 @@ namespace ATC { int i = 0; for (iset = nodeSet.begin(); iset != nodeSet.end(); iset++) { int inode = *iset; - const BC_SET & allBCs + const BC_SET & allBCs = ((bcValues_.find(thisField))->second)[thisIndex]; BC_SET::const_iterator bset; for (bset = allBCs.begin(); bset != allBCs.end(); bset++) { diff --git a/lib/atc/PrescribedDataManager.h b/lib/atc/PrescribedDataManager.h index 738c34d593..330bf8ff65 100644 --- a/lib/atc/PrescribedDataManager.h +++ b/lib/atc/PrescribedDataManager.h @@ -19,8 +19,8 @@ namespace ATC { /** - * @class PrescribedDataManager - * @brief Base class for managing initial conditions, essential/natural "boundary" conditions and sources + * @class PrescribedDataManager + * @brief Base class for managing initial conditions, essential/natural "boundary" conditions and sources */ class PrescribedDataManager { @@ -29,7 +29,7 @@ namespace ATC { /** exclusive conditions: free | fixed field | flux or domain source */ //enum Bc_Type {FREE=0,FIELD,SOURCE}; - PrescribedDataManager(FE_Engine * feEngine, + PrescribedDataManager(FE_Engine * feEngine, const std::map & fieldSize); ~PrescribedDataManager(); @@ -38,34 +38,34 @@ namespace ATC { void remove_field(FieldName fieldName); /** direct access to ics */ - std::map < FieldName, Array2D < XT_Function * > > * + std::map < FieldName, Array2D < XT_Function * > > * ics(void) { return & ics_; } - const Array2D < XT_Function * > * + const Array2D < XT_Function * > * ics(FieldName fieldName) { return & ics_[fieldName]; } /** direct access to bcs */ - const std::map < FieldName, BCS > & bcs(void) const - { - return bcValues_; + const std::map < FieldName, BCS > & bcs(void) const + { + return bcValues_; } /** */ - const BCS & bcs(const FieldName fieldName) const - { - return (bcValues_.find(fieldName))->second; + const BCS & bcs(const FieldName fieldName) const + { + return (bcValues_.find(fieldName))->second; } /** */ void bcs - (const FieldName fieldName, const std::set nodes, BCS & bcs, + (const FieldName fieldName, const std::set nodes, BCS & bcs, bool local = false) const; /** */ - std::map < FieldName, Array2D < XT_Function * > > * + std::map < FieldName, Array2D < XT_Function * > > * bc_functions(void) { return & bcs_; } /** */ - const Array2D < XT_Function * > * + const Array2D < XT_Function * > * bc_functions(FieldName fieldName) { return & bcs_[fieldName]; } /** */ ROBIN_SURFACE_SOURCE * robin_functions(void) { return & faceSourcesRobin_; } - bool has_robin_source(FieldName fieldName) const { + bool has_robin_source(FieldName fieldName) const { return ((faceSourcesRobin_.find(fieldName)->second).size() > 0) ; } /** */ @@ -73,33 +73,33 @@ namespace ATC { robin_functions(FieldName fieldName) { return & faceSourcesRobin_[fieldName]; } /** */ OPEN_SURFACE * open_faces(void) { return & facesOpen_; } - bool has_open_face(FieldName fieldName) const { + bool has_open_face(FieldName fieldName) const { return ((facesOpen_.find(fieldName)->second).size() > 0) ; } /** */ const std::set * open_faces(FieldName fieldName) { return & facesOpen_[fieldName]; } - + /** query initial state */ - bool is_initially_fixed(const int node, + bool is_initially_fixed(const int node, const FieldName thisField, const int thisIndex=0) const - { - return ((ics_.find(thisField)->second))(node,thisIndex) ? true : false ; + { + return ((ics_.find(thisField)->second))(node,thisIndex) ? true : false ; } /** query state */ - bool is_fixed(const int node, + bool is_fixed(const int node, const FieldName thisField, const int thisIndex=0) const - { - return ((bcs_.find(thisField)->second))(node,thisIndex) ? true : false ; + { + return ((bcs_.find(thisField)->second))(node,thisIndex) ? true : false ; } /** */ std::set fixed_nodes( const FieldName thisField, const int thisIndex=0) const - { + { std::set fixed; const Array2D < XT_Function *> & bcs = bcs_.find(thisField)->second; for (int node = 0; node < bcs.nRows() ; node++) { @@ -122,7 +122,7 @@ namespace ATC { bool all_fixed( const FieldName thisField, const int thisIndex=-1) const - { + { if (thisIndex < 0) { // static_casts are to iterface with std::vector without compiler warngings bool allFixed = (fixed_nodes(thisField,0).size() == static_cast(nNodes_) ); @@ -140,7 +140,7 @@ namespace ATC { bool none_fixed( const FieldName thisField, const int thisIndex=0) const - { + { return (fixed_nodes(thisField,thisIndex).size() == 0 ) && (faceSourcesRobin_.size() == 0) && (facesOpen_.size() == 0); @@ -150,9 +150,9 @@ namespace ATC { std::set flux_face_nodes( const FieldName thisField, const int thisIndex=0) const - { + { std::set fluxes; - //list of nodes to insert. + //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int *toInsert = new int[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; @@ -188,7 +188,7 @@ namespace ATC { std::set fluxes, const int thisIndex=0) const { - //list of nodes to insert. + //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int *toInsert = new int[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; @@ -221,9 +221,9 @@ namespace ATC { std::set flux_element_nodes( const FieldName thisField, const int thisIndex=0) const - { + { std::set fluxes; - //list of nodes to insert. + //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int *toInsert = new int[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; @@ -256,7 +256,7 @@ namespace ATC { std::set fluxes, const int thisIndex=0) const { - //list of nodes to insert. + //list of nodes to insert. //1 for nodes to insert, 0 for nodes not to insert. int *toInsert = new int[nNodes_]; for (int i = 0; i < nNodes_; ++i) toInsert[i] = 0; @@ -286,51 +286,51 @@ namespace ATC { bool no_fluxes( const FieldName thisField, const int thisIndex=0) const - { + { return ((flux_element_nodes(thisField,thisIndex).size() == 0) && (flux_face_nodes(thisField,thisIndex).size() == 0)); } - + /** set initial field values */ - void fix_initial_field (const std::string nodesetName, - const FieldName thisField, - const int thisIndex, + void fix_initial_field (const std::string nodesetName, + const FieldName thisField, + const int thisIndex, const XT_Function * f); /** un/set field values at fixed nodesets */ - void fix_field (const std::set nodeset, - const FieldName thisField, - const int thisIndex, + void fix_field (const std::set nodeset, + const FieldName thisField, + const int thisIndex, const XT_Function * f); /** un/set field values at fixed nodesets */ - void fix_field (const std::string nodesetName, - const FieldName thisField, - const int thisIndex, + void fix_field (const std::string nodesetName, + const FieldName thisField, + const int thisIndex, const XT_Function * f); - void unfix_field (const std::string nodesetName, - const FieldName thisField, - const int thisIndex); + void unfix_field (const std::string nodesetName, + const FieldName thisField, + const int thisIndex); /** un/set field values at fixed nodes */ - void fix_field (const int nodeId, - const FieldName thisField, - const int thisIndex, + void fix_field (const int nodeId, + const FieldName thisField, + const int thisIndex, const XT_Function * f); - void unfix_field (const int nodeId, - const FieldName thisField, - const int thisIndex); + void unfix_field (const int nodeId, + const FieldName thisField, + const int thisIndex); /** un/set fluxes */ void fix_flux (const std::string facesetName, - const FieldName thisField, - const int thisIndex, + const FieldName thisField, + const int thisIndex, const XT_Function * f); void unfix_flux(const std::string facesetName, - const FieldName thisField, + const FieldName thisField, const int thisIndex); void fix_robin (const std::string facesetName, - const FieldName thisField, - const int thisIndex, + const FieldName thisField, + const int thisIndex, const UXT_Function * f); void unfix_robin(const std::string facesetName, - const FieldName thisField, + const FieldName thisField, const int thisIndex); void fix_open (const std::string facesetName, const FieldName thisField); @@ -338,37 +338,37 @@ namespace ATC { const FieldName thisField); /** un/set sources */ void fix_source(const std::string elemsetName, - const FieldName thisField, - const int thisIndex, + const FieldName thisField, + const int thisIndex, const XT_Function * f); - void fix_source( const FieldName thisField, - const int thisIndex, + void fix_source( const FieldName thisField, + const int thisIndex, const std::set > & source); void unfix_source(const std::string elemsetName, - const FieldName thisField, + const FieldName thisField, const int thisIndex); /** get initial conditions */ - void set_initial_conditions(const double time, + void set_initial_conditions(const double time, FIELDS & fields, FIELDS & dot_fields, FIELDS & ddot_fields, FIELDS & dddot_fields); /** get "boundary" conditions on fields */ - void set_fixed_fields(const double time, + void set_fixed_fields(const double time, FIELDS & fields, FIELDS & dot_fields, FIELDS & ddot_fields, FIELDS & dddot_fields); /** get "boundary" conditions on a single field */ - void set_fixed_field(const double time, + void set_fixed_field(const double time, const FieldName & fieldName, DENS_MAT & fieldMatrix); /** get "boundary" conditions on a single time derivative field */ - void set_fixed_dfield(const double time, + void set_fixed_dfield(const double time, const FieldName & fieldName, DENS_MAT & dfieldMatrix); /** get "sources" (flux and sources: divided by leading coef of ODE) */ - void set_sources(const double time, + void set_sources(const double time, FIELDS & sources); /** debugging status output */ @@ -396,13 +396,13 @@ namespace ATC { std::map < FieldName, Array2D < XT_Function * > > bcs_; /** sources : XT_Function * f = faceSources_[field][face](idof) */ - std::map < FieldName, std::map < std::pair , Array < XT_Function * > > > + std::map < FieldName, std::map < std::pair , Array < XT_Function * > > > faceSources_; /** sources : UXT_Function * f = faceSourcesRobin_[field][face](idof) */ - std::map < FieldName, std::map < std::pair , Array < UXT_Function * > > > + std::map < FieldName, std::map < std::pair , Array < UXT_Function * > > > faceSourcesRobin_; /** sources : facesOpen_[field][face] */ - std::map < FieldName, std::set < std::pair > > + std::map < FieldName, std::set < std::pair > > facesOpen_; /** sources : XT_Function * f = elementSources_[field](ielem,idof) */ std::map < FieldName, Array2D < XT_Function * > > elementSources_; diff --git a/lib/atc/Quadrature.cpp b/lib/atc/Quadrature.cpp index 94fe4a701c..d36031d89e 100644 --- a/lib/atc/Quadrature.cpp +++ b/lib/atc/Quadrature.cpp @@ -36,7 +36,7 @@ Quadrature::Quadrature() } // ----------------------------------------------------------------- -// line quadrature: positions & weights +// line quadrature: positions & weights // ----------------------------------------------------------------- /** domain of integration is -1 to 1 */ void Quadrature::set_line_quadrature(const int ng, double* xg, double* wg) @@ -74,7 +74,7 @@ void Quadrature::set_line_quadrature(const int ng, double* xg, double* wg) xg[9] = 0.97390653; wg[9] = 0.06667134; } else { - throw ATC_Error("Invalid choice of number of quadrature points"); + throw ATC_Error("Invalid choice of number of quadrature points"); } } diff --git a/lib/atc/Quadrature.h b/lib/atc/Quadrature.h index 7854e9c3f3..35aab4994c 100644 --- a/lib/atc/Quadrature.h +++ b/lib/atc/Quadrature.h @@ -2,9 +2,9 @@ #define QUADRATURE_H namespace ATC { -/** - * @class Quadrature - * @brief create quadrature lists +/** + * @class Quadrature + * @brief create quadrature lists */ class Quadrature { public: diff --git a/lib/atc/SchrodingerSolver.cpp b/lib/atc/SchrodingerSolver.cpp index 3819562a70..a59191a229 100644 --- a/lib/atc/SchrodingerSolver.cpp +++ b/lib/atc/SchrodingerSolver.cpp @@ -18,12 +18,12 @@ using std::min; using ATC_Utility::to_string; using ATC_Utility::sgn; -const double zero_tol = 1.e-12; -const double f_tol = 1.e-8; +const double zero_tol = 1.e-12; +const double f_tol = 1.e-8; namespace ATC { -enum oneDconservationEnum {ONED_DENSITY=0, ONED_FLUX, ONED_GLOBAL_FLUX}; +enum oneDconservationEnum {ONED_DENSITY=0, ONED_FLUX, ONED_GLOBAL_FLUX}; @@ -61,7 +61,7 @@ double fermi_dirac(const double E, const double T) //----------------------------------------------------- void SchrodingerSolver::initialize() { - SPAR_MAT sparseM; + SPAR_MAT sparseM; atc_->fe_engine()->compute_mass_matrix(sparseM); M_ = sparseM.dense_copy(); } @@ -83,7 +83,7 @@ double fermi_dirac(const double E, const double T) atc_->element_to_material_map(), stiffness_); DENS_MAT K(stiffness_.dense_copy()); set fixedNodes = prescribedDataMgr_->fixed_nodes(ELECTRON_WAVEFUNCTION); - const BC_SET & bcs + const BC_SET & bcs = (prescribedDataMgr_->bcs(ELECTRON_WAVEFUNCTION))[0]; DENS_MAT & psi = (atc_->field(ELECTRON_WAVEFUNCTION)).set_quantity(); DENS_MAT & eVecs = (atc_->field(ELECTRON_WAVEFUNCTIONS)).set_quantity(); @@ -97,13 +97,13 @@ double fermi_dirac(const double E, const double T) return true; } // (1) Helmholtz solve for inhomongeneous bcs - + LinearSolver helmholtzSolver_(K,bcs,LinearSolver::AUTO_SOLVE,-1,parallel_); - + psi.reset(nNodes_,1); - // (2) Eigenvalue solve + // (2) Eigenvalue solve helmholtzSolver_.eigen_system(eVals,eVecs,&M_); - return true; + return true; } //======================================================== @@ -119,7 +119,7 @@ double fermi_dirac(const double E, const double T) const Array< double > & oneDdxs, bool parallel ) - : SchrodingerSolver(fieldName, physicsModel, feEngine, prescribedDataMgr, + : SchrodingerSolver(fieldName, physicsModel, feEngine, prescribedDataMgr, atc, parallel), oneDslices_(oneDslices), oneDdxs_(oneDdxs) @@ -144,7 +144,7 @@ double fermi_dirac(const double E, const double T) DENS_MAT & Ef = (atc_->field(FERMI_ENERGY)).set_quantity(); DENS_MAT & n = (atc_->field(ELECTRON_DENSITY)).set_quantity(); DENS_MAT & T = (atc_->field(ELECTRON_TEMPERATURE)).set_quantity(); - + // stiffness = K + V M SPAR_MAT stiffness_; Array2D rhsMask(NUM_FIELDS,NUM_FLUX); @@ -158,7 +158,7 @@ double fermi_dirac(const double E, const double T) atc_->element_to_material_map(), stiffness_); DENS_MAT K(stiffness_.dense_copy()); - // Eigenvalue solve + // Eigenvalue solve DENS_MAT K1,M1; int nslices = oneDslices_.size(); DENS_MAT b ; @@ -186,24 +186,24 @@ double fermi_dirac(const double E, const double T) eigensolver.eigen_system(evals1,evecs1,&M1); eindex.clear(); for (int j = 0; j < snodes; j++) eindex.insert(iEVal++); - eVals.insert(eindex,one, evals1); + eVals.insert(eindex,one, evals1); eindex.clear(); for (int j = 0; j < snodes; j++) eindex.insert(j); eVecs.insert(slice,eindex,evecs1); // slice charge density n1.reset(snodes,1); - + set::const_iterator iset; double aveE_f = 0; - for (iset = slice.begin(); iset != slice.end(); iset++) { - int gnode = *iset; + for (iset = slice.begin(); iset != slice.end(); iset++) { + int gnode = *iset; aveE_f += Ef(gnode,0); } aveE_f /= snodes; -//#define VERBOSE +//#define VERBOSE #ifdef VERBOSE stringstream ss; - ss << " slice "+to_string(islice+1)+" E_f "+to_string(aveE_f) << "\n" + ss << " slice "+to_string(islice+1)+" E_f "+to_string(aveE_f) << "\n" << "#-----------------------------------------------\n" << "# E-Ef f psi n\n" << "#-----------------------------------------------\n"; @@ -211,17 +211,17 @@ double fermi_dirac(const double E, const double T) // B: compute charge density on slice int node = 0; for (iset = slice.begin(); iset != slice.end(); iset++) { // node - int gnode = *iset; + int gnode = *iset; double temp = T(gnode,0); for (int mode = 0; mode < snodes-nfixed; mode++) { double Ei = evals1(mode,0); double E = Ei-aveE_f; - double f = fermi_dirac(E,temp); + double f = fermi_dirac(E,temp); double psi1 = evecs1(node,mode); // 2nd index corresp to evals order #ifdef VERBOSE ss << node<<":"<set_fixed_nodes(); Te = alpha*Te0; - + schrodingerSolver_->solve(atc_->fields()); - + for (int l = 0; l < nNodes_; l++) { int count = 0; double T_e = Te(l,0); for (int m = 0; m < nNodes_; m++) { double f = fermi_dirac(E_I(m,0), T_e); - if (f > tol) count++; + if (f > tol) count++; } } // compute charge density DENS_MAN & n = atc_->field(ELECTRON_DENSITY); //(n.quantity()).print("DENSITY"); atc_->nodal_projection(ELECTRON_DENSITY,physicsModel_,n); - atc_->set_fixed_nodes(); - - + atc_->set_fixed_nodes(); + + // solve poisson eqn for electric potential atc_->set_fixed_nodes(); Te = alpha*Te0; poissonSolver_->solve(atc_->fields(),rhs); - + //DENS_MAT dn = n; //DENS_MAT dpsi = psi; //DENS_MAT dphi = phi; @@ -421,7 +421,7 @@ double fermi_dirac(const double E, const double T) //dn -= nPrev; //dpsi -= psiPrev; //dphi -= phiPrev; - + norm = (n.quantity()-nPrev).norm(); if (i == 0 && j==0) norm0 = (n.quantity()).norm(); //normPrev = norm; @@ -436,11 +436,11 @@ double fermi_dirac(const double E, const double T) // Tmax_ *= 0.5; } } - + //=================================================================== // SliceSchrodingerPoissonSolver //=================================================================== - SliceSchrodingerPoissonSolver::SliceSchrodingerPoissonSolver( + SliceSchrodingerPoissonSolver::SliceSchrodingerPoissonSolver( /*const*/ ATC_Coupling * atc, SchrodingerSolver * schrodingerSolver, PoissonSolver * poissonSolver, @@ -479,37 +479,37 @@ double fermi_dirac(const double E, const double T) Array2D nHistory(nslices,2); // target for constraint - double target = 0.0; + double target = 0.0; set & slice = oneDslices_(0); // note assume first slice is fixed - if (oneDconserve_ == ONED_FLUX) atc_->set_sources(); + if (oneDconserve_ == ONED_FLUX) atc_->set_sources(); DENS_MAT & nSource = (atc_->source(ELECTRON_DENSITY)).set_quantity(); - for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { + for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { if (oneDconserve_ == ONED_FLUX) target += nSource(*iset,0); else target += n(*iset,0); } - target /= slice.size(); + target /= slice.size(); #ifdef VERBOSE if (oneDconserve_ == ONED_FLUX) { if (target > 0) ATC::LammpsInterface::instance()->print_msg_once(" influx target "+ to_string(target)); else ATC::LammpsInterface::instance()->print_msg_once(" efflux target "+ to_string(target)); } #endif - + // A: self consistency loop between Phi and n(psi_i) double error = 1.0; - for (int i = 0; i < maxConsistencyIter_ ; ++i) { + for (int i = 0; i < maxConsistencyIter_ ; ++i) { atc_->set_fixed_nodes(); - if (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) - poissonSolver_->solve(atc_->fields(),rhs); + if (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) + poissonSolver_->solve(atc_->fields(),rhs); if (! atc_->prescribedDataMgr_->all_fixed(ELECTRON_DENSITY) ) { // iterate on Ef - //if (i==0) Ef = -1.0*phi;// E ~ -|e| \Phi, charge of electron e = 1 - Ef = -1.0*phi; - + //if (i==0) Ef = -1.0*phi;// E ~ -|e| \Phi, charge of electron e = 1 + Ef = -1.0*phi; + Ef +=Ef_shift_; // B: conservation constraint - for (int j = 0; j < maxConstraintIter_ ; ++j) { + for (int j = 0; j < maxConstraintIter_ ; ++j) { schrodingerSolver_->solve(atc_->fields()); // n(E_f) atc_->set_fixed_nodes(); error = update_fermi_energy(target,(j==0),fluxes);// root finder @@ -517,7 +517,7 @@ double fermi_dirac(const double E, const double T) ATC::LammpsInterface::instance()->print_msg_once(to_string(i)+":"+to_string(j)+" constraint_error "+to_string(error)+" / "+to_string(tol*target)+"\n"); #endif // exit condition based on constraint satisfaction - if (error < tol*fabs(target)) break; + if (error < tol*fabs(target)) break; } // loop j : flux constraint // error based on change in field (Cauchy convergence) if (i == 0) { @@ -556,7 +556,7 @@ double fermi_dirac(const double E, const double T) rhsMask(ELECTRON_DENSITY,FLUX) = true; //#define WIP_REJ atc_->compute_flux(rhsMask,atc_->fields_,fluxes,physicsModel_); - y = & ( fluxes[ELECTRON_DENSITY][oneDcoor_] ); + y = & ( fluxes[ELECTRON_DENSITY][oneDcoor_] ); } BCS bcs; double error = 0; @@ -571,10 +571,10 @@ double fermi_dirac(const double E, const double T) atc_->prescribedDataMgr_->bcs(ELECTRON_WAVEFUNCTION,slice,bcs,true); const BC_SET & bc = bcs[0]; int nFixed = bc.size(); - if (nFixed == nSlice) continue; // skip if all fixed + if (nFixed == nSlice) continue; // skip if all fixed double Y = 0.0, X = 0.0; double nAve = 0., phiAve = 0.; - for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { + for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; X += Ef(gnode,0); Y += (*y)(gnode,0); @@ -585,14 +585,14 @@ double fermi_dirac(const double E, const double T) Y /= nSlice; nAve /= nSlice; phiAve /= nSlice; - // now adjust Ef for each slice - double dY = Y - EfHistory_(islice,0); + // now adjust Ef for each slice + double dY = Y - EfHistory_(islice,0); double dX = X - EfHistory_(islice,1); - double err = target - Y; + double err = target - Y; if (target*Y < -zero_tol*target) { #ifdef VERBOSE cStr = " opp. SIGNS"; -#else +#else ATC::LammpsInterface::instance()->print_msg_once("WARNING: slice "+to_string(islice)+" target and quantity opposite signs "+to_string(Y)); #endif } @@ -601,21 +601,21 @@ double fermi_dirac(const double E, const double T) if (first) { dEf = (err < 0) ? -safe_dEf_ : safe_dEf_; } - else { + else { if (fabs(dY) < zero_tol*dX) throw ATC_Error("zero increment in conserved field on slice:"+to_string(islice)); dEf = err / dY * dX; if (fabs(dEf) > safe_dEf_) { dEf = safe_dEf_* dEf / fabs(dEf); #ifdef VERBOSE Estr = " !!"; -#else +#else ATC::LammpsInterface::instance()->print_msg_once("WARNING: slice "+to_string(islice)+ " large Delta E_f "+to_string(dEf)); #endif } } - for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { + for (set::const_iterator iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; - Ef(gnode,0) += dEf; + Ef(gnode,0) += dEf; } EfHistory_(islice,0) = Y; EfHistory_(islice,1) = X; @@ -624,14 +624,14 @@ double fermi_dirac(const double E, const double T) ATC::LammpsInterface::instance()->print_msg_once(" slice"+to_string(islice,2) +cStr+to_string(4,Y/target) +Estr+to_string(4,X)+" n"+to_string(5,nAve)+" phi"+to_string(4,phiAve)); //ATC::LammpsInterface::instance()->print_msg_once(" slice "+to_string(islice) +cStr+to_string(4,Y/target) +" E_f"+to_string(4,X)+dEstr+to_string(4,X-EfHistory_(std::max(0,islice-1),1))+" n"+to_string(4,nAve)+" phi"+to_string(4,phiAve)+" "+to_string(nFixed)+" dn "+to_string(4,dnAve)+" dphi "+to_string(4,dphiAve)); #endif - } // loop slice + } // loop slice return error; } //=================================================================== // GlobalSliceSchrodingerPoissonSolver //=================================================================== - GlobalSliceSchrodingerPoissonSolver::GlobalSliceSchrodingerPoissonSolver( + GlobalSliceSchrodingerPoissonSolver::GlobalSliceSchrodingerPoissonSolver( /*const*/ ATC_Coupling * atc, SchrodingerSolver * schrodingerSolver, PoissonSolver * poissonSolver, @@ -642,11 +642,11 @@ double fermi_dirac(const double E, const double T) double Ef0, double alpha, double safe_dEf, - double tol, + double tol, double mu, double D ) : SliceSchrodingerPoissonSolver(atc,schrodingerSolver,poissonSolver,physicsModel,maxConsistencyIter,maxConstraintIter,oneDconserve,0,0), - solver_(nullptr), + solver_(nullptr), mobility_(mu),diffusivity_(D) { Ef0_ = Ef0; @@ -680,10 +680,10 @@ double fermi_dirac(const double E, const double T) } A(0,0) = -2; A(0,1) = 1; - A(m-1,m-1) = -2; - A(m-1,m-2) = 1; + A(m-1,m-1) = -2; + A(m-1,m-2) = 1; //if (nfixed_ == 1) { A(m-1,m-1) = -1; } - double dx = oneDdxs_(0); + double dx = oneDdxs_(0); A *= 1./dx; A.print("stiffness",4); SPAR_MAT K(A); @@ -703,14 +703,14 @@ double fermi_dirac(const double E, const double T) B.print("gradient",4); SPAR_MAT G(B); G_ = G; - + DENS_MAT C(nNodes_,nNodes_); // local to ATC nodemap: k --> gnode = *iset int k = 0; set::const_iterator iset; for (int islice = 0; islice < nslices_; islice++) { set & slice = oneDslices_(islice); - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { double v = 0.5/dx; if ( k < sliceSize_ || k+1 > (nslices_-1)*sliceSize_ ) v *=2.0; if (islice > 0) { C(k,k-sliceSize_) += v; } @@ -732,7 +732,7 @@ double fermi_dirac(const double E, const double T) ATC::LammpsInterface::instance()->print_msg_once("schrodinger-poisson solver: Dirichlet INLET, Dirichlet; OUTLET"); else if (nfixed_ ==1) ATC::LammpsInterface::instance()->print_msg_once("schrodinger-poisson solver: Dirichlet INLET, Neumann; OUTLET"); - else + else ATC_Error("schrodinger-poisson solver:too many fixed"); } GlobalSliceSchrodingerPoissonSolver::~GlobalSliceSchrodingerPoissonSolver(void) { @@ -746,10 +746,10 @@ double fermi_dirac(const double E, const double T) DENS_MAT & Ef = (atc_->field(FERMI_ENERGY)).set_quantity(); Ef.reset(phi.nRows(),1); norm_ = norm0_ = 1.0; - for (int i = 0; i < maxConstraintIter_ ; ++i) { + for (int i = 0; i < maxConstraintIter_ ; ++i) { atc_->set_fixed_nodes(); if (! atc_->prescribedDataMgr_->all_fixed(ELECTRIC_POTENTIAL) ) { - poissonSolver_->solve(atc_->fields(),rhs); + poissonSolver_->solve(atc_->fields(),rhs); } else { ATC::LammpsInterface::instance()->print_msg_once("WARNING: phi is fixed"); @@ -771,10 +771,10 @@ double fermi_dirac(const double E, const double T) report(i+1); if (i == 0 && norm_ > tol_) norm0_ = norm_; else { if (norm_ < tol_*norm0_) break; } - } + } } //-------------------------------------------------------------------------- - void GlobalSliceSchrodingerPoissonSolver::exponential_electron_density() + void GlobalSliceSchrodingerPoissonSolver::exponential_electron_density() { std::cout << "******************HACK******************\n"; @@ -786,12 +786,12 @@ double fermi_dirac(const double E, const double T) for (int islice = 0; islice < nslices_; islice++) { set & slice = oneDslices_(islice); double aveE_f = 0.0; - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; aveE_f += Ef(gnode,0); } aveE_f /= slice.size(); - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; //std::cout << phi(gnode,0)+aveE_f << "\n"; //n(gnode,0) = -n0*exp(-(phi(gnode,0)+aveE_f)/(kBeV_*T)); @@ -806,7 +806,7 @@ double fermi_dirac(const double E, const double T) } } //-------------------------------------------------------------------------- - void GlobalSliceSchrodingerPoissonSolver::report(int i) + void GlobalSliceSchrodingerPoissonSolver::report(int i) { const DENS_MAT & phi = (atc_->fields_[ELECTRIC_POTENTIAL]).quantity(); const DENS_MAT & n = (atc_->fields_[ELECTRON_DENSITY] ).quantity(); @@ -852,8 +852,8 @@ double fermi_dirac(const double E, const double T) int j = nslices_-1; double lambdaN = 0.; std::string space = "*"; - if (nfixed_ == 1) { - lambdaN = lambda_(nslices_-2); + if (nfixed_ == 1) { + lambdaN = lambda_(nslices_-2); space = " "; } ss << to_string(nslices_,2) << space << to_string(6,dJn) << " " << to_string(6,lambdaN) << " " << to_string(6,F_(j)) << " " << to_string(6,Phi_(j)) << " " << to_string(6,n_(j)) << " " << to_string(6,J_(j)) << "\n"; @@ -874,7 +874,7 @@ double fermi_dirac(const double E, const double T) // grad phi for (int islice = 0; islice < nslices_; islice++) { set & slice = oneDslices_(islice); - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; f(k) = phi(gnode,0); k++; @@ -887,7 +887,7 @@ double fermi_dirac(const double E, const double T) // grad n for (int islice = 0; islice < nslices_; islice++) { set & slice = oneDslices_(islice); - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; f(k) = n(gnode,0); k++; @@ -906,7 +906,7 @@ double fermi_dirac(const double E, const double T) for (int islice = 0; islice < nslices_; islice++) { set & slice = oneDslices_(islice); J_(islice) = 0; - for (iset = slice.begin(); iset != slice.end(); iset++) { + for (iset = slice.begin(); iset != slice.end(); iset++) { J_(islice) += flux_(k); k++; } @@ -914,10 +914,10 @@ double fermi_dirac(const double E, const double T) //std::cout << islice << " J " << J_(islice) << "\n"; } //J_.print("J"); - dJ_ = G_*J_; + dJ_ = G_*J_; } //-------------------------------------------------------------------------- - void GlobalSliceSchrodingerPoissonSolver::update_fermi_level() + void GlobalSliceSchrodingerPoissonSolver::update_fermi_level() { DENS_MAT & Ef = (atc_->field(FERMI_ENERGY) ).set_quantity(); @@ -941,7 +941,7 @@ double fermi_dirac(const double E, const double T) Phi_(islice) = Phi; // average potential N /= slice.size(); n_(islice) = N; // average electron density - + //F_(j) += min(fabs(alpha_*lambda),safe_dEf_)*sgn(lambda); for (iset = slice.begin(); iset != slice.end(); iset++) { int gnode = *iset; diff --git a/lib/atc/SchrodingerSolver.h b/lib/atc/SchrodingerSolver.h index e2addc48a3..e81572af84 100644 --- a/lib/atc/SchrodingerSolver.h +++ b/lib/atc/SchrodingerSolver.h @@ -21,7 +21,7 @@ class PoissonSolver; /** * @class SchrodingerSolver - * @brief a class to solve the (time-independent) Schrodinger equation + * @brief a class to solve the (time-independent) Schrodinger equation */ class SchrodingerSolver { @@ -47,13 +47,13 @@ class SchrodingerSolver { void initialize(void); /** solve */ - virtual bool solve(FIELDS & fields); + virtual bool solve(FIELDS & fields); + - protected: - + /** Pointer to ATC */ ATC_Coupling * atc_; @@ -109,10 +109,10 @@ class SliceSchrodingerSolver : public SchrodingerSolver { void initialize(void); /** solve */ - virtual bool solve(FIELDS & fields); + virtual bool solve(FIELDS & fields); - Array< std::set > & slices(void){ return oneDslices_;} - Array< double > & dxs(void){ return oneDdxs_;} + Array< std::set > & slices(void){ return oneDslices_;} + Array< double > & dxs(void){ return oneDdxs_;} protected: @@ -177,7 +177,7 @@ class SliceSchrodingerPoissonSolver : public SchrodingerPoissonSolver { ); protected: int nslices_; - double update_fermi_energy(double target, bool first, + double update_fermi_energy(double target, bool first, GRAD_FIELD_MATS & fluxes); int oneDconserve_; int oneDcoor_; @@ -236,7 +236,7 @@ class GlobalSliceSchrodingerPoissonSolver : public SliceSchrodingerPoissonSolver /** * @class SchrodingerSolver - * @brief a manager class + * @brief a manager class */ class SchrodingerPoissonManager { public: @@ -247,7 +247,7 @@ class SchrodingerPoissonManager { bool modify(int narg, char **arg); /** initialize */ - SchrodingerPoissonSolver * initialize( + SchrodingerPoissonSolver * initialize( /*const*/ ATC_Coupling * atc, SchrodingerSolver * schrodingerSolver, PoissonSolver * poissonSolver, diff --git a/lib/atc/ShapeFunction.h b/lib/atc/ShapeFunction.h index 62b2138cd7..4b38b6296e 100644 --- a/lib/atc/ShapeFunction.h +++ b/lib/atc/ShapeFunction.h @@ -25,34 +25,34 @@ namespace ATC { * @class FeEngineInterface * @class Base class for defining interfaces to the finite element engine to handle different shape functions */ - + class FeEngineInterface { - + public: - + // constructor FeEngineInterface(FE_Engine * feEngine, DENS_MAN * coordinates) : feEngine_(feEngine), coordinates_(coordinates) {}; // destructor virtual ~FeEngineInterface() {}; - + /** evaluate shape function at a set of coordinates */ virtual void evaluate_shape_function(int index, POINT_VAL & data) = 0; - + protected: - + /** pointer to the engine */ FE_Engine * feEngine_; - + /** quantity defining locations */ DENS_MAN * coordinates_; - + private: - + // do not define FeEngineInterface(); - + }; /** @@ -63,7 +63,7 @@ namespace ATC { class FeEngineInterfacePu : public FeEngineInterface { public: - + // constructor FeEngineInterfacePu(FE_Engine * feEngine) : FeEngineInterface(feEngine) {}; @@ -94,7 +94,7 @@ namespace ATC { class FeEngineInterfaceMls : public FeEngineInterface { public: - + // constructor FeEngineInterfaceMls(FE_Engine * feEngine) : FeEngineInterface(feEngine) {}; @@ -130,7 +130,7 @@ namespace ATC { ShapeFunctionBase(FE_Engine * feEngine, DENS_MAN * coordinates) : DependencyManager(), feEngineInterface_(feEngine), coordinates_(coordinates) {coordinates_->register_dependence(this)}; - + // destructor virtual ~ShapeFunctionBase() {coordinates_->remove_dependence(this)}; @@ -184,7 +184,7 @@ namespace ATC { * @class ShapeFunction * @class Defines general shape functions for restriction and interpolation */ - + class ShapeFunction : public ShapeFunctionBase { public: @@ -229,7 +229,7 @@ namespace ATC { /** apply a reset if needed */ virtual void reset(); - + /** storage for shape function values, indexed by rows of coordinates */ vector values; @@ -239,7 +239,7 @@ namespace ATC { ShapeFunction(); }; - + /** * @class ShapeFunctionAtomic * @class Defines shape functions for restriction and interpolation for atomic data @@ -329,7 +329,7 @@ namespace ATC { // destructor virtual ~ShapeFunctionAtomicMask() {mask_->remove_dependence(this);}; - + protected: @@ -350,7 +350,7 @@ namespace ATC { * @class ShapeFunctionGrad * @class Defines general shape gradients functions for restriction and interpolation */ - + class ShapeFunctionGrad : public ShapeFunctionBase { public: @@ -395,7 +395,7 @@ namespace ATC { /** apply a reset if needed */ virtual void reset(); - + /** storage for shape function gradients, indexed by rows of coordinates */ vector values; @@ -405,7 +405,7 @@ namespace ATC { ShapeFunctionGrad(); }; - + /** * @class ShapeFunctionGradAtomic * @class Defines shape functions gradients for restriction and interpolation for atomic data @@ -495,7 +495,7 @@ namespace ATC { // destructor virtual ~ShapeFunctionGradAtomicMask() {mask_->remove_dependence(this);}; - + protected: diff --git a/lib/atc/SparseMatrix-inl.h b/lib/atc/SparseMatrix-inl.h index 2923d6daa5..3a46c193f2 100644 --- a/lib/atc/SparseMatrix-inl.h +++ b/lib/atc/SparseMatrix-inl.h @@ -6,17 +6,17 @@ namespace ATC_matrix { -template +template TRI_COORD::TRI_COORD(INDEX row, INDEX col) : i(row), j(col) {} -template -TRI_COORD::TRI_COORD(INDEX row, INDEX col, T val, bool add_to) +template +TRI_COORD::TRI_COORD(INDEX row, INDEX col, T val, bool add_to) : i(row), j(col), v(val), add(add_to) {} - + //----------------------------------------------------------------------------- // default constructor - creates an empty sparsematrix with specified size //----------------------------------------------------------------------------- template -SparseMatrix::SparseMatrix(INDEX rows, INDEX cols) +SparseMatrix::SparseMatrix(INDEX rows, INDEX cols) : _val(nullptr), _ia(nullptr), _ja(nullptr), _size(0), _nRowsCRS(0), hasTemplate_(false), _nRows(rows),_nCols(cols) {} //----------------------------------------------------------------------------- @@ -26,16 +26,16 @@ template SparseMatrix::SparseMatrix(const SparseMatrix& C) : Matrix(), _val(nullptr), _ia(nullptr), _ja(nullptr), hasTemplate_(false) { - _copy(C); + _copy(C); } //----------------------------------------------------------------------------- // copy constructor - converts from DenseMatrix //----------------------------------------------------------------------------- template -SparseMatrix::SparseMatrix(const DenseMatrix& C) +SparseMatrix::SparseMatrix(const DenseMatrix& C) : Matrix(), _val(nullptr), _ia(nullptr), _ja(nullptr), hasTemplate_(false) { - reset(C); + reset(C); } //----------------------------------------------------------------------------- @@ -43,9 +43,9 @@ SparseMatrix::SparseMatrix(const DenseMatrix& C) // an array of col indeces, and an array of nonzero values. //----------------------------------------------------------------------------- template -SparseMatrix::SparseMatrix(INDEX* rows, INDEX* cols, T* vals, +SparseMatrix::SparseMatrix(INDEX* rows, INDEX* cols, T* vals, INDEX size, INDEX nRows, INDEX nCols, INDEX nRowsCRS) - : hasTemplate_(true) + : hasTemplate_(true) { _val = vals; _ia = rows; @@ -77,7 +77,7 @@ void SparseMatrix::_create(INDEX size, INDEX nrows) ERROR_FOR_BACKTRACE exit(EXIT_FAILURE); } - if (!_ia) return; + if (!_ia) return; // automatically handle the ends of rowpointer *_ia = 0; // first non-zero is the zero index _ia[_nRowsCRS] = _size; // last row pointer is the size @@ -88,7 +88,7 @@ void SparseMatrix::_create(INDEX size, INDEX nrows) template void SparseMatrix::_delete() { - + std::vector >().swap(_tri); // completely deletes _tri if (_val) delete [] _val; if (_ia) delete [] _ia; @@ -101,7 +101,7 @@ void SparseMatrix::_delete() // full memory copy of C into this //----------------------------------------------------------------------------- template -void SparseMatrix::_copy(const SparseMatrix &C) +void SparseMatrix::_copy(const SparseMatrix &C) { compress(C); _delete(); @@ -116,7 +116,7 @@ void SparseMatrix::_copy(const SparseMatrix &C) _nCols = C._nCols; _nRows = C._nRows; if (_nCols > 0 && _nRows > 0) hasTemplate_ = true; // needs if since map seems to call the copy instead of the default constructor -} +} // this version is accessible to derived classes template void SparseMatrix::copy(const SparseMatrix &C) @@ -138,21 +138,21 @@ void SparseMatrix::_set_equal(const Matrix &r) for (INDEX i=0; i*>(ptr_r)) this->reset(r); else - { + { std::cout <<"Error in general sparse matrix assignment\n"; exit(1); } -} +} // General flat index by value operator (by nth nonzero) -template inline T SparseMatrix::operator[](INDEX i) const +template inline T SparseMatrix::operator[](INDEX i) const { - VICK(i); return _val[i]; + VICK(i); return _val[i]; } // General flat index by reference operator (by nth nonzero) template inline T& SparseMatrix::operator[](INDEX i) { - VICK(i); return _val[i]; + VICK(i); return _val[i]; } template @@ -163,7 +163,7 @@ T SparseMatrix::_zero = T(0); //----------------------------------------------------------------------------- template bool triplet_comparision(const TRI_COORD &x, const TRI_COORD &y) -{ +{ const bool row_less = (x.i) < (y.i); const bool row_equal = (x.i) == (y.i); const bool col_less = (x.j) < (y.j); @@ -174,7 +174,7 @@ bool triplet_comparision(const TRI_COORD &x, const TRI_COORD &y) //----------------------------------------------------------------------------- template bool triplets_equal(const TRI_COORD &x, const TRI_COORD &y) -{ +{ return x.i==y.i && x.j==y.j; } //----------------------------------------------------------------------------- @@ -217,12 +217,12 @@ SparseMatrix operator*(const SparseMatrix &A, const DiagonalMatrix& D) { GCK(A, D, A.nCols()!=D.nRows(),"SparseMatrix * DiagonalMatrix") SparseMatrix C(A); // C has same sparcity as A - + // C(i,j) = A(i,k) * D(k, j) * j==k INDEX i, ij; - for (i=0; i operator*(const SparseMatrix &A, const SparseMatrix &B) SparseMatrix C(A.nRows(), B.nCols()); if (At.empty() || B.empty()) return C; - + INDEX k, ki, kj; INDEX K = std::min(At._nRowsCRS, B._nRowsCRS); for (k=0; k::compress() // Sort and find the number of unique triplets. // Triplet values will all be not present in existing CRS structure. - const INDEX nUnique = CountUniqueTriplets(); + const INDEX nUnique = CountUniqueTriplets(); // Max number of rows in new CRS structure. const INDEX nRows = std::max((INDEX)_tri.back().i+1, _nRowsCRS); - + // make a new CRS structure INDEX *ia = new INDEX [nRows+1]; INDEX *ja = new INDEX [nUnique]; @@ -296,7 +296,7 @@ void SparseMatrix::compress() INDEX i; for (i=1; i::compress() for (i=0; i=_size)) { next = nextTRI; // advance the triplet counter, and skip voided TRIPLET entries @@ -324,7 +324,7 @@ void SparseMatrix::compress() else if (crs_pt < _size) { next = nextCRS; // Advance the CRS counter, don't set next if we are at the end. - if (++crs_pt < _size) { + if (++crs_pt < _size) { // advance to the row corresponding to this value while (crs_pt >= _ia[crs_row+1]) { crs_row++; @@ -360,8 +360,8 @@ INDEX SparseMatrix::CountUniqueTriplets() if (_tri.empty()) return _size; std::sort(_tri.begin(), _tri.end(), triplet_comparision); INDEX nUnique=1 + _size; - - typename std::vector >::reverse_iterator t; + + typename std::vector >::reverse_iterator t; // Loop backwards over all new triplets. for (t = _tri.rbegin(); t+1!=_tri.rend(); ++t) { // If this triplet is the same as the preceding one. @@ -388,7 +388,7 @@ bool SparseMatrix::has_entry(INDEX i, INDEX j) const template bool SparseMatrix::has_entry_uncompressed(INDEX i, INDEX j) const { - for (unsigned k=0; k<_tri.size() ; k++) { + for (unsigned k=0; k<_tri.size() ; k++) { if (_tri[k].i == i && _tri[k].j == j) return true; } return false; @@ -416,7 +416,7 @@ bool SparseMatrix::has_template(void) const // Index by copy operator - return zero if not found //----------------------------------------------------------------------------- template -T SparseMatrix::operator()(INDEX i, INDEX j) const +T SparseMatrix::operator()(INDEX i, INDEX j) const { MICK(i,j); // Matrix Index ChecKing compress(*this); @@ -438,7 +438,7 @@ T& SparseMatrix::operator()(INDEX i, INDEX j) if (f>=_ia[i] && f<_ia[i+1] && _ja[f] == j) return _val[f]; } // NEVER use index operator as LHS to modify values not already in the - // sparcity pattern - the crude check below will only catch this on the + // sparcity pattern - the crude check below will only catch this on the // second infraction. if (_zero != T(0)) std::cout << "Use add or set for SparseMatrix\n"; return _zero; @@ -489,7 +489,7 @@ TRIPLET SparseMatrix::triplet(INDEX i) const if (i >= _ia[_nRowsCRS]) { gerror("ERROR: tried indexing triplet of sparse matrix beyond range"); } - + INDEX row(std::lower_bound(_ia, _ia+_nRowsCRS, i)-_ia); row -= _ia[row] != i; return TRIPLET(row, _ja[i], _val[i]); @@ -511,11 +511,11 @@ void SparseMatrix::reset(INDEX rows, INDEX cols, bool /* zero */) template void SparseMatrix::resize(INDEX rows, INDEX cols, bool copy) { -//if (copy) throw; +//if (copy) throw; if (_nRowsCRS>rows) { _delete(); } - if (copy) + if (copy) _nRows = rows; _nCols = cols; // a check on this would be expensive } @@ -523,7 +523,7 @@ void SparseMatrix::resize(INDEX rows, INDEX cols, bool copy) // get sparsity from DenseMatrix, if TOL < 0, then only zero values are added //----------------------------------------------------------------------------- template -void SparseMatrix::reset(const DenseMatrix& D, double TOL) +void SparseMatrix::reset(const DenseMatrix& D, double TOL) { _delete(); // clears all values // if TOL is specified then TOL = TOL^2 * max(abs(D))^2 @@ -558,8 +558,8 @@ void SparseMatrix::dense_copy(DenseMatrix & D ) const { SparseMatrix::compress(*this); D.reset(nRows(),nCols()); - for (INDEX i=0; i<_nRowsCRS; i++) - for (INDEX j=_ia[i]; j<_ia[i+1]; j++) + for (INDEX i=0; i<_nRowsCRS; i++) + for (INDEX j=_ia[i]; j<_ia[i+1]; j++) D(i, _ja[j]) = _val[j]; } template @@ -573,15 +573,15 @@ DenseMatrix SparseMatrix::dense_copy(void) const // returns true if the matrix has no non-zero elements //----------------------------------------------------------------------------- template -bool SparseMatrix::empty() const +bool SparseMatrix::empty() const { - return _size==0 && _tri.empty(); + return _size==0 && _tri.empty(); } //----------------------------------------------------------------------------- -// returns the number of rows specified by the user +// returns the number of rows specified by the user //----------------------------------------------------------------------------- template -inline INDEX SparseMatrix::nRows() const +inline INDEX SparseMatrix::nRows() const { return _nRows; } @@ -589,12 +589,12 @@ inline INDEX SparseMatrix::nRows() const // returns ?????????????????????? //----------------------------------------------------------------------------- template -inline INDEX SparseMatrix::nRowsCRS() const +inline INDEX SparseMatrix::nRowsCRS() const { return _nRowsCRS; } //----------------------------------------------------------------------------- -// returns the number of columns specified by the user +// returns the number of columns specified by the user //----------------------------------------------------------------------------- template inline INDEX SparseMatrix::nCols() const @@ -605,21 +605,21 @@ inline INDEX SparseMatrix::nCols() const // returns the number of non-zeros in the matrix //----------------------------------------------------------------------------- template -INDEX SparseMatrix::size() const +INDEX SparseMatrix::size() const { compress(*this); - return _size; + return _size; } //----------------------------------------------------------------------------- // returns the number of nonzero elements in a row //----------------------------------------------------------------------------- template -INDEX SparseMatrix::RowSize(INDEX r) const +INDEX SparseMatrix::RowSize(INDEX r) const { compress(*this); GCHK(r>=_nRows, "Rowsize: invalid row"); if (r >= _nRowsCRS) return 0; - return _ia[r+1]-_ia[r]; + return _ia[r+1]-_ia[r]; } //----------------------------------------------------------------------------- // returns a pointer to the data, causes a compress @@ -628,22 +628,22 @@ template T* SparseMatrix::ptr() const { compress(*this); - return _val; + return _val; } template INDEX* SparseMatrix::rows() const { compress(*this); - return _ia; + return _ia; } template INDEX* SparseMatrix::cols() const { compress(*this); - return _ja; + return _ja; } //----------------------------------------------------------------------------- -// returns true if (i,j) falls in the user specified range +// returns true if (i,j) falls in the user specified range //----------------------------------------------------------------------------- template bool SparseMatrix::in_range(INDEX i, INDEX j) const @@ -654,7 +654,7 @@ bool SparseMatrix::in_range(INDEX i, INDEX j) const // assigns this sparsematrix from another one - full memory copy //----------------------------------------------------------------------------- template -SparseMatrix& SparseMatrix::operator=(const SparseMatrix &C) +SparseMatrix& SparseMatrix::operator=(const SparseMatrix &C) { _delete(); _copy(C); @@ -673,7 +673,7 @@ SparseMatrix& SparseMatrix::operator=(const T v) // scales this sparse matrix by a constant //----------------------------------------------------------------------------- template -void SparseMatrix::set_all_elements_to(const T &a) +void SparseMatrix::set_all_elements_to(const T &a) { compress(*this); for (INDEX i=0; i::set_all_elements_to(const T &a) // scales this sparse matrix by a constant //----------------------------------------------------------------------------- template -SparseMatrix& SparseMatrix::operator*=(const T &a) +SparseMatrix& SparseMatrix::operator*=(const T &a) { compress(*this); for (INDEX i=0; i& SparseMatrix::operator*=(const SparseMatrix &a) } //----------------------------------------------------------------------------- -// Adds two sparse matrices together. +// Adds two sparse matrices together. //----------------------------------------------------------------------------- template -SparseMatrix& SparseMatrix::operator+=(const SparseMatrix & R) +SparseMatrix& SparseMatrix::operator+=(const SparseMatrix & R) { compress(R); @@ -711,16 +711,16 @@ SparseMatrix& SparseMatrix::operator+=(const SparseMatrix & R) T *Rval = R.ptr(); int nRowsCRS = R.nRowsCRS(); - + int rowR, colR; T valR; - for (rowR = 0; rowR < nRowsCRS; ++rowR) { + for (rowR = 0; rowR < nRowsCRS; ++rowR) { for (int j = Ria[rowR]; j < Ria[rowR+1]; ++j) { colR = Rja[j]; valR = Rval[j]; - - // Because we simply want to add the value, we call add and let compress + + // Because we simply want to add the value, we call add and let compress // take care of the rest--we don't have to worry about extant entries. add(rowR, colR, valR); } @@ -729,13 +729,13 @@ SparseMatrix& SparseMatrix::operator+=(const SparseMatrix & R) } //----------------------------------------------------------------------------- -// Return matrix transpose +// Return matrix transpose //----------------------------------------------------------------------------- template -SparseMatrix SparseMatrix::transpose() const +SparseMatrix SparseMatrix::transpose() const { compress(*this); - SparseMatrix At(nCols(), nRows()); + SparseMatrix At(nCols(), nRows()); for (INDEX i=0; i<_nRowsCRS; i++) for (INDEX ij=_ia[i]; ij<_ia[i+1]; ij++) @@ -753,7 +753,7 @@ SparseMatrix& SparseMatrix::row_scale(const Vector &v) compress(*this); INDEX i,ij; GCK(*this, v, v.size()!=nRows(), "Incompatible Vector length in row_scale."); - for(i=0; i<_nRowsCRS; i++) + for(i=0; i<_nRowsCRS; i++) for(ij=_ia[i]; ij<_ia[i+1]; ij++) _val[ij] *= v[i]; return *this; } @@ -766,7 +766,7 @@ SparseMatrix& SparseMatrix::col_scale(const Vector &v) compress(*this); INDEX i,ij; GCK(*this, v, v.size()!=nCols(), "Incompatible Vector length in col_scale."); - for(i=0; i<_nRowsCRS; i++) + for(i=0; i<_nRowsCRS; i++) for(ij=_ia[i]; ij<_ia[i+1]; ij++) _val[ij] *= v[_ja[ij]]; return *this; } @@ -780,7 +780,7 @@ DenseVector SparseMatrix::col_sum() const INDEX i,ij; GCHK(!nRows(), "SparseMatrix::Matrix not initialized in col_sum.") DenseVector csum(nCols()); - for(i=0; i<_nRowsCRS; i++) + for(i=0; i<_nRowsCRS; i++) for(ij=_ia[i]; ij<_ia[i+1]; ij++) csum(_ja[ij]) += _val[ij]; return(csum); } @@ -793,8 +793,8 @@ DenseVector SparseMatrix::column_count() const compress(*this); INDEX i,j; DenseVector counts(nCols()); - - for (i=0; i<_nRowsCRS; i++) + + for (i=0; i<_nRowsCRS; i++) for(j=_ia[i]; j<_ia[i+1]; j++) counts(_ja[j])++; return(counts); } @@ -802,7 +802,7 @@ DenseVector SparseMatrix::column_count() const // Writes a the nonzeros of a row to a vector //----------------------------------------------------------------------------- template -void SparseMatrix::row(INDEX i, DenseVector& row, DenseVector& indx) const +void SparseMatrix::row(INDEX i, DenseVector& row, DenseVector& indx) const { compress(*this); GCHK(i>=nRows(), "get_row() - invalid row number"); @@ -814,7 +814,7 @@ void SparseMatrix::row(INDEX i, DenseVector& row, DenseVector& indx row.resize(RowSize(i)); indx.resize(row.size()); INDEX idx=0, ij; - for(ij=_ia[i]; ij<_ia[i+1]; ij++) + for(ij=_ia[i]; ij<_ia[i+1]; ij++) { row(idx) = _val[ij]; indx(idx++) = _ja[ij]; @@ -825,7 +825,7 @@ void SparseMatrix::row(INDEX i, DenseVector& row, DenseVector& indx //----------------------------------------------------------------------------- template void SparseMatrix:: -weighted_least_squares(const SparseMatrix &N, const DiagonalMatrix &D) +weighted_least_squares(const SparseMatrix &N, const DiagonalMatrix &D) { compress(N); GCK(N,D,N.nRows()!=D.nRows(),"SparseMatrix::WeightedLeastSquares()"); @@ -841,17 +841,17 @@ weighted_least_squares(const SparseMatrix &N, const DiagonalMatrix &D) compress(); } //----------------------------------------------------------------------------- -// Return a diagonal matrix containing the diagonal entries of this matrix +// Return a diagonal matrix containing the diagonal entries of this matrix //----------------------------------------------------------------------------- template -DiagonalMatrix SparseMatrix::diag() const +DiagonalMatrix SparseMatrix::diag() const { compress(*this); DiagonalMatrix D(nRows(), true); // initialized to zero INDEX i, ij; for (i=0; i<_nRowsCRS; i++) - { - for(ij=_ia[i]; ij<_ia[i+1]; ij++) + { + for(ij=_ia[i]; ij<_ia[i+1]; ij++) { if (_ja[ij]>=i) // have we reached or passed the diagonal? { @@ -866,14 +866,14 @@ DiagonalMatrix SparseMatrix::diag() const // Return a diagonal matrix containing row-sum lumped entries of the matrix //----------------------------------------------------------------------------- template -DiagonalMatrix SparseMatrix::row_sum_lump() const +DiagonalMatrix SparseMatrix::row_sum_lump() const { compress(*this); DiagonalMatrix D(nRows(), true); // initialized to zero INDEX i, ij; for (i=0; i<_nRowsCRS; i++) - { - for(ij=_ia[i]; ij<_ia[i+1]; ij++) + { + for(ij=_ia[i]; ij<_ia[i+1]; ij++) { D(i,i) += _val[ij]; } @@ -884,14 +884,14 @@ DiagonalMatrix SparseMatrix::row_sum_lump() const // output function - builds a string with each nonzero triplet value //----------------------------------------------------------------------------- template -std::string SparseMatrix::to_string() const +std::string SparseMatrix::to_string() const { compress(*this); - std::string out; + std::string out; INDEX i, ij; for(i=0; i<_nRowsCRS; i++) { - for(ij=_ia[i]; ij<_ia[i+1]; ij++) + for(ij=_ia[i]; ij<_ia[i+1]; ij++) { if (ij) out += "\n"; // append newline if not first nonzero out += "(" + ATC_Utility::to_string(i) + ", "; // append "(i," @@ -905,7 +905,7 @@ std::string SparseMatrix::to_string() const // returns the maximum value in the row //----------------------------------------------------------------------------- template -T SparseMatrix::row_max(INDEX row) const +T SparseMatrix::row_max(INDEX row) const { compress(*this); if (!RowSize(row)) return (T)0; // if there are no nonzeros in the row @@ -918,7 +918,7 @@ T SparseMatrix::row_max(INDEX row) const // returns the minimum value in the row //----------------------------------------------------------------------------- template -T SparseMatrix::row_min(INDEX row) const +T SparseMatrix::row_min(INDEX row) const { compress(*this); if (!RowSize(row)) return (T)0; // if there are no nonzeros in the row @@ -931,13 +931,13 @@ T SparseMatrix::row_min(INDEX row) const // prints a histogram of the values of a row to the screen //----------------------------------------------------------------------------- template -void SparseMatrix::print_row_histogram(const std::string &name, INDEX nbins) const +void SparseMatrix::print_row_histogram(const std::string &name, INDEX nbins) const { compress(*this); std::cout << "Begin histogram " << name << "\n"; - std::cout << "# rows: " << _nRows << " columns: " << _nCols + std::cout << "# rows: " << _nRows << " columns: " << _nCols << " size: " << _size << "\n"; - for(INDEX i=0; i<_nRows; i++) + for(INDEX i=0; i<_nRows; i++) { print_row_histogram(i, nbins); std::cout << "\n"; @@ -948,7 +948,7 @@ void SparseMatrix::print_row_histogram(const std::string &name, INDEX nbins) // prints a histogram of the values of a row to the screen //----------------------------------------------------------------------------- template -void SparseMatrix::print_row_histogram(INDEX row, INDEX nbins) const +void SparseMatrix::print_row_histogram(INDEX row, INDEX nbins) const { compress(*this); if (!nbins) nbins++; @@ -958,9 +958,9 @@ void SparseMatrix::print_row_histogram(INDEX row, INDEX nbins) const const T range = max-min; const double bin_size = range/double(nbins); if (range<=0.0) counts[nbins-1]=RowSize(row); - else + else { - for(INDEX ij=_ia[row]; ij<_ia[row+1]; ij++) + for(INDEX ij=_ia[row]; ij<_ia[row+1]; ij++) { INDEX bin = INDEX((_val[ij]-min)/bin_size); counts[bin-(bin==nbins)]++; @@ -969,7 +969,7 @@ void SparseMatrix::print_row_histogram(INDEX row, INDEX nbins) const std::cout<::print_row_histogram(INDEX row, INDEX nbins) const // prints the triplets the screen //----------------------------------------------------------------------------- template -void SparseMatrix::print_triplets() const +void SparseMatrix::print_triplets() const { typename std::vector >::const_iterator t; std::string out; @@ -999,13 +999,13 @@ void SparseMatrix::print_triplets() const // Outputs a string to a sparse Matlab type //----------------------------------------------------------------------------- template -void SparseMatrix::matlab(std::ostream &o, const std::string &s) const +void SparseMatrix::matlab(std::ostream &o, const std::string &s) const { compress(*this); INDEX i, ij; o << s <<" = sparse(" << nRows() << "," << nCols() << ");\n"; o << std::showbase << std::scientific; - for(i=0; i<_nRowsCRS; i++) + for(i=0; i<_nRowsCRS; i++) for(ij=_ia[i]; ij<_ia[i+1]; ij++) o<::matlab(std::ostream &o, const std::string &s) const template void SparseMatrix::binary_write(std::fstream& f) const { - compress(*this); - f.write((char*)&_size, sizeof(INDEX)); // writes number of nonzeros + compress(*this); + f.write((char*)&_size, sizeof(INDEX)); // writes number of nonzeros f.write((char*)&_nRowsCRS, sizeof(INDEX)); // writes number of rows in crs f.write((char*)&_nRows, sizeof(INDEX)); // write matrix rows f.write((char*)&_nCols, sizeof(INDEX)); // write number of columns if (!_size) return; - f.write((char*)_val, sizeof(T) *_size); - f.write((char*)_ja, sizeof(INDEX)*_size); - f.write((char*)_ia, sizeof(INDEX)*(_nRowsCRS+1)); + f.write((char*)_val, sizeof(T) *_size); + f.write((char*)_ja, sizeof(INDEX)*_size); + f.write((char*)_ia, sizeof(INDEX)*(_nRowsCRS+1)); } //----------------------------------------------------------------------------- // Reads a SparseMatrix from a binary file. (wipes out any original data) @@ -1041,7 +1041,7 @@ void SparseMatrix::binary_read(std::fstream& f) _create(_size,_nRowsCRS); f.read((char*)_val, sizeof(T)*_size); f.read((char*)_ja, sizeof(INDEX)*_size); - f.read((char*)_ia, sizeof(INDEX)*(_nRowsCRS+1)); + f.read((char*)_ia, sizeof(INDEX)*(_nRowsCRS+1)); } //----------------------------------------------------------------------------- diff --git a/lib/atc/SparseMatrix.h b/lib/atc/SparseMatrix.h index 700d2f3af6..2d219c8963 100644 --- a/lib/atc/SparseMatrix.h +++ b/lib/atc/SparseMatrix.h @@ -10,7 +10,7 @@ namespace ATC_matrix { * @struct TRI_COORD * @brief Triplet SparseMatrix entry */ -template +template struct TRI_COORD { TRI_COORD(INDEX row=0, INDEX col=0); @@ -25,7 +25,7 @@ void ParMultAB(MPI_Comm comm, const SparseMatrix& A, const Matrix& B, Dens /** * @class SparseMatrix - * @brief Stores data in triplet format or CRS format + * @brief Stores data in triplet format or CRS format */ template class SparseMatrix : public Matrix @@ -50,10 +50,10 @@ public: SparseMatrix(INDEX rows=0, INDEX cols=0); SparseMatrix(const SparseMatrix& c); SparseMatrix(const DenseMatrix& c); - SparseMatrix(INDEX* rows, INDEX* cols, T* vals, INDEX size, + SparseMatrix(INDEX* rows, INDEX* cols, T* vals, INDEX size, INDEX nRows, INDEX nCols, INDEX nRowsCRS); virtual ~SparseMatrix() { _delete(); } - + //* General index by value (requires a binary search on the row) T operator()(INDEX i, INDEX j) const; //* General index by reference (requires a binary search on the row) @@ -74,10 +74,10 @@ public: //* only changes the bounds of the matrix, no deletion void resize(INDEX rows=0, INDEX cols=0, bool zero=true); //* reset - from DenseMatrix - this will be SLOW - void reset(const DenseMatrix& D, double TOL=-1.0); + void reset(const DenseMatrix& D, double TOL=-1.0); //* copy data void copy(const T * ptr, INDEX rows=0, INDEX cols=0); - + void dense_copy(DenseMatrix& D) const; DenseMatrix dense_copy(void) const; @@ -87,7 +87,7 @@ public: INDEX nRows() const; INDEX nRowsCRS() const; //* returns the user-specified number of cols - INDEX nCols() const; + INDEX nCols() const; //* returns the number of non-zero elements INDEX size() const; //* returns the number of non-zeros in a row @@ -248,23 +248,23 @@ public: //! Reads a SparseMatrix from a binary file. (wipes out any original data) void binary_read(std::fstream& f); //* Dump templated type to disk; operation not safe for all types - void write_restart(FILE *f) const; + void write_restart(FILE *f) const; /* * \section Utility functions */ //* converts all triplets and merges with CRS - void compress(); + void compress(); //* converts T to CRS - static void compress(const SparseMatrix &C); + static void compress(const SparseMatrix &C); //* sorts and returns the # of unique triplets - INDEX CountUniqueTriplets(); + INDEX CountUniqueTriplets(); private: //* creates a CRS structure void _create(INDEX size, INDEX nrows); //* clears all memory and nulls references - void _delete(); + void _delete(); //* copies all data from another SparseMatrix void _copy(const SparseMatrix &C); //* general sparse matrix assignment @@ -279,7 +279,7 @@ protected: T * _val; // matrix non-zeros INDEX *_ia, *_ja; // ptrs to rows, column indexes INDEX _size, _nRowsCRS; // # of non-zeros, rows - bool hasTemplate_; + bool hasTemplate_; void copy(const SparseMatrix &C); @@ -287,7 +287,7 @@ protected: mutable std::vector > _tri; /* * \section User specified variables - */ + */ INDEX _nRows, _nCols; static T _zero; }; diff --git a/lib/atc/SparseVector-inl.h b/lib/atc/SparseVector-inl.h index 7f2c844bd6..81fed4d538 100644 --- a/lib/atc/SparseVector-inl.h +++ b/lib/atc/SparseVector-inl.h @@ -10,7 +10,7 @@ SparseVector sparse_rand(INDEX n, INDEX fill, int seed=1234) srand(seed); const double rmax_inv = 1.0/double(RAND_MAX); SparseVector r(n); - while (r.size() &a, const SparseVector &b) STORE::const_iterator bi=b.data_.find(ai->first); if (bi == b.data_.end()) continue; v += ai->second * bi->second; - } + } return v; } // Computes the product of a SparseMatrix transpose with a SparseVector (M'*v). @@ -70,7 +70,7 @@ SparseVector operator*(const SparseMatrix &M, const SparseVector &v) } if (yi!=0.0) y(i)+=yi; } - return y; + return y; } // computes the product of a SparseMatrix transpose with a SparseVector (M'*v). @@ -81,7 +81,7 @@ SparseVector operator*(const SparseVector &v, const SparseMatrix &M) for (INDEX i=0; isecond * M._v[ij]; } return y; @@ -104,7 +104,7 @@ std::string SparseVector::to_string() const return str; } -// Indexes the ith component of the vector or returns zero if not found. +// Indexes the ith component of the vector or returns zero if not found. template T SparseVector::operator()(INDEX i, INDEX /* j */) const { @@ -113,27 +113,27 @@ T SparseVector::operator()(INDEX i, INDEX /* j */) const return it->second; } -// Indexes the ith component of the vector or returns zero if not found. +// Indexes the ith component of the vector or returns zero if not found. template T& SparseVector::operator()(INDEX i, INDEX /* j */) { - return data_[i]; + return data_[i]; } -// Indexes the ith component of the vector or returns zero if not found. +// Indexes the ith component of the vector or returns zero if not found. template T SparseVector::operator[](INDEX i) const { return (*this)(i); } -// Indexes the ith component of the vector or returns zero if not found. +// Indexes the ith component of the vector or returns zero if not found. template T& SparseVector::operator[](INDEX i) { return (*this)(i); } // Returns a pair (index, value) for a nonzero in the vector. -template +template std::pair SparseVector::pair(INDEX i) const { STORE::const_iterator it=data_.begin() + i; @@ -141,7 +141,7 @@ std::pair SparseVector::pair(INDEX i) const } //* Adds SparseVector x, scaled by s to this one. Can be different sparcity. -template +template void SparseVector::add_scaled(SparseVector& x, const T& s) { STORE::const_iterator it; @@ -212,7 +212,7 @@ void SparseVector::write_restart(FILE */* F */) const { } -// writes a stream to a matlab script to recreate this variable +// writes a stream to a matlab script to recreate this variable template void SparseVector::matlab(std::ostream &o, const std::string &s) const { diff --git a/lib/atc/SparseVector.h b/lib/atc/SparseVector.h index d387b45b66..e2d6720193 100644 --- a/lib/atc/SparseVector.h +++ b/lib/atc/SparseVector.h @@ -12,8 +12,8 @@ template class SparseVector; template T dot(const SparseVector &a, const SparseVector &b); /** - * @class SparseVector - * @brief Class for vectors that contain a majority of zero elements and provides relevant operations + * @class SparseVector + * @brief Class for vectors that contain a majority of zero elements and provides relevant operations */ template @@ -37,17 +37,17 @@ class SparseVector : public Vector { public: //* Constructor - sets length of vector (NOT # of nonzeros). SparseVector(INDEX length=0); - //* Copies another SparseVector - SparseVector(const SparseVector &c); + //* Copies another SparseVector + SparseVector(const SparseVector &c); //* Copies a general Vector (avoid if possible, its going to be slow). - SparseVector(const Vector &c); + SparseVector(const Vector &c); //* Overrides output to string function to list only nonzeros and indices. std::string to_string() const; //* Indexing operators (w/ const overloading). //@{ T operator()(INDEX i, INDEX j=0) const; - + T& operator()(INDEX i, INDEX j=0); T operator[](INDEX i) const; T& operator[](INDEX i); @@ -88,9 +88,9 @@ protected: //@{ SparseVector(const Matrix &c); SparseVector& operator=(Matrix &c); - T* ptr() const {return nullptr; } + T* ptr() const {return nullptr; } //@} - + STORE data_; //*> sparse data structure INDEX length_; //*> number of rows }; @@ -98,6 +98,6 @@ protected: } // end namespace #include "SparseVector-inl.h" -#undef STORE +#undef STORE #endif diff --git a/lib/atc/SpeciesTimeIntegrator.cpp b/lib/atc/SpeciesTimeIntegrator.cpp index 3215b159f8..98e4e10268 100644 --- a/lib/atc/SpeciesTimeIntegrator.cpp +++ b/lib/atc/SpeciesTimeIntegrator.cpp @@ -24,7 +24,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor // Grab data from ATC - //-------------------------------------------------------- + //-------------------------------------------------------- SpeciesTimeIntegrator::SpeciesTimeIntegrator(ATC_CouplingMass * atc, TimeIntegrationType timeIntegrationType) : TimeIntegrator(atc, timeIntegrationType), @@ -88,7 +88,7 @@ namespace ATC { //-------------------------------------------------------- void SpeciesTimeIntegrator::pack_fields(RESTART_LIST & data) { - + TimeIntegrator::pack_fields(data); } @@ -101,7 +101,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor // Grab data from ATC - //-------------------------------------------------------- + //-------------------------------------------------------- SpeciesIntegrationMethod::SpeciesIntegrationMethod(SpeciesTimeIntegrator * speciesTimeIntegrator, const map > & moleculeIds) : TimeIntegrationMethod(speciesTimeIntegrator), @@ -124,10 +124,10 @@ namespace ATC { void SpeciesIntegrationMethod::construct_transfers() { InterscaleManager & interscaleManager = atc_->interscale_manager(); - + // get existing data nodalAtomicMassDensity_ = interscaleManager.dense_matrix(field_to_intrinsic_name(MASS_DENSITY)); - if (atc_->has_tracked_species()) + if (atc_->has_tracked_species()) nodalAtomicSpeciesConcentration_ = interscaleManager.dense_matrix(field_to_intrinsic_name(SPECIES_CONCENTRATION)); } @@ -139,7 +139,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- SpeciesTimeIntegratorFractionalStep::SpeciesTimeIntegratorFractionalStep(SpeciesTimeIntegrator * speciesTimeIntegrator, const map > & moleculeIds) : SpeciesIntegrationMethod(speciesTimeIntegrator,moleculeIds) @@ -161,10 +161,10 @@ namespace ATC { } if (!timeFilterManager->end_equilibrate()) { - nodalAtomicSpeciesConcentrationFiltered_ = nodalAtomicSpeciesConcentration_->quantity(); + nodalAtomicSpeciesConcentrationFiltered_ = nodalAtomicSpeciesConcentration_->quantity(); } - + pre_final_integrate1(0.); } @@ -172,7 +172,7 @@ namespace ATC { // pre_initial_integrate1 //-------------------------------------------------------- void SpeciesTimeIntegratorFractionalStep::pre_initial_integrate1(double dt) - { + { const DENS_MAT & my(nodalAtomicSpeciesConcentration_->quantity()); // updated filtered energy using explicit-implicit scheme timeFilter_->apply_pre_step1(nodalAtomicSpeciesConcentrationFiltered_.set_quantity(), @@ -182,15 +182,15 @@ namespace ATC { //-------------------------------------------------------- // pre_final_integrate1 - // first time integration computations + // first time integration computations // before FractionalStep step 2 //-------------------------------------------------------- void SpeciesTimeIntegratorFractionalStep::pre_final_integrate1(double /* dt */) { // Compute MD contribution to FEM equation - - - massDensity_ = nodalAtomicMassDensity_->quantity(); + + + massDensity_ = nodalAtomicMassDensity_->quantity(); speciesConcentration_ = nodalAtomicSpeciesConcentration_->quantity(); atc_->set_fixed_nodes(); } @@ -204,7 +204,7 @@ namespace ATC { timeFilter_->apply_post_step1( nodalAtomicSpeciesConcentrationFiltered_.set_quantity(), nodalAtomicSpeciesConcentration_->quantity(),dt); - speciesConcentration_ = nodalAtomicSpeciesConcentrationFiltered_.quantity(); + speciesConcentration_ = nodalAtomicSpeciesConcentrationFiltered_.quantity(); } //-------------------------------------------------------- @@ -213,7 +213,7 @@ namespace ATC { //-------------------------------------------------------- void SpeciesTimeIntegratorFractionalStep::post_process() { - + map >::const_iterator molecule; for (molecule = moleculeIds_.begin(); molecule != moleculeIds_.end(); molecule++) { DENS_MAN & nodalMoleculeMassDensityOut(atc_->tagged_dens_man(molecule->first)); diff --git a/lib/atc/SpeciesTimeIntegrator.h b/lib/atc/SpeciesTimeIntegrator.h index 64cc07022c..01e1659a09 100644 --- a/lib/atc/SpeciesTimeIntegrator.h +++ b/lib/atc/SpeciesTimeIntegrator.h @@ -13,48 +13,48 @@ namespace ATC { // forward declarations class ATC_CouplingMass; class SpeciesIntegrationMethod; - + /** * @class SpeciesTimeIntegrator * @brief Class for various time integrators for species FE quantities in the Eulerian frame * (handles parsing and stores basic data structures) */ - + class SpeciesTimeIntegrator : public TimeIntegrator { - + public: - + // constructor SpeciesTimeIntegrator(ATC_CouplingMass * atc, TimeIntegrationType timeIntegrationType); - + // destructor virtual ~SpeciesTimeIntegrator(){}; - + /** parser/modifier */ virtual bool modify(int narg, char **arg); - + /** create objects to implement requested numerical method */ virtual void construct_methods(); - + /** pack persistent fields */ virtual void pack_fields(RESTART_LIST & data); - + DENS_MAN & nodal_atomic_species_concentration_filtered() { return nodalAtomicSpeciesConcentrationFiltered_; } protected: - + /** sets of molecules tracked */ const std::map > & moleculeIds_; /** data */ DENS_MAN nodalAtomicSpeciesConcentrationFiltered_; - + private: - + // DO NOT define this SpeciesTimeIntegrator(); - + }; /** @@ -63,31 +63,31 @@ namespace ATC { */ class SpeciesIntegrationMethod : public TimeIntegrationMethod { - + public: - + // constructor SpeciesIntegrationMethod(SpeciesTimeIntegrator * speciesTimeIntegrator, const std::map > & moleculeIds); - + // destructor virtual ~SpeciesIntegrationMethod() {nodalAtomicMassDensity_=nullptr;}; /** create and get necessary transfer operators */ virtual void construct_transfers(); - + protected: /** time filtering object */ TimeFilter * timeFilter_; /** finite element mass density field */ DENS_MAN & massDensity_; - + /** atomic nodal mass density field */ // OBSOLETE? DENS_MAN & nodalAtomicMassDensityOut_; DENS_MAN * nodalAtomicMassDensity_; - + /** finite element mass density field */ DENS_MAN & speciesConcentration_; DENS_MAN * nodalAtomicSpeciesConcentration_; @@ -100,7 +100,7 @@ namespace ATC { // DO NOT define this SpeciesIntegrationMethod(); - + }; /** @@ -111,19 +111,19 @@ namespace ATC { */ class SpeciesTimeIntegratorFractionalStep : public SpeciesIntegrationMethod { - + public: - + // constructor SpeciesTimeIntegratorFractionalStep(SpeciesTimeIntegrator * speciesTimeIntegrator, const std::map > & moleculeIds); - + // destructor virtual ~SpeciesTimeIntegratorFractionalStep(){}; /** pre time integration */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer virtual void pre_initial_integrate1(double dt); virtual void pre_final_integrate1(double dt); @@ -131,12 +131,12 @@ namespace ATC { /** post processing step before output */ virtual void post_process(); - + private: - + // DO NOT define this SpeciesTimeIntegratorFractionalStep(); - + }; /** * @class SpeciesTimeIntegratorFractionalStepFiltered @@ -146,19 +146,19 @@ namespace ATC { */ class SpeciesTimeIntegratorFractionalStepFiltered : public SpeciesTimeIntegratorFractionalStep { - + public: - + // constructor SpeciesTimeIntegratorFractionalStepFiltered(SpeciesTimeIntegrator * speciesTimeIntegrator, const std::map > & moleculeIds); - + // destructor virtual ~SpeciesTimeIntegratorFractionalStepFiltered(){}; /** pre time integration */ virtual void initialize() {}; - + // time step methods, corresponding to ATC_Transfer /** first part of pre_final_integrate */ virtual void pre_final_integrate1(double dt); @@ -167,10 +167,10 @@ namespace ATC { virtual void post_process(){}; private: - + // DO NOT define this SpeciesTimeIntegratorFractionalStepFiltered(); - + }; }; diff --git a/lib/atc/Stress.cpp b/lib/atc/Stress.cpp index a1445bd8ea..90608dad15 100644 --- a/lib/atc/Stress.cpp +++ b/lib/atc/Stress.cpp @@ -1,9 +1,9 @@ #include "Stress.h" #include "CauchyBorn.h" #include "CBLattice.h" -#include "CbLjCut.h" -#include "CbLjSmoothLinear.h" -#include "CbEam.h" +#include "CbLjCut.h" +#include "CbLjSmoothLinear.h" +#include "CbEam.h" #include "ATC_Error.h" #include "LammpsInterface.h" #include "VoigtOperations.h" @@ -24,7 +24,7 @@ using std::fstream; namespace ATC { //============================================================================= -// extracts a stress at an integration point +// extracts a stress at an integration point // Note: Utility function: not in header //============================================================================= DENS_MAT extract_stress(const DENS_MAT_VEC &sigma, INDEX ip=0) @@ -41,7 +41,7 @@ double compute_pressure(const DENS_MAT_VEC &sigma, const DENS_MAT &F) { // pressure in units (mass-velocity^2)/Volume (LAMMPS real) double p = (sigma[0](0,0) + sigma[1](0,1) + sigma[2](0,2)) * (1.0/3.0); - p *= 1.0e14/6.0221415; // convert from units real to Pa + p *= 1.0e14/6.0221415; // convert from units real to Pa p *= 1.0/101235.0; // convert from Pa to ATM return p * pow(det(F), -1.0/3.0); // convert from PK2 to Cauchy stress } @@ -55,7 +55,7 @@ void deformation_gradient(const DENS_MAT_VEC &du, INDEX q, MATRIX &F) for (INDEX j=0; jsecond)[0]).nRows(); energy.reset(nRows,1); ATC::LammpsInterface::instance()->print_msg("WARNING: returning dummy elastic energy"); - + } //============================================================================= // isotropic linear elastic //============================================================================= -StressLinearElastic::StressLinearElastic(fstream &fileId) +StressLinearElastic::StressLinearElastic(fstream &fileId) : StressCubicElastic(), E_(0), nu_(0), mu_(0), lambda_(0) { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); @@ -88,8 +88,8 @@ StressLinearElastic::StressLinearElastic(fstream &fileId) StressCubicElastic::c11_ = E_*(1-nu_)/(1+nu_)/(1-2*nu_); StressCubicElastic::c12_ = E_*nu_ /(1+nu_)/(1-2*nu_); StressCubicElastic::c44_ = E_/(1+nu_)/2; - if (nu_ < 0.0 || nu_ > 1.0) - throw ATC_Error("bad linear elastic constants"); + if (nu_ < 0.0 || nu_ > 1.0) + throw ATC_Error("bad linear elastic constants"); if (lambda_ < 0.0 || mu_ < 0.0) throw ATC_Error("bad continuum material parameter"); return; @@ -141,7 +141,7 @@ StressLinearElastic::StressLinearElastic(fstream &fileId) //============================================================================= // cubic elastic //============================================================================= -StressCubicElastic::StressCubicElastic(fstream &fileId) +StressCubicElastic::StressCubicElastic(fstream &fileId) : c11_(0), c12_(0), c44_(0) { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); @@ -152,16 +152,16 @@ StressCubicElastic::StressCubicElastic(fstream &fileId) else if (line[0]=="c11") c11_ = str2dbl(line[1]); else if (line[0]=="c12") c12_ = str2dbl(line[1]); else if (line[0]=="c44") c44_ = str2dbl(line[1]); - else throw ATC_Error( "unrecognized material function"); + else throw ATC_Error( "unrecognized material function"); } } //--------------------------------------------------------------------------- // compute the stress at N integration points from the displacement gradient -// T_{ij} = 1/2*C_{ijkl}*(u_{k,l} + u_{l,k}) +// T_{ij} = 1/2*C_{ijkl}*(u_{k,l} + u_{l,k}) //--------------------------------------------------------------------------- void StressCubicElastic::stress(const FIELD_MATS & /* fields */, const GRAD_FIELD_MATS &gradFields, - DENS_MAT_VEC &sigma) + DENS_MAT_VEC &sigma) { GRAD_FIELD_MATS::const_iterator du_itr = gradFields.find(DISPLACEMENT); const DENS_MAT_VEC &du = du_itr->second; @@ -197,7 +197,7 @@ StressCubicElastic::StressCubicElastic(fstream &fileId) //--------------------------------------------------------------------------- // compute the elastic energy at N integration points from displacement gradient // E = 1/8*C_{ijkl}* (u_{k,l} + u_{l,k})* (u_{i,j} + u_{j,i})*rho ? -// = 1/2 (4 c44 (u12^2 + u13^2 + u23^2) + 2 c12 (u11 u22 + u11 u33 + u22 u33) +// = 1/2 (4 c44 (u12^2 + u13^2 + u23^2) + 2 c12 (u11 u22 + u11 u33 + u22 u33) // + c11 (u11^2 + u22^2 + u33^2)) //--------------------------------------------------------------------------- void StressCubicElastic::elastic_energy(const FIELD_MATS & /* fields */, @@ -223,21 +223,21 @@ StressCubicElastic::StressCubicElastic(fstream &fileId) const double c44 = c44_; //double scale = (ATC::LammpsInterface::instance()->mvv2e()); for (INDEX gp=0; gp line; @@ -315,8 +315,8 @@ StressCauchyBorn::StressCauchyBorn(fstream &fileId, CbData &cb) if (line.empty()) continue; // skip blank lines else if (line[0]=="end") { delete cblattice_; - if (!potential_) throw ATC_Error( "no potential defined"); - cblattice_ = new CBLattice(cbdata_.cell_vectors, cbdata_.basis_vectors); + if (!potential_) throw ATC_Error( "no potential defined"); + cblattice_ = new CBLattice(cbdata_.cell_vectors, cbdata_.basis_vectors); return; } else if (line[0] == "pair_style") { @@ -324,7 +324,7 @@ StressCauchyBorn::StressCauchyBorn(fstream &fileId, CbData &cb) if (line.size()<3) throw(ATC_Error("no lj/cut cutoff radius")); const double rc = str2dbl(line[2]); while (!fileId.eof()) { // find next pair_coeff command - command_line(fileId, line); + command_line(fileId, line); if (line.size() && line[0]=="pair_coeff") break; } if (line[0] != "pair_coeff" || line.size() != 3) { @@ -346,7 +346,7 @@ StressCauchyBorn::StressCauchyBorn(fstream &fileId, CbData &cb) delete potential_; potential_ = new CbLjSmoothLinear(str2dbl(line[1]), str2dbl(line[2]), rc); } - else if (line[1] == "eam") { // Embedded atom method potential + else if (line[1] == "eam") { // Embedded atom method potential delete potential_; potential_ = new CbEam(); } @@ -356,7 +356,7 @@ StressCauchyBorn::StressCauchyBorn(fstream &fileId, CbData &cb) else if (line[0] == "temperature" && line.size() == 2) { fixed_temperature_ = str2dbl(line[1]); } - else if (line[0]=="material" || line[0]=="stress") /* ignore this */; + else if (line[0]=="material" || line[0]=="stress") /* ignore this */; else throw ATC_Error( "Unrecognized Cauchy-Born parameter: "+line[0]+"."); } @@ -374,13 +374,13 @@ StressCauchyBorn::~StressCauchyBorn() //============================================================================== // initialize //============================================================================== -void StressCauchyBorn::initialize(void) +void StressCauchyBorn::initialize(void) { if (!initialized_) { if (makeLinear_) linearize(); stringstream ss; - double k = stiffness()*cbdata_.e2mvv; + double k = stiffness()*cbdata_.e2mvv; double m = cbdata_.atom_mass; double w0 = sqrt(k*m); ss << "CB stiffness: " << stiffness() << " Einstein freq: " << w0; @@ -403,8 +403,8 @@ double StressCauchyBorn::stiffness(void) const //============================================================================== // compute the stress at N integration points from the displacement gradient //============================================================================== -void StressCauchyBorn::stress(const FIELD_MATS &fields, - const GRAD_FIELD_MATS &gradFields, +void StressCauchyBorn::stress(const FIELD_MATS &fields, + const GRAD_FIELD_MATS &gradFields, DENS_MAT_VEC &sigma) { if (cubicMat_) { @@ -418,9 +418,9 @@ void StressCauchyBorn::stress(const FIELD_MATS &fields, // negative because stress must return (-) stress const double fact = -cbdata_.inv_atom_volume * cbdata_.e2mvv; const DENS_MAT_VEC &du(disp_gradient->second); - const INDEX num_integration_pts = du.front().nRows(); + const INDEX num_integration_pts = du.front().nRows(); const INDEX nsd = du.size(); - DENS_MAT F(nsd,nsd); // displacement gradient + DENS_MAT F(nsd,nsd); // displacement gradient bool temp_varies = (temp != fields.end()); sigma.assign(nsd, DENS_MAT(num_integration_pts, nsd)); StressAtIP S(sigma); // wrapper for quadrature points. @@ -440,8 +440,8 @@ void StressCauchyBorn::stress(const FIELD_MATS &fields, cb_stress(args, S); // copy symmetric part of stress and scale by V0 - for (INDEX i=0; i0)/potential(T=0) energy density. [mvv/L^3] //============================================================================== -void StressCauchyBorn::elastic_energy(const FIELD_MATS &fields, +void StressCauchyBorn::elastic_energy(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &energy) const { @@ -471,14 +471,14 @@ void StressCauchyBorn::elastic_energy(const FIELD_MATS &fields, energy[gp] = cb_energy(StressArgs(vac, potential_, cbdata_.boltzmann, cbdata_.hbar, T)); } // Scaling factor - scale by atomic volume and energy conversion. - + energy *= cbdata_.inv_atom_volume * cbdata_.e2mvv; } //============================================================================== // Computes entropic energy density. [mvv/L^3] //============================================================================== -void StressCauchyBorn::entropic_energy(const FIELD_MATS &fields, +void StressCauchyBorn::entropic_energy(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &energy) const { @@ -504,7 +504,7 @@ void StressCauchyBorn::entropic_energy(const FIELD_MATS &fields, void StressCauchyBorn::linearize(MATRIX *F) { if (cubicMat_) delete cubicMat_; - DENS_MAT C; + DENS_MAT C; if (F) tangent(*F, C); else tangent(eye(3,3), C); cubicMat_ = new StressCubicElastic(C(0,0), C(0,1), C(3,3)); @@ -514,7 +514,7 @@ void StressCauchyBorn::linearize(MATRIX *F) double c12 = C(0,1)/cbdata_.e2mvv; double c44 = C(3,3)/cbdata_.e2mvv; ss << "created cubic stress function:" - << "\n lammps ATC units" + << "\n lammps ATC units" << "\n c11=" << c11 << " " << C(0,0) << "\n c12=" << c12 << " " << C(0,1) << "\n c44=" << c44 << " " << C(3,3); @@ -546,7 +546,7 @@ DENS_VEC StressCauchyBorn::elasticity_tensor(const VECTOR &Fv, MATRIX &C, const } DENS_VEC StressCauchyBorn::elasticity_tensor(const MATRIX &F, MATRIX &C, const ElasticityTensorType type) const { - double T = 0; + double T = 0; AtomCluster vac; cblattice_->atom_cluster(F, potential_->cutoff_radius(), vac); if (vac.size() < 4) throw ATC_Error("StressCauchyBorn::second_elasticity_tensor cluster does not have sufficient atoms"); @@ -569,7 +569,7 @@ DENS_VEC StressCauchyBorn::elasticity_tensor(const MATRIX &F, MATRIX &C, const E C.reset(size,size); for (INDEX a=0; aphi_r(d); // computes phi' double phi_rr = potential_->phi_rr(d); // computes phi'' double fact1 = 0.5*phi_r*rinv; // 1/2 see Philips - double fact2 = 0.5*(phi_rr - phi_r*rinv) * rinv*rinv; + double fact2 = 0.5*(phi_rr - phi_r*rinv) * rinv*rinv; if (hasEAM) { double rho_r = potential_->rho_r(d); // computes rho' double rho_rr = potential_->rho_rr(d); // computes rho'' fact1 += embed_p*rho_r*rinv; - fact2 += embed_p*(rho_rr - rho_r*rinv) * rinv*rinv; + fact2 += embed_p*(rho_rr - rho_r*rinv) * rinv*rinv; Zfp += Z*(rho_r*rinv); } for (INDEX i=0; i0)/potential(T=0) energy density + DENS_MAT_VEC &stress)=0; + //* Computes free (T>0)/potential(T=0) energy density //* Units: mvv/L^3 (i.e. for units Real: g/(mol ps^2 A^2) ) virtual void elastic_energy(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &energy) const; //* Returns the material tangent at a given deformation gradient. - virtual void tangent(const MATRIX & /* F */, MATRIX & /* C */) const + virtual void tangent(const MATRIX & /* F */, MATRIX & /* C */) const {throw ATC_Error("Stress::tangent: unimplemented function");} }; @@ -44,7 +44,7 @@ namespace ATC { /** * @class StressCubicElastic * @brief Class for computing stress for a cubic elastic material - */ + */ class StressCubicElastic : public Stress { @@ -69,7 +69,7 @@ namespace ATC { /** * @class StressCubicElasticDamped * @brief Class for computing stress for a cubic elastic material w/ damping - */ + */ class StressCubicElasticDamped : public StressCubicElastic { @@ -85,8 +85,8 @@ namespace ATC { }; /** - * @class StressLinearElastic - * @brief Class for computing stress for a linear elastic material + * @class StressLinearElastic + * @brief Class for computing stress for a linear elastic material */ class StressLinearElastic : public StressCubicElastic @@ -99,7 +99,7 @@ namespace ATC { protected: double E_, nu_; double mu_, lambda_; - }; + }; // forward declarations needed by StressCauchyBorn class CbPotential; @@ -120,7 +120,7 @@ namespace ATC { /** * @class StressCauchyBorn - * @brief Class for computing the stress and elastic constants for a + * @brief Class for computing the stress and elastic constants for a * @brief Cauchy-Born material. */ @@ -129,17 +129,17 @@ namespace ATC { { public: StressCauchyBorn(std::fstream &matfile, CbData &cb); - virtual ~StressCauchyBorn(); + virtual ~StressCauchyBorn(); virtual void initialize(void); //* Returns the stress computed from a 0K Cauchy-Born approxmation. virtual void stress(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT_VEC &flux); - //* Computes free (T>0)/potential(T=0) energy density + //* Computes free (T>0)/potential(T=0) energy density //* Units: mvv/L^3 (i.e. for units Real: g/(mol ps^2 A^2) ) - virtual void elastic_energy(const FIELD_MATS &fields, + virtual void elastic_energy(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &energy) const; - //* Computes entropic energy density + //* Computes entropic energy density void entropic_energy(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, DENS_MAT &energy) const; //* Returns the material tangent at a given deformation gradient. @@ -171,13 +171,13 @@ namespace ATC { void function(const VECTOR & F, DENS_VEC & R) { DENS_MAT B; - tangent(F,R,B); + tangent(F,R,B); } void tangent(const VECTOR & F, DENS_VEC & R, MATRIX & B) { cbP_ = cauchyBornStress_->elasticity_tensor(F, B); - - R = cbP_ - targetP_; + + R = cbP_ - targetP_; } private: StressCauchyBorn * cauchyBornStress_; @@ -195,13 +195,13 @@ namespace ATC { void function(const VECTOR & U, DENS_VEC & r) { DENS_MAT C; - tangent(U,r,C); + tangent(U,r,C); } void tangent(const VECTOR & U, DENS_VEC & r, MATRIX & C) { cbS_ = cauchyBornStress_->elasticity_tensor(U, C, SECOND_ELASTICITY_TENSOR); - - r = cbS_ - targetS_; + + r = cbS_ - targetS_; } private: StressCauchyBorn * cauchyBornStress_; @@ -209,4 +209,4 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/ThermalTimeIntegrator.cpp b/lib/atc/ThermalTimeIntegrator.cpp index 8c0b8d6dae..514f41af0c 100644 --- a/lib/atc/ThermalTimeIntegrator.cpp +++ b/lib/atc/ThermalTimeIntegrator.cpp @@ -16,7 +16,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor - //-------------------------------------------------------- + //-------------------------------------------------------- ThermalTimeIntegrator::ThermalTimeIntegrator(ATC_Coupling * atc, TimeIntegrationType timeIntegrationType) : TimeIntegrator(atc, timeIntegrationType) @@ -38,7 +38,7 @@ namespace ATC { \section syntax fix_modify AtC time_integration \n - descriptor (string) = time integration type \n - + various time integration methods for the finite elements\n \section description gear - atomic velocity update with 2nd order Verlet, nodal temperature update with 3rd or 4th order Gear, thermostats based on controlling power \n @@ -50,7 +50,7 @@ namespace ATC { \section related see \ref man_fix_atc \section default - none + none */ if (strcmp(arg[argIndex],"gear")==0) { timeIntegrationType_ = GEAR; @@ -90,12 +90,12 @@ namespace ATC { throw ATC_Error("Unknown time integration type in ThermalTimeIntegrator::Initialize()"); } } - + if (timeFilterManager_->filter_dynamics()) { switch (timeIntegrationType_) { case GEAR: { timeIntegrationMethod_ = new ThermalTimeIntegratorGearFiltered(this); - break; + break; } case FRACTIONAL_STEP: { timeIntegrationMethod_ = new ThermalTimeIntegratorFractionalStepFiltered(this); @@ -167,7 +167,7 @@ namespace ATC { nodalAtomicTemperature_ = (atc_->interscale_manager()).dense_matrix("NodalAtomicTemperature"); } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class ThermalIntegratorGear @@ -193,9 +193,9 @@ namespace ATC { { ThermalIntegrationMethod::construct_transfers(); InterscaleManager & interscaleManager = atc_->interscale_manager(); - + // add in power computation - DotTwiceKineticEnergy * dotTwiceKineticEnergy = + DotTwiceKineticEnergy * dotTwiceKineticEnergy = new DotTwiceKineticEnergy(atc_); interscaleManager.add_per_atom_quantity(dotTwiceKineticEnergy,"DotTwiceKineticEnergy"); nodalAtomicPower_ = new AtfShapeFunctionRestriction(atc_, @@ -252,7 +252,7 @@ namespace ATC { timeFilter_->apply_post_step2(nodalAtomicPowerFiltered_.set_quantity(), myNodalAtomicPower,dt); temperatureRhs_ += myNodalAtomicPower; - + // Finish updating temperature _temperatureResidual_.resize(atc_->num_nodes(),1); atc_->apply_inverse_mass_matrix(temperatureRhs_.quantity(), @@ -260,7 +260,7 @@ namespace ATC { TEMPERATURE); _temperatureResidual_ -= temperatureRoc_.quantity(); _temperatureResidual_ *= dt; - + gear1_3_correct(temperature_.set_quantity(), temperatureRoc_.set_quantity(), temperature2Roc_.set_quantity(), @@ -303,7 +303,7 @@ namespace ATC { temperature3Roc_(atc_->field_3roc(TEMPERATURE)) { // do nothing - + // specifically if history data is required and we need another time filter object for the fields } @@ -323,7 +323,7 @@ namespace ATC { //-------------------------------------------------------- // post_final_integrate1 - // first time integration computations + // first time integration computations // after Verlet step 2 //-------------------------------------------------------- void ThermalTimeIntegratorGearFiltered::post_final_integrate1(double dt) @@ -331,7 +331,7 @@ namespace ATC { DENS_MAT & myNodalAtomicPowerFiltered(nodalAtomicPowerFiltered_.set_quantity()); timeFilter_->apply_post_step2(myNodalAtomicPowerFiltered,nodalAtomicPower_->quantity(),dt); temperatureRhs_ += myNodalAtomicPowerFiltered; - + // Finish updating temperature _temperatureResidual_.resize(atc_->num_nodes(),1); atc_->apply_inverse_mass_matrix(temperatureRhs_.quantity(), @@ -429,7 +429,7 @@ namespace ATC { if (!timeFilterManager->end_equilibrate()) { // implies an initial condition of the instantaneous atomic energy // for the corresponding filtered variable, consistent with the temperature - nodalAtomicEnergyFiltered_ = nodalAtomicEnergy_->quantity(); + nodalAtomicEnergyFiltered_ = nodalAtomicEnergy_->quantity(); nodalAtomicPowerFiltered_.reset(atc_->num_nodes(),1); } } @@ -457,7 +457,7 @@ namespace ATC { apply_gear_predictor(dt); // update filtered nodal atomic power - + // that way thermostat and integrator can be consistent timeFilter_->apply_pre_step1(nodalAtomicPowerFiltered_.set_quantity(), nodalAtomicPower_,dt); @@ -472,16 +472,16 @@ namespace ATC { //-------------------------------------------------------- void ThermalTimeIntegratorFractionalStep::pre_final_integrate1(double dt) { - + // before the new rhs is computed but after atomic velocity is updated // to allow for general notions of temperature beyond kinetic. // compute change in restricted atomic energy nodalAtomicPower_ += nodalAtomicEnergy_->quantity(); - + // update FE temperature with change in temperature from MD compute_temperature_delta(nodalAtomicPower_,dt); temperature_ += atomicTemperatureDelta_.quantity(); - + // approximation to power for output nodalAtomicPower_ /= dt; timeFilter_->apply_post_step1(nodalAtomicPowerFiltered_.set_quantity(), diff --git a/lib/atc/ThermalTimeIntegrator.h b/lib/atc/ThermalTimeIntegrator.h index 8f5175d8a2..4e90c1df1d 100644 --- a/lib/atc/ThermalTimeIntegrator.h +++ b/lib/atc/ThermalTimeIntegrator.h @@ -17,13 +17,13 @@ namespace ATC { */ class ThermalTimeIntegrator : public TimeIntegrator { - + public: - + // constructor ThermalTimeIntegrator(ATC_Coupling * atc, TimeIntegrationType timeIntegrationType); - + // destructor virtual ~ThermalTimeIntegrator(){}; @@ -39,15 +39,15 @@ namespace ATC { // Member data access /** access for filtered atomic power */ DENS_MAN & nodal_atomic_power_filtered(){return nodalAtomicPowerFiltered_;}; - + /** access for filtered atomic energy */ // note: nodalAtomicEnergy_ should always be reset as it tracks the original energy + MD evolution DENS_MAN & nodal_atomic_energy_filtered(){return nodalAtomicEnergyFiltered_;}; - + protected: /** filtered atomic power */ - + DENS_MAN nodalAtomicPowerFiltered_; /** filtered atomic energy due initial conditions and MD updates */ @@ -57,7 +57,7 @@ namespace ATC { // DO NOT define this ThermalTimeIntegrator(); - + }; /** @@ -66,12 +66,12 @@ namespace ATC { */ class ThermalIntegrationMethod : public TimeIntegrationMethod { - + public: - + // constructor ThermalIntegrationMethod(ThermalTimeIntegrator * thermalTimeIntegrator); - + // destructor virtual ~ThermalIntegrationMethod() {}; @@ -112,21 +112,21 @@ namespace ATC { // DO NOT define this ThermalIntegrationMethod(); - + }; /** * @class ThermalTimeIntegratorGear - * @brief Class uses 3rd order Gear integration for time integration of FE temperature field + * @brief Class uses 3rd order Gear integration for time integration of FE temperature field */ class ThermalTimeIntegratorGear : public ThermalIntegrationMethod { - + public: - + // constructor ThermalTimeIntegratorGear(ThermalTimeIntegrator * ThermalTimeIntegrator); - + // destructor virtual ~ThermalTimeIntegratorGear() {}; @@ -135,7 +135,7 @@ namespace ATC { /** pre time integration initialization of data */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer /** second part of pre_initial_integrate */ virtual void pre_initial_integrate2(double dt); @@ -157,10 +157,10 @@ namespace ATC { AtfShapeFunctionRestriction * nodalAtomicPower_; private: - + // DO NOT define this ThermalTimeIntegratorGear(); - + }; /** @@ -169,15 +169,15 @@ namespace ATC { */ class ThermalTimeIntegratorGearFiltered : public ThermalTimeIntegratorGear { - + public: - + // constructor ThermalTimeIntegratorGearFiltered(ThermalTimeIntegrator * thermalTimeIntegrator); - + // destructor virtual ~ThermalTimeIntegratorGearFiltered(){}; - + // time step methods, corresponding to ATC_Transfer /** second part of pre_initial_integrate */ virtual void pre_initial_integrate2(double dt); @@ -188,7 +188,7 @@ namespace ATC { /** parallel post-processing operations pre-output */ virtual void post_process(); - + protected: /** finite element temperature 3rd time derivative */ @@ -198,16 +198,16 @@ namespace ATC { // DO NOT define this ThermalTimeIntegratorGearFiltered(); - + }; /** - * @class ThermalTimeIntegratorFractionalStep + * @class ThermalTimeIntegratorFractionalStep * @brief Class for using 3rd order Gear integration to update FE contributions to temperature field - * (Uses same update for the atomic contributions to the finite - * elements as are used by the LAMMPS integration scheme + * (Uses same update for the atomic contributions to the finite + * elements as are used by the LAMMPS integration scheme * for the atomic velocities and positions, i.e. Verlet.) - */ + */ class ThermalTimeIntegratorFractionalStep : public ThermalIntegrationMethod { @@ -215,16 +215,16 @@ namespace ATC { // constructor ThermalTimeIntegratorFractionalStep(ThermalTimeIntegrator * ThermalTimeIntegrator); - + // destructor virtual ~ThermalTimeIntegratorFractionalStep() {}; - + /** create and get necessary transfer operators */ virtual void construct_transfers(); /** pre time integration initialization of data */ virtual void initialize(); - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -303,10 +303,10 @@ namespace ATC { // constructor ThermalTimeIntegratorFractionalStepFiltered(ThermalTimeIntegrator * ThermalTimeIntegrator); - + // destructor virtual ~ThermalTimeIntegratorFractionalStepFiltered(); - + // time step methods, corresponding to ATC_Transfer /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); diff --git a/lib/atc/Thermostat.cpp b/lib/atc/Thermostat.cpp index 217f2394e2..2b5d469a12 100644 --- a/lib/atc/Thermostat.cpp +++ b/lib/atc/Thermostat.cpp @@ -38,13 +38,13 @@ namespace ATC { int argIndex = 0; if (strcmp(arg[argIndex],"thermal")==0) { argIndex++; - + // thermostat type - /*! \page man_control_thermal fix_modify AtC control thermal + /*! \page man_control_thermal fix_modify AtC control thermal \section syntax fix_modify AtC control thermal - control_type (string) = none | rescale | hoover | flux\n - + fix_modify AtC control thermal rescale \n - frequency (int) = time step frequency for applying velocity rescaling \n @@ -53,8 +53,8 @@ namespace ATC { fix_modify AtC control thermal flux \n - boundary_integration_type (string) = faceset | interpolate\n - face_set_id (string), optional = id of boundary face set, if not specified - (or not possible when the atomic domain does not line up with - mesh boundaries) defaults to an atomic-quadrature approximate + (or not possible when the atomic domain does not line up with + mesh boundaries) defaults to an atomic-quadrature approximate evaulation, does not work with interpolate\n \section examples fix_modify AtC control thermal none \n @@ -63,7 +63,7 @@ namespace ATC { fix_modify AtC control thermal flux \n fix_modify AtC control thermal flux faceset bndy_faces \n \section description - Sets the energy exchange mechansim from the finite elements to the atoms, managed through a control algorithm. Rescale computes a scale factor for each atom to match the finite element temperature. Hoover is a Gaussian least-constraint isokinetic thermostat enforces that the nodal restricted atomic temperature matches the finite element temperature. Flux is a similar mode, but rather adds energy to the atoms based on conservation of energy. Hoover and flux allows the prescription of sources or fixed temperatures on the atoms. + Sets the energy exchange mechansim from the finite elements to the atoms, managed through a control algorithm. Rescale computes a scale factor for each atom to match the finite element temperature. Hoover is a Gaussian least-constraint isokinetic thermostat enforces that the nodal restricted atomic temperature matches the finite element temperature. Flux is a similar mode, but rather adds energy to the atoms based on conservation of energy. Hoover and flux allows the prescription of sources or fixed temperatures on the atoms. \section restrictions only for be used with specific transfers : thermal (rescale, hoover, flux), two_temperature (flux) \n @@ -106,7 +106,7 @@ namespace ATC { couplingMode_ = FLUX; howOften_ = 1; argIndex++; - + boundaryIntegrationType_ = atc_->parse_boundary_integration(narg-argIndex,&arg[argIndex],boundaryFaceSet_); foundMatch = true; } @@ -157,9 +157,9 @@ namespace ATC { //-------------------------------------------------------- // construct_methods: // instantiations desired regulator method(s) - + // dependence, but in general there is also a - // time integrator dependence. In general the + // time integrator dependence. In general the // precedence order is: // time filter -> time integrator -> thermostat // In the future this may need to be added if @@ -186,7 +186,7 @@ namespace ATC { timeFilter_ = timeFilterManager->construct(TimeFilterManager::EXPLICIT_IMPLICIT); } } - + if (timeFilterManager->filter_dynamics()) { switch (regulatorTarget_) { case NONE: { @@ -346,7 +346,7 @@ namespace ATC { throw ATC_Error("Unknown thermostat target in Thermostat::initialize"); } } - + AtomicRegulator::reset_method(); } else { @@ -359,7 +359,7 @@ namespace ATC { // Class ThermostatShapeFunction //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -418,7 +418,7 @@ namespace ATC { // Class ThermostatRescale //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -487,7 +487,7 @@ namespace ATC { { // compute right-hand side this->set_rhs(_rhs_); - + // solve equations solve_for_lambda(_rhs_,lambda_->set_quantity()); } @@ -550,7 +550,7 @@ namespace ATC { InterscaleManager & interscaleManager(atc_->interscale_manager()); // get fluctuating PE at nodes - nodalAtomicFluctuatingPotentialEnergy_ = + nodalAtomicFluctuatingPotentialEnergy_ = interscaleManager.dense_matrix("NodalAtomicFluctuatingPotentialEnergy"); } @@ -598,7 +598,7 @@ namespace ATC { // Class ThermostatFsSolver //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -720,20 +720,20 @@ namespace ATC { if (error < tolerance_) break; } - + if (error >= tolerance_) { stringstream message; message << "WARNING: Iterative solve for lambda failed to converge after " << lambdaMaxIterations_ << " iterations, final tolerance was " << error << "\n"; ATC::LammpsInterface::instance()->print_msg(message.str()); } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class ThermostatGlcFs //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -787,7 +787,7 @@ namespace ATC { // get data from manager atomMasses_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_MASS), nodalAtomicEnergy_ = interscaleManager.dense_matrix("NodalAtomicEnergy"); - + // thermostat forces based on lambda and the atomic velocities atomThermostatForces_ = new AtomicThermostatForce(atc_,atomLambdas_); interscaleManager.add_per_atom_quantity(atomThermostatForces_, @@ -816,7 +816,7 @@ namespace ATC { void ThermostatGlcFs::initialize() { RegulatorMethod::initialize(); - + TimeFilterManager * timeFilterManager = atc_->time_filter_manager(); if (!timeFilterManager->end_equilibrate()) { // we should reset lambda and lambdaForce to zero in this case @@ -939,7 +939,7 @@ namespace ATC { // do full prediction if we just redid the shape functions if (full_prediction()) { this->compute_lambda(dt); - + atomThermostatForces_->unfix_quantity(); // allow update of atomic force applied by lambda } @@ -952,7 +952,7 @@ namespace ATC { if (full_prediction()) atomThermostatForces_->fix_quantity(); - + // update predicted nodal variables for second half of time step this->add_to_energy(myNodalAtomicLambdaPower,deltaEnergy2_,0.5*dt); // following manipulations performed this way for efficiency @@ -979,7 +979,7 @@ namespace ATC { // apply lambda force to atoms and compute instantaneous lambda power for second half of time step DENS_MAT & myNodalAtomicLambdaPower(nodalAtomicLambdaPower_->set_quantity()); // allow computation of force applied by lambda using current velocities - atomThermostatForces_->unfix_quantity(); + atomThermostatForces_->unfix_quantity(); atomThermostatForces_->quantity(); atomThermostatForces_->fix_quantity(); apply_to_atoms(atomVelocities_,nodalAtomicEnergy_, @@ -994,8 +994,8 @@ namespace ATC { this->add_to_energy(myNodalAtomicLambdaPower,deltaEnergy2_,0.5*dt); atc_->apply_inverse_mass_matrix(deltaEnergy2_,TEMPERATURE); myTemperature += deltaEnergy2_; - - + + isFirstTimestep_ = false; } @@ -1016,7 +1016,7 @@ namespace ATC { // solve linear system for lambda guess DENS_MAT & lambda(lambda_->set_quantity()); solve_for_lambda(rhs_,lambda); - + // iterate to solution if (iterateSolution) { iterate_lambda(rhs_); @@ -1031,7 +1031,7 @@ namespace ATC { //-------------------------------------------------------- void ThermostatGlcFs::compute_boundary_flux(FIELDS & fields) { - + lambdaSolver_->compute_boundary_flux(fields); } @@ -1057,7 +1057,7 @@ namespace ATC { // Class ThermostatSolverFlux //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and thermostat data @@ -1135,13 +1135,13 @@ namespace ATC { interscaleManager.add_set_int(regulatedNodes_, regulatorPrefix_+"ThermostatRegulatedNodes"); } - + // if localized monitor nodes with applied fluxes if (atomicRegulator_->use_localized_lambda()) { if ((atomicRegulator_->coupling_mode() == Thermostat::FLUX) && (atomicRegulator_->boundary_integration_type() != NO_QUADRATURE)) { // include boundary nodes applicationNodes_ = new FluxBoundaryNodes(atc_); - + boundaryNodes_ = new BoundaryNodes(atc_); interscaleManager.add_set_int(boundaryNodes_, regulatorPrefix_+"ThermostatBoundaryNodes"); @@ -1157,7 +1157,7 @@ namespace ATC { applicationNodes_ = regulatedNodes_; } - // special set of boundary elements for boundary flux quadrature + // special set of boundary elements for boundary flux quadrature if ((atomicRegulator_->boundary_integration_type() == FE_INTERPOLATION) && (atomicRegulator_->use_localized_lambda())) { elementMask_ = interscaleManager.dense_matrix_bool(regulatorPrefix_+"BoundaryElementMask"); @@ -1227,10 +1227,10 @@ namespace ATC { void ThermostatIntegratorFlux::set_thermostat_rhs(DENS_MAT & rhs, double /* dt */) { - + // only tested with flux != 0 + ess bc = 0 - // (a) for flux based : + // (a) for flux based : // form rhs : 2/3kB * W_I^-1 * \int N_I r dV // vs Wagner, CMAME, 2008 eq(24) RHS_I = 2/(3kB) flux_I // fluxes are set in ATC transfer @@ -1259,7 +1259,7 @@ namespace ATC { // Class ThermostatSolverFixed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and thermostat data @@ -1357,14 +1357,14 @@ namespace ATC { else { throw ATC_Error("ThermostatSolverFixed::construct_regulated_nodes - couldn't determine set of regulated nodes"); } - + interscaleManager.add_set_int(regulatedNodes_, regulatorPrefix_+"ThermostatRegulatedNodes"); } applicationNodes_ = regulatedNodes_; - // special set of boundary elements for defining regulated atoms + // special set of boundary elements for defining regulated atoms if (atomicRegulator_->use_localized_lambda()) { elementMask_ = interscaleManager.dense_matrix_bool(regulatorPrefix_+"BoundaryElementMask"); if (!elementMask_) { @@ -1380,7 +1380,7 @@ namespace ATC { // Class ThermostatIntegratorFixed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and thermostat data @@ -1552,11 +1552,11 @@ namespace ATC { //-------------------------------------------------------- void ThermostatIntegratorFixed::apply_post_corrector(double dt) { - + bool halveForce = halve_force(); ThermostatGlcFs::apply_post_corrector(dt); - + // update filtered energy with lambda power DENS_MAT & myNodalAtomicLambdaPower(nodalAtomicLambdaPower_->set_quantity()); timeFilter_->apply_post_step2(nodalAtomicEnergyFiltered_.set_quantity(), @@ -1567,8 +1567,8 @@ namespace ATC { // 1) makes up for poor initial condition // 2) accounts for possibly large value of lambda when atomic shape function values change // from eulerian mapping after more than 1 timestep - // avoids unstable oscillations arising from - // thermostat having to correct for error introduced in lambda changing the + // avoids unstable oscillations arising from + // thermostat having to correct for error introduced in lambda changing the // shape function matrices lambdaSolver_->scale_lambda(0.5); firstHalfAtomForces_ = atomThermostatForcesPredVel_; @@ -1589,11 +1589,11 @@ namespace ATC { double /* dt */) { deltaEnergy.resize(nNodes_,1); - + SetDependencyManager * myRegulatedNodes = (atc_->interscale_manager()).set_int(regulatorPrefix_+"ThermostatRegulatedNodes"); const set & regulatedNodes(myRegulatedNodes->quantity()); - + for (int i = 0; i < nNodes_; i++) { if (regulatedNodes.find(i) != regulatedNodes.end()) { deltaEnergy(i,0) = 0.; @@ -1620,7 +1620,7 @@ namespace ATC { const set & regulatedNodes(myRegulatedNodes->quantity()); double factor = (1./dt)/keMultiplier_; rhs.resize(nNodes_,1); - + for (int i = 0; i < nNodes_; i++) { if (regulatedNodes.find(i) != regulatedNodes.end()) { rhs(i,0) = factor*(deltaNodalAtomicEnergy_(i,0) - deltaFeEnergy_(i,0)); @@ -1636,7 +1636,7 @@ namespace ATC { // Class ThermostatIntegratorFluxFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and thermostat data @@ -1707,24 +1707,24 @@ namespace ATC { void ThermostatIntegratorFluxFiltered::set_thermostat_rhs(DENS_MAT & rhs, double dt) { - + // only tested with flux != 0 + ess bc = 0 - // (a) for flux based : + // (a) for flux based : // form rhs : 2/3kB * W_I^-1 * \int N_I r dV // vs Wagner, CMAME, 2008 eq(24) RHS_I = 2/(3kB) flux_I // fluxes are set in ATC transfer // invert heatSource_ to get unfiltered source // relevant coefficients from time filter - + double coefF1 = timeFilter_->filtered_coefficient_pre_s1(2.*dt); double coefF2 = timeFilter_->filtered_coefficient_post_s1(2.*dt); double coefU1 = timeFilter_->unfiltered_coefficient_pre_s1(2.*dt); double coefU2 = timeFilter_->unfiltered_coefficient_post_s1(2.*dt); const DENS_MAT & heatSource(heatSource_.quantity()); - SetDependencyManager * myApplicationNodes = + SetDependencyManager * myApplicationNodes = (atc_->interscale_manager()).set_int(regulatorPrefix_+"ThermostatApplicationNodes"); const set & applicationNodes(myApplicationNodes->quantity()); rhs.resize(nNodes_,1); @@ -1761,7 +1761,7 @@ namespace ATC { // Class ThermostatIntegratorFixedFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor // Grab references to ATC and thermostat data @@ -1780,8 +1780,8 @@ namespace ATC { // the change in the nodal atomic energy // that has occurred over the past timestep //-------------------------------------------------------- - - + + void ThermostatIntegratorFixedFiltered::initialize_delta_nodal_atomic_energy(double dt) { // initialize delta energy @@ -1846,7 +1846,7 @@ namespace ATC { double factor = (1./dt)/keMultiplier_; factor /= timeFilter_->unfiltered_coefficient_post_s1(2.*dt); rhs.resize(nNodes_,1); - + for (int i = 0; i < nNodes_; i++) { if (regulatedNodes.find(i) != regulatedNodes.end()) { rhs(i,0) = factor*(deltaNodalAtomicEnergy_(i,0) - deltaFeEnergy_(i,0)); @@ -1879,7 +1879,7 @@ namespace ATC { // Class ThermostatFluxFixed //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -1989,7 +1989,7 @@ namespace ATC { // Class ThermostatFluxFixedFiltered //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -2015,7 +2015,7 @@ namespace ATC { // Class ThermostatGlc //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -2128,13 +2128,13 @@ namespace ATC { // get managed data nodalAtomicPower_ = interscaleManager.dense_matrix("NodalAtomicPower"); - + // power induced by lambda - DotTwiceKineticEnergy * atomicLambdaPower = + DotTwiceKineticEnergy * atomicLambdaPower = new DotTwiceKineticEnergy(atc_,atomThermostatForces_); interscaleManager.add_per_atom_quantity(atomicLambdaPower, regulatorPrefix_+"AtomicLambdaPower"); - + // restriction to nodes of power induced by lambda nodalAtomicLambdaPower_ = new AtfShapeFunctionRestriction(atc_, atomicLambdaPower, @@ -2211,15 +2211,15 @@ namespace ATC { //-------------------------------------------------------- void ThermostatPowerVerlet::set_thermostat_rhs(DENS_MAT & rhs_nodes) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV // vs Wagner, CMAME, 2008 eq(24) RHS_I = 2/(3kB) flux_I // fluxes are set in ATC transfer rhs_nodes = heatSource_.quantity(); - + // (b) for ess. bcs // form rhs : {sum_a (2 * N_Ia * v_ia * f_ia) - (dtheta/dt)_I} - + // replace rhs for prescribed nodes const DENS_MAT & myNodalAtomicPower(nodalAtomicPower_->quantity()); const DIAG_MAT & myMdMassMatrix(mdMassMatrix_.quantity()); @@ -2241,7 +2241,7 @@ namespace ATC { { // set up rhs set_thermostat_rhs(_rhs_); - + // solve linear system for lambda DENS_MAT & myLambda(lambda_->set_quantity()); solve_for_lambda(_rhs_,myLambda); @@ -2292,7 +2292,7 @@ namespace ATC { { // set up data consistent with stage 3 of ATC_Method::initialize lambdaHoover_ = atomicRegulator_->regulator_data(regulatorPrefix_+"LambdaHoover",1); - + } //-------------------------------------------------------- @@ -2313,18 +2313,18 @@ namespace ATC { AtomicThermostatForce * atomHooverThermostatForces = new AtomicThermostatForce(atc_,atomHooverLambdas); interscaleManager.add_per_atom_quantity(atomHooverThermostatForces, regulatorPrefix_+"AtomHooverThermostatForce"); - SummedAtomicQuantity * atomTotalThermostatForces = + SummedAtomicQuantity * atomTotalThermostatForces = new SummedAtomicQuantity(atc_,atomThermostatForces_,atomHooverThermostatForces); interscaleManager.add_per_atom_quantity(atomTotalThermostatForces, regulatorPrefix_+"AtomTotalThermostatForce"); atomThermostatForces_ = atomTotalThermostatForces; - + // transfers dependent on time integration method - DotTwiceKineticEnergy * atomicHooverLambdaPower = + DotTwiceKineticEnergy * atomicHooverLambdaPower = new DotTwiceKineticEnergy(atc_,atomHooverThermostatForces); interscaleManager.add_per_atom_quantity(atomicHooverLambdaPower, regulatorPrefix_+"AtomicHooverLambdaPower"); - + nodalAtomicHooverLambdaPower_ = new AtfShapeFunctionRestriction(atc_, atomicHooverLambdaPower, interscaleManager.per_atom_sparse_matrix("Interpolant")); @@ -2354,14 +2354,14 @@ namespace ATC { // apply prescribed/extrinsic sources and fixed nodes ThermostatPowerVerlet::compute_thermostat(0.5*dt); _nodalAtomicLambdaPowerOut_ = nodalAtomicLambdaPower_->quantity(); // save power from lambda in power-based thermostat - + // set up Hoover rhs set_hoover_rhs(_rhs_); - + // solve linear system for lambda DENS_MAT & myLambda(lambdaHoover_->set_quantity()); solve_for_lambda(_rhs_,myLambda); - + // compute force applied by lambda // compute nodal atomic power from Hoover coupling // only add in contribution to uncoupled nodes @@ -2384,7 +2384,7 @@ namespace ATC { //-------------------------------------------------------- // add_to_nodal_lambda_power: - // determines the power exerted by the Hoover + // determines the power exerted by the Hoover // thermostat at each FE node //-------------------------------------------------------- void ThermostatHooverVerlet::add_to_lambda_power(const DENS_MAT & /* myLambdaForce */, @@ -2429,7 +2429,7 @@ namespace ATC { void ThermostatPowerVerletFiltered::compute_boundary_flux(FIELDS & fields) { ThermostatPowerVerlet::compute_boundary_flux(fields); - + // compute boundary flux rate of change fluxRoc_[TEMPERATURE] = 0.; atc_->compute_boundary_flux(fieldMask_, @@ -2438,11 +2438,11 @@ namespace ATC { atomMaterialGroups_, shpFcnDerivs_); - + // compute extrinsic model rate of change (atc_->extrinsic_model_manager()).set_sources(fieldsRoc_,fluxRoc_); - heatSourceRoc_ = fluxRoc_[TEMPERATURE].quantity(); + heatSourceRoc_ = fluxRoc_[TEMPERATURE].quantity(); } //-------------------------------------------------------- @@ -2464,7 +2464,7 @@ namespace ATC { //-------------------------------------------------------- void ThermostatPowerVerletFiltered::set_thermostat_rhs(DENS_MAT & rhs_nodes) { - // (a) for flux based : + // (a) for flux based : // form rhs : \int N_I r dV // vs Wagner, CMAME, 2008 eq(24) RHS_I = 2/(3kB) flux_I // fluxes are set in ATC transfer @@ -2529,18 +2529,18 @@ namespace ATC { AtomicThermostatForce * atomHooverThermostatForces = new AtomicThermostatForce(atc_,atomHooverLambdas); interscaleManager.add_per_atom_quantity(atomHooverThermostatForces, regulatorPrefix_+"AtomHooverThermostatForce"); - SummedAtomicQuantity * atomTotalThermostatForces = + SummedAtomicQuantity * atomTotalThermostatForces = new SummedAtomicQuantity(atc_,atomThermostatForces_,atomHooverThermostatForces); interscaleManager.add_per_atom_quantity(atomTotalThermostatForces, regulatorPrefix_+"AtomTotalThermostatForce"); atomThermostatForces_ = atomTotalThermostatForces; - + // transfers dependent on time integration method - DotTwiceKineticEnergy * atomicHooverLambdaPower = + DotTwiceKineticEnergy * atomicHooverLambdaPower = new DotTwiceKineticEnergy(atc_,atomHooverThermostatForces); interscaleManager.add_per_atom_quantity(atomicHooverLambdaPower, regulatorPrefix_+"AtomicHooverLambdaPower"); - + nodalAtomicHooverLambdaPower_ = new AtfShapeFunctionRestriction(atc_, atomicHooverLambdaPower, interscaleManager.per_atom_sparse_matrix("Interpolant")); @@ -2559,15 +2559,15 @@ namespace ATC { // apply prescribed/extrinsic sources and fixed nodes ThermostatPowerVerletFiltered::compute_thermostat(0.5*dt); _nodalAtomicLambdaPowerOut_ = nodalAtomicLambdaPower_->quantity(); // save power from lambda in power-based thermostat - + // set up Hoover rhs set_hoover_rhs(_rhs_); - + // solve linear system for lambda DENS_MAT & myLambda(lambdaHoover_->set_quantity()); solve_for_lambda(_rhs_,myLambda); - - + + // compute force applied by lambda // compute nodal atomic power from Hoover coupling // only add in contribution to uncoupled nodes @@ -2590,7 +2590,7 @@ namespace ATC { //-------------------------------------------------------- // add_to_nodal_lambda_power: - // determines the power exerted by the Hoover + // determines the power exerted by the Hoover // thermostat at each FE node //-------------------------------------------------------- void ThermostatHooverVerletFiltered::add_to_lambda_power(const DENS_MAT & /* myLambdaForce */, diff --git a/lib/atc/Thermostat.h b/lib/atc/Thermostat.h index 3764d0b835..2222dea452 100644 --- a/lib/atc/Thermostat.h +++ b/lib/atc/Thermostat.h @@ -22,22 +22,22 @@ namespace ATC { * @brief Manager class for atom-continuum control of thermal energy */ class Thermostat : public AtomicRegulator { - + public: // constructor Thermostat(ATC_Coupling * atc, const std::string & regulatorPrefix = ""); - + // destructor virtual ~Thermostat(){}; - + /** parser/modifier */ virtual bool modify(int narg, char **arg); /** instantiate up the desired method(s) */ virtual void construct_methods(); - + // data access, intended for method objects /** reset the nodal power to a prescribed value */ virtual void reset_lambda_contribution(const DENS_MAT & target); @@ -57,10 +57,10 @@ namespace ATC { int lambdaMaxIterations_; private: - + // DO NOT define this Thermostat(); - + }; /** @@ -68,15 +68,15 @@ namespace ATC { * @brief Class for thermostat algorithms using the shape function matrices * (thermostats have general for of N^T w N lambda = rhs) */ - + class ThermostatShapeFunction : public RegulatorShapeFunction { - + public: - + ThermostatShapeFunction(AtomicRegulator * thermostat, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatShapeFunction() {}; /** instantiate all needed data */ @@ -89,9 +89,9 @@ namespace ATC { virtual void set_weights(); // member data - + /** MD mass matrix */ - DIAG_MAN & mdMassMatrix_; + DIAG_MAN & mdMassMatrix_; /** pointer to atom velocities */ FundamentalAtomQuantity * atomVelocities_; @@ -110,20 +110,20 @@ namespace ATC { * @class ThermostatRescale * @brief Enforces constraint on atomic kinetic energy based on FE temperature */ - + class ThermostatRescale : public ThermostatShapeFunction { - + public: friend class KinetoThermostatRescale; // since this is sometimes used as a set of member functions for friend - + ThermostatRescale(AtomicRegulator * thermostat); - + virtual ~ThermostatRescale() {}; /** instantiate all needed data */ virtual void construct_transfers(); - + /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); @@ -133,7 +133,7 @@ namespace ATC { /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: /** set weighting factor for in matrix Nhat^T * weights * Nhat */ @@ -147,7 +147,7 @@ namespace ATC { /** construct the RHS vector */ virtual void set_rhs(DENS_MAT & rhs); - + /** FE temperature field */ DENS_MAN & nodalTemperature_; @@ -161,7 +161,7 @@ namespace ATC { // DO NOT define this ThermostatRescale(); - + }; /** @@ -169,13 +169,13 @@ namespace ATC { * @brief Enforces constraint on atomic kinetic energy based on FE temperature * when the temperature is a mix of the KE and PE */ - + class ThermostatRescaleMixedKePe : public ThermostatRescale { - + public: - + ThermostatRescaleMixedKePe(AtomicRegulator * thermostat); - + virtual ~ThermostatRescaleMixedKePe() {}; /** instantiate all needed data */ @@ -183,7 +183,7 @@ namespace ATC { /** pre-run initialization of method data */ virtual void initialize(); - + protected: /** set weighting factor for in matrix Nhat^T * weights * Nhat */ @@ -205,7 +205,7 @@ namespace ATC { // DO NOT define this ThermostatRescaleMixedKePe(); - + }; /** @@ -213,16 +213,16 @@ namespace ATC { * @brief Class for solving the linear system for lambda * (thermostats have general for of N^T w N lambda = rhs) */ - + class ThermostatFsSolver : public RegulatorShapeFunction { - + public: - + ThermostatFsSolver(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatFsSolver() {}; /** pre-run initialization of method data */ @@ -240,7 +240,7 @@ namespace ATC { protected: - // methods + // methods /** solves the non-linear equation for lambda iteratively */ void iterate_lambda(const MATRIX & rhs); @@ -277,15 +277,15 @@ namespace ATC { * @class ThermostatGlcFs * @brief Class for thermostat algorithms which perform the time-integration component of the fractional step method */ - + class ThermostatGlcFs : public RegulatorMethod { - + public: - + ThermostatGlcFs(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatGlcFs() {}; /** instantiate all needed data */ @@ -302,10 +302,10 @@ namespace ATC { /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); - + /** compute boundary flux, requires regulator input since it is part of the coupling scheme */ virtual void compute_boundary_flux(FIELDS & fields); - + /** get data for output */ virtual void output(OUTPUT_LIST & outputData); @@ -343,9 +343,9 @@ namespace ATC { /** solver for lambda linear system */ ThermostatFsSolver * lambdaSolver_; - + /** MD mass matrix */ - DIAG_MAN & mdMassMatrix_; + DIAG_MAN & mdMassMatrix_; /** pointer to atom velocities */ FundamentalAtomQuantity * atomVelocities_; @@ -413,18 +413,18 @@ namespace ATC { */ class ThermostatSolverFlux : public ThermostatFsSolver { - + public: - + ThermostatSolverFlux(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatSolverFlux() {}; /** instantiate all needed data */ virtual void construct_transfers(); - + protected: // methods @@ -444,18 +444,18 @@ namespace ATC { */ class ThermostatIntegratorFlux : public ThermostatGlcFs { - + public: - + ThermostatIntegratorFlux(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatIntegratorFlux() {}; /** pre-run initialization of method data */ virtual void initialize(); - + protected: /** sets up appropriate rhs for thermostat equations */ @@ -484,18 +484,18 @@ namespace ATC { */ class ThermostatSolverFixed : public ThermostatFsSolver { - + public: - + ThermostatSolverFixed(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatSolverFixed() {}; /** instantiate all needed data */ virtual void construct_transfers(); - + protected: // methods @@ -515,13 +515,13 @@ namespace ATC { */ class ThermostatIntegratorFixed : public ThermostatGlcFs { - + public: - + ThermostatIntegratorFixed(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatIntegratorFixed() {}; /** instantiate all needed data */ @@ -529,7 +529,7 @@ namespace ATC { /** pre-run initialization of method data */ virtual void initialize(); - + /** applies thermostat to atoms in the predictor phase */ virtual void apply_pre_predictor(double dt); @@ -545,7 +545,7 @@ namespace ATC { /** determine if local shape function matrices are needed */ virtual bool use_local_shape_functions() const {return atomicRegulator_->use_localized_lambda();}; - + protected: // methods @@ -613,13 +613,13 @@ namespace ATC { */ class ThermostatIntegratorFluxFiltered : public ThermostatIntegratorFlux { - + public: - + ThermostatIntegratorFluxFiltered(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatIntegratorFluxFiltered() {}; /** pre-run initialization of method data */ @@ -630,7 +630,7 @@ namespace ATC { /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: /** sets up appropriate rhs for thermostat equations */ @@ -660,20 +660,20 @@ namespace ATC { * @brief Class for thermostatting using the temperature matching constraint and is compatible with the fractional step time-integration with time filtering */ - + class ThermostatIntegratorFixedFiltered : public ThermostatIntegratorFixed { - + public: - + ThermostatIntegratorFixedFiltered(AtomicRegulator * thermostat, int lambdaMaxIterations, const std::string & regulatorPrefix = ""); - + virtual ~ThermostatIntegratorFixedFiltered() {}; /** get data for output */ virtual void output(OUTPUT_LIST & outputData); - + protected: // methods @@ -711,7 +711,7 @@ namespace ATC { ThermostatFluxFixed(AtomicRegulator * thermostat, int lambdaMaxIterations, bool constructThermostats = true); - + virtual ~ThermostatFluxFixed(); /** instantiate all needed data */ @@ -728,7 +728,7 @@ namespace ATC { /** applies thermostat to atoms in the post-corrector phase */ virtual void apply_post_corrector(double dt); - + /** get data for output */ virtual void output(OUTPUT_LIST & outputData); @@ -765,7 +765,7 @@ namespace ATC { ThermostatFluxFixedFiltered(AtomicRegulator * thermostat, int lambdaMaxIterations); - + virtual ~ThermostatFluxFixedFiltered(){}; private: @@ -779,13 +779,13 @@ namespace ATC { * @class ThermostatGlc * @brief Class for thermostat algorithms based on Gaussian least constraints (GLC) */ - + class ThermostatGlc : public ThermostatShapeFunction { - + public: - + ThermostatGlc(AtomicRegulator * thermostat); - + virtual ~ThermostatGlc() {}; /** instantiate all needed data */ @@ -795,7 +795,7 @@ namespace ATC { // methods /** apply forces to atoms */ - virtual void apply_to_atoms(PerAtomQuantity * atomicVelocity, + virtual void apply_to_atoms(PerAtomQuantity * atomicVelocity, const DENS_MAT & lambdaForce, double dt); @@ -830,21 +830,21 @@ namespace ATC { * @brief Class for thermostatting using the heat flux matching constraint and is compatible with the Gear time-integration */ - + class ThermostatPowerVerlet : public ThermostatGlc { - + public: ThermostatPowerVerlet(AtomicRegulator * thermostat); - + virtual ~ThermostatPowerVerlet() {}; /** instantiate all needed data */ virtual void construct_transfers(); - + /** pre-run initialization of method data */ virtual void initialize(); - + /** applies thermostat to atoms in the predictor phase */ virtual void apply_pre_predictor(double dt); @@ -895,19 +895,19 @@ namespace ATC { ThermostatPowerVerlet(); }; - + /** * @class ThermostatHooverVerlet * @brief Classfor thermostatting using the temperature matching constraint and is compatible with - Gear time-integration + Gear time-integration */ - + class ThermostatHooverVerlet : public ThermostatPowerVerlet { - + public: ThermostatHooverVerlet(AtomicRegulator * thermostat); - + virtual ~ThermostatHooverVerlet() {}; /** instantiate all needed data */ @@ -956,13 +956,13 @@ namespace ATC { * @brief Class for thermostatting using the heat flux matching constraint and is compatible with Gear time-integration with time filtering */ - + class ThermostatPowerVerletFiltered : public ThermostatPowerVerlet { - + public: ThermostatPowerVerletFiltered(AtomicRegulator * thermostat); - + virtual ~ThermostatPowerVerletFiltered(){}; /** get data for output */ @@ -987,7 +987,7 @@ namespace ATC { /** references to ATC field rates of changing for inverting the filtered heat sources */ FIELDS & fieldsRoc_; - + /** flux rate of changes for inverting filtered fluxes */ FIELDS fluxRoc_; @@ -1006,21 +1006,21 @@ namespace ATC { * @brief Class for thermostatting using the temperature matching constraint and is compatible with Gear time-integration with time filtering */ - + class ThermostatHooverVerletFiltered : public ThermostatPowerVerletFiltered { - + public: ThermostatHooverVerletFiltered(AtomicRegulator * thermostat); - + virtual ~ThermostatHooverVerletFiltered() {}; /** instantiate all needed data */ virtual void construct_transfers(); - + /** final tasks of a run */ virtual void finish() {}; - + /** compute boundary flux, requires thermostat input since it is part of the coupling scheme */ virtual void compute_boundary_flux(FIELDS & /* fields */) {boundaryFlux_[TEMPERATURE] = 0.;}; diff --git a/lib/atc/TimeFilter.cpp b/lib/atc/TimeFilter.cpp index ece3429c86..6cb4309cfc 100644 --- a/lib/atc/TimeFilter.cpp +++ b/lib/atc/TimeFilter.cpp @@ -10,7 +10,7 @@ namespace ATC { // Class TimeFilterManager //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -25,7 +25,7 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -35,7 +35,7 @@ namespace ATC { for (it = timeFilterSet_.begin(); it != timeFilterSet_.end(); it++) if (*it) delete *it; } - + //-------------------------------------------------------- // modify // parses input commands @@ -43,7 +43,7 @@ namespace ATC { bool TimeFilterManager::modify(int /* narg */, char ** arg) { bool foundMatch = false; - + // filter scale size /*! \page man_filter_scale fix_modify AtC filter scale \section syntax @@ -96,7 +96,7 @@ namespace ATC { \section default off */ - else if (strcmp(arg[0],"on")==0) { + else if (strcmp(arg[0],"on")==0) { if (filterScale_<=0. && filterType_ != STEP_FILTER) throw ATC_Error("Filtering time scale not initialized"); useFilter_ = true; @@ -110,7 +110,7 @@ namespace ATC { equilibrateFilter_ = false; foundMatch = true; } - else if (strcmp(arg[0],"off")==0) { + else if (strcmp(arg[0],"off")==0) { useFilter_ = false; equilibrateFilter_ = false; endEquilibrate_ = false; @@ -127,8 +127,8 @@ namespace ATC { foundMatch = true; } - // filter type - /*! \page man_filter_type fix_modify AtC filter type + // filter type + /*! \page man_filter_type fix_modify AtC filter type \section syntax fix_modify AtC filter type \n @@ -146,16 +146,16 @@ namespace ATC { \ref man_filter_scale \section default - No default. + No default. */ - else if (strcmp(arg[0],"type")==0) { - if (strcmp(arg[1],"exponential")==0) { + else if (strcmp(arg[0],"type")==0) { + if (strcmp(arg[1],"exponential")==0) { filterType_ = EXPONENTIAL_FILTER; } - else if (strcmp(arg[1],"step")==0) { + else if (strcmp(arg[1],"step")==0) { filterType_ = STEP_FILTER; } - else if (strcmp(arg[1],"no_filter")==0) { + else if (strcmp(arg[1],"no_filter")==0) { filterType_ = NO_FILTER; } else throw ATC_Error("Not a supported time filter type"); @@ -180,51 +180,51 @@ namespace ATC { // construct // instantiates the filter //-------------------------------------------------------- - + TimeFilter * TimeFilterManager::construct(const FilterIntegrationType intType) { TimeFilter * newTimeFilter; if (useFilter_ || equilibrateFilter_) { if (filterType_ == EXPONENTIAL_FILTER) { if (intType == IMPLICIT_EXPLICIT) { - newTimeFilter = new TimeFilterImplicitExplicit(*this); + newTimeFilter = new TimeFilterImplicitExplicit(*this); } else if (intType == EXPLICIT_IMPLICIT) { - newTimeFilter = new TimeFilterExplicitImplicit(*this); + newTimeFilter = new TimeFilterExplicitImplicit(*this); } else if (intType == EXPLICIT) { - newTimeFilter = new TimeFilterExplicit(*this); + newTimeFilter = new TimeFilterExplicit(*this); } else if (intType == IMPLICIT) { - newTimeFilter = new TimeFilterImplicit(*this); + newTimeFilter = new TimeFilterImplicit(*this); } else if (intType == IMPLICIT_UPDATE) { - newTimeFilter = new TimeFilterImplicitUpdate(*this); + newTimeFilter = new TimeFilterImplicitUpdate(*this); } else if (intType == CRANK_NICHOLSON) { - newTimeFilter = new TimeFilterCrankNicolson(*this); + newTimeFilter = new TimeFilterCrankNicolson(*this); } else { // default to return base class - newTimeFilter = new TimeFilter(*this); + newTimeFilter = new TimeFilter(*this); } } else if (filterType_ == STEP_FILTER) { - newTimeFilter = new TimeFilterStep(*this); + newTimeFilter = new TimeFilterStep(*this); } else newTimeFilter = nullptr; } else { // default to return base class - newTimeFilter = new TimeFilter(*this); + newTimeFilter = new TimeFilter(*this); } timeFilterSet_.insert(newTimeFilter); return newTimeFilter; } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilter //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -275,13 +275,13 @@ namespace ATC { unFilteredQuantityOld_.reset(target.nRows(),target.nCols()); unFilteredQuantityOld_ = target; } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterExplicit //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -290,13 +290,13 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterImplicit //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -305,13 +305,13 @@ namespace ATC { { // do nothing } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterImplicitExplicit //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -326,7 +326,7 @@ namespace ATC { // Class TimeFilterExplicitImplicit //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -341,7 +341,7 @@ namespace ATC { // Class TimeFilterImplicitUpdate //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -356,7 +356,7 @@ namespace ATC { // Class TimeFilterStep //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- diff --git a/lib/atc/TimeFilter.h b/lib/atc/TimeFilter.h index 321d9bb8e6..07ca91efef 100644 --- a/lib/atc/TimeFilter.h +++ b/lib/atc/TimeFilter.h @@ -1,4 +1,4 @@ -// The type of filter used should be determined by the +// The type of filter used should be determined by the // integrator since filtering much match the time integration scheme @@ -29,7 +29,7 @@ namespace ATC { //-------------------------------------------------------- class TimeFilterManager { - + public: /** enumeration for the functional form underlying the filter */ @@ -49,13 +49,13 @@ namespace ATC { IMPLICIT, IMPLICIT_UPDATE }; - + // constructor TimeFilterManager(ATC_Method * atc); - + // destructor ~TimeFilterManager(); - + /** parser/modifier */ bool modify(int narg, char **arg); @@ -64,10 +64,10 @@ namespace ATC { /** get filter base function */ TimeFilterType filter_type() const {return filterType_;}; - + /** return filtering time scale */ double filter_scale() const {return filterScale_;}; - + /** check if dynamics should be filtering */ bool filter_dynamics() const {return useFilter_;}; @@ -85,26 +85,26 @@ namespace ATC { /** construct the appropriate time filter */ TimeFilter * construct(const FilterIntegrationType type = CRANK_NICHOLSON); - + protected: TimeFilterManager(){}; - + /** pointer to access ATC methods */ ATC_Method * atc_; /** description of underlying function form of filter */ TimeFilterType filterType_; - + /** filtering time scale */ double filterScale_; - + /** flag to see if filtering is active */ bool useFilter_; /** flag to see if we are equilibrating the filtered variables */ bool equilibrateFilter_; - + /** flag to reset data */ bool needReset_; @@ -113,7 +113,7 @@ namespace ATC { /** set to store all time filters for later deletion */ std::set timeFilterSet_; - + }; /** @@ -130,12 +130,12 @@ namespace ATC { class TimeFilter { - + public: - + // constructor TimeFilter(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilter(){}; @@ -144,67 +144,67 @@ namespace ATC { /** pre time integration with a target for an initial condition */ virtual void initialize(const MATRIX & /* target */){initialize();}; - + /** Step 1: apply first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & /* filteredQuantity */, const MATRIX & unFilteredQuantity, double /* dt */) { TimeFilter::unFilteredQuantityOld_ = unFilteredQuantity;} - + /** Step 2: apply second step in a time filter update in pre integration phase */ virtual void apply_pre_step2(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** Step 3: apply first step in a time filter update in post integration phase */ virtual void apply_post_step1(MATRIX & filteredQuantity, const MATRIX & unFilteredQuantity, - double /* dt */) + double /* dt */) { filteredQuantity = unFilteredQuantity;}; - + /** Step 4: apply second step in a time filter update in post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, const MATRIX & unFilteredQuantity, double /* dt */) { filteredQuantity = unFilteredQuantity;} - + /** coefficient multipling unfiltered terms in apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double /* dt */){return 0.;}; /** coefficient multipling old filtered terms in apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double /* dt */){return 0.;}; - + /** coefficient multipling unfiltered terms in apply_post_step1 method */ virtual double unfiltered_coefficient_post_s1(double /* dt */){return 0.;}; /** coefficient multipling old filtered terms in apply_post_step1 method */ virtual double filtered_coefficient_post_s1(double /* dt */){return 0.;}; - + /** coefficient multipling unfiltered terms in apply_pre_step2 method */ virtual double unfiltered_coefficient_pre_s2(double /* dt */){return 0.;}; /** coefficient multipling old filtered terms in apply_pre_step2 method */ virtual double filtered_coefficient_pre_s2(double /* dt */){return 0.;}; - + /** coefficient multipling unfiltered terms in apply_post_step2 method */ virtual double unfiltered_coefficient_post_s2(double /* dt */){return 0.;}; /** coefficient multipling old filtered terms in apply_post_step2 method */ virtual double filtered_coefficient_post_s2(double /* dt */){return 0.;}; - + /** rate of filtered quantity to be called in post integration phase */ virtual void rate(MATRIX & rate, const MATRIX & /* filteredQuantity */, const MATRIX & unFilteredQuantity, double dt = 0.0) - { rate = 1/dt*(unFilteredQuantity - TimeFilter::unFilteredQuantityOld_);}; + { rate = 1/dt*(unFilteredQuantity - TimeFilter::unFilteredQuantityOld_);}; protected: - + TimeFilter(){}; /** pointer to access ATC methods */ @@ -218,7 +218,7 @@ namespace ATC { /** member data to track old unfiltered values */ DENS_MAT unFilteredQuantityOld_; - + }; /** @@ -234,29 +234,29 @@ namespace ATC { //-------------------------------------------------------- class TimeFilterExponential : public TimeFilter { - + public: - + // constructor TimeFilterExponential(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterExponential(){}; /** apply first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply second step in a time filter update in pre integration phase */ virtual void apply_pre_step2(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply first step in a time filter update in post integration phase */ virtual void apply_post_step1(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply second step in a time filter update in post integration phase */ virtual void apply_post_step2(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, @@ -279,14 +279,14 @@ namespace ATC { protected: TimeFilterExponential(){}; - + //-------------------------------------------------------- //-------------------------------------------------------- // filter integration functions not associated // with any particular class //-------------------------------------------------------- //-------------------------------------------------------- - + void update_filter(MATRIX & filteredQuantity, const MATRIX & unfilteredQuantity, MATRIX & unfilteredQuantityOld, @@ -313,12 +313,12 @@ namespace ATC { double filtered_coef(double tau, double dt) { return 1./(1./dt+1./(2.*tau))*( 1./dt-1./(2*tau) ); }; - + void update_filter_implicit(MATRIX & filteredQuantity, const MATRIX & unfilteredQuantity, double tau, double dt) - { + { filteredQuantity /= 1.0 + dt/tau; filteredQuantity += (dt)/(tau+dt)*unfilteredQuantity; } @@ -328,13 +328,13 @@ namespace ATC { double tau, double dt) { filteredQuantity += (1./(1.+dt/tau))*(dt/tau)*unfilteredQuantity; }; - + double unfiltered_coef_implicit(double tau, double dt) { return (1./(1.+dt/tau))*(dt/tau); }; double filtered_coef_implicit(double tau, double dt) { return (1./(1.+dt/tau)); }; - + void update_filter_explicit(MATRIX & filteredQuantity, const MATRIX & unfilteredQuantity, double tau, @@ -343,13 +343,13 @@ namespace ATC { filteredQuantity *= (1.-(dt/tau)); filteredQuantity += (dt/tau)*unfilteredQuantity; } - + void add_to_filter_explicit(MATRIX & filteredQuantity, const MATRIX & unfilteredQuantity, double tau, double dt) { filteredQuantity += (dt/tau)*unfilteredQuantity; }; - + double unfiltered_coef_explicit(double tau, double dt) { return (dt/tau); }; @@ -362,28 +362,28 @@ namespace ATC { * @class TimeFilterCrankNicolson * @brief Time Filter using Crank-Nicolson advancement of filtered quantity ODE's */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterCrankNicolson //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterCrankNicolson : public TimeFilterExponential { - + public: - + // constructor TimeFilterCrankNicolson(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterCrankNicolson(){}; /** pre time integration */ virtual void initialize(){throw ATC_Error("TimeFilterCrankNicolson::initialize() an initial condition is required for this time filter");}; - + /** pre time integration with an initial condition */ virtual void initialize(const MATRIX & target); - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, @@ -395,31 +395,31 @@ namespace ATC { MATRIX const & unFilteredQuantity, double dt) { add_to_filter(filteredQuantity,unFilteredQuantity,unFilteredQuantityOld_,TimeFilter::filterScale_,dt); }; - + /** applies second step in a time filter update in the post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter(filteredQuantity,unFilteredQuantity,unFilteredQuantityOld_,TimeFilter::filterScale_,dt); }; - + /** return coefficient multipling unfiltered terms in the apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double dt){return unfiltered_coef(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef(TimeFilter::filterScale_,dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s2(double dt){return unfiltered_coef(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_post_step2 method */ virtual double filtered_coefficient_post_s2(double dt){return filtered_coef(TimeFilter::filterScale_,dt);}; - + protected: - + TimeFilterCrankNicolson(); - + }; - + /** * @class TimeFilterExplicit * @brief Time Filter using explicit advancement of filtered quantity ODE's @@ -431,15 +431,15 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterExplicit : public TimeFilterExponential { - + public: - + // constructor TimeFilterExplicit(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterExplicit(){}; - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, @@ -451,31 +451,31 @@ namespace ATC { MATRIX const & unFilteredQuantity, double dt) { add_to_filter_explicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,dt); }; - + /** applies second step in a time filter update in the post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter_explicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,dt); }; - + /** return coefficient multipling unfiltered terms in the apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double dt){return unfiltered_coef_explicit(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef_explicit(TimeFilter::filterScale_,dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s2(double dt){return unfiltered_coef_explicit(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_post_step2 method */ virtual double filtered_coefficient_post_s2(double dt){return filtered_coef_explicit(TimeFilter::filterScale_,dt);}; - + protected: - + TimeFilterExplicit(); - + }; - + /** * @class TimeFilterImplicit * @brief Time Filter using implicit advancement of filtered quantity ODE's @@ -487,21 +487,21 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterImplicit : public TimeFilterExponential { - + public: - + // constructor TimeFilterImplicit(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterImplicit(){}; - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter_implicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,dt); }; - + /** applies second step in a time filter update in the post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, @@ -513,19 +513,19 @@ namespace ATC { /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s2(double dt){return unfiltered_coef_implicit(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_post_step2 method */ virtual double filtered_coefficient_post_s2(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,dt);}; - + protected: - + TimeFilterImplicit(); - + }; - + /** * @class TimeFilterImplicitExplicit * @brief Time Filter using two-step implicit/explicit advancement of filtered quantity ODE's @@ -537,43 +537,43 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterImplicitExplicit : public TimeFilterExponential { - + public: - + // constructor TimeFilterImplicitExplicit(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterImplicitExplicit(){}; - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter_implicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,0.5*dt); }; - + /** applies second step in a time filter update in the post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter_explicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,0.5*dt); }; - + /** return coefficient multipling unfiltered terms in the apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double dt){return unfiltered_coef_implicit(TimeFilter::filterScale_,0.5*dt);}; /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,0.5*dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s2(double dt){return unfiltered_coef_explicit(TimeFilter::filterScale_,0.5*dt);}; /** return coefficient multipling old filtered terms in the apply_post_step2 method */ virtual double filtered_coefficient_post_s2(double dt){return filtered_coef_explicit(TimeFilter::filterScale_,0.5*dt);}; - + protected: - + TimeFilterImplicitExplicit(); - + }; /** @@ -587,15 +587,15 @@ namespace ATC { //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterExplicitImplicit : public TimeFilterExponential { - + public: - + // constructor TimeFilterExplicitImplicit(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterExplicitImplicit(){}; - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, @@ -619,13 +619,13 @@ namespace ATC { MATRIX const & unFilteredQuantity, double dt) { add_to_filter_implicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,0.5*dt); }; - + /** return coefficient multipling unfiltered terms in the apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double dt){return unfiltered_coef_explicit(TimeFilter::filterScale_,0.5*dt);}; /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef_explicit(TimeFilter::filterScale_,0.5*dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s1(double dt){return unfiltered_coef_implicit(TimeFilter::filterScale_,0.5*dt);}; @@ -633,61 +633,61 @@ namespace ATC { virtual double filtered_coefficient_post_s1(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,0.5*dt);}; protected: - + TimeFilterExplicitImplicit(); - + }; /** * @class TimeFilterImplicitUpdate * @brief Time Filter using implicit advancement of filtered quantity ODE's but adds on contribution at the end of the second step */ - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterImplicitUpdate //-------------------------------------------------------- //-------------------------------------------------------- class TimeFilterImplicitUpdate : public TimeFilterExponential { - + public: - + // constructor TimeFilterImplicitUpdate(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterImplicitUpdate(){}; - + /** applies first step in a time filter update in the pre integration phase */ virtual void apply_pre_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { update_filter_implicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,dt); }; - + /** applies second step in a time filter update in the post integration phase */ virtual void apply_post_step1(MATRIX & filteredQuantity, MATRIX const & unFilteredQuantity, double dt) { add_to_filter_implicit(filteredQuantity,unFilteredQuantity,TimeFilter::filterScale_,dt); }; - + /** return coefficient multipling unfiltered terms in the apply_pre_step1 method */ virtual double unfiltered_coefficient_pre_s1(double dt){return unfiltered_coef_implicit(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_pre_step1 method */ virtual double filtered_coefficient_pre_s1(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,dt);}; - + /** return coefficient multipling unfiltered terms in the apply_post_step2 method */ virtual double unfiltered_coefficient_post_s1(double dt){return unfiltered_coef_implicit(TimeFilter::filterScale_,dt);}; /** return coefficient multipling old filtered terms in the apply_post_step2 method */ virtual double filtered_coefficient_post_s1(double dt){return filtered_coef_implicit(TimeFilter::filterScale_,dt);}; - + protected: - + TimeFilterImplicitUpdate(); - + }; - + //-------------------------------------------------------- //-------------------------------------------------------- // Class TimeFilterStep @@ -695,12 +695,12 @@ namespace ATC { //-------------------------------------------------------- class TimeFilterStep : public TimeFilter { - + public: - + // constructor TimeFilterStep(TimeFilterManager & timeFilterManager); - + // destructor virtual ~TimeFilterStep(){}; @@ -711,23 +711,23 @@ namespace ATC { virtual void apply_pre_step1(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply second step in a time filter update in pre integration phase */ virtual void apply_pre_step2(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply first step in a time filter update in post integration phase */ virtual void apply_post_step1(MATRIX & /* filteredQuantity */, const MATRIX & /* unFilteredQuantity */, double /* dt */) {}; - + /** apply second step in a time filter update in post integration phase */ virtual void apply_post_step2(MATRIX & filteredQuantity, const MATRIX & unFilteredQuantity, - double dt) + double dt) { update_filter(filteredQuantity, unFilteredQuantity, - TimeFilter::unFilteredQuantityOld_, TimeFilter::filterScale_, dt); + TimeFilter::unFilteredQuantityOld_, TimeFilter::filterScale_, dt); } /** time rate of filtered quantity */ @@ -745,9 +745,9 @@ namespace ATC { protected: TimeFilterStep(){}; - + double elapsedTime_; - + void update_filter(MATRIX & filteredQuantity, const MATRIX & unfilteredQuantity, MATRIX & unfilteredQuantitySum, @@ -764,10 +764,10 @@ namespace ATC { else { // a running average elapsedTime_ += dt; unfilteredQuantitySum += unfilteredQuantity*dt; - filteredQuantity = unfilteredQuantitySum; + filteredQuantity = unfilteredQuantitySum; filteredQuantity /= elapsedTime_; } - if (elapsedTime_ >= tau && tau > 0) { + if (elapsedTime_ >= tau && tau > 0) { elapsedTime_ = 0.0; } }; diff --git a/lib/atc/TimeIntegrator.cpp b/lib/atc/TimeIntegrator.cpp index f370d17170..85d1193117 100644 --- a/lib/atc/TimeIntegrator.cpp +++ b/lib/atc/TimeIntegrator.cpp @@ -10,7 +10,7 @@ namespace ATC { // Class AtomTimeIntegratorType //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -45,14 +45,14 @@ namespace ATC { void AtomTimeIntegratorType::init_integrate_velocity(double dt) { const DENS_MAT & m(mass_->quantity()); - + _deltaQuantity_ = force_->quantity(); _deltaQuantity_ /= m; _deltaQuantity_ *= 0.5*dt; (*velocity_) += _deltaQuantity_; } - + //-------------------------------------------------------- // initial_integrate_position // position update in first part of velocity-verlet @@ -84,7 +84,7 @@ namespace ATC { // Class TimeIntegrator //-------------------------------------------------------- //-------------------------------------------------------- - + //-------------------------------------------------------- // Constructor //-------------------------------------------------------- @@ -170,7 +170,7 @@ namespace ATC { //-------------------------------------------------------- // pre_final_integrate1 - // first time integration computations + // first time integration computations // before Verlet step 2 //-------------------------------------------------------- void TimeIntegrator::pre_final_integrate1(double dt) @@ -190,7 +190,7 @@ namespace ATC { //-------------------------------------------------------- // post_final_integrate1 - // first time integration computations + // first time integration computations // after Verlet step 2 //-------------------------------------------------------- void TimeIntegrator::post_final_integrate1(double dt) @@ -270,7 +270,7 @@ namespace ATC { void TimeIntegrator::pack_fields(RESTART_LIST & data) { timeIntegrationMethod_->pack_fields(data); - + //timeFilter_->pack_fields(data); } @@ -292,7 +292,7 @@ namespace ATC { //-------------------------------------------------------- // Constructor // Grab data from ATC - //-------------------------------------------------------- + //-------------------------------------------------------- TimeIntegrationMethod::TimeIntegrationMethod(TimeIntegrator * timeIntegrator) : timeIntegrator_(timeIntegrator), atc_(timeIntegrator_->atc()) diff --git a/lib/atc/TimeIntegrator.h b/lib/atc/TimeIntegrator.h index ccb9b9f426..109aedc195 100644 --- a/lib/atc/TimeIntegrator.h +++ b/lib/atc/TimeIntegrator.h @@ -18,7 +18,7 @@ namespace ATC { */ class AtomTimeIntegrator { - + public: // constructor @@ -29,7 +29,7 @@ namespace ATC { /** create and get necessary transfer operators */ virtual void construct_transfers(){}; - + /** Predictor phase, Verlet first step for velocity */ virtual void init_integrate_velocity(double /* dt */){}; @@ -47,7 +47,7 @@ namespace ATC { */ class AtomTimeIntegratorType : public AtomTimeIntegrator { - + public: // constructor @@ -58,7 +58,7 @@ namespace ATC { /** create and get necessary transfer operators */ virtual void construct_transfers(); - + /** Predictor phase, Verlet first step for velocity */ virtual void init_integrate_velocity(double dt); @@ -102,9 +102,9 @@ namespace ATC { * @class TimeIntegrator * @brief Base class for various time integrators for FE quantities */ - + class TimeIntegrator { - + public: /** types of time integration */ @@ -119,14 +119,14 @@ namespace ATC { CRANK_NICOLSON, DIRECT }; - + // constructor TimeIntegrator(ATC_Coupling * atc, TimeIntegrationType timeIntegrationType = STEADY); - + // destructor virtual ~TimeIntegrator(); - + /** parser/modifier */ virtual bool modify(int /* narg */, char ** /* arg */){return false;}; @@ -141,7 +141,7 @@ namespace ATC { /** flag if reset is needed */ bool need_reset() const {return needReset_;}; - + // time step methods, corresponding to ATC_Coupling /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double dt); @@ -152,12 +152,12 @@ namespace ATC { virtual void post_initial_integrate1(double dt); /** second part of post_initial_integrate */ virtual void post_initial_integrate2(double dt); - + /** first part of pre_final_integrate */ virtual void pre_final_integrate1(double dt); /** second part of pre_final_integrate */ virtual void pre_final_integrate2(double dt); - + /** first part of post_final_integrate */ virtual void post_final_integrate1(double dt); /** second part of post_final_integrate */ @@ -206,19 +206,19 @@ namespace ATC { /** pointer to time integrator method */ TimeIntegrationMethod * timeIntegrationMethod_; - + /** pointer to access ATC methods */ ATC_Coupling * atc_; - + /** time filter for specific updates */ TimeFilter * timeFilter_; /** time filter manager for getting time filtering info */ TimeFilterManager * timeFilterManager_; - + /** type of integration scheme being used */ TimeIntegrationType timeIntegrationType_; - + /** flat to reset data */ bool needReset_; @@ -235,12 +235,12 @@ namespace ATC { */ class TimeIntegrationMethod { - + public: - + // constructor TimeIntegrationMethod(TimeIntegrator * timeIntegrator); - + // destructor virtual ~TimeIntegrationMethod(){}; @@ -248,7 +248,7 @@ namespace ATC { virtual void construct_transfers(){}; /** pre time integration */ virtual void initialize(){}; - + // time step methods, corresponding to ATC_Coupling and TimeIntegrator /** first part of pre_initial_integrate */ virtual void pre_initial_integrate1(double /* dt */){}; @@ -259,12 +259,12 @@ namespace ATC { virtual void post_initial_integrate1(double /* dt */){}; /** second part of post_initial_integrate */ virtual void post_initial_integrate2(double /* dt */){}; - + /** first part of pre_final_integrate */ virtual void pre_final_integrate1(double /* dt */){}; /** second part of pre_final_integrate */ virtual void pre_final_integrate2(double /* dt */){}; - + /** first part of post_final_integrate */ virtual void post_final_integrate1(double /* dt */){}; /** second part of post_final_integrate */ @@ -288,7 +288,7 @@ namespace ATC { /** finalize any states */ virtual void finish(){}; - + protected: /** owning time integrator */ @@ -358,7 +358,7 @@ namespace ATC { dot_f = dot_f + (1./dt)*R_f; ddot_f = ddot_f + (1./dt/dt)*R_f; }; - + inline void explicit_1(MATRIX & f, const MATRIX & dot_f, double dt) diff --git a/lib/atc/TransferLibrary.cpp b/lib/atc/TransferLibrary.cpp index b77a91fd2e..bfce8da9c5 100644 --- a/lib/atc/TransferLibrary.cpp +++ b/lib/atc/TransferLibrary.cpp @@ -37,7 +37,7 @@ namespace ATC { shapeFunction_(shapeFunction), lammpsInterface_(atc->lammps_interface()), feEngine_(atc->fe_engine()), - tol_(1.e-10) + tol_(1.e-10) { shapeFunction_->register_dependence(this); } @@ -65,7 +65,7 @@ namespace ATC { _scale_.resize(nNodes); for (int i = 0; i < nNodes; i++) { - if ((abs(lhs(i,i)) > 0.)) + if ((abs(lhs(i,i)) > 0.)) _scale_(i) = 1.; else _scale_(i) = 0.; @@ -78,7 +78,7 @@ namespace ATC { } } lhs.compress(); - + // solve equation LinearSolver solver(lhs, ATC::LinearSolver::ITERATIVE_SOLVE_SYMMETRIC, true); solver.set_max_iterations(lhs.nRows()); @@ -146,7 +146,7 @@ namespace ATC { shapeFunction_(shapeFunction), atomElement_(atomElement), feEngine_(atc->fe_engine()), - tol_(1.e-10) + tol_(1.e-10) { shapeFunction_->register_dependence(this); if (!atomElement_) { @@ -162,7 +162,7 @@ namespace ATC { void NodalAtomVolumeElement::reset_quantity() const { // Using analyses by G. Wagner and J. Templeton, weights ~ phi*M^{-1}*V - // where phi are the dimensionless shape/weighting functions, + // where phi are the dimensionless shape/weighting functions, // M is the "mass" matrix M_IJ, // V is the vector of nodal and element volumes // @@ -185,11 +185,11 @@ namespace ATC { int thisCol = nNodes+atomElement(a,0); nodEltShpFcnMatrix.set(a,thisCol,1); } - + SPAR_MAT neMassMatrix(neSize,neSize); atc_->compute_consistent_md_mass_matrix(nodEltShpFcnMatrix,neMassMatrix); - - // form vector of nodal and elemental volumes + + // form vector of nodal and elemental volumes _nodeVolumesMatrix_.resize(nNodes,nNodes); feEngine_->compute_lumped_mass_matrix(_nodeVolumesMatrix_); _nodeVolumes_.resize(nNodes); @@ -217,13 +217,13 @@ namespace ATC { averageEltVolume += (maxx-minx)*(maxy-miny)*(maxz-minz); } averageEltVolume /= nElts; - + // correct entries of mass matrix if no atoms in shape function support double totalNodalVolume = _nodeVolumes_.sum(); double averageNodalVolume = totalNodalVolume/nNodes; _scale_.resize(neSize); for (int i = 0; i < neSize; i++) { - if ((abs(neMassMatrix(i,i)) > 0.)) { + if ((abs(neMassMatrix(i,i)) > 0.)) { _scale_(i) = 1.; } else { printf("No atoms are in support of node/element %i\n",i); @@ -234,7 +234,7 @@ namespace ATC { for (int i = 0; i < neSize; i++) { if (_scale_(i) < 0.5) { neMassMatrix.set(i,i,1.); - if (i < nNodes) { + if (i < nNodes) { _nodeElementVolumes_(i) = averageNodalVolume; } else { _nodeElementVolumes_(i) = averageEltVolume; @@ -242,11 +242,11 @@ namespace ATC { } } neMassMatrix.compress(); - + // solve equation LinearSolver solver(neMassMatrix, ATC::LinearSolver::ITERATIVE_SOLVE_SYMMETRIC, true); solver.set_max_iterations(neMassMatrix.nRows()); - double myTol = 1.e-10; + double myTol = 1.e-10; solver.set_tolerance(myTol); quantity_.resize(neSize,0); CLON_VEC tempQuantity(quantity_,CLONE_COL,0); @@ -329,7 +329,7 @@ namespace ATC { if (!hasGhost_) { hasGhost_ = (atc->interscale_manager()).dense_matrix_int("ElementHasGhost"); } - + hasInternal_->register_dependence(this); if (hasGhost_) hasGhost_->register_dependence(this); } @@ -354,7 +354,7 @@ namespace ATC { quantity_(i,0) = !hasInternal(i,0); } } - + const set & nullElements = feEngine_->null_elements(); set::const_iterator iset; for (iset = nullElements.begin(); iset != nullElements.end(); iset++) { @@ -421,7 +421,7 @@ namespace ATC { SetDependencyManager * nodeSet) : nodeSet_(nodeSet), feMesh_((atc->fe_engine())->fe_mesh()) - { + { nodeSet_->register_dependence(this); } @@ -483,15 +483,15 @@ namespace ATC { _nodesGhost_.reset(nNodes_); _nodesGhost_ = 0; Array nodes; - - - + + + vector myElems = feEngine_->fe_mesh()->owned_elts(); if (hasGhost_) { const INT_ARRAY & hasGhost(hasGhost_->quantity()) ; // iterate through all elements owned by this processor - - + + for (vector::iterator elemsIter = myElems.begin(); elemsIter != myElems.end(); ++elemsIter) @@ -510,7 +510,7 @@ namespace ATC { } } // sum up partial result arrays - + lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesInternal_.ptr(), _nodesInternal_.size()); lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesGhost_.ptr(), _nodesGhost_.size()); } @@ -582,9 +582,9 @@ namespace ATC { _nodesGhost_.reset(nNodes_); _nodesGhost_ = 0; Array nodes; - - - + + + vector myElems = feEngine_->fe_mesh()->owned_elts(); // iterate through all elements owned by this processor for (vector::iterator elemsIter = myElems.begin(); @@ -605,7 +605,7 @@ namespace ATC { } } } - + // sum up partial result arrays lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesInternal_.ptr(), _nodesInternal_.size()); lammpsInterface_->logical_or(MPI_IN_PLACE, _nodesGhost_.ptr(), _nodesGhost_.size()); @@ -882,7 +882,7 @@ namespace ATC { } } } - + //-------------------------------------------------------- //-------------------------------------------------------- // Class MappedQuantity @@ -967,7 +967,7 @@ namespace ATC { { const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); quantity_.clear(); - + for (int i = 0; i < nodeType.size(); ++i) { if (nodeType(i,0) != FE_ONLY) { quantity_.insert(i); @@ -981,7 +981,7 @@ namespace ATC { void RegulatedNodes::insert_boundary_nodes() const { const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); - + for (int i = 0; i < nodeType.size(); ++i) { if (nodeType(i,0) == BOUNDARY) { quantity_.insert(i); @@ -1012,7 +1012,7 @@ namespace ATC { //-------------------------------------------------------- void RegulatedNodes::insert_fixed_nodes() const { - + const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); map::const_iterator fs_iter; @@ -1038,7 +1038,7 @@ namespace ATC { const INT_ARRAY & nodeType(nodalGeometryType_->quantity()); set::const_iterator inode; map::const_iterator fs_iter; - + for (fs_iter = fieldSizes_.begin(); fs_iter != fieldSizes_.end(); fs_iter++) { for (int j = 0; j < fs_iter->second; j++) { set faceFluxNodes = prescribedDataManager_->flux_face_nodes(fs_iter->first,j); @@ -1104,7 +1104,7 @@ namespace ATC { void FluxNodes::reset_quantity() const { quantity_.clear(); - + // a) they have a fixed face flux RegulatedNodes::insert_face_fluxes(); @@ -1161,7 +1161,7 @@ namespace ATC { void FixedNodes::reset_quantity() const { quantity_.clear(); - + // a) they are a fixed node RegulatedNodes::insert_fixed_nodes(); } @@ -1533,7 +1533,7 @@ namespace ATC { DENS_MAN* atomCoarseGrainingPositions): atc_(atc), source_(source), - kernelFunction_(kernelFunction), + kernelFunction_(kernelFunction), atomCoarseGrainingPositions_(atomCoarseGrainingPositions), feMesh_((atc_->fe_engine())->fe_mesh()) { @@ -1551,7 +1551,7 @@ namespace ATC { int nNodes = feMesh_->num_nodes_unique(); quantity_.resize(nNodes,source.nCols()); _quantityLocal_.reset(nNodes,source.nCols()); - + if (source.nRows()>0) { DENS_VEC xI(positions.nCols()),xa(positions.nCols()),xaI(positions.nCols()); double val; @@ -1696,7 +1696,7 @@ namespace ATC { _localWeights_ = (accumulant_->quantity()).col_sum(); } lammpsInterface_->allsum(_localWeights_.ptr(),_weights_.ptr(),nNodes); - + // assign weights quantity_.resize(nNodes,nNodes); for (int i = 0; i < nNodes; i++) { @@ -1732,7 +1732,7 @@ namespace ATC { { const DENS_MAT & weights(weights_->quantity()); int nNodes = weights.nRows(); - + // assign weights quantity_.resize(nNodes,nNodes); for (int i = 0; i < nNodes; i++) { @@ -1756,7 +1756,7 @@ namespace ATC { //-------------------------------------------------------- KernelInverseVolumes::KernelInverseVolumes(ATC_Method * atc, KernelFunction* kernelFunction): - kernelFunction_(kernelFunction), + kernelFunction_(kernelFunction), feMesh_((atc->fe_engine())->fe_mesh()) { // do nothing @@ -1807,7 +1807,7 @@ namespace ATC { quantity_.resize(nNodes,source.nCols()); _quantityLocal_.reset(nNodes,source.nCols()); DENS_VEC xj(atc_->nsd()); - + if (source.nRows()>0) { for (int j = 0; j < source.nRows(); j++) { for (int k = 0; k < atc_->nsd(); k++) { @@ -1820,7 +1820,7 @@ namespace ATC { //quantity_(inode,k) += shp(I)*source(j,k); _quantityLocal_(inode,k) += shp(I)*source(j,k); } - } + } } } // accumulate across processors @@ -1946,7 +1946,7 @@ namespace ATC { //-------------------------------------------------------- void NativeShapeFunctionGradient::reset_quantity() const { - feEngine_->compute_gradient_matrix(quantity_); + feEngine_->compute_gradient_matrix(quantity_); } //-------------------------------------------------------- @@ -1971,7 +1971,7 @@ namespace ATC { //-------------------------------------------------------- // destructor //-------------------------------------------------------- - OnTheFlyShapeFunctionProlongation::~OnTheFlyShapeFunctionProlongation() + OnTheFlyShapeFunctionProlongation::~OnTheFlyShapeFunctionProlongation() { atomCoarseGrainingPositions_->remove_dependence(this); }; diff --git a/lib/atc/TransferLibrary.h b/lib/atc/TransferLibrary.h index d1f27e5e6d..0f33e8071b 100644 --- a/lib/atc/TransferLibrary.h +++ b/lib/atc/TransferLibrary.h @@ -25,14 +25,14 @@ namespace ATC { * @class NodalAtomVolume * @brief Computes the nodal volumes which coarse grain the volume per atom */ - + class NodalAtomVolume : public DenseMatrixTransfer { public: - + // constructor NodalAtomVolume(ATC_Method * atc, SPAR_MAN * shapeFunction); - + // destructor virtual ~NodalAtomVolume() {shapeFunction_->remove_dependence(this);}; @@ -81,14 +81,14 @@ namespace ATC { * @class NodalVolume * @brief Computes the nodal volumes associated with the support of each nodal shape function */ - + class NodalVolume : public NodalAtomVolume { public: - + // constructor NodalVolume(ATC_Method * atc, SPAR_MAN * shapeFunction) : NodalAtomVolume(atc,shapeFunction) {}; - + // destructor virtual ~NodalVolume() {}; @@ -108,15 +108,15 @@ namespace ATC { * @class NodalAtomVolumeElement * @brief Computes the nodal volumes which coarse grain the volume per atom based on element volumes */ - + class NodalAtomVolumeElement : public DenseMatrixTransfer { public: - + // constructor NodalAtomVolumeElement(ATC_Method * atc, SPAR_MAN * shapeFunction, PerAtomQuantity * atomElement=nullptr); - + // destructor virtual ~NodalAtomVolumeElement() { shapeFunction_->remove_dependence(this); @@ -170,11 +170,11 @@ namespace ATC { class AtomTypeElement : public DenseMatrixTransfer { public: - + // constructor AtomTypeElement(ATC_Coupling * atc, PerAtomQuantity * atomElement = nullptr); - + // destructor virtual ~AtomTypeElement() { atomElement_->remove_dependence(this); @@ -208,12 +208,12 @@ namespace ATC { class ElementMask : public DenseMatrixTransfer { public: - + // constructor ElementMask(ATC_Coupling * atc, MatrixDependencyManager * hasInternal = nullptr, MatrixDependencyManager * hasGhost = nullptr); - + // destructor virtual ~ElementMask() { hasInternal_->remove_dependence(this); @@ -248,11 +248,11 @@ namespace ATC { class AtomElementMask : public DenseMatrixTransfer { public: - + // constructor AtomElementMask(ATC_Coupling * atc, MatrixDependencyManager * hasAtoms = nullptr); - + // destructor virtual ~AtomElementMask() { hasAtoms_->remove_dependence(this); @@ -280,16 +280,16 @@ namespace ATC { * @class NodalGeometryType * @brief Computes the computational geometry associated with each node with respect to the FE and MD regions */ - + class NodalGeometryType : public DenseMatrixTransfer { public: - + // constructor NodalGeometryType(ATC_Coupling * atc, MatrixDependencyManager * hasInternal = nullptr, MatrixDependencyManager * hasGhost = nullptr); - + // destructor virtual ~NodalGeometryType() { hasInternal_->remove_dependence(this); @@ -331,15 +331,15 @@ namespace ATC { * @class NodalGeometryTypeElementSet * @brief Divdes nodes into MD, FE, and boundary based on if they are connected to nodes in internal and not internal */ - + class NodalGeometryTypeElementSet : public DenseMatrixTransfer { public: - + // constructor NodalGeometryTypeElementSet(ATC_Coupling * atc, MatrixDependencyManager * hasInternal = nullptr); - + // destructor virtual ~NodalGeometryTypeElementSet() { hasInternal_->remove_dependence(this); @@ -381,10 +381,10 @@ namespace ATC { class LargeToSmallMap : public DenseMatrixTransfer { public: - + // constructor LargeToSmallMap() : size_(0) {}; - + // destructor virtual ~LargeToSmallMap() {}; @@ -400,17 +400,17 @@ namespace ATC { /** * @class NodeToSubset - * @brief mapping from all nodes to a subset + * @brief mapping from all nodes to a subset */ class NodeToSubset : public LargeToSmallMap { public: - + // constructor NodeToSubset(ATC_Method * atc, SetDependencyManager * subsetNodes); - + // destructor virtual ~NodeToSubset() { subsetNodes_->remove_dependence(this); @@ -420,7 +420,7 @@ namespace ATC { virtual void reset_quantity() const; protected: - + /** pointer to atc to get the number of nodes */ const ATC_Method * atc_; @@ -436,16 +436,16 @@ namespace ATC { /** * @class SubsetToNode - * @brief mapping from a subset of nodes to all nodes + * @brief mapping from a subset of nodes to all nodes */ class SubsetToNode : public DenseMatrixTransfer { public: - + // constructor SubsetToNode(NodeToSubset * nodeToSubset); - + // destructor virtual ~SubsetToNode() { nodeToSubset_->remove_dependence(this); @@ -470,16 +470,16 @@ namespace ATC { * @class ReducedSparseMatrix * @brief reduction of a sparse matrix to only those columns consistent with the map */ - + class ReducedSparseMatrix : public SparseMatrixTransfer { public: - + // constructor ReducedSparseMatrix(ATC_Method * atc, SPAR_MAN * source, LargeToSmallAtomMap * map); - + // destructor virtual ~ReducedSparseMatrix(); @@ -509,17 +509,17 @@ namespace ATC { * @class RowMappedSparseMatrix * @brief mapping of rows from a sparse matrix to a new sparse matrix */ - + class RowMappedSparseMatrix : public ReducedSparseMatrix { public: - + // constructor RowMappedSparseMatrix(ATC_Method * atc, SPAR_MAN * source, LargeToSmallAtomMap * map) : ReducedSparseMatrix(atc,source,map) {}; - + // destructor virtual ~RowMappedSparseMatrix() {}; @@ -539,16 +539,16 @@ namespace ATC { * @class RowMappedSparseMatrixVector * @brief mapping of rows from a vector sparse matrices to a new vector of sparse matrices */ - + class RowMappedSparseMatrixVector : public VectorTransfer { public: - + // constructor RowMappedSparseMatrixVector(ATC_Method * atc, VectorDependencyManager * source, LargeToSmallAtomMap * map); - + // destructor virtual ~RowMappedSparseMatrixVector(); @@ -578,16 +578,16 @@ namespace ATC { * @class MappedDiagonalMatrix * @brief mapping of a diagonal matrix to a new diagronal matrix */ - + class MappedDiagonalMatrix : public DiagonalMatrixTransfer { public: - + // constructor MappedDiagonalMatrix(ATC_Method * atc, DIAG_MAN * source, LargeToSmallAtomMap * map); - + // destructor virtual ~MappedDiagonalMatrix(); @@ -613,16 +613,16 @@ namespace ATC { * @class MappedQuantity * @brief generic reduced mapping */ - + class MappedQuantity : public DenseMatrixTransfer { public: - + // constructor MappedQuantity(ATC_Method * atc, DENS_MAN * source, LargeToSmallMap * map); - + // destructor virtual ~MappedQuantity() { source_->remove_dependence(this); @@ -655,12 +655,12 @@ namespace ATC { class RegulatedNodes : public SetTransfer { public: - + // constructor RegulatedNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr); - + // destructor virtual ~RegulatedNodes() { nodalGeometryType_->remove_dependence(this); @@ -717,13 +717,13 @@ namespace ATC { class FluxNodes : public RegulatedNodes { public: - + // constructor FluxNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : RegulatedNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~FluxNodes() {}; @@ -747,13 +747,13 @@ namespace ATC { class BoundaryNodes : public RegulatedNodes { public: - + // constructor BoundaryNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : RegulatedNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~BoundaryNodes() {}; @@ -777,13 +777,13 @@ namespace ATC { class FluxBoundaryNodes : public FluxNodes { public: - + // constructor FluxBoundaryNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : FluxNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~FluxBoundaryNodes() {}; @@ -807,13 +807,13 @@ namespace ATC { class AllRegulatedNodes : public FluxBoundaryNodes { public: - + // constructor AllRegulatedNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : FluxBoundaryNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~AllRegulatedNodes() {}; @@ -837,13 +837,13 @@ namespace ATC { class FixedNodes : public RegulatedNodes { public: - + // constructor FixedNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : RegulatedNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~FixedNodes() {}; @@ -867,13 +867,13 @@ namespace ATC { class FixedBoundaryNodes : public FixedNodes { public: - + // constructor FixedBoundaryNodes(ATC_Coupling * atc, FieldName fieldName = NUM_TOTAL_FIELDS, MatrixDependencyManager * nodalGeometryType = nullptr) : FixedNodes(atc,fieldName,nodalGeometryType) {}; - + // destructor virtual ~FixedBoundaryNodes() {}; @@ -896,7 +896,7 @@ namespace ATC { class ElementMaskNodeSet : public DenseMatrixTransfer { public: - + // constructor ElementMaskNodeSet(ATC_Coupling * atc, SetDependencyManager * nodeSet); @@ -962,7 +962,7 @@ namespace ATC { * @class Interpolant * @brief constructs the spatial values of the shape functions */ - + class Interpolant : public SparseMatrixTransfer { public: @@ -970,8 +970,8 @@ namespace ATC { // constructor Interpolant(ATC_Method * atc, MatrixDependencyManager* pointToElementMap, - DENS_MAN* pointPositions); - + DENS_MAN* pointPositions); + // destructor virtual ~Interpolant() { pointToElementMap_->remove_dependence(this); @@ -1005,7 +1005,7 @@ namespace ATC { * @class InterpolantGradient * @brief constructs the spatial derivatives of the shape functions */ - + class InterpolantGradient : public VectorTransfer { public: @@ -1013,8 +1013,8 @@ namespace ATC { // constructor InterpolantGradient(ATC_Method * atc, MatrixDependencyManager* pointToElementMap, - DENS_MAN* pointPositions); - + DENS_MAN* pointPositions); + // destructor virtual ~InterpolantGradient(); @@ -1045,7 +1045,7 @@ namespace ATC { * @class PerAtomShapeFunctionGradient * @brief constructs the spatial derivatives of the shape functions at each atom */ - + class PerAtomShapeFunctionGradient : public VectorTransfer { public: @@ -1055,8 +1055,8 @@ namespace ATC { MatrixDependencyManager* atomToElementMap = nullptr, DENS_MAN* atomPositions = nullptr, const std::string & tag = "AtomicShapeFunctionGradient", - AtomType atomType = INTERNAL); - + AtomType atomType = INTERNAL); + // destructor virtual ~PerAtomShapeFunctionGradient(); @@ -1090,7 +1090,7 @@ namespace ATC { * @class InterpolantSmallMolecule * @brief constructs the spatial values of the shape functions for small molecules */ - + class InterpolantSmallMolecule : public Interpolant { public: @@ -1099,8 +1099,8 @@ namespace ATC { InterpolantSmallMolecule(ATC_Method * atc, MatrixDependencyManager* moleculeToElementMap, DENS_MAN* moleculePositions, - MoleculeSet * moleculeSet); - + MoleculeSet * moleculeSet); + // destructor virtual ~InterpolantSmallMolecule(); @@ -1134,10 +1134,10 @@ namespace ATC { class DenseMatrixQuotient : public DenseMatrixTransfer { public: - + // constructor DenseMatrixQuotient(DENS_MAN * matrixNumerator, DENS_MAN * matrixDenominator); - + // destructor virtual ~DenseMatrixQuotient() { matrixNumerator_->remove_dependence(this); @@ -1151,8 +1151,8 @@ namespace ATC { virtual int nCols() const {return matrixNumerator_->nCols();}; protected: - - DENS_MAN* matrixNumerator_; + + DENS_MAN* matrixNumerator_; DENS_MAN* matrixDenominator_; private: @@ -1170,10 +1170,10 @@ namespace ATC { class DenseMatrixSum : public DenseMatrixTransfer { public: - + // constructor DenseMatrixSum(DENS_MAN * matrixOne, DENS_MAN * matrixTwo); - + // destructor virtual ~DenseMatrixSum() { matrixOne_->remove_dependence(this); @@ -1187,8 +1187,8 @@ namespace ATC { virtual int nCols() const {return matrixOne_->nCols();}; protected: - - DENS_MAN* matrixOne_; + + DENS_MAN* matrixOne_; DENS_MAN* matrixTwo_; private: @@ -1206,10 +1206,10 @@ namespace ATC { class DenseMatrixDelta : public DenseMatrixTransfer { public: - + // constructor DenseMatrixDelta(DENS_MAN * current, DENS_MAT * reference); - + // destructor virtual ~DenseMatrixDelta() { matrix_->remove_dependence(this); @@ -1219,8 +1219,8 @@ namespace ATC { virtual void reset_quantity() const; protected: - - DENS_MAN* matrix_; + + DENS_MAN* matrix_; DENS_MAT* reference_; private: @@ -1234,7 +1234,7 @@ namespace ATC { * @class OnTheFlyKernelAccumulation * @brief implements the accumulant on the fly */ - + class OnTheFlyKernelAccumulation : public DenseMatrixTransfer { public: @@ -1243,8 +1243,8 @@ namespace ATC { OnTheFlyKernelAccumulation(ATC_Method * atc, PerAtomQuantity * source, KernelFunction* kernelFunction, - DENS_MAN* atomCoarseGrainingPositions); - + DENS_MAN* atomCoarseGrainingPositions); + // destructor virtual ~OnTheFlyKernelAccumulation() { source_->remove_dependence(this); @@ -1285,7 +1285,7 @@ namespace ATC { * @class OnTheFlyKernelAccumulationNormalized * @brief implements a normalized accumulant on the fly */ - + class OnTheFlyKernelAccumulationNormalized : public OnTheFlyKernelAccumulation { public: @@ -1296,7 +1296,7 @@ namespace ATC { KernelFunction* kernelFunction, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights); - + // destructor virtual ~OnTheFlyKernelAccumulationNormalized() { weights_->remove_dependence(this); @@ -1320,7 +1320,7 @@ namespace ATC { * @class OnTheFlyKernelAccumulationNormalizedReferenced * @brief implements a normalized referenced accumulant on the fly */ - + class OnTheFlyKernelAccumulationNormalizedReferenced : public OnTheFlyKernelAccumulationNormalized { public: @@ -1332,7 +1332,7 @@ namespace ATC { DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, DENS_MAN * reference); - + // destructor virtual ~OnTheFlyKernelAccumulationNormalizedReferenced() { reference_->remove_dependence(this); @@ -1357,7 +1357,7 @@ namespace ATC { * @class OnTheFlyKernelNormalizedAccumulationScaled * @brief implements a scaled accumulant on the fly */ - + class OnTheFlyKernelAccumulationNormalizedScaled : public OnTheFlyKernelAccumulationNormalized { public: @@ -1369,7 +1369,7 @@ namespace ATC { DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, const double scale); - + // destructor virtual ~OnTheFlyKernelAccumulationNormalizedScaled() { atomCoarseGrainingPositions_->remove_dependence(this); @@ -1397,10 +1397,10 @@ namespace ATC { class AccumulantWeights : public DiagonalMatrixTransfer { public: - + // constructor AccumulantWeights(SPAR_MAN * accumulant); - + // destructor virtual ~AccumulantWeights() { accumulant_->remove_dependence(this); @@ -1410,7 +1410,7 @@ namespace ATC { virtual void reset_quantity() const; protected: - + SPAR_MAN* accumulant_; // workspace @@ -1432,10 +1432,10 @@ namespace ATC { class OnTheFlyKernelWeights : public DiagonalMatrixTransfer { public: - + // constructor OnTheFlyKernelWeights(DENS_MAN * weights); - + // destructor virtual ~OnTheFlyKernelWeights() { weights_->remove_dependence(this); @@ -1445,7 +1445,7 @@ namespace ATC { virtual void reset_quantity() const; protected: - + DENS_MAN* weights_; private: @@ -1463,11 +1463,11 @@ namespace ATC { class KernelInverseVolumes : public DiagonalMatrixTransfer { public: - + // constructor KernelInverseVolumes(ATC_Method * atc, KernelFunction* kernelFunction); - + // destructor virtual ~KernelInverseVolumes() {}; @@ -1475,7 +1475,7 @@ namespace ATC { virtual void reset_quantity() const; protected: - + /** kernel function being used */ KernelFunction* kernelFunction_; @@ -1493,7 +1493,7 @@ namespace ATC { * @class OnTheFlyMeshAccumulation * @brief implements the mesh-based accumulant on the fly */ - + class OnTheFlyMeshAccumulation : public DenseMatrixTransfer { public: @@ -1501,8 +1501,8 @@ namespace ATC { // constructor OnTheFlyMeshAccumulation(ATC_Method * atc, PerAtomQuantity * source, - DENS_MAN* atomCoarseGrainingPositions); - + DENS_MAN* atomCoarseGrainingPositions); + // destructor virtual ~OnTheFlyMeshAccumulation() { source_->remove_dependence(this); @@ -1513,7 +1513,7 @@ namespace ATC { virtual void reset_quantity() const; /** access nCols_ */ - virtual int nCols() const { return source_->nCols(); } + virtual int nCols() const { return source_->nCols(); } protected: @@ -1543,7 +1543,7 @@ namespace ATC { * @class OnTheFlyMeshAccumulationNormalized * @brief implements a normalized mesh-based accumulant on the fly */ - + class OnTheFlyMeshAccumulationNormalized : public OnTheFlyMeshAccumulation { public: @@ -1553,7 +1553,7 @@ namespace ATC { PerAtomQuantity * source, DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights); - + // destructor virtual ~OnTheFlyMeshAccumulationNormalized() { weights_->remove_dependence(this); @@ -1577,7 +1577,7 @@ namespace ATC { * @class OnTheFlyMeshAccumulationNormalizedReferenced * @brief implements a normalized referenced mesh-based accumulant on the fly */ - + class OnTheFlyMeshAccumulationNormalizedReferenced : public OnTheFlyMeshAccumulationNormalized { public: @@ -1588,7 +1588,7 @@ namespace ATC { DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, DENS_MAN * reference); - + // destructor virtual ~OnTheFlyMeshAccumulationNormalizedReferenced() { reference_->remove_dependence(this); @@ -1613,7 +1613,7 @@ namespace ATC { * @class OnTheFlyMeshAccumulationNormalizedScaled * @brief implements a scaled mesh-based accumulant on the fly */ - + class OnTheFlyMeshAccumulationNormalizedScaled : public OnTheFlyMeshAccumulationNormalized { public: @@ -1624,7 +1624,7 @@ namespace ATC { DENS_MAN* atomCoarseGrainingPositions, DIAG_MAN* weights, const double scale); - + // destructor virtual ~OnTheFlyMeshAccumulationNormalizedScaled() { atomCoarseGrainingPositions_->remove_dependence(this); @@ -1648,14 +1648,14 @@ namespace ATC { * @class NativeShapeFunctionGradient * @brief constructs the spatial derivatives of the shape functions */ - + class NativeShapeFunctionGradient : public VectorTransfer { public: // constructor NativeShapeFunctionGradient(ATC_Method * atc); - + // destructor virtual ~NativeShapeFunctionGradient(); @@ -1680,7 +1680,7 @@ namespace ATC { * @class OnTheFlyShapeFunctionProlongation * @brief implements the interpolant on the fly */ - + class OnTheFlyShapeFunctionProlongation : public FeToAtomTransfer { public: @@ -1688,8 +1688,8 @@ namespace ATC { // constructor OnTheFlyShapeFunctionProlongation(ATC_Method * atc, DENS_MAN * source, - DENS_MAN * atomCoarseGrainingPositions); - + DENS_MAN * atomCoarseGrainingPositions); + // destructor virtual ~OnTheFlyShapeFunctionProlongation(); diff --git a/lib/atc/TransferOperator.cpp b/lib/atc/TransferOperator.cpp index ab91141c6a..a4edb8a710 100644 --- a/lib/atc/TransferOperator.cpp +++ b/lib/atc/TransferOperator.cpp @@ -157,9 +157,9 @@ namespace ATC { // reallocate memory only if sizing has changed const SPAR_MAT & shapeFunctionMatrix(shapeFunction_->quantity()); quantity_.resize(shapeFunctionMatrix.nCols(),sourceMatrix.nCols()); - + local_restriction(sourceMatrix,shapeFunctionMatrix); - + // communicate for total restriction int count = quantity_.nRows()*quantity_.nCols(); lammpsInterface_->allsum(_workspace_.ptr(),quantity_.ptr(),count); @@ -221,9 +221,9 @@ namespace ATC { // reallocate memory only if sizing has changed const SPAR_MAT & shapeFunctionMatrix(shapeFunction_->quantity()); quantity_.resize(shapeFunctionMatrix.nCols(),sourceMatrix.nCols()); - + local_restriction(sourceMatrix,shapeFunctionMatrix); - + // communicate for total restriction int count = quantity_.nRows()*quantity_.nCols(); lammpsInterface_->allsum(_workspace_.ptr(),quantity_.ptr(),count); @@ -322,15 +322,15 @@ namespace ATC { // reallocate memory only if sizing has changed const SPAR_MAT & accumulantMatrix(accumulant_->quantity()); quantity_.resize(accumulantMatrix.nCols(),sourceMatrix.nCols()); - + local_restriction(sourceMatrix,accumulantMatrix); - + // communicate for total restriction int count = quantity_.nRows()*quantity_.nCols(); lammpsInterface_->allsum(_workspace_.ptr(),quantity_.ptr(),count); if (weights_) { CLON_VEC w(weights_->quantity()); - quantity_ *= w; + quantity_ *= w; } } @@ -551,10 +551,10 @@ namespace ATC { const DENS_MAT & positions(coarseGrainingPositions_->quantity()); // reallocate memory only if sizing has changed quantity_.resize(atc_->num_nodes(),sourceMatrix.nCols()); - + local_restriction(sourceMatrix,positions, kernelFunction_); - + // communicate for total restriction int count = quantity_.nRows()*quantity_.nCols(); lammpsInterface_->allsum(_workspace_.ptr(),quantity_.ptr(),count); @@ -854,7 +854,7 @@ namespace ATC { _temp_ = shapeFunctionMatrix*sourceMatrix; for (int i = 0; i < quantity_.size(); ++i) { quantity_(i,i) = _temp_(i,0); - } + } } } } diff --git a/lib/atc/TransferOperator.h b/lib/atc/TransferOperator.h index 5cf578b77c..665a0d3cdb 100644 --- a/lib/atc/TransferOperator.h +++ b/lib/atc/TransferOperator.h @@ -15,28 +15,28 @@ namespace ATC { class FE_Mesh; /** - * @class DenseMatrixTransfer + * @class DenseMatrixTransfer * @brief Class for defining objects that generate dense matrix quantities from other matrix quantities */ template class DenseMatrixTransfer : public MatrixDependencyManager { public: - + // constructor DenseMatrixTransfer() : MatrixDependencyManager(), lammpsInterface_(LammpsInterface::instance()) {}; - + // destructor virtual ~DenseMatrixTransfer() {}; /** apply transfer operator */ virtual const DenseMatrix & quantity() const { if (this->need_reset()) { - this->reset_quantity(); + this->reset_quantity(); MatrixDependencyManager::needReset_ = false; - } + } return MatrixDependencyManager::quantity_; }; @@ -92,19 +92,19 @@ namespace ATC { }; /** - * @class SparseMatrixTransfer + * @class SparseMatrixTransfer * @brief Class for defining objects that generate dense matrix quantities from other matrix quantities */ template class SparseMatrixTransfer : public MatrixDependencyManager { public: - + // constructor SparseMatrixTransfer() : MatrixDependencyManager(), lammpsInterface_(LammpsInterface::instance()) {}; - + // destructor virtual ~SparseMatrixTransfer() {}; @@ -163,19 +163,19 @@ namespace ATC { }; /** - * @class DiagonalMatrixTransfer + * @class DiagonalMatrixTransfer * @brief Class for defining objects that generate diagonal matrix quantities from other matrix quantities */ template class DiagonalMatrixTransfer : public MatrixDependencyManager { public: - + // constructor DiagonalMatrixTransfer() : MatrixDependencyManager(), lammpsInterface_(LammpsInterface::instance()) {}; - + // destructor virtual ~DiagonalMatrixTransfer() {}; @@ -234,18 +234,18 @@ namespace ATC { }; /** - * @class SetTransfer + * @class SetTransfer * @brief Class for defining objects that generate sets using prescribed algorithms */ template class SetTransfer : public SetDependencyManager { public: - + // constructor SetTransfer() : SetDependencyManager() {}; - + // destructor virtual ~SetTransfer() {}; @@ -264,18 +264,18 @@ namespace ATC { }; /** - * @class VectorTransfer + * @class VectorTransfer * @brief Class for defining objects that generate sets using prescribed algorithms */ template class VectorTransfer : public VectorDependencyManager { public: - + // constructor VectorTransfer() : VectorDependencyManager() {}; - + // destructor virtual ~VectorTransfer() {}; @@ -294,18 +294,18 @@ namespace ATC { }; /** - * @class AtomToFeTransfer - * @brief Class for defining objects to transfer atomistic quantities to FE quantities + * @class AtomToFeTransfer + * @brief Class for defining objects to transfer atomistic quantities to FE quantities */ class AtomToFeTransfer : public DenseMatrixTransfer { public: - + // constructor AtomToFeTransfer(ATC_Method * atc, PerAtomQuantity * source); - + // destructor virtual ~AtomToFeTransfer(); @@ -325,18 +325,18 @@ namespace ATC { }; /** - * @class AtomDiagonalMatrixToFeTransfer - * @brief Class for defining objects to transfer atomistic quantities to FE quantities + * @class AtomDiagonalMatrixToFeTransfer + * @brief Class for defining objects to transfer atomistic quantities to FE quantities */ class AtomDiagonalMatrixToFeTransfer : public DenseMatrixTransfer { public: - + // constructor AtomDiagonalMatrixToFeTransfer(ATC_Method * atc, PerAtomDiagonalMatrix * source); - + // destructor virtual ~AtomDiagonalMatrixToFeTransfer(); @@ -363,12 +363,12 @@ namespace ATC { class FeToAtomTransfer : public ProtectedAtomQuantity { public: - + // constructor FeToAtomTransfer(ATC_Method * atc, DENS_MAN * source, AtomType atomType = INTERNAL); - + // destructor virtual ~FeToAtomTransfer(); @@ -392,11 +392,11 @@ namespace ATC { class FeToAtomDiagonalMatrix : public ProtectedAtomDiagonalMatrix { public: - + // constructor FeToAtomDiagonalMatrix(ATC_Method * atc, DENS_MAN * source); - + // destructor virtual ~FeToAtomDiagonalMatrix(); @@ -420,11 +420,11 @@ namespace ATC { class MatToMatTransfer : public DenseMatrixTransfer { public: - + // constructor MatToMatTransfer(MatrixDependencyManager * source) : source_(source) {source_->register_dependence(this);}; - + // destructor virtual ~MatToMatTransfer() {source_->remove_dependence(this);}; @@ -445,16 +445,16 @@ namespace ATC { * @brief Class for defining objects that transfer atomistic quantities to FE using shape functions * (implements restrict_volumetric_quantity) */ - + class AtfShapeFunctionRestriction : public AtomToFeTransfer { public: - + // constructor AtfShapeFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * shapeFunction); - + // destructor virtual ~AtfShapeFunctionRestriction(); @@ -467,8 +467,8 @@ namespace ATC { SPAR_MAN * shapeFunction_; /** persistent workspace */ - - + + mutable DENS_MAT _workspace_; /** applies restriction operation across all processors */ @@ -493,12 +493,12 @@ namespace ATC { class AdmtfShapeFunctionRestriction : public AtomDiagonalMatrixToFeTransfer { public: - + // constructor AdmtfShapeFunctionRestriction(ATC_Method * atc, PerAtomDiagonalMatrix * source, SPAR_MAN * shapeFunction); - + // destructor virtual ~AdmtfShapeFunctionRestriction(); @@ -511,8 +511,8 @@ namespace ATC { SPAR_MAN * shapeFunction_; /** persistent workspace */ - - + + mutable DENS_MAT _workspace_; /** applies restriction operation across all processors */ @@ -531,19 +531,19 @@ namespace ATC { /** * @class AtfProjection - * @brief + * @brief */ class AtfProjection : public AtomToFeTransfer { public: - + // constructor AtfProjection(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * accumulant, DIAG_MAN * weights = nullptr); - + // destructor virtual ~AtfProjection(); @@ -561,8 +561,8 @@ namespace ATC { DENS_MAT * reference_; /** persistent workspace */ - - + + mutable DENS_MAT _workspace_; /** applies restriction operation across all processors */ @@ -581,14 +581,14 @@ namespace ATC { class AtfProjectionScaled : public AtfProjection { public: - + // constructor AtfProjectionScaled(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * accumulant, const double scale, DIAG_MAN * weights = nullptr); - + // destructor virtual ~AtfProjectionScaled(); @@ -608,20 +608,20 @@ namespace ATC { /** * @class AtfProjectionReferenced - * @brief + * @brief */ class AtfProjectionReferenced : public AtfProjection { public: - + // constructor AtfProjectionReferenced(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * accumulant, DENS_MAN * reference, DIAG_MAN * weights = nullptr); - + // destructor virtual ~AtfProjectionReferenced(); @@ -651,13 +651,13 @@ namespace ATC { class AtfWeightedShapeFunctionRestriction : public AtfShapeFunctionRestriction { public: - + // constructor AtfWeightedShapeFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * shapeFunction, DIAG_MAN * weights); - + // destructor virtual ~AtfWeightedShapeFunctionRestriction() {weights_->remove_dependence(this);}; @@ -686,13 +686,13 @@ namespace ATC { class AtfNodeWeightedShapeFunctionRestriction : public AtfShapeFunctionRestriction { public: - + // constructor AtfNodeWeightedShapeFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, SPAR_MAN * shapeFunction, DIAG_MAN * weights); - + // destructor virtual ~AtfNodeWeightedShapeFunctionRestriction() {weights_->remove_dependence(this);}; @@ -721,12 +721,12 @@ namespace ATC { class AtfShapeFunctionProjection : public MatToMatTransfer { public: - + // constructor - AtfShapeFunctionProjection(ATC_Method * atc, + AtfShapeFunctionProjection(ATC_Method * atc, DENS_MAN * source, FieldName thisField); - + // destructor virtual ~AtfShapeFunctionProjection(); @@ -751,19 +751,19 @@ namespace ATC { /** * @class AtfShapeFunctionMdProjection * @brief Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region - * (implements project_md/project_md_volumetric_quantity assuming + * (implements project_md/project_md_volumetric_quantity assuming * restrict_unscaled/restrict_volumetric_quantity has been applied) */ class AtfShapeFunctionMdProjection : public MatToMatTransfer { public: - + // constructor - AtfShapeFunctionMdProjection(ATC_Method * atc, + AtfShapeFunctionMdProjection(ATC_Method * atc, DENS_MAN * source, FieldName thisField); - + // destructor virtual ~AtfShapeFunctionMdProjection(); @@ -788,20 +788,20 @@ namespace ATC { /** * @class AtfShapeFunctionMdProjectionScaled * @brief Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region with a scaling factor - * (implements project_md/project_md_volumetric_quantity assuming + * (implements project_md/project_md_volumetric_quantity assuming * restrict_unscaled/restrict_volumetric_quantity has been applied) */ class AtfShapeFunctionMdProjectionScaled : public AtfShapeFunctionMdProjection { public: - + // constructor AtfShapeFunctionMdProjectionScaled(ATC_Method * atc, DENS_MAN * source, double scale, FieldName thisField); - + // destructor virtual ~AtfShapeFunctionMdProjectionScaled(); @@ -823,20 +823,20 @@ namespace ATC { /** * @class AtfShapeFunctionMdProjectionReferenced * @brief Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region with respect to a reference - * (implements project_md/project_md_volumetric_quantity assuming + * (implements project_md/project_md_volumetric_quantity assuming * restrict_unscaled/restrict_volumetric_quantity has been applied) */ class AtfShapeFunctionMdProjectionReferenced : public AtfShapeFunctionMdProjection { public: - + // constructor AtfShapeFunctionMdProjectionReferenced(ATC_Method * atc, DENS_MAN * source, DENS_MAN * reference, FieldName thisField); - + // destructor virtual ~AtfShapeFunctionMdProjectionReferenced(); @@ -863,13 +863,13 @@ namespace ATC { class AtfKernelFunctionRestriction : public AtomToFeTransfer { public: - + // constructor AtfKernelFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, PerAtomQuantity * coarseGrainingPositions, KernelFunction * kernelFunction); - + // destructor virtual ~AtfKernelFunctionRestriction(); @@ -888,8 +888,8 @@ namespace ATC { const FE_Mesh * feMesh_; /** persistent workspace */ - - + + mutable DENS_MAT _workspace_; mutable DENS_VEC _xI_, _xa_, _xaI_; @@ -917,14 +917,14 @@ namespace ATC { class AtfWeightedKernelFunctionRestriction : public AtfKernelFunctionRestriction { public: - + // constructor AtfWeightedKernelFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, PerAtomQuantity * coarseGrainingPositions, KernelFunction * kernelFunction, DIAG_MAN * weights); - + // destructor virtual ~AtfWeightedKernelFunctionRestriction() {weights_->remove_dependence(this);}; @@ -954,14 +954,14 @@ namespace ATC { class AtfNodeWeightedKernelFunctionRestriction : public AtfKernelFunctionRestriction { public: - + // constructor AtfNodeWeightedKernelFunctionRestriction(ATC_Method * atc, PerAtomQuantity * source, PerAtomQuantity * coarseGrainingPositions, KernelFunction * kernelFunction, DIAG_MAN * weights); - + // destructor virtual ~AtfNodeWeightedKernelFunctionRestriction() {weights_->remove_dependence(this);}; @@ -989,13 +989,13 @@ namespace ATC { class FtaShapeFunctionProlongation : public FeToAtomTransfer { public: - + // constructor FtaShapeFunctionProlongation(ATC_Method * atc, DENS_MAN * source, SPAR_MAN * shapeFunction, AtomType atomType = INTERNAL); - + // destructor virtual ~FtaShapeFunctionProlongation(); @@ -1023,12 +1023,12 @@ namespace ATC { class FtaShapeFunctionProlongationDiagonalMatrix : public FeToAtomDiagonalMatrix { public: - + // constructor FtaShapeFunctionProlongationDiagonalMatrix(ATC_Method * atc, DENS_MAN * source, SPAR_MAN * shapeFunction); - + // destructor virtual ~FtaShapeFunctionProlongationDiagonalMatrix(); @@ -1056,68 +1056,68 @@ namespace ATC { */ class MatToGradBySparse : public MatToMatTransfer { - public: + public: - //constructor + //constructor MatToGradBySparse(ATC_Method * atc, DENS_MAN * source, VectorDependencyManager * gradientMatrices); //destructor virtual ~MatToGradBySparse(); - // apply transfer operator + // apply transfer operator virtual void reset_quantity() const; protected: - + // pointer to sparseMatrix VectorDependencyManager * gradientMatrices_; - private: + private: // do not define MatToGradBySparse(); - + }; /** * transfer from dense to dense by diagonal matrix multiplier for anything - **/ + **/ class DiagonalMatrixMultiply : public MatToMatTransfer { - public: + public: - //constructor + //constructor DiagonalMatrixMultiply(DENS_MAN * source, DIAG_MAN * diagonalMatrix); //destructor virtual ~DiagonalMatrixMultiply(); - // apply transfer operator + // apply transfer operator virtual void reset_quantity() const; protected: - + // pointer to sparseMatrix DIAG_MAN * diagonalMatrix_; - private: + private: // do not define DiagonalMatrixMultiply(); - + }; #ifdef ATC_WHO /** // class sparse matrix multiplier for anything //delete later -**/ +**/ class SparseMatrixMultiply : public MatToMatTransfer { - public: + public: - //constructor + //constructor SparseMatrixMultiply(ATC_Method * atc, DENS_MAN * source, SPAR_MAN * sparseMatrix); @@ -1125,18 +1125,18 @@ namespace ATC { virtual ~SparseMatrixMultiply(); protected: - + // pointer to sparseMatrix SPAR_MAN * sparseMatrix_; - - // apply transfer operator + + // apply transfer operator virtual const DENS_MAT & quantity() const; - private: + private: // do not define SparseMatrixMultiply(); - + }; #endif diff --git a/lib/atc/Utility.h b/lib/atc/Utility.h index 6693df9323..e8f9a50ffa 100644 --- a/lib/atc/Utility.h +++ b/lib/atc/Utility.h @@ -22,8 +22,8 @@ namespace ATC_Utility /** constants */ static const double Pi_ = 4.0*atan(1.0); static const double Big_ = 1.e20; - const static double parsetol_ = 1.0e-8; - //const static double parsetol_ = 1.0e-10; + const static double parsetol_ = 1.0e-8; + //const static double parsetol_ = 1.0e-10; const static double parsebig_ = 1.0e10; /** scalar triple product */ @@ -59,36 +59,36 @@ namespace ATC_Utility return ( (dblL > dblR) || ((dblL <= (dblR + \ std::numeric_limits::epsilon() * \ - tolMult * std::max(fabs(dblL), fabs(dblR)))) && + tolMult * std::max(fabs(dblL), fabs(dblR)))) && (dblR <= (dblL + \ std::numeric_limits::epsilon() * \ tolMult * std::max(fabs(dblL), fabs(dblR)))))); } inline double tolerance(double x, double tol = parsetol_) { - return std::max(tol,tol*fabs(x)); + return std::max(tol,tol*fabs(x)); } inline double nudge_up(double x) { return x+tolerance(x); } inline double nudge_down(double x) { return x-tolerance(x); } inline double parse_min(const char * arg) { if (std::strcmp(arg,"INF") == 0) return -parsebig_; else if (std::strcmp(arg,"-INF") == 0) return -parsebig_; - else return (atof(arg)); - } - inline double parse_max(const char * arg) { - if (std::strcmp(arg,"INF") == 0) return parsebig_; + else return (atof(arg)); + } + inline double parse_max(const char * arg) { + if (std::strcmp(arg,"INF") == 0) return parsebig_; else return (atof(arg)); - } + } inline double parse_minmax(const char * arg) { if (std::strcmp(arg,"-INF") == 0) return -parsebig_; else if (std::strcmp(arg,"INF") == 0) return parsebig_; - else return atof(arg); - } + else return atof(arg); + } inline void split_values(double & min, double & max) { min = nudge_down(min); max = nudge_up(max); - } - + } + /** Returns true if the value v is between min & max */ template @@ -121,7 +121,7 @@ namespace ATC_Utility static double t = t_new; double dt = t_new - t; t = t_new; - return dt; + return dt; } /** A simple timer */ inline double timer() @@ -129,10 +129,10 @@ namespace ATC_Utility double t_new = clock() / (double) CLOCKS_PER_SEC; static double t = t_new; // done once at first time the function is evoked double dt = t_new - t; - return dt; + return dt; } /** Binary search between low & high for value (assumes array is sorted) */ - + template inline int search_sorted(const T* A, T value, int low, int high) { @@ -187,7 +187,7 @@ namespace ATC_Utility inline std::string to_string(int precision, const double v) { char b[50]; - sprintf(b, "%*.*f",4+precision,precision, v); + sprintf(b, "%*.*f",4+precision,precision, v); std::string s(b); return s; } @@ -222,7 +222,7 @@ namespace ATC_Utility inline double str2dbl(const std::string &s) { return str2T(s, double(0.0)); } /** tests if conversion to double is possible */ - inline bool is_dbl(const std::string &s) + inline bool is_dbl(const std::string &s) { char *endptr; strtod(s.c_str(), &endptr); @@ -236,7 +236,7 @@ namespace ATC_Utility while (it != s.end() && std::isdigit(*it)) ++it; return !s.empty() && it == s.end(); } - + /** convert a string to an int */ inline int str2int(const std::string &s) { return str2T(s, int(4)); } @@ -268,7 +268,7 @@ namespace ATC_Utility std::transform(s.begin(),s.end(),s.begin(),static_cast(toupper)); return s; } - + /** removes any whitespace from the beginning or end of string */ static std::string& trim(std::string &s) { @@ -289,10 +289,10 @@ namespace ATC_Utility { begin = s.find_first_not_of(del, end); // find beginning of fragment end = s.find_first_of(del,begin); - if (begin != std::string::npos) // safe if end is npos-1 - ss.push_back(s.substr(begin,end-begin)); + if (begin != std::string::npos) // safe if end is npos-1 + ss.push_back(s.substr(begin,end-begin)); } - } + } static std::string cap(std::string & s) { s[0] = toupper(s[0]); @@ -310,7 +310,7 @@ namespace ATC_Utility } return name; } - + //* scans a string for a list of commands delimited by ', \t' with # comments //* @param line The input line to be parsed //* @cs A vector of strings parsed from the input line @@ -321,7 +321,7 @@ namespace ATC_Utility to_lower(trim(line)); split(line, cs); } - + //* reads a single line from a file and splits it into a vector of strings //* returns the number of strings in the vector inline int command_line(std::fstream &fid, std::vector &cs) diff --git a/lib/atc/Vector.cpp b/lib/atc/Vector.cpp index 36a840119b..2f8dce6e5a 100644 --- a/lib/atc/Vector.cpp +++ b/lib/atc/Vector.cpp @@ -10,7 +10,7 @@ void MultMv(const Matrix &A, const Vector &v, DenseVector: matrix-vector multiply"); if (c.size() != sA[At]) { @@ -25,9 +25,9 @@ void MultMv(const Matrix &A, const Vector &v, DenseVector -//void MultMv(const Matrix &A, const Vector &v, DenseVector &c, +//void MultMv(const Matrix &A, const Vector &v, DenseVector &c, // const bool At=0, T a=1, T b=0); /****************************************************************************** @@ -40,7 +40,7 @@ public: virtual void copy(const T * ptr, INDEX nRows, INDEX nCols=1)=0; void write_restart(FILE *f) const; // will be virtual - + // output to matlab using Matrix::matlab; void matlab(std::ostream &o, const std::string &s="v") const; @@ -60,7 +60,7 @@ public: /////////////////////////////////////////////////////////////////////////////// //* performs a matrix-vector multiply with default naive implementation template -void MultMv(const Matrix &A, const Vector &v, DenseVector &c, +void MultMv(const Matrix &A, const Vector &v, DenseVector &c, const bool At, T /* a */, T b) { const INDEX sA[2] = {A.nRows(), A.nCols()}; // m is sA[At] k is sA[!At] @@ -95,12 +95,12 @@ DenseVector operator*(const Vector &a, const Matrix &B) return c; } /////////////////////////////////////////////////////////////////////////////// -//* Multiply a vector by a scalar +//* Multiply a vector by a scalar template DenseVector operator*(const Vector &v, const T s) { DenseVector r(v); - r*=s; + r*=s; return r; } /////////////////////////////////////////////////////////////////////////////// @@ -109,7 +109,7 @@ template DenseVector operator*(const T s, const Vector &v) { DenseVector r(v); - r*=s; + r*=s; return r; } /////////////////////////////////////////////////////////////////////////////// @@ -148,8 +148,8 @@ template std::string Vector::to_string() const { std::string s; - int sz = this->size(); - for (INDEX i = 0; i < sz; i++) + int sz = this->size(); + for (INDEX i = 0; i < sz; i++) s += std::string(i?"\t":"") + ATC_Utility::to_string((*this)[i],myPrecision); return s; } @@ -159,8 +159,8 @@ template void Vector::matlab(std::ostream &o, const std::string &s) const { o << s <<"=zeros(" << this->size() << ",1);\n"; - int sz = this->size(); - for (INDEX i = 0; i < sz; i++) + int sz = this->size(); + for (INDEX i = 0; i < sz; i++) o << s << "("<::write_restart(FILE *f) const template inline INDEX Vector::nCols() const { - return 1; + return 1; } /////////////////////////////////////////////////////////////////////////////// //* returns true if INDEX i is within the range of the vector template -bool Vector::in_range(INDEX i) const +bool Vector::in_range(INDEX i) const { - return isize(); + return isize(); } /////////////////////////////////////////////////////////////////////////////// //* returns true if m has the same number of elements this vector template -bool Vector::same_size(const Vector &m) const +bool Vector::same_size(const Vector &m) const { - return this->size() == m.size(); + return this->size() == m.size(); } /////////////////////////////////////////////////////////////////////////////// //* returns true if a and b have the same number of elements template inline bool Vector::same_size(const Vector &a, const Vector &b) { - return a.same_size(b); + return a.same_size(b); } //---------------------------------------------------------------------------- // general matrix assignment (for densely packed matrices) @@ -209,9 +209,9 @@ void Vector::_set_equal(const Matrix &r) this->resize(r.nRows(), r.nCols()); const Matrix *pr = &r; #ifdef OBSOLETE - if (const SparseMatrix *ps = dynamic_cast*>(pr))//sparse_cast(pr)) + if (const SparseMatrix *ps = dynamic_cast*>(pr))//sparse_cast(pr)) copy_sparse_to_matrix(ps, *this); - + else if (dynamic_cast*>(pr))//diag_cast(pr)) // r is Diagonal? { this->zero(); diff --git a/lib/atc/ViscousStress.cpp b/lib/atc/ViscousStress.cpp index 305769af68..f21e6827dd 100644 --- a/lib/atc/ViscousStress.cpp +++ b/lib/atc/ViscousStress.cpp @@ -14,7 +14,7 @@ namespace ATC { //============================================================================= // isotropic constant viscosity //============================================================================= -ViscousStressConstant::ViscousStressConstant(fstream &fileId) +ViscousStressConstant::ViscousStressConstant(fstream &fileId) : ViscousStress(), viscosity_(0) { if (!fileId.is_open()) throw ATC_Error("cannot open material file"); @@ -22,7 +22,7 @@ ViscousStressConstant::ViscousStressConstant(fstream &fileId) while(fileId.good()) { command_line(fileId, line); if (line[0] == "end") { - if (viscosity_ < 0.0) + if (viscosity_ < 0.0) throw ATC_Error("ViscousStressConstant:: bad constant viscosity"); return; } @@ -74,7 +74,7 @@ void ViscousStressConstant::viscosity(const FIELD_MATS &fields, DENS_MAT &coefs) const { const DENS_MAT & v = (fields.find(VELOCITY))->second; - + coefs.resize(v.nRows(),v.nCols()); coefs = -1.*viscosity_; } diff --git a/lib/atc/ViscousStress.h b/lib/atc/ViscousStress.h index 1636aa5bc3..6d901a3010 100644 --- a/lib/atc/ViscousStress.h +++ b/lib/atc/ViscousStress.h @@ -12,7 +12,7 @@ namespace ATC { /** * @class ViscousStress - * @brief Base class that defines interface for a constitutive law + * @brief Base class that defines interface for a constitutive law * @brief that computes viscous stresses given all field and gradient information. */ class ViscousStress @@ -27,12 +27,12 @@ namespace ATC { //* Units: mvv/L^3 (i.e. for units Real: g/(mol ps^2 A^2) ) virtual void viscous_stress(const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, - DENS_MAT_VEC &stress)=0; + DENS_MAT_VEC &stress)=0; virtual void viscosity(const FIELD_MATS & /* fields */, DENS_MAT & /* coefs */) const {throw ATC_Error("ViscousStress::viscosity: unimplemented function");} //* Returns the derivative of the stress tensor for a given strain-rate tensor. - virtual void tangent(const MATRIX & /* F */, MATRIX & /* C */) const + virtual void tangent(const MATRIX & /* F */, MATRIX & /* C */) const {throw ATC_Error("ViscousStress::tangent: unimplemented function");} }; @@ -41,7 +41,7 @@ namespace ATC { * @class ViscousStressConstant * @brief Class for computing stress for a constant viscosity material * assuming divergence-free flow - */ + */ class ViscousStressConstant : public ViscousStress { @@ -61,4 +61,4 @@ namespace ATC { }; } -#endif +#endif diff --git a/lib/atc/VoigtOperations.h b/lib/atc/VoigtOperations.h index 73ce7918ae..6f3fdd1c96 100644 --- a/lib/atc/VoigtOperations.h +++ b/lib/atc/VoigtOperations.h @@ -5,17 +5,17 @@ -// Voigt indexing puts a symmetric 3x3 matrix into a +// Voigt indexing puts a symmetric 3x3 matrix into a // vector form: [0 1 2 3 4 5] // -// matrix form: [[ 0 5 4 ] +// matrix form: [[ 0 5 4 ] // [ 5 1 3 ] // [ 4 3 2 ]] // // unsymmetric version // vector form: [0 1 2 3 4 5 6 7 8] // -// matrix form: [[ 0 5 4 ] +// matrix form: [[ 0 5 4 ] // [ 8 1 3 ] // [ 7 6 2 ]] @@ -34,10 +34,10 @@ namespace voigt3 { //* Inputs 6-length vectors A, B inline DENS_VEC dsymm(const DENS_VEC &A, const DENS_VEC &B) { - DENS_VEC C(6,false); + DENS_VEC C(6,false); C(0) = A(0)*B(0)+A(5)*B(5)+A(4)*B(4); C(1) = A(5)*B(5)+A(1)*B(1)+A(3)*B(3); - C(2) = A(4)*B(4)+A(3)*B(3)+A(2)*B(2); + C(2) = A(4)*B(4)+A(3)*B(3)+A(2)*B(2); C(3) = A(5)*B(4)+A(1)*B(3)+A(3)*B(2); C(4) = A(0)*B(4)+A(5)*B(3)+A(4)*B(2); C(5) = A(0)*B(5)+A(5)*B(1)+A(4)*B(3); @@ -62,21 +62,21 @@ namespace voigt3 { inline DENS_MAT derivative_of_square(const DENS_VEC &C) { DENS_MAT D(6,6); - D(0,0)=2.0*C(0); D(0,1)=0.0; D(0,2)=0.0; - D(1,0)=0.0; D(1,1)=2.0*C(1); D(1,2)=0.0; - D(2,0)=0.0; D(2,1)=0.0; D(2,2)=2.0*C(2); + D(0,0)=2.0*C(0); D(0,1)=0.0; D(0,2)=0.0; + D(1,0)=0.0; D(1,1)=2.0*C(1); D(1,2)=0.0; + D(2,0)=0.0; D(2,1)=0.0; D(2,2)=2.0*C(2); D(0,3)=0.0; D(0,4)=2.0*C(4); D(0,5)=2.0*C(5); D(1,3)=2.0*C(3); D(1,4)=0.0; D(1,5)=2.0*C(5); D(2,3)=2.0*C(3); D(2,4)=2.0*C(4); D(2,5)=0.0; - D(3,0)=0.0; D(3,1)=C(3); D(3,2)=C(3); - D(4,0)=C(4); D(4,1)=0.0; D(4,2)=C(4); - D(5,0)=C(5); D(5,1)=C(5); D(5,2)=0.0; - + D(3,0)=0.0; D(3,1)=C(3); D(3,2)=C(3); + D(4,0)=C(4); D(4,1)=0.0; D(4,2)=C(4); + D(5,0)=C(5); D(5,1)=C(5); D(5,2)=0.0; + D(3,3)=C(1)+C(2); D(3,4)=C(5); D(3,5)=C(4); D(4,3)=C(5); D(4,4)=C(0)+C(2); D(4,5)=C(3); - D(5,3)=C(4); D(5,4)=C(3); D(5,5)=C(0)+C(1); + D(5,3)=C(4); D(5,4)=C(3); D(5,5)=C(0)+C(1); return D; } @@ -102,9 +102,9 @@ namespace voigt3 { DENS_VEC I(voigt_size,false); for (INDEX i=0; i needs; return needs; - } + } }; }; diff --git a/lib/atc/WeakEquationDiffusion.cpp b/lib/atc/WeakEquationDiffusion.cpp index 5470d30b1b..643b7956ba 100644 --- a/lib/atc/WeakEquationDiffusion.cpp +++ b/lib/atc/WeakEquationDiffusion.cpp @@ -14,7 +14,7 @@ namespace ATC { // Constructor //-------------------------------------------------------------- WeakEquationDiffusion::WeakEquationDiffusion() - : WeakEquation(DYNAMIC_PDE,SPECIES_CONCENTRATION,1) + : WeakEquation(DYNAMIC_PDE,SPECIES_CONCENTRATION,1) {} //-------------------------------------------------------------- // Destructor @@ -47,4 +47,4 @@ void WeakEquationDiffusion::B_integrand( } }; // end namespace - + diff --git a/lib/atc/WeakEquationDiffusion.h b/lib/atc/WeakEquationDiffusion.h index 057f499382..5e60d9cfbf 100644 --- a/lib/atc/WeakEquationDiffusion.h +++ b/lib/atc/WeakEquationDiffusion.h @@ -12,19 +12,19 @@ namespace ATC{ * @class WeakEquationDiffusion * @brief species diffusion * c q,t = div q --> - * int M c q,t = int B q + * int M c q,t = int B q */ class WeakEquationDiffusion : public WeakEquation { public: - - // constructor + + // constructor WeakEquationDiffusion(); // destructor virtual ~WeakEquationDiffusion(); - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, @@ -43,7 +43,7 @@ class WeakEquationDiffusion : public WeakEquation { { std::set needs; return needs; - } + } }; }; diff --git a/lib/atc/WeakEquationElectronContinuity.cpp b/lib/atc/WeakEquationElectronContinuity.cpp index 193da6e2c7..4c5024c1b1 100644 --- a/lib/atc/WeakEquationElectronContinuity.cpp +++ b/lib/atc/WeakEquationElectronContinuity.cpp @@ -29,7 +29,7 @@ void WeakEquationElectronContinuity::M_integrand( { FIELD_MATS::const_iterator nField = fields.find(ELECTRON_DENSITY); const DENS_MAT & n = nField->second; - density.resize(n.nRows(),n.nCols()); + density.resize(n.nRows(),n.nCols()); density = 1; } @@ -77,7 +77,7 @@ void WeakEquationElectronEquilibrium::M_integrand( { FIELD_MATS::const_iterator nField = fields.find(ELECTRON_DENSITY); const DENS_MAT & n = nField->second; - density.reset(n.nRows(),n.nCols()); + density.reset(n.nRows(),n.nCols()); density = 1; } diff --git a/lib/atc/WeakEquationElectronContinuity.h b/lib/atc/WeakEquationElectronContinuity.h index f7e00246da..7f667118c0 100644 --- a/lib/atc/WeakEquationElectronContinuity.h +++ b/lib/atc/WeakEquationElectronContinuity.h @@ -10,7 +10,7 @@ namespace ATC{ /** * @class WeakEquationElectronContinuity - * @brief Electron continuity + * @brief Electron continuity * n,t = div J + (G-R) --> * M n,t = int B J + int N (G-R) */ @@ -18,13 +18,13 @@ namespace ATC{ class WeakEquationElectronContinuity : public WeakEquation { public: - - // constructor + + // constructor WeakEquationElectronContinuity(); // destructor virtual ~WeakEquationElectronContinuity(); - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, @@ -40,7 +40,7 @@ class WeakEquationElectronContinuity : public WeakEquation { /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} - virtual bool N_integrand(const FIELD_MATS &fields, + virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const; @@ -57,7 +57,7 @@ class WeakEquationElectronContinuity : public WeakEquation { /** * @class WeakEquationElectronEquilibrium - * @brief Electron continuity from equilibrium + * @brief Electron continuity from equilibrium * n = n(\phi) * M n = int N n(\phi) */ @@ -65,15 +65,15 @@ class WeakEquationElectronContinuity : public WeakEquation { class WeakEquationElectronEquilibrium : public WeakEquation { public: - - // constructor + + // constructor WeakEquationElectronEquilibrium(); // destructor virtual ~WeakEquationElectronEquilibrium(); - + /** density that used to form the mass matrix */ - + virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, const Material * material, @@ -81,12 +81,12 @@ class WeakEquationElectronEquilibrium : public WeakEquation { /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} - virtual bool N_integrand(const FIELD_MATS &fields, + virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const; - - + + /** flux that is integrated with B = Grad N as its weight */ virtual bool has_B_integrand(void) const {return true;} virtual void B_integrand(const FIELD_MATS &fields, diff --git a/lib/atc/WeakEquationElectronMomentum.cpp b/lib/atc/WeakEquationElectronMomentum.cpp index c4728c7bd5..7ccd6370bf 100644 --- a/lib/atc/WeakEquationElectronMomentum.cpp +++ b/lib/atc/WeakEquationElectronMomentum.cpp @@ -28,7 +28,7 @@ void WeakEquationElectronMomentum::convection(const FIELD_MATS &fields, // set up mass density FIELD_MATS::const_iterator nField = fields.find(ELECTRON_DENSITY); const DENS_MAT & n = nField->second; - DENS_MAT nMe(n.nRows(),n.nCols()); + DENS_MAT nMe(n.nRows(),n.nCols()); material->inv_effective_mass(fields,nMe); nMe = n.div_by_element(nMe); @@ -38,7 +38,7 @@ void WeakEquationElectronMomentum::convection(const FIELD_MATS &fields, const CLON_VEC u(velocity,CLONE_COL,0); const CLON_VEC v(velocity,CLONE_COL,1); const CLON_VEC w(velocity,CLONE_COL,2); - flux[0] = velocity; + flux[0] = velocity; flux[1] = velocity; flux[2] = velocity; CLON_VEC nuu(flux[0],CLONE_COL,0); @@ -50,7 +50,7 @@ void WeakEquationElectronMomentum::convection(const FIELD_MATS &fields, CLON_VEC nwu(flux[0],CLONE_COL,2); CLON_VEC nwv(flux[1],CLONE_COL,2); CLON_VEC nww(flux[2],CLONE_COL,2); - + for (int i = 0; i < n.nRows(); i++) { // tensor product of velocities nuu(i) *= nMe(i,0)*u(i); @@ -126,17 +126,17 @@ void WeakEquationElectronMomentumDDM::thermal_stress(const FIELD_MATS &fields, // ith velocity component has thermal stress of // d_i n * Cp * Te - DENS_MAT nCp(DTe[0].nRows(),DTe[0].nCols()); + DENS_MAT nCp(DTe[0].nRows(),DTe[0].nCols()); material->electron_heat_capacity(fields,nCp); nCp *= 2./3.; // correction to capacity account for convection - + tsx += nCp.mult_by_element(DTe[0]); tsy += nCp.mult_by_element(DTe[1]); tsz += nCp.mult_by_element(DTe[2]); - + FIELD_MATS::const_iterator tField = fields.find(ELECTRON_TEMPERATURE); const DENS_MAT & Te = tField->second; - + material->D_electron_heat_capacity(fields,gradFields,_dnCp_); for (int i = 0; i < nsd_; i++) _dnCp_[i] *= 2./3.; // correction to capacity account for convection @@ -173,7 +173,7 @@ bool WeakEquationElectronMomentumDDM::N_integrand( FIELD_MATS::const_iterator nField = fields.find(ELECTRON_DENSITY); const DENS_MAT & n = nField->second; - + CLON_VEC tsx(flux,CLONE_COL,0); CLON_VEC tsy(flux,CLONE_COL,1); CLON_VEC tsz(flux,CLONE_COL,2); diff --git a/lib/atc/WeakEquationElectronMomentum.h b/lib/atc/WeakEquationElectronMomentum.h index 0010b012cd..66e8b5b005 100644 --- a/lib/atc/WeakEquationElectronMomentum.h +++ b/lib/atc/WeakEquationElectronMomentum.h @@ -12,9 +12,9 @@ namespace ATC{ /** * @class WeakEquationElectronMomentum - * @brief Electron momentum + * @brief Electron momentum * rho v,t = div P --> - * int M rho v,t = int B P + * int M rho v,t = int B P */ class WeakEquationElectronMomentum : public WeakEquation { @@ -25,7 +25,7 @@ namespace ATC{ // destructor virtual ~WeakEquationElectronMomentum(); - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, @@ -38,7 +38,7 @@ namespace ATC{ const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT_VEC &flux) const ; - + /** necessary interfaces */ virtual std::set needs_material_functions(void) const { @@ -59,7 +59,7 @@ namespace ATC{ * @class WeakEquationElectronMomentumDDM * @brief Electron momentum - drift diffusion * rho v,t = div P --> - * int M rho v,t = int B P + * int M rho v,t = int B P */ class WeakEquationElectronMomentumDDM : public WeakEquationElectronMomentum { @@ -67,29 +67,29 @@ namespace ATC{ public: // constructor WeakEquationElectronMomentumDDM(); - + // destructor virtual ~WeakEquationElectronMomentumDDM(); - + /** density that used to form the mass matrix */ virtual void M_integrand(const FIELD_MATS &fields, const Material * material, DENS_MAT &density ) const ; - + /** flux that is integrated with grad N as its weight */ virtual bool has_B_integrand(void) const {return false;} virtual void B_integrand(const FIELD_MATS & /* fields */, const GRAD_FIELD_MATS & /* grad_fields */, const Material * /* material */, DENS_MAT_VEC &/* flux */) const {}; - + /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const ; - + /** necessary interfaces */ virtual std::set needs_material_functions(void) const { @@ -100,7 +100,7 @@ namespace ATC{ needs.insert("electric_displacement"); return needs; } - + protected: /** computes thermal stresses arising from convection */ virtual void thermal_stress(const FIELD_MATS &fields, @@ -112,6 +112,6 @@ namespace ATC{ mutable DENS_MAT_VEC _dnCp_; mutable DENS_MAT_VEC _electricForce_; }; - + }; #endif diff --git a/lib/atc/WeakEquationElectronTemperature.cpp b/lib/atc/WeakEquationElectronTemperature.cpp index 72315dd1e6..368db1005e 100644 --- a/lib/atc/WeakEquationElectronTemperature.cpp +++ b/lib/atc/WeakEquationElectronTemperature.cpp @@ -86,8 +86,8 @@ WeakEquationElectronTemperatureJouleHeating::WeakEquationElectronTemperatureJoul //eV2E_ = (ATC::LammpsInterface::instance()->qe2f()) // * (ATC::LammpsInterface::instance()->ftm2v()); eV2E_ = ATC::LammpsInterface::instance()->qv2e(); - int nSD = 3; - _J_.assign(nSD, DENS_MAT()); + int nSD = 3; + _J_.assign(nSD, DENS_MAT()); _E_.assign(nSD, DENS_MAT()); } //-------------------------------------------------------------- @@ -130,18 +130,18 @@ bool WeakEquationElectronTemperatureJouleHeating::N_integrand( const Material * material, DENS_MAT &flux) const { - + // call base class to get electron_temperature terms WeakEquationElectronTemperature::N_integrand(fields, grad_fields, material, flux); // Joule heating = -I.grad Psi = J.grad Psi \approx J.E - DENS_MAT jouleHeating; - material->electron_flux (fields, grad_fields, _J_); + DENS_MAT jouleHeating; + material->electron_flux (fields, grad_fields, _J_); material->electric_field(fields, grad_fields, _E_); jouleHeating = _J_[0].mult_by_element(_E_[0]); for (DENS_MAT_VEC::size_type i=1; i < _J_.size(); i++) jouleHeating += _J_[i].mult_by_element(_E_[i]); jouleHeating *= eV2E_; - flux -= jouleHeating; + flux -= jouleHeating; return true; } @@ -155,8 +155,8 @@ bool WeakEquationElectronTemperatureJouleHeating::N_integrand( WeakEquationElectronTemperatureConvection::WeakEquationElectronTemperatureConvection() : WeakEquationElectronTemperatureJouleHeating() { - int nSD = 3; - _convectiveFlux_.assign(nSD, DENS_MAT()); + int nSD = 3; + _convectiveFlux_.assign(nSD, DENS_MAT()); } //-------------------------------------------------------------- @@ -175,7 +175,7 @@ void WeakEquationElectronTemperatureConvection::B_integrand( DENS_MAT_VEC &flux) const { // add diffusion term - + WeakEquationElectronTemperatureJouleHeating::B_integrand(fields, grad_fields, material, flux); //flux[0] = 0.; //flux[1] = 0.; @@ -204,8 +204,8 @@ bool WeakEquationElectronTemperatureConvection::N_integrand( DENS_MAT capacity; material->electron_heat_capacity(fields, capacity); capacity *= 2./3.; // correction in DDM equations - - + + //FIELD_MATS::const_iterator dField = fields.find(ELECTRON_DENSITY); FIELD_MATS::const_iterator tField = fields.find(ELECTRON_TEMPERATURE); //const DENS_MAT & density = dField->second; @@ -221,10 +221,10 @@ bool WeakEquationElectronTemperatureConvection::N_integrand( //keExchange *= density; keExchange *= temperature; keExchange *= capacity; - + flux -= keExchange; #endif - return true; + return true; } }; // end namespace diff --git a/lib/atc/WeakEquationElectronTemperature.h b/lib/atc/WeakEquationElectronTemperature.h index 1a5ecbab00..cf7ea97350 100644 --- a/lib/atc/WeakEquationElectronTemperature.h +++ b/lib/atc/WeakEquationElectronTemperature.h @@ -10,21 +10,21 @@ namespace ATC{ /** * @class WeakEquationElectronTemperature - * @brief Electron temperature - * c T_e,t = div q_e + g(T_e-T_p) --> + * @brief Electron temperature + * c T_e,t = div q_e + g(T_e-T_p) --> * int M c T_e,t = int B q_e + int N g */ class WeakEquationElectronTemperature : public WeakEquation { public: - - // constructor + + // constructor WeakEquationElectronTemperature(); // destructor virtual ~WeakEquationElectronTemperature(); - + /** integrand that used to form the energy */ virtual bool has_E_integrand(void) const {return true;} virtual void E_integrand(const FIELD_MATS &fields, @@ -47,7 +47,7 @@ class WeakEquationElectronTemperature : public WeakEquation { /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} - virtual bool N_integrand(const FIELD_MATS &fields, + virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const ; @@ -68,21 +68,21 @@ class WeakEquationElectronTemperature : public WeakEquation { /** * @class WeakEquationElectronTemperatureJouleHeating * @brief Electron temperature with Joule heating - * c T_e,t = div q_e + g(T_e-T_p) + J.E --> + * c T_e,t = div q_e + g(T_e-T_p) + J.E --> * int M c T_e,t = int B q_e + int N ( g + J.E) */ -class WeakEquationElectronTemperatureJouleHeating : - public WeakEquationElectronTemperature +class WeakEquationElectronTemperatureJouleHeating : + public WeakEquationElectronTemperature { public: - - // constructor + + // constructor WeakEquationElectronTemperatureJouleHeating(); // destructor virtual ~WeakEquationElectronTemperatureJouleHeating(); - + /** integrand that used to form the energy */ virtual bool has_E_integrand(void) const {return true;} virtual void E_integrand(const FIELD_MATS &fields, @@ -105,7 +105,7 @@ class WeakEquationElectronTemperatureJouleHeating : /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} - virtual bool N_integrand(const FIELD_MATS &fields, + virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const; @@ -113,7 +113,7 @@ class WeakEquationElectronTemperatureJouleHeating : /** necessary interfaces */ virtual std::set needs_material_functions(void) const { - std::set needs + std::set needs = WeakEquationElectronTemperature::needs_material_functions(); needs.insert("electric_field"); return needs; @@ -121,7 +121,7 @@ class WeakEquationElectronTemperatureJouleHeating : protected: - + /** conversion factor for charge * voltage --> mass length^2 / time^2 */ double eV2E_; @@ -131,16 +131,16 @@ class WeakEquationElectronTemperatureJouleHeating : /** * @class WeakEquationElectronTemperatureConvection * @brief Electron temperature with convection - * c ( T_e,t + grad m_e J.E T_e / e ) = div q_e + g(T_e-T_p) + c n T_e grad J.E/(n e) --> + * c ( T_e,t + grad m_e J.E T_e / e ) = div q_e + g(T_e-T_p) + c n T_e grad J.E/(n e) --> * int M c T_e,t = int B ( q_e - c m_e J.E T_e / e ) + int N ( g + c n T_e grad J.E/(n e) ) */ -class WeakEquationElectronTemperatureConvection : +class WeakEquationElectronTemperatureConvection : public WeakEquationElectronTemperatureJouleHeating { public: - - // constructor + + // constructor WeakEquationElectronTemperatureConvection(); // destructor @@ -155,7 +155,7 @@ class WeakEquationElectronTemperatureConvection : /** flux that is integrated with N as its weight */ virtual bool has_N_integrand(void) const {return true;} - virtual bool N_integrand(const FIELD_MATS &fields, + virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &flux) const; @@ -163,7 +163,7 @@ class WeakEquationElectronTemperatureConvection : /** necessary interfaces */ virtual std::set needs_material_functions(void) const { - std::set needs + std::set needs = WeakEquationElectronTemperature::needs_material_functions(); needs.insert("electron_drag_power"); return needs; @@ -173,7 +173,7 @@ class WeakEquationElectronTemperatureConvection : /** workspace variable for the convective flux */ mutable DENS_MAT_VEC _convectiveFlux_; - + }; }; // end namespace diff --git a/lib/atc/WeakEquationMassDiffusion.cpp b/lib/atc/WeakEquationMassDiffusion.cpp index 47ca01bbe4..122d3ee891 100644 --- a/lib/atc/WeakEquationMassDiffusion.cpp +++ b/lib/atc/WeakEquationMassDiffusion.cpp @@ -47,4 +47,4 @@ void WeakEquationMassDiffusion::B_integrand( } }; // end namespace - + diff --git a/lib/atc/WeakEquationMassDiffusion.h b/lib/atc/WeakEquationMassDiffusion.h index 5b3a654300..7239e248cb 100644 --- a/lib/atc/WeakEquationMassDiffusion.h +++ b/lib/atc/WeakEquationMassDiffusion.h @@ -10,7 +10,7 @@ namespace ATC{ /** * @class WeakEquationMassDiffusion - * @brief Mass diffusion + * @brief Mass diffusion * c rho,t = div rho --> * int M c rho,t = int B rho */ @@ -18,13 +18,13 @@ namespace ATC{ class WeakEquationMassDiffusion : public WeakEquation { public: - - // constructor + + // constructor WeakEquationMassDiffusion(); // destructor virtual ~WeakEquationMassDiffusion(); - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, diff --git a/lib/atc/WeakEquationMomentum.cpp b/lib/atc/WeakEquationMomentum.cpp index 39400d3167..d38ea0121f 100644 --- a/lib/atc/WeakEquationMomentum.cpp +++ b/lib/atc/WeakEquationMomentum.cpp @@ -49,7 +49,7 @@ bool WeakEquationMomentum::N_integrand( const Material * material, DENS_MAT &flux) const { - return material->body_force(fields, flux); + return material->body_force(fields, flux); } //-------------------------------------------------------------- @@ -73,7 +73,7 @@ WeakEquationMomentumElectrostatic::WeakEquationMomentumElectrostatic() { // convert charge * electric field --> force qE2f_ = (ATC::LammpsInterface::instance()->qe2f()); - _E_.assign(3, DENS_MAT()); + _E_.assign(3, DENS_MAT()); } //-------------------------------------------------------------- @@ -81,21 +81,21 @@ bool WeakEquationMomentumElectrostatic::N_integrand( const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, - DENS_MAT &flux) const + DENS_MAT &flux) const { material->electric_field(fields, grad_fields, _E_); // "conversion" of grad scalar to vector field int nsd = _E_.size(); - flux.resize(_E_[0].nRows(),nsd); + flux.resize(_E_[0].nRows(),nsd); FIELD_MATS::const_iterator nField = fields.find(ELECTRON_DENSITY); const DENS_MAT & n = nField->second; for (int i=0; i < nsd; i++) { CLON_VEC fi = column(flux,i); fi = _E_[i]; - fi *= -qE2f_*n; + fi *= -qE2f_*n; } - return true; + return true; } //============================================================== // Class WeakEquationMomentumDiffusion @@ -152,6 +152,6 @@ bool WeakEquationMomentumDiffusion::N_integrand( const Material * material, DENS_MAT &flux) const { - return material->body_force(fields, flux); + return material->body_force(fields, flux); } }; // END namespace diff --git a/lib/atc/WeakEquationMomentum.h b/lib/atc/WeakEquationMomentum.h index cb1e829e98..bf47c8b1cc 100644 --- a/lib/atc/WeakEquationMomentum.h +++ b/lib/atc/WeakEquationMomentum.h @@ -12,9 +12,9 @@ class Material; /** * @class WeakEquationMomentum - * @brief Momentum + * @brief Momentum * rho v,t = div P --> - * int M rho v,t = int B P + * int M rho v,t = int B P */ class WeakEquationMomentum : public WeakEquation { @@ -33,7 +33,7 @@ class WeakEquationMomentum : public WeakEquation { const GRAD_FIELD_MATS &grad_fields, const Material * material, DENS_MAT &energy ) const; - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, @@ -80,7 +80,7 @@ class WeakEquationMomentumElectrostatic : public WeakEquationMomentum { // destructor virtual ~WeakEquationMomentumElectrostatic(){}; - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, @@ -93,7 +93,7 @@ class WeakEquationMomentumElectrostatic : public WeakEquationMomentum { virtual void B_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, - DENS_MAT_VEC &flux) const + DENS_MAT_VEC &flux) const { WeakEquationMomentum::B_integrand(fields, grad_fields, material, flux); } /** flux that is integrated with N as its weight */ @@ -101,7 +101,7 @@ class WeakEquationMomentumElectrostatic : public WeakEquationMomentum { virtual bool N_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, - DENS_MAT &flux) const ; + DENS_MAT &flux) const ; /** necessary interfaces */ virtual std::set needs_material_functions(void) const @@ -133,7 +133,7 @@ class WeakEquationMomentumDiffusion : public WeakEquation { /** integrand that used to form the energy */ virtual bool has_E_integrand(void) const {return false;} - + /** density that used to form the mass matrix */ virtual bool has_M_integrand(void) const {return true;} virtual void M_integrand(const FIELD_MATS &fields, diff --git a/lib/atc/WeakEquationPhononTemperature.cpp b/lib/atc/WeakEquationPhononTemperature.cpp index fe1ac894bd..aec735deea 100644 --- a/lib/atc/WeakEquationPhononTemperature.cpp +++ b/lib/atc/WeakEquationPhononTemperature.cpp @@ -69,12 +69,12 @@ WeakEquationPhononTemperatureExchange::WeakEquationPhononTemperatureExchange() //--------------------------------------------------------------------- WeakEquationPhononTemperatureExchange::~WeakEquationPhononTemperatureExchange(void) {} - + //--------------------------------------------------------------------- // compute energy //--------------------------------------------------------------------- void WeakEquationPhononTemperatureExchange::E_integrand( - const FIELD_MATS &fields, + const FIELD_MATS &fields, const GRAD_FIELD_MATS &gradFields, const Material * material, DENS_MAT &energy ) const @@ -121,4 +121,4 @@ bool WeakEquationPhononTemperatureExchange::N_integrand( }; // end namespace - + diff --git a/lib/atc/WeakEquationPhononTemperature.h b/lib/atc/WeakEquationPhononTemperature.h index f3dfcac527..b0ffe5e9ab 100644 --- a/lib/atc/WeakEquationPhononTemperature.h +++ b/lib/atc/WeakEquationPhononTemperature.h @@ -10,21 +10,21 @@ namespace ATC{ /** * @class WeakEquationPhononTemperature - * @brief Phonon temperature + * @brief Phonon temperature * c T_p,t = div q_p --> - * int M c T_p,t = int B q_p + * int M c T_p,t = int B q_p */ class WeakEquationPhononTemperature : public WeakEquation { public: - - // constructor + + // constructor WeakEquationPhononTemperature(); // destructor virtual ~WeakEquationPhononTemperature(); - + /** integrand that used to form the energy */ virtual bool has_E_integrand(void) const {return true;} virtual void E_integrand(const FIELD_MATS &fields, @@ -63,17 +63,17 @@ class WeakEquationPhononTemperature : public WeakEquation { * int M c T_p,t = int B q_p + int N g */ -class WeakEquationPhononTemperatureExchange : +class WeakEquationPhononTemperatureExchange : public WeakEquationPhononTemperature { public: - - // constructor + + // constructor WeakEquationPhononTemperatureExchange(); // destructor virtual ~WeakEquationPhononTemperatureExchange(); - + /** integrand that used to form the energy */ virtual bool has_E_integrand(void) const {return true;} virtual void E_integrand(const FIELD_MATS &fields, diff --git a/lib/atc/WeakEquationPoisson.cpp b/lib/atc/WeakEquationPoisson.cpp index 4440c02bd3..75a9684e20 100644 --- a/lib/atc/WeakEquationPoisson.cpp +++ b/lib/atc/WeakEquationPoisson.cpp @@ -10,9 +10,9 @@ namespace ATC { //============================================================== // R = B^T flux + N source = 0 -// 0 = B^T perm B phi - N rho_+ +// 0 = B^T perm B phi - N rho_+ + - //-------------------------------------------------------------- // Constructor //-------------------------------------------------------------- @@ -86,7 +86,7 @@ bool WeakEquationPoissonConstantRHS::N_integrand( FIELD_MATS::const_iterator nIter = fields.find(ELECTRON_DENSITY); if (nIter != fields.end()) { const DENS_MAT & n = nIter->second; - flux = -1.0*n; + flux = -1.0*n; return true; } return false; diff --git a/lib/atc/WeakEquationPoisson.h b/lib/atc/WeakEquationPoisson.h index b004b350ce..3a95ee91df 100644 --- a/lib/atc/WeakEquationPoisson.h +++ b/lib/atc/WeakEquationPoisson.h @@ -18,13 +18,13 @@ namespace ATC{ class WeakEquationPoisson : public WeakEquation { public: - - // constructor + + // constructor WeakEquationPoisson(); // destructor virtual ~WeakEquationPoisson(){}; - + /** flux that is integrated with B = Grad N as its weight */ virtual bool has_B_integrand(void) const {return true;} virtual void B_integrand(const FIELD_MATS &fields, @@ -74,19 +74,19 @@ class WeakEquationPoisson : public WeakEquation { class WeakEquationPoissonConstantRHS : public WeakEquationPoisson { public: - - // constructor + + // constructor WeakEquationPoissonConstantRHS(); // destructor virtual ~WeakEquationPoissonConstantRHS(){}; - + /** flux that is integrated with B = Grad N as its weight */ virtual bool has_B_integrand(void) const {return true;} virtual void B_integrand(const FIELD_MATS &fields, const GRAD_FIELD_MATS &grad_fields, const Material * material, - DENS_MAT_VEC &flux) const + DENS_MAT_VEC &flux) const { WeakEquationPoisson::B_integrand(fields, grad_fields, material, flux) ; } /** flux that is integrated with N as its weight */ diff --git a/lib/atc/WeakEquationSchrodinger.h b/lib/atc/WeakEquationSchrodinger.h index c7d46fa5d2..f46b7fdb72 100644 --- a/lib/atc/WeakEquationSchrodinger.h +++ b/lib/atc/WeakEquationSchrodinger.h @@ -1,5 +1,5 @@ #ifndef WEAK_EQUATION_SCHRODINGER_H -#define WEAK_EQUATION_SCHRODINGER_H +#define WEAK_EQUATION_SCHRODINGER_H #include #include @@ -11,20 +11,20 @@ namespace ATC{ /** * @class WeakEquationSchrodinger * @brief Schrodinger equation - * -hbar^2 /2 1/m^* psi,xx + phi psi = E psi + * -hbar^2 /2 1/m^* psi,xx + phi psi = E psi * (-c*B^T B + phi N^T N) psi = E N^T N psi */ class WeakEquationSchrodinger : public WeakEquation { public: - - // constructor + + // constructor WeakEquationSchrodinger(); // destructor virtual ~WeakEquationSchrodinger(); - + /** RHS stiffness matrix */ virtual bool has_BB_tangent_coefficients(void) const {return true;} virtual void BB_tangent_coefficients(const FieldName field, diff --git a/lib/awpmd/README b/lib/awpmd/README index d829361a1b..2c7a2aeda0 100644 --- a/lib/awpmd/README +++ b/lib/awpmd/README @@ -5,7 +5,7 @@ valuev at physik.hu-berlin.de June 2011 This is version 0.9 of the AWPMD library taken from JIHT GridMD project. -It contains interface to calculate electronic and electron-ion Hamiltonian, +It contains interface to calculate electronic and electron-ion Hamiltonian, norm matrix and forces for AWPMD method. AWPMD is an open source program distributed under the terms diff --git a/lib/awpmd/ivutils/include/lapack_inter.h b/lib/awpmd/ivutils/include/lapack_inter.h index e4497fc840..ac3e062b5b 100644 --- a/lib/awpmd/ivutils/include/lapack_inter.h +++ b/lib/awpmd/ivutils/include/lapack_inter.h @@ -20,7 +20,7 @@ typedef complex lapack_complex_double; inline void ZPPTRI( char* uplo, const lapack_int* n, lapack_complex_double* ap, lapack_int* info ){ ZPPTRI(uplo, (int*)n, (MKL_Complex16*)ap, (int*)info); } - + #else #define DGETRF dgetrf_ @@ -32,17 +32,17 @@ typedef complex lapack_complex_double; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - void dgetrf_( const lapack_int* m, const lapack_int* n, double* a, const lapack_int* lda, + void dgetrf_( const lapack_int* m, const lapack_int* n, double* a, const lapack_int* lda, lapack_int* ipiv, lapack_int* info ); - void dgetrs_( const char* trans, const lapack_int* n, const lapack_int* nrhs, - const double* a, const lapack_int* lda, const lapack_int* ipiv, + void dgetrs_( const char* trans, const lapack_int* n, const lapack_int* nrhs, + const double* a, const lapack_int* lda, const lapack_int* ipiv, double* b, const lapack_int* ldb, lapack_int* info ); - void dgetri_( const lapack_int* n, double* a, const lapack_int* lda, - const lapack_int* ipiv, double* work, const lapack_int* lwork, + void dgetri_( const lapack_int* n, double* a, const lapack_int* lda, + const lapack_int* ipiv, double* work, const lapack_int* lwork, lapack_int* info ); - void zpptrf_( const char* uplo, const lapack_int* n, lapack_complex_double* ap, + void zpptrf_( const char* uplo, const lapack_int* n, lapack_complex_double* ap, lapack_int* info ); - void zpptri_( const char* uplo, const lapack_int* n, lapack_complex_double* ap, + void zpptri_( const char* uplo, const lapack_int* n, lapack_complex_double* ap, lapack_int* info ); #ifdef __cplusplus } diff --git a/lib/awpmd/ivutils/include/logexc.h b/lib/awpmd/ivutils/include/logexc.h index 2eebfcc0ce..46f0406f1e 100644 --- a/lib/awpmd/ivutils/include/logexc.h +++ b/lib/awpmd/ivutils/include/logexc.h @@ -32,7 +32,7 @@ enum vbLEVELS{ vblMESS3 = 0x20, ///< report messages of level 3 (not important) vblMESS4 = 0x40, ///< report messages of level 4 (anything possible) vblALLMESS = vblMESS1|vblMESS2|vblMESS3|vblMESS4, ///< report all messages - vblPROGR = 0x80, ///< report progress + vblPROGR = 0x80, ///< report progress vblALL = 0xffff }; @@ -43,7 +43,7 @@ enum vbLEVELS{ template struct log_exception_traits{ /// exception level according to the vbLEVELS - static int level(const exc_t & /* signal */){ return vblFATAL; } + static int level(const exc_t & /* signal */){ return vblFATAL; } /// the string name of exception category static string name(const exc_t & /* signal */){ return typeid(exc_t).name();} /// adds some more explanations to the description @@ -60,9 +60,9 @@ struct log_exception_traits{ template<> struct log_exception_traits{ /// exception level according to the vbLEVELS - static int level(const int &signal){ return signal; } + static int level(const int &signal){ return signal; } /// the string name of exception category - static string name(const int &signal){ + static string name(const int &signal){ if(signal&vblFATAL) return "fatal error"; else if(signal&vblOERR) @@ -88,8 +88,8 @@ struct log_exception_traits{ /// vbLEVELS exceptions act as integers template<> struct log_exception_traits{ - static int level(const enum vbLEVELS &signal){ return log_exception_traits::level(signal); } - static string name(const enum vbLEVELS &signal){ return log_exception_traits::name(signal); } + static int level(const enum vbLEVELS &signal){ return log_exception_traits::level(signal); } + static string name(const enum vbLEVELS &signal){ return log_exception_traits::name(signal); } static enum vbLEVELS add_words(const enum vbLEVELS &orig, const char * /* words */){ return orig; } @@ -99,7 +99,7 @@ struct log_exception_traits{ /// message(signal,errcode, text) is used to either throw an exception or return errorcode /// At first, the the level of error is determined via log_exception_traits<>::level(signal) /// For integer (enum) signals the level is the signal itself. -/// Then text is printed, if signal level is listed in output levels or (or in extra outlevels, if they are set) +/// Then text is printed, if signal level is listed in output levels or (or in extra outlevels, if they are set) /// via log_text() function. /// If level has vblERR bit, the behaviour is controlled by the flag specified in set_throw(flag): /// flag=0: nothing done; @@ -121,13 +121,13 @@ protected: int throw_ex; int outlevel, eoutlevel; int stoplevel, estoplevel; - + static message_logger *glogp; /// used to restore the previous global logger message_logger *prev, *next; public: - - message_logger(const string &descriptor_="", int out_level=vblALLBAD|vblMESS1, + + message_logger(const string &descriptor_="", int out_level=vblALLBAD|vblMESS1, int stop_level=vblFATAL, int throw_exceptions=0, int use_globally=0) :descriptor(descriptor_),prev(nullptr),next(nullptr){ set_throw(throw_exceptions); @@ -137,11 +137,11 @@ public: set_global(true); } } - + /// returns a reference to global logger /// if not set, links with default message_logger static message_logger &global(); - + /// sets/unsets this logger as the global logger int set_global(bool set){ if(set){ @@ -154,7 +154,7 @@ public: } else{ if(glogp!=this) // was not set as the global - return -1; + return -1; glogp=prev; if(glogp) glogp->next=nullptr; @@ -162,7 +162,7 @@ public: } return 1; } - + virtual void set_throw(int throw_exceptions){ throw_ex=throw_exceptions; } @@ -177,7 +177,7 @@ public: eoutlevel=out_level; estoplevel=stop_level; } - + template int message(const exc_t &signal, int errcode, const char *what, ...){ int level=log_exception_traits::level(signal); @@ -189,15 +189,15 @@ public: log_text(level,log_exception_traits::name(signal).c_str(),buff); } if(level&vblERR){ - if(throw_ex==1) // throws exc_t exception + if(throw_ex==1) // throws exc_t exception throw log_exception_traits::add_words(signal,buff); - else if(throw_ex==2) // throws pair<>(int,const char*) exception + else if(throw_ex==2) // throws pair<>(int,const char*) exception throw make_pair(errcode,what); - else if(throw_ex==3) // throws int exception + else if(throw_ex==3) // throws int exception throw errcode; - } + } if(level&(estoplevel ? estoplevel: stoplevel) ){ // needs to stop - exit(errcode); + exit(errcode); } return errcode; } @@ -210,7 +210,7 @@ public: printf("%s\n",messtext); } - /// checks that the deleted one is not in global logger chain + /// checks that the deleted one is not in global logger chain ~message_logger(){ if(prev){ prev->next=next; @@ -231,7 +231,7 @@ int message(const exc_t &signal, int errcode, const char *what, ...){ vsnprintf(buff,1024,what,args); return message_logger::glogp->message(signal,errcode,buff); } - else + else return -1; } @@ -240,8 +240,8 @@ class stdfile_logger: public message_logger { protected: FILE *fout, *ferr; public: - stdfile_logger(const string &descriptor_="", int throw_exceptions=0, - FILE *out=stdout, FILE *err=stderr, + stdfile_logger(const string &descriptor_="", int throw_exceptions=0, + FILE *out=stdout, FILE *err=stderr, int out_level=vblALLBAD|vblMESS1,int stop_level=vblFATAL, int use_globally=0) : message_logger(descriptor_,out_level,stop_level,throw_exceptions,use_globally),fout(nullptr), ferr(nullptr){ @@ -253,7 +253,7 @@ public: fclose(fout); fout=out; } - + virtual void set_err(FILE *err, int close_prev=0){ if(close_prev && ferr && ferr!=stderr && ferr !=stdout) fclose(ferr); @@ -272,7 +272,7 @@ public: } }; -/// format a string +/// format a string const char *logfmt(const char *format,...); /// macros with common usage @@ -295,7 +295,7 @@ const char *logfmt(const char *format,...); /// where level and name are defined whithin a class struct log_exception { /// exception level according to the vbLEVELS - static int level(const log_exception &signal){ return vblFATAL; } + static int level(const log_exception &signal){ return vblFATAL; } /// the string name of exception category static string name(const log_exception &signal){ return "undefined exception";} }; @@ -303,8 +303,8 @@ struct log_exception { /// log_exceptions act as themselves template<> struct log_exception_traits{ - static int level(const log_exception &signal){ return log_exception::level(signal); } - static string name(const log_exception &signal){ return log_exception::name(signal); } + static int level(const log_exception &signal){ return log_exception::level(signal); } + static string name(const log_exception &signal){ return log_exception::name(signal); } }; # endif diff --git a/lib/awpmd/ivutils/include/wavepacket.h b/lib/awpmd/ivutils/include/wavepacket.h index 337a056e79..5a787f0809 100644 --- a/lib/awpmd/ivutils/include/wavepacket.h +++ b/lib/awpmd/ivutils/include/wavepacket.h @@ -12,7 +12,7 @@ using namespace std; -/** @file wpmd.h +/** @file wpmd.h @brief Classes to handle Gaussian Wave Packets. */ // Constants @@ -89,7 +89,7 @@ public: WavePacket operator*(const WavePacket& other) const { return WavePacket(a+other.a,b+other.b,lz+other.lz); } - + /// returns the integral of w(x) over 3D space cdouble integral() const { cdouble z = lz + b.norm2()/(4.*a); @@ -171,7 +171,7 @@ public: ///\en Transforms derivatives of a function with respect to WP parameters /// from internal into physical representation, i. e.:\n /// from df/d{are,aim,b0re,b0im,b1re,b1im,b2re,b2im} (8 values accessed by input iterator d_it in the given order)\n - /// to df/d{x0,x1,x2}, df/d{p0,p1,p2}, df/dw, df/dpw + /// to df/d{x0,x1,x2}, df/d{p0,p1,p2}, df/dw, df/dpw /// The supplied inputs (val) are modified by op: val=op(val,phys_der). /// Use operation=eq_second for the supplied inputs to be replaced by new physical derivative values. /// The input and output locations may coinside, an internal buffer is used for transformation. @@ -189,7 +189,7 @@ public: for(int i=0;i<3;i++){ dfn[i]= 2*real(a)*dfdi[2+2*i]+2*imag(a)*dfdi[2+2*i+1]; dfn[3+i]= dfdi[2+2*i+1]*(/*m_electron*/1./h_p) ; //*(h_plank/m_electron); - dfn[7]+=-(r[i]*dfdi[2+2*i+1]/w)/h_p; + dfn[7]+=-(r[i]*dfdi[2+2*i+1]/w)/h_p; dfn[6]+=-2*r[i]*(t*dfdi[2+2*i]+imag(a)*dfdi[2+2*i+1]/w); } int i=0; @@ -201,7 +201,7 @@ public: *dfdpw=op(*dfdpw,dfn[i++]); } - + ///\en Compares the wave packet to another on a per component basis. /// \return \retval 0 if all component differences are 0 within tolerance \a tol (EQUAL), /// \retval -1 for LESS @@ -229,7 +229,7 @@ public: for(int i=0;i<3;i++){ fe_x[ic1+k1][i]+= -2*real(wk.a)*E_der[s1][indw1+8*k1+2+2*i]-2*imag(wk.a)*E_der[s1][indw1+8*k1+2+2*i+1]; fe_p[ic1+k1][i]+= (-E_der[s1][indw1+8*k1+2+2*i+1])*(m_electron/h_plank); //*(h_plank/m_electron); - fe_pw[ic1+k1]+=(r[i]*E_der[s1][indw1+8*k1+2+2*i+1]/w)/h_plank; + fe_pw[ic1+k1]+=(r[i]*E_der[s1][indw1+8*k1+2+2*i+1]/w)/h_plank; fe_w[ic1+k1]+=2*r[i]*(t*E_der[s1][indw1+8*k1+2+2*i]+imag(wk.a)*E_der[s1][indw1+8*k1+2+2*i+1]/w); } #endif diff --git a/lib/awpmd/systems/interact/TCP/tcpdefs.h b/lib/awpmd/systems/interact/TCP/tcpdefs.h index e1e0b3553c..ac070c1daf 100644 --- a/lib/awpmd/systems/interact/TCP/tcpdefs.h +++ b/lib/awpmd/systems/interact/TCP/tcpdefs.h @@ -14,4 +14,4 @@ const double coul_pref=14.39965172693122; // e^2/(4*pi*eps0), eV*A const double eV_to_K=11604.447517053462; // Temperature in K correspondent to 1eV # endif -# endif \ No newline at end of file +# endif diff --git a/lib/awpmd/systems/interact/TCP/wpmd.cpp b/lib/awpmd/systems/interact/TCP/wpmd.cpp index 660d7c21d7..def5a9cdca 100644 --- a/lib/awpmd/systems/interact/TCP/wpmd.cpp +++ b/lib/awpmd/systems/interact/TCP/wpmd.cpp @@ -4,13 +4,13 @@ // Calculates derivative overlap matrix IDD void OverlapDeriv::calc_der_overlap(bool self, cdouble cc1, cdouble c2){ - cVector_3 I3 = I1 * ((bb_4a + 2.5) / w12.a); + cVector_3 I3 = I1 * ((bb_4a + 2.5) / w12.a); cdouble I4 = I0 * ( bb_4a *(bb_4a + 5.) + 3.75 ) / w12.a / w12.a; // calculate derivatives <(phi_k)'_q_k | (phi_l)'_q_l>: IDD.set(0, 0, I4 - (d1.l + d2.l)*I2 + d1.l*d2.l*I0 ); // over a_k_re and a_l_re IDD.set(0, 1, i_unit*( I4 - (d1.l + d2.m)*I2 + d1.l*d2.m*I0 ) ); // over a_k_re and a_l_im - if(!self) + if(!self) IDD.set(1, 0, i_unit1*( I4 + (d1.m - d2.l)*I2 - d1.m*d2.l*I0 ) ); // over a_k_im and a_l_re else IDD.set(1,0, conj(IDD(0,1))); @@ -33,7 +33,7 @@ void OverlapDeriv::calc_der_overlap(bool self, cdouble cc1, cdouble c2){ IDD.set((i+1)*2, 1, conj(IDD(1,(i+1)*2)) ); // over b_k_re and a_l_im IDD.set((i+1)*2+1, 1, conj(IDD(1,(i+1)*2+1)) ); // over b_k_im and a_l_im } - + for(int j=0;j<3;j++){ if(!self || j>=i){ cdouble I2ij = I0 / w12.a * @@ -62,10 +62,10 @@ void OverlapDeriv::calc_der_overlap(bool self, cdouble cc1, cdouble c2){ IDD.set((j+1)*2+1,(i+1)*2+1, conj(IDD((i+1)*2+1,(j+1)*2+1 )) ); } } // j - } // i + } // i if(real(cc1)){ // adding terms for split-packet - + IDD.set(8, 0, c2*da2_re() ); // over c_1_re and a_2_re IDD.set(8, 1, c2*da2_im() ); // over c_1_re and a_2_im IDD.set(9, 0, -i_unit*c2*da2_re() ); // over c_1_im and a_2_re @@ -105,7 +105,7 @@ WavePacket AWPMD::create_wp(Vector_3 &x, Vector_3 &v, double &w, double &pw, dou w=w0; pw=0.; } - + double rw; if(Lextra>0){ // width PBC, keeping the width are within [0,Lextra] w=fmod(w,Lextra); @@ -139,11 +139,11 @@ void AWPMD::resize(int flag){ M[s].init(ne[s],nvar[s]); L[s].init(ne[s],nvar[s]); } - } + } Eiep.assign((size_t)ni,0); Eiip.assign((size_t)ni,0); - + } @@ -153,7 +153,7 @@ void AWPMD::resize(int flag){ //e 0x4 -- PBC along Z //e cell specifies the lengths of the simulation box in all directions //e if PBCs are used, the corresponding coordinates of electrons and ions -//e in periodic directions must be within a range [0, cell[per_dir]) +//e in periodic directions must be within a range [0, cell[per_dir]) //e @returns 1 if OK int AWPMD::set_pbc(const Vector_3P pcell, int pbc_){ if(!pcell) @@ -212,9 +212,9 @@ int AWPMD::set_ions(int n, double* q, Vector_3P x) } //e same as interaction, but using Hartee factorization (no antisymmetrization) -int AWPMD::interaction_hartree(int flag, Vector_3P fi, Vector_3P fe_x, +int AWPMD::interaction_hartree(int flag, Vector_3P fi, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c){ - + // 0. resizing the arrays if needed enum APPROX tmp=HARTREE; swap(tmp,approx); // do not need large matrices @@ -222,7 +222,7 @@ int AWPMD::interaction_hartree(int flag, Vector_3P fi, Vector_3P fe_x, swap(tmp,approx); //1. clearing forces clear_forces(flag,fi,fe_x,fe_p,fe_w,fe_pw,fe_c); - + Eee = Ew = 0.; for(int s1=0;s1<2;s1++){ Ee[s1]=0.; @@ -246,9 +246,9 @@ int AWPMD::interaction_hartree(int flag, Vector_3P fi, Vector_3P fe_x, if(constraint == HARM) Ew += harm_w0_4 * w1*w1; // width force contribution //double dE=2*Epot/w; - //if(d->fw1)d->fw1[c1]+=dE; + //if(d->fw1)d->fw1[c1]+=dE; //if(fw2 && fw2!=fw1)fw2[c1]+=dE; - + // e-e interaction for(int s2=s1;s2<2;s2++){ for(int c2=(s1==s2 ? c1+1 : 0) ;c2fw2){ d->fw2[c2]+=sgn2*dEw*w2; } - }*/ + }*/ } } // e-i interaction @@ -328,14 +328,14 @@ int AWPMD::interaction_hartree(int flag, Vector_3P fi, Vector_3P fe_x, //e initializes internal buffers for calculations (set_electrons must be called first) //int init(){} -//e calculates interaction in the system of ni ions + electrons +//e calculates interaction in the system of ni ions + electrons //e the electonic subsystem must be previously setup by set_electrons, ionic by set_ions //e the iterators are describing ionic system only // 0x1 -- give back ion forces // 0x2 -- add ion forces to the existing set // 0x4 -- calculate derivatives for electronic time step (NOT IMPLEMENTED) //e if PBCs are used the coords must be within a range [0, cell) -int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, +int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c){ if(approx==HARTREE) return interaction_hartree(flag,fi,fe_x,fe_p,fe_w,fe_pw,fe_c); @@ -343,7 +343,7 @@ int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, resize(flag); // 1. clearing forces clear_forces(flag,fi,fe_x,fe_p,fe_w,fe_pw,fe_c); - + //2. calculating overlap matrix for(int s=0;s<2;s++){ int nes = ne[s]; @@ -370,10 +370,10 @@ int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, ZPPTRF("L",&nes,Y[s].arr,&info); // analyze return code here if(info<0) - return LOGERR(info,logfmt("AWPMD.interacton: call to ZPTRF failed (exitcode %d)!",info),LINFO); + return LOGERR(info,logfmt("AWPMD.interacton: call to ZPTRF failed (exitcode %d)!",info),LINFO); ZPPTRI("L",&nes,Y[s].arr,&info); if(info<0) - return LOGERR(info,logfmt("AWPMD.interacton: call to ZPTRI failed (exitcode %d)!",info),LINFO); + return LOGERR(info,logfmt("AWPMD.interacton: call to ZPTRI failed (exitcode %d)!",info),LINFO); /*f1=fopen(logfmt("matrY_%d.d",s),"wt"); @@ -402,7 +402,7 @@ int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, WavePacket& wl=wp[s][l]; if(pbc) ndr=move_to_image(wl,wk); - + WavePacket wkl=wl*conj(wk); //Vector_3 rrkl=wkl.get_r(); cVector_3 v1=wl.b*conj(wk.a)-conj(wk.b)*wl.a; @@ -421,13 +421,13 @@ int AWPMD::interaction(int flag, Vector_3P fi, Vector_3P fe_x, // e-i energy cdouble sum(0.,0.); - for(int i=0;i: @@ -640,7 +640,7 @@ void AWPMD::norm_matrix(int s){ IDD.set(k8+(i+1)*2, l8+1, i_unit1*( I3[i] - dl.m*I1[i] + dk.u[i]*(I2 - dl.m*I0) ) ); // over b_k_re and a_l_im IDD.set(k8+(i+1)*2+1, l8+1, -I3[i] + dl.m*I1[i] - dk.v[i]*(dl.m*I0 - I2) ); // over b_k_im and a_l_im } - + for(j=0;j<3;j++){ cdouble I2ij = I0 / wkl.a * (i==j ? wkl.b[i]*wkl.b[i] / wkl.a / 4 + 0.5 @@ -675,7 +675,7 @@ void AWPMD::norm_matrix(int s){ for(qi=0; qi split_c[2]; ///<\en split coefficients for electrons (c_re, c_im) or (psi,phi) depending on the norm mode vector nspl[2]; ///<\en number of wave packets for each electron (size is ne[i]) - + vector wf_norm[2]; ///<\en norms for each electron - vector wf_norm_der[2]; ///<\en norm derivative - vector ovl_der[2]; ///<\en overlap derivative: \ + vector wf_norm_der[2]; ///<\en norm derivative + vector ovl_der[2]; ///<\en overlap derivative: \ vector E_der[2]; ///<\en energy derivative with respect to {a,b} coordinates - vector< cdouble > Lh[2]; ///<\en Substitute for L in Hartree case: block matrices 1x(10*nspl[i]) + vector< cdouble > Lh[2]; ///<\en Substitute for L in Hartree case: block matrices 1x(10*nspl[i]) vector< sqmatrix > Normh[2]; ///<\en Substitute for Norm in Hartree case: block matrices ///\en resizes all internal arrays according to new electrons (wavepackets) added virtual void resize(int flag); - + public: AWPMD_split():s_add(0),spl_add(0){} //virtual ~AWPMD_split() {}; this line causes a segmentation fault, temporarily disabling - - + + ///\en Prepares to setup a new system of particles using \ref add_ion(), /// \ref add_electron() and \ref add_split(). - /// There is no need to call this function when using + /// There is no need to call this function when using /// \ref set_electrons() and \ref set_ions() to setup particles. virtual void reset(){ for(int s=0;s<2;s++){ split_c[s].clear(); - nspl[s].clear(); + nspl[s].clear(); } s_add=0; spl_add=0; @@ -112,7 +112,7 @@ public: /// If PBCs are used the coords must be within the range [0, cell) /// the \a splits array defines the number of wavepackets required for each electron /// the data for splits should be placed in the corresponding data arrays - /// \a c array contains the splits mixing coefficints + /// \a c array contains the splits mixing coefficints /// \a n is the number of electrons of a given spin component /// Electron velocity v is multiplied by mass to obtain momentum. /// Default mass (-1) means me. @@ -134,12 +134,12 @@ public: /// \return global id of the wavepacket (starting from 0 for each spin s) /// Electron velocity v is multiplied by mass to obtain momentum. /// Default mass (-1) means me. - /// The tags must be nonzero, >0 for the local particle, <0 for ghost particle. + /// The tags must be nonzero, >0 for the local particle, <0 for ghost particle. /// Unique particle id is abs(tag). - /// Default tag (0) means inserting the current particle id as local particle. + /// Default tag (0) means inserting the current particle id as local particle. int add_split(Vector_3 &x, Vector_3 &v, double &w, double &pw, Vector_2 &c, double mass=-1, double q=-1., int tag=0); - - + + ///\en gets current electronic coordinates, and (optionally) number of wave packets for each electron int get_electrons(int spin, Vector_3P x, Vector_3P v, double* w, double* pw, cdouble *c, int *splits=nullptr, double mass=-1); @@ -147,16 +147,16 @@ public: void eterm_deriv(int ic1,int s1, int c1,int k1,int ic2,int s2, int c2,int j2,cdouble pref, const OverlapDeriv &o,cdouble v,cdouble dv_aj_conj, cdouble dv_ak,cVector_3 dv_bj_conj, cVector_3 dv_bk); - + ///\en adds the derivatives of Y for the term v*Y[s](c2,c1) void y_deriv(cdouble v,int s, int c2, int c1); - + ///\en Calculates block norms an derivatives void calc_norms(int flag); - + ///\en Prepares force arrays according to \a flag setting for interaction() - virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x, + virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c); ///\en Calcualtes the overlap between two electrons taking all split WPs into account. @@ -164,10 +164,10 @@ public: cdouble overlap(int ic1, int s1, int c1,int ic2, int s2, int c2); //e same as interaction, but using Hartee factorization (no antisymmetrization) - int interaction_hartree(int flag=0, Vector_3P fi=nullptr, Vector_3P fe_x=nullptr, + int interaction_hartree(int flag=0, Vector_3P fi=nullptr, Vector_3P fe_x=nullptr, Vector_3P fe_p=nullptr, double *fe_w=nullptr, double *fe_pw=nullptr, Vector_2P fe_c=nullptr); - ///\en Calculates interaction in the system of ni ions + electrons + ///\en Calculates interaction in the system of ni ions + electrons /// the electonic subsystem must be previously setup by set_electrons, ionic by set_ions /// 0x1 -- give back ion forces \n /// 0x2 -- add ion forces to the existing set \n @@ -178,19 +178,19 @@ public: /// the forces may be obtained then using \ref get_el_forces() for all WPs \n /// or separately for each WP using \ref get_wp_force() /// if PBCs are used the coords must be within a range [0, cell) - int interaction(int flag=0, Vector_3P fi=nullptr, Vector_3P fe_x=nullptr, + int interaction(int flag=0, Vector_3P fi=nullptr, Vector_3P fe_x=nullptr, Vector_3P fe_p=nullptr, double *fe_w=nullptr, double *fe_pw=nullptr, Vector_2P fe_c=nullptr); ///\en Get electronic forcess in the arrays provided, using calculated internal representation /// Valid flag settings are:\n /// 0x4 -- overwrite existing forces \n /// 0x8 -- add electronic forces to the existing arrays \n - void get_el_forces(int flag, Vector_3P fe_x, + void get_el_forces(int flag, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c); - + void get_wp_force(int s, int ispl, Vector_3P fe_x, Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c){ - WavePacket wk=wp[s][ispl]; + WavePacket wk=wp[s][ispl]; int indw1=8*ispl; int indn1=(nvar[s]/10)*8+2*ispl; wk.int2phys_der< eq_minus_second >(E_der[s].begin()+indw1,(double *)fe_x,(double *)fe_p,fe_w,fe_pw,1./one_h); diff --git a/lib/colvars/colvarproxy.cpp b/lib/colvars/colvarproxy.cpp index d0f83c70a7..d418acd0c1 100644 --- a/lib/colvars/colvarproxy.cpp +++ b/lib/colvars/colvarproxy.cpp @@ -601,16 +601,16 @@ int colvarproxy_script::run_force_callback() int colvarproxy_script::run_colvar_callback(std::string const & /* name */, - std::vector const & /* cvcs */, - colvarvalue & /* value */) + std::vector const & /* cvcs */, + colvarvalue & /* value */) { return COLVARS_NOT_IMPLEMENTED; } int colvarproxy_script::run_colvar_gradient_callback(std::string const & /* name */, - std::vector const & /* cvcs */, - std::vector > & /* gradient */) + std::vector const & /* cvcs */, + std::vector > & /* gradient */) { return COLVARS_NOT_IMPLEMENTED; } diff --git a/lib/gpu/cudpp_mini/cudpp.cpp b/lib/gpu/cudpp_mini/cudpp.cpp index 9506320748..4acea78c8a 100644 --- a/lib/gpu/cudpp_mini/cudpp.cpp +++ b/lib/gpu/cudpp_mini/cudpp.cpp @@ -3,18 +3,18 @@ // ------------------------------------------------------------- // $Revision: 5632 $ // $Date: 2009-07-01 14:36:01 +1000 (Wed, 01 Jul 2009) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt in // the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * cudpp.cpp * * @brief Main library source file. Implements wrappers for public - * interface. - * + * interface. + * * Main library source file. Implements wrappers for public * interface. These wrappers call application-level operators. * As this grows we may decide to partition into multiple source @@ -25,12 +25,12 @@ * \defgroup publicInterface CUDPP Public Interface * The CUDA public interface comprises the functions, structs, and enums * defined in cudpp.h. Public interface functions call functions in the - * \link cudpp_app Application-Level\endlink interface. The public + * \link cudpp_app Application-Level\endlink interface. The public * interface functions include Plan Interface functions and Algorithm * Interface functions. Plan Interface functions are used for creating * CUDPP Plan objects which contain configuration details, intermediate - * storage space, and in the case of cudppSparseMatrix(), data. The - * Algorithm Interface is the set of functions that do the real work + * storage space, and in the case of cudppSparseMatrix(), data. The + * Algorithm Interface is the set of functions that do the real work * of CUDPP, such as cudppScan() and cudppSparseMatrixVectorMultiply. * * @{ @@ -53,10 +53,10 @@ * @brief Performs a scan operation of numElements on its input in * GPU memory (d_in) and places the output in GPU memory * (d_out), with the scan parameters specified in the plan pointed to by - * planHandle. - - * The input to a scan operation is an input array, a binary associative - * operator (like + or max), and an identity element for that operator + * planHandle. + + * The input to a scan operation is an input array, a binary associative + * operator (like + or max), and an identity element for that operator * (+'s identity is 0). The output of scan is the same size as its input. * Informally, the output at each element is the result of operator * applied to each input that comes before it. For instance, the @@ -71,27 +71,27 @@ * @htmlonly⊕@endhtmlonly@latexonly$\oplus$@endlatexonly ... * @htmlonly⊕@endhtmlonly@latexonly$\oplus$@endlatexonly * ini-1. - * - * CUDPP supports "exclusive" and "inclusive" scans. For the ADD operator, - * an exclusive scan computes the sum of all input elements before the - * current element, while an inclusive scan computes the sum of all input - * elements up to and including the current element. - * + * + * CUDPP supports "exclusive" and "inclusive" scans. For the ADD operator, + * an exclusive scan computes the sum of all input elements before the + * current element, while an inclusive scan computes the sum of all input + * elements up to and including the current element. + * * Before calling scan, create an internal plan using cudppPlan(). - * - * After you are finished with the scan plan, clean up with cudppDestroyPlan(). - * + * + * After you are finished with the scan plan, clean up with cudppDestroyPlan(). + * * @param[in] planHandle Handle to plan for this scan * @param[out] d_out output of scan, in GPU memory * @param[in] d_in input to scan, in GPU memory * @param[in] numElements number of elements to scan - * + * * @see cudppPlan, cudppDestroyPlan */ CUDPP_DLL CUDPPResult cudppScan(CUDPPHandle planHandle, - void *d_out, - const void *d_in, + void *d_out, + const void *d_in, size_t numElements) { CUDPPScanPlan *plan = (CUDPPScanPlan*)CUDPPPlanManager::GetPlan(planHandle); @@ -101,7 +101,7 @@ CUDPPResult cudppScan(CUDPPHandle planHandle, return CUDPP_SUCCESS; } else - { + { return CUDPP_ERROR_UNKNOWN; //! @todo Return more specific errors } } @@ -110,17 +110,17 @@ CUDPPResult cudppScan(CUDPPHandle planHandle, * @brief Performs a segmented scan operation of numElements on its input in * GPU memory (d_idata) and places the output in GPU memory * (d_out), with the scan parameters specified in the plan pointed to by - * planHandle. - + * planHandle. + * The input to a segmented scan operation is an input array of data, - * an input array of flags which demarcate segments, a binary associative - * operator (like + or max), and an identity element for that operator + * an input array of flags which demarcate segments, a binary associative + * operator (like + or max), and an identity element for that operator * (+'s identity is 0). The array of flags is the same length as the input - * with 1 marking the the first element of a segment and 0 otherwise. The - * output of segmented scan is the same size as its input. Informally, the - * output at each element is the result of operator applied to each input - * that comes before it in that segment. For instance, the output of - * segmented sum-scan at each element is the sum of all the input elements + * with 1 marking the the first element of a segment and 0 otherwise. The + * output of segmented scan is the same size as its input. Informally, the + * output at each element is the result of operator applied to each input + * that comes before it in that segment. For instance, the output of + * segmented sum-scan at each element is the sum of all the input elements * before that input in that segment. * * More formally, for associative operator @@ -132,32 +132,32 @@ CUDPPResult cudppScan(CUDPPHandle planHandle, * @htmlonly⊕@endhtmlonly@latexonly$\oplus$@endlatexonly * ini-1. * k is the index of the first element of the segment in which i lies - * - * We support both "exclusive" and "inclusive" variants. For a segmented sum-scan, - * the exclusive variant computes the sum of all input elements before the - * current element in that segment, while the inclusive variant computes the - * sum of all input elements up to and including the current element, in - * that segment. - * + * + * We support both "exclusive" and "inclusive" variants. For a segmented sum-scan, + * the exclusive variant computes the sum of all input elements before the + * current element in that segment, while the inclusive variant computes the + * sum of all input elements up to and including the current element, in + * that segment. + * * Before calling segmented scan, create an internal plan using cudppPlan(). - * - * After you are finished with the scan plan, clean up with cudppDestroyPlan(). + * + * After you are finished with the scan plan, clean up with cudppDestroyPlan(). * @param[in] planHandle Handle to plan for this scan * @param[out] d_out output of segmented scan, in GPU memory * @param[in] d_idata input data to segmented scan, in GPU memory * @param[in] d_iflags input flags to segmented scan, in GPU memory * @param[in] numElements number of elements to perform segmented scan on - * + * * @see cudppPlan, cudppDestroyPlan - + CUDPP_DLL CUDPPResult cudppSegmentedScan(CUDPPHandle planHandle, - void *d_out, + void *d_out, const void *d_idata, const unsigned int *d_iflags, size_t numElements) { - CUDPPSegmentedScanPlan *plan = + CUDPPSegmentedScanPlan *plan = (CUDPPSegmentedScanPlan*)CUDPPPlanManager::GetPlan(planHandle); if (plan != nullptr) { @@ -165,7 +165,7 @@ CUDPPResult cudppSegmentedScan(CUDPPHandle planHandle, return CUDPP_SUCCESS; } else - { + { return CUDPP_ERROR_UNKNOWN; //! @todo Return more specific errors } } @@ -173,29 +173,29 @@ CUDPPResult cudppSegmentedScan(CUDPPHandle planHandle, /** * @brief Performs numRows parallel scan operations of numElements * each on its input (d_in) and places the output in d_out, - * with the scan parameters set by config. Exactly like cudppScan + * with the scan parameters set by config. Exactly like cudppScan * except that it runs on multiple rows in parallel. - * + * * Note that to achieve good performance with cudppMultiScan one should * allocate the device arrays passed to it so that all rows are aligned * to the correct boundaries for the architecture the app is running on. - * The easy way to do this is to use cudaMallocPitch() to allocate a - * 2D array on the device. Use the \a rowPitch parameter to cudppPlan() - * to specify this pitch. The easiest way is to pass the device pitch + * The easy way to do this is to use cudaMallocPitch() to allocate a + * 2D array on the device. Use the \a rowPitch parameter to cudppPlan() + * to specify this pitch. The easiest way is to pass the device pitch * returned by cudaMallocPitch to cudppPlan() via \a rowPitch. - * + * * @param[in] planHandle handle to CUDPPScanPlan * @param[out] d_out output of scan, in GPU memory * @param[in] d_in input to scan, in GPU memory * @param[in] numElements number of elements (per row) to scan * @param[in] numRows number of rows to scan in parallel - * + * * @see cudppScan, cudppPlan CUDPP_DLL CUDPPResult cudppMultiScan(CUDPPHandle planHandle, - void *d_out, - const void *d_in, + void *d_out, + const void *d_in, size_t numElements, size_t numRows) { @@ -206,23 +206,23 @@ CUDPPResult cudppMultiScan(CUDPPHandle planHandle, return CUDPP_SUCCESS; } else - { + { return CUDPP_ERROR_UNKNOWN; //! @todo Return more specific errors } } */ /** - * @brief Given an array \a d_in and an array of 1/0 flags in \a + * @brief Given an array \a d_in and an array of 1/0 flags in \a * deviceValid, returns a compacted array in \a d_out of corresponding * only the "valid" values from \a d_in. - * + * * Takes as input an array of elements in GPU memory * (\a d_in) and an equal-sized unsigned int array in GPU memory * (\a deviceValid) that indicate which of those input elements are * valid. The output is a packed array, in GPU memory, of only those * elements marked as valid. - * + * * Internally, uses cudppScan. * * Example: @@ -237,7 +237,7 @@ CUDPPResult cudppMultiScan(CUDPPHandle planHandle, * wants is a final compacted array. Often one just wants the array of indices * to which each input element should go in the output. The split() routine used * in radix sort might make more sense to expose. - * + * * @param[in] planHandle handle to CUDPPCompactPlan * @param[out] d_out compacted output * @param[out] d_numValidElements set during cudppCompact; is set with the @@ -248,16 +248,16 @@ CUDPPResult cudppMultiScan(CUDPPHandle planHandle, CUDPP_DLL CUDPPResult cudppCompact(CUDPPHandle planHandle, - void *d_out, + void *d_out, size_t *d_numValidElements, - const void *d_in, + const void *d_in, const unsigned int *d_isValid, size_t numElements) { CUDPPCompactPlan *plan = (CUDPPCompactPlan*)CUDPPPlanManager::GetPlan(planHandle); if (plan != nullptr) { - cudppCompactDispatch(d_out, d_numValidElements, d_in, d_isValid, + cudppCompactDispatch(d_out, d_numValidElements, d_in, d_isValid, numElements, plan); return CUDPP_SUCCESS; } @@ -269,12 +269,12 @@ CUDPPResult cudppCompact(CUDPPHandle planHandle, */ /** * @brief Sorts key-value pairs or keys only - * + * * Takes as input an array of keys in GPU memory * (d_keys) and an optional array of corresponding values, - * and outputs sorted arrays of keys and (optionally) values in place. - * Key-value and key-only sort is selected through the configuration of - * the plan, using the options CUDPP_OPTION_KEYS_ONLY and + * and outputs sorted arrays of keys and (optionally) values in place. + * Key-value and key-only sort is selected through the configuration of + * the plan, using the options CUDPP_OPTION_KEYS_ONLY and * CUDPP_OPTION_KEY_VALUE_PAIRS. * * Supported key types are CUDPP_FLOAT and CUDPP_UINT. Values can be @@ -282,11 +282,11 @@ CUDPPResult cudppCompact(CUDPPHandle planHandle, * and cast to unsigned int). * * @todo Determine if we need to provide an "out of place" sort interface. - * + * * @param[in] planHandle handle to CUDPPSortPlan * @param[out] d_keys keys by which key-value pairs will be sorted * @param[in] d_values values to be sorted - * @param[in] keyBits the number of least significant bits in each element + * @param[in] keyBits the number of least significant bits in each element * of d_keys to sort by * @param[in] numElements number of elements in d_keys and d_values * @@ -295,7 +295,7 @@ CUDPPResult cudppCompact(CUDPPHandle planHandle, CUDPP_DLL CUDPPResult cudppSort(CUDPPHandle planHandle, void *d_keys, - void *d_values, + void *d_values, int keyBits, size_t numElements) { @@ -320,17 +320,17 @@ CUDPPResult cudppSort(CUDPPHandle planHandle, * @param sparseMatrixHandle Handle to a sparse matrix object created with cudppSparseMatrix() * @param d_y The output vector, y * @param d_x The input vector, x - * + * * @see cudppSparseMatrix, cudppDestroySparseMatrix - + CUDPP_DLL CUDPPResult cudppSparseMatrixVectorMultiply(CUDPPHandle sparseMatrixHandle, void *d_y, const void *d_x) { - CUDPPSparseMatrixVectorMultiplyPlan *plan = + CUDPPSparseMatrixVectorMultiplyPlan *plan = (CUDPPSparseMatrixVectorMultiplyPlan*)CUDPPPlanManager::GetPlan(sparseMatrixHandle); - + if (plan != nullptr) { cudppSparseMatrixVectorMultiplyDispatch(d_y, d_x, plan); @@ -345,15 +345,15 @@ CUDPPResult cudppSparseMatrixVectorMultiply(CUDPPHandle sparseMatrixHandl /** * @brief Rand puts \a numElements random 32-bit elements into \a d_out * - + * Outputs \a numElements random values to \a d_out. \a d_out must be of * type unsigned int, allocated in device memory. - * + * * The algorithm used for the random number generation is stored in \a planHandle. * Depending on the specification of the pseudo random number generator(PRNG), * the generator may have one or more seeds. To set the seed, use cudppRandSeed(). - * - * @todo Currently only MD5 PRNG is supported. We may provide more rand routines in + * + * @todo Currently only MD5 PRNG is supported. We may provide more rand routines in * the future. * * @param[in] planHandle Handle to plan for rand @@ -361,7 +361,7 @@ CUDPPResult cudppSparseMatrixVectorMultiply(CUDPPHandle sparseMatrixHandl * @param[out] d_out output of rand, in GPU memory. Should be an array of unsigned integers. * * @see cudppPlan, CUDPPConfiguration, CUDPPAlgorithm - + CUDPP_DLL CUDPPResult cudppRand(CUDPPHandle planHandle,void * d_out, size_t numElements) { @@ -379,16 +379,16 @@ CUDPPResult cudppRand(CUDPPHandle planHandle,void * d_out, size_t numElements) /**@brief Sets the seed used for rand * - * The seed is crucial to any random number generator as it allows a - * sequence of random numbers to be replicated. Since there may be - * multiple different rand algorithms in CUDPP, cudppRandSeed - * uses \a planHandle to determine which seed to set. Each rand - * algorithm has its own unique set of seeds depending on what + * The seed is crucial to any random number generator as it allows a + * sequence of random numbers to be replicated. Since there may be + * multiple different rand algorithms in CUDPP, cudppRandSeed + * uses \a planHandle to determine which seed to set. Each rand + * algorithm has its own unique set of seeds depending on what * the algorithm needs. * * @param[in] planHandle the handle to the plan which specifies which rand seed to set * @param[in] seed the value which the internal cudpp seed will be set to - + CUDPP_DLL CUDPPResult cudppRandSeed(const CUDPPHandle planHandle, unsigned int seed) { diff --git a/lib/gpu/cudpp_mini/cudpp.h b/lib/gpu/cudpp_mini/cudpp.h index 2f38d780a5..da2bb9b79c 100644 --- a/lib/gpu/cudpp_mini/cudpp.h +++ b/lib/gpu/cudpp_mini/cudpp.h @@ -3,21 +3,21 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt in // the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * cudpp.h - * + * * @brief Main library header file. Defines public interface. * - * The CUDPP public interface is a C-only interface to enable - * linking with code written in other languages (e.g. C, C++, - * and Fortran). While the internals of CUDPP are not limited - * to C (C++ features are used), the public interface is + * The CUDPP public interface is a C-only interface to enable + * linking with code written in other languages (e.g. C, C++, + * and Fortran). While the internals of CUDPP are not limited + * to C (C++ features are used), the public interface is * entirely C (thus it is declared "extern C"). */ @@ -25,53 +25,53 @@ * \mainpage * * \section introduction Introduction - * + * * CUDPP is the CUDA Data Parallel Primitives Library. CUDPP is a - * library of data-parallel algorithm primitives such as - * parallel-prefix-sum ("scan"), parallel sort and parallel reduction. - * Primitives such as these are important building blocks for a wide - * variety of data-parallel algorithms, including sorting, stream - * compaction, and building data structures such as trees and + * library of data-parallel algorithm primitives such as + * parallel-prefix-sum ("scan"), parallel sort and parallel reduction. + * Primitives such as these are important building blocks for a wide + * variety of data-parallel algorithms, including sorting, stream + * compaction, and building data structures such as trees and * summed-area tables. * * \section overview Overview Presentation - * + * * A brief set of slides that describe the features, design principles, * applications and impact of CUDPP is available here: * CUDPP Presentation. * * \section homepage Homepage * Homepage for CUDPP: http://code.google.com/p/cudpp - * + * * Announcements and discussion of CUDPP are hosted on the * CUDPP Google Group. - * + * * \section getting-started Getting Started with CUDPP * - * You may want to start by browsing the \link publicInterface CUDPP Public - * Interface\endlink. For information on building CUDPP, see + * You may want to start by browsing the \link publicInterface CUDPP Public + * Interface\endlink. For information on building CUDPP, see * \ref building-cudpp "Building CUDPP". * - * The "apps" subdirectory included with CUDPP has a few source code samples + * The "apps" subdirectory included with CUDPP has a few source code samples * that use CUDPP: - * - \ref example_simpleCUDPP "simpleCUDPP", a simple example of using + * - \ref example_simpleCUDPP "simpleCUDPP", a simple example of using * cudppScan() - * - satGL, an example of using cudppMultiScan() to generate a summed-area - * table (SAT) of a scene rendered in real time. The SAT is then used to simulate + * - satGL, an example of using cudppMultiScan() to generate a summed-area + * table (SAT) of a scene rendered in real time. The SAT is then used to simulate * depth of field blur. - * - cudpp_testrig, a comprehensive test application for all the functionality + * - cudpp_testrig, a comprehensive test application for all the functionality * of CUDPP * - * We have also provided a code walkthrough of the + * We have also provided a code walkthrough of the * \ref example_simpleCUDPP "simpleCUDPP" example. * * \section getting-help Getting Help and Reporting Problems * - * To get help using CUDPP, please use the + * To get help using CUDPP, please use the * CUDPP Google Group. * - * To report CUDPP bugs or request features, you may use either the above - * CUDPP Google Group, or you can file an issue directly using + * To report CUDPP bugs or request features, you may use either the above + * CUDPP Google Group, or you can file an issue directly using * Google Code. * * \section release-notes Release Notes @@ -79,111 +79,111 @@ * For specific release details see the \ref changelog "Change Log". * * This release (1.1.1) is a bugfix release to CUDPP 1.1 that includes - * fixes to support CUDA 3.0 and the new NVIDIA Fermi architecture, + * fixes to support CUDA 3.0 and the new NVIDIA Fermi architecture, * including GeForce 400 series and Tesla 20 series GPUs. It also has * bug fixes for 64-bit OSes. - * + * * \section opSys Operating System Support - * + * * This release (1.1.1) has been thoroughly tested on the following OSes. * - Windows XP (32-bit) (CUDA 2.2, 3.0) * - Windows 7 (64-bit) (CUDA 3.0) * - Redhat Enterprise Linux 5 (64-bit) (CUDA 3.0) * - and Mac OS X 10.6 (Snow Leopard, 64-bit) (CUDA 3.0) * - * We expect CUDPP to build and run correctly on other flavors of Linux - * and Windows, but these are not actively tested by the developers at + * We expect CUDPP to build and run correctly on other flavors of Linux + * and Windows, but these are not actively tested by the developers at * this time. * - * Notes: CUDPP is not compatible with CUDA 2.1. A compiler bug in 2.1 - * causes the compiler to crash. Also, starting with CUDPP 1.1.1, we are - * no longer testing CUDA device emulation, because it is deprecated in - * CUDA 3.0 and will be removed from future CUDA versions. + * Notes: CUDPP is not compatible with CUDA 2.1. A compiler bug in 2.1 + * causes the compiler to crash. Also, starting with CUDPP 1.1.1, we are + * no longer testing CUDA device emulation, because it is deprecated in + * CUDA 3.0 and will be removed from future CUDA versions. * * \section cuda CUDA * CUDPP is implemented in - * CUDA C/C++. It requires the - * CUDA Toolkit version 2.2 or later. Please see the NVIDIA - * CUDA homepage to download - * CUDA as well as the CUDA Programming Guide and CUDA SDK, which includes many - * CUDA code examples. Some of the samples in the CUDA SDK (including + * CUDA C/C++. It requires the + * CUDA Toolkit version 2.2 or later. Please see the NVIDIA + * CUDA homepage to download + * CUDA as well as the CUDA Programming Guide and CUDA SDK, which includes many + * CUDA code examples. Some of the samples in the CUDA SDK (including * "marchingCubes", "lineOfSight", and radixSort) also use CUDPP. * * \section design-goals Design Goals * Design goals for CUDPP include: - * + * * - Performance. We aim to provide best-of-class performance for our - * primitives. We welcome suggestions and contributions that will improve - * CUDPP performance. We also want to provide primitives that can be easily - * benchmarked, and compared against other implementations on GPUs and other + * primitives. We welcome suggestions and contributions that will improve + * CUDPP performance. We also want to provide primitives that can be easily + * benchmarked, and compared against other implementations on GPUs and other * processors. * - Modularity. We want our primitives to be easily included in other * applications. To that end we have made the following design decisions: - * - CUDPP is provided as a library that can link against other applications. + * - CUDPP is provided as a library that can link against other applications. * - CUDPP calls run on the GPU on GPU data. Thus they can be used - * as standalone calls on the GPU (on GPU data initialized by the - * calling application) and, more importantly, as GPU components in larger + * as standalone calls on the GPU (on GPU data initialized by the + * calling application) and, more importantly, as GPU components in larger * CPU/GPU applications. * - CUDPP is implemented as 4 layers: - * -# The \link publicInterface Public Interface\endlink is the external - * library interface, which is the intended entry point for most - * applications. The public interface calls into the + * -# The \link publicInterface Public Interface\endlink is the external + * library interface, which is the intended entry point for most + * applications. The public interface calls into the * \link cudpp_app Application-Level API\endlink. * -# The \link cudpp_app Application-Level API\endlink comprises functions - * callable from CPU code. These functions execute code jointly on the - * CPU (host) and the GPU by calling into the + * callable from CPU code. These functions execute code jointly on the + * CPU (host) and the GPU by calling into the * \link cudpp_kernel Kernel-Level API\endlink below them. * -# The \link cudpp_kernel Kernel-Level API\endlink comprises functions - * that run entirely on the GPU across an entire grid of thread blocks. - * These functions may call into the \link cudpp_cta CTA-Level API\endlink + * that run entirely on the GPU across an entire grid of thread blocks. + * These functions may call into the \link cudpp_cta CTA-Level API\endlink * below them. - * -# The \link cudpp_cta CTA-Level API\endlink comprises functions that run - * entirely on the GPU within a single Cooperative Thread Array (CTA, - * aka thread block). These are low-level functions that implement core - * data-parallel algorithms, typically by processing data within shared + * -# The \link cudpp_cta CTA-Level API\endlink comprises functions that run + * entirely on the GPU within a single Cooperative Thread Array (CTA, + * aka thread block). These are low-level functions that implement core + * data-parallel algorithms, typically by processing data within shared * (CUDA \c __shared__) memory. * - * Programmers may use any of the lower three CUDPP layers in their own - * programs by building the source directly into their application. However, - * the typical usage of CUDPP is to link to the library and invoke functions in - * the CUDPP \link publicInterface Public Interface\endlink, as in the - * \ref example_simpleCUDPP "simpleCUDPP", satGL, and cudpp_testrig application + * Programmers may use any of the lower three CUDPP layers in their own + * programs by building the source directly into their application. However, + * the typical usage of CUDPP is to link to the library and invoke functions in + * the CUDPP \link publicInterface Public Interface\endlink, as in the + * \ref example_simpleCUDPP "simpleCUDPP", satGL, and cudpp_testrig application * examples included in the CUDPP distribution. * - * In the future, if and when CUDA supports building device-level libraries, we - * hope to enhance CUDPP to ease the use of CUDPP internal algorithms at all + * In the future, if and when CUDA supports building device-level libraries, we + * hope to enhance CUDPP to ease the use of CUDPP internal algorithms at all * levels. * * \subsection uses Use Cases * We expect the normal use of CUDPP will be in one of two ways: - * -# Linking the CUDPP library against another application. + * -# Linking the CUDPP library against another application. * -# Running our "test" application, cudpp_testrig, that exercises * CUDPP functionality. * * \section references References * The following publications describe work incorporated in CUDPP. - * + * * - Mark Harris, Shubhabrata Sengupta, and John D. Owens. "Parallel Prefix Sum (Scan) with CUDA". In Hubert Nguyen, editor, GPU Gems 3, chapter 39, pages 851–876. Addison Wesley, August 2007. http://graphics.idav.ucdavis.edu/publications/print_pub?pub_id=916 * - Shubhabrata Sengupta, Mark Harris, Yao Zhang, and John D. Owens. "Scan Primitives for GPU Computing". In Graphics Hardware 2007, pages 97–106, August 2007. http://graphics.idav.ucdavis.edu/publications/print_pub?pub_id=915 * - Shubhabrata Sengupta, Mark Harris, and Michael Garland. "Efficient parallel scan algorithms for GPUs". NVIDIA Technical Report NVR-2008-003, December 2008. http://mgarland.org/papers.html#segscan-tr * - Nadathur Satish, Mark Harris, and Michael Garland. "Designing Efficient Sorting Algorithms for Manycore GPUs". In Proceedings of the 23rd IEEE International Parallel & Distributed Processing Symposium, May 2009. http://mgarland.org/papers.html#gpusort * - Stanley Tzeng, Li-Yi Wei. "Parallel White Noise Generation on a GPU via Cryptographic Hash". In Proceedings of the 2008 Symposium on Interactive 3D Graphics and Games, pages 79–87, February 2008. http://research.microsoft.com/apps/pubs/default.aspx?id=70502 * - * Many researchers are using CUDPP in their work, and there are many publications - * that have used it \ref cudpp_refs "(references)". If your work uses CUDPP, please + * Many researchers are using CUDPP in their work, and there are many publications + * that have used it \ref cudpp_refs "(references)". If your work uses CUDPP, please * let us know by sending us a reference (preferably in BibTeX format) to your work. - * + * * \section citing Citing CUDPP * * If you make use of CUDPP primitives in your work and want to cite - * CUDPP (thanks!), we would prefer for you to cite the appropriate - * papers above, since they form the core of CUDPP. To be more specific, - * the GPU Gems paper describes (unsegmented) scan, multi-scan for - * summed-area tables, and stream compaction. The NVIDIA technical report - * describes the current scan and segmented scan algorithms used in the - * library, and the Graphics Hardware paper describes an earlier - * implementation of segmented scan, quicksort, and sparse matrix-vector - * multiply. The IPDPS paper describes the radix sort used in CUDPP, and + * CUDPP (thanks!), we would prefer for you to cite the appropriate + * papers above, since they form the core of CUDPP. To be more specific, + * the GPU Gems paper describes (unsegmented) scan, multi-scan for + * summed-area tables, and stream compaction. The NVIDIA technical report + * describes the current scan and segmented scan algorithms used in the + * library, and the Graphics Hardware paper describes an earlier + * implementation of segmented scan, quicksort, and sparse matrix-vector + * multiply. The IPDPS paper describes the radix sort used in CUDPP, and * the I3D paper describes the random number generation algorithm. * * \section credits Credits @@ -194,17 +194,17 @@ * - Stanley Tzeng, University of California, Davis * - Yao Zhang, University of California, Davis * - Andrew Davidson, University of California, Davis (formerly Louisiana State University) - * + * * \subsection contributors Other CUDPP Contributors * - Nadatur Satish, University of California, Berkeley * * \subsection acknowledgments Acknowledgments * - * Thanks to Jim Ahrens, Timo Aila, Nathan Bell, Ian Buck, Guy Blelloch, - * Jeff Bolz, Michael Garland, Jeff Inman, Eric Lengyel, Samuli Laine, - * David Luebke, Pat McCormick, and Richard Vuduc for their contributions - * during the development of this library. - * + * Thanks to Jim Ahrens, Timo Aila, Nathan Bell, Ian Buck, Guy Blelloch, + * Jeff Bolz, Michael Garland, Jeff Inman, Eric Lengyel, Samuli Laine, + * David Luebke, Pat McCormick, and Richard Vuduc for their contributions + * during the development of this library. + * * CUDPP Developers from UC Davis thank their funding agencies: * - Department of Energy Early Career Principal Investigator Award * DE-FG02-04ER25609 @@ -214,12 +214,12 @@ * - Generous hardware donations from NVIDIA * * \section license-overview CUDPP Copyright and Software License - * CUDPP is copyright The Regents of the University of California, Davis campus - * and NVIDIA Corporation. The library, examples, and all source code are - * released under the BSD license, designed to encourage reuse of this software - * in other projects, both commercial and non-commercial. For details, please - * see the \ref license page. - * + * CUDPP is copyright The Regents of the University of California, Davis campus + * and NVIDIA Corporation. The library, examples, and all source code are + * released under the BSD license, designed to encourage reuse of this software + * in other projects, both commercial and non-commercial. For details, please + * see the \ref license page. + * * Note that prior to release 1.1 of CUDPP, the license used was a modified * BSD license. With release 1.1, this license was replaced with the pure BSD * license to facilitate the use of open source hosting of the code. @@ -230,26 +230,26 @@ * * \section licenseBSD CUDPP License * - * CUDPP is released under the + * CUDPP is released under the * BSD license. - * + * * @include license.txt * */ -/** +/** * @page changelog CUDPP Change Log * * @include changelog.txt */ -/** +/** * @page cudpp_refs Publications that use CUDPP * * @htmlinclude doc/bib/cudpp_refs.html */ -/** +/** * @page cudpp_refs_bib Bibliography for publications that use CUDPP * * @htmlinclude doc/bib/cudpp_refs_bib.html @@ -258,43 +258,43 @@ /** * @page building-cudpp Building CUDPP * - * CUDPP has currently been tested in Windows XP, Windows Vista, Mac OS X + * CUDPP has currently been tested in Windows XP, Windows Vista, Mac OS X * and Linux. See \ref release-notes for release specific platform support. * * \section build-win32 Building CUDPP on Windows XP * - * CUDPP can be built using either or MSVC 8 (2005) or MSVC 9 (2008). To - * build, open cudpp/cudpp.sln. Then you can build the library - * using the "build" command as you would with any other workspace. There are - * four configurations: debug, release, emudebug, and emurelease. The first - * two are self-explanatory. The second two are built to use CUDA device + * CUDPP can be built using either or MSVC 8 (2005) or MSVC 9 (2008). To + * build, open cudpp/cudpp.sln. Then you can build the library + * using the "build" command as you would with any other workspace. There are + * four configurations: debug, release, emudebug, and emurelease. The first + * two are self-explanatory. The second two are built to use CUDA device * emulation, meaning they will be run (slowly) on the CPU. * * \section build-linux Building CUDPP on Linux and Mac OS X * - * CUDPP can be built using standard g++ and Make tools on Linux, by typing - * "make" in the "cudpp/" subdirectory. Before building CUDPP, you should - * first build the CUDA Utility Library (libcutil) by typing "make; make dbg=1" - * in the "common/" subdirectory. This will generate libcutil.a and - * libcutilD.a. - * - * The makefile for CUDPP and all sample applications take the optional + * CUDPP can be built using standard g++ and Make tools on Linux, by typing + * "make" in the "cudpp/" subdirectory. Before building CUDPP, you should + * first build the CUDA Utility Library (libcutil) by typing "make; make dbg=1" + * in the "common/" subdirectory. This will generate libcutil.a and + * libcutilD.a. + * + * The makefile for CUDPP and all sample applications take the optional * arguments "emu=1" and "dbg=1". The former builds CUDPP for device emulation, * and the latter for debugging. The two flags can be combined. "verbose=1" * can be used to see all compiler output. * * \section build-apps Building CUDPP Sample Applications - * - * The sample applications in the "apps/" subdirectory can be built exactly - * like CUDPP is--either by opening the appropriate .sln/.vcproj file in MSVC + * + * The sample applications in the "apps/" subdirectory can be built exactly + * like CUDPP is--either by opening the appropriate .sln/.vcproj file in MSVC * in Windows, or using "make" in Linux. * * On some Linux installations you will get linker errors relating to "-lXi" - * and "-lXmu". To fix this, you will need to install libXi and libXmu. On - * Debian and Ubuntu, for example, you can simply run - * "sudo apt-get install libxi-dev", and + * and "-lXmu". To fix this, you will need to install libXi and libXmu. On + * Debian and Ubuntu, for example, you can simply run + * "sudo apt-get install libxi-dev", and * "sudo apt-get install libxmu-dev" - * + * */ #ifndef __CUDPP_H__ @@ -312,7 +312,7 @@ extern "C" { enum CUDPPResult { CUDPP_SUCCESS = 0, /**< No error. */ - CUDPP_ERROR_INVALID_HANDLE, /**< Specified handle (for example, + CUDPP_ERROR_INVALID_HANDLE, /**< Specified handle (for example, to a plan) is invalid. **/ CUDPP_ERROR_ILLEGAL_CONFIGURATION, /**< Specified configuration is illegal. For example, an @@ -321,9 +321,9 @@ enum CUDPPResult CUDPP_ERROR_UNKNOWN = 9999 /**< Unknown or untraceable error. */ }; -/** +/** * @brief Options for configuring CUDPP algorithms. - * + * * @see CUDPPConfiguration, cudppPlan, CUDPPAlgorithm */ enum CUDPPOption @@ -344,13 +344,13 @@ enum CUDPPOption * the CTAs (blocks) with no * communication between blocks. * @todo Currently ignored. */ - CUDPP_OPTION_KEYS_ONLY = 0x20, /**< No associated value to a key + CUDPP_OPTION_KEYS_ONLY = 0x20, /**< No associated value to a key * (for global radix sort) */ CUDPP_OPTION_KEY_VALUE_PAIRS = 0x40, /**< Each key has an associated value */ }; -/** +/** * @brief Datatypes supported by CUDPP algorithms. * * @see CUDPPConfiguration, cudppPlan @@ -364,7 +364,7 @@ enum CUDPPDatatype CUDPP_FLOAT //!< Float type (C float) }; -/** +/** * @brief Operators supported by CUDPP algorithms (currently scan and * segmented scan). * @@ -383,7 +383,7 @@ enum CUDPPOperator /** * @brief Algorithms supported by CUDPP. Used to create appropriate plans using * cudppPlan. -* +* * @see CUDPPConfiguration, cudppPlan */ enum CUDPPAlgorithm @@ -415,7 +415,7 @@ struct CUDPPConfiguration #define CUDPP_INVALID_HANDLE 0xC0DABAD1 typedef size_t CUDPPHandle; -/* To use CUDPP as a static library, #define CUDPP_STATIC_LIB before +/* To use CUDPP as a static library, #define CUDPP_STATIC_LIB before * including cudpp.h */ #define CUDPP_STATIC_LIB @@ -438,10 +438,10 @@ typedef size_t CUDPPHandle; // Plan allocation (for scan, sort, and compact) CUDPP_DLL -CUDPPResult cudppPlan(CUDPPHandle *planHandle, - CUDPPConfiguration config, - size_t n, - size_t rows, +CUDPPResult cudppPlan(CUDPPHandle *planHandle, + CUDPPConfiguration config, + size_t n, + size_t rows, size_t rowPitch); CUDPP_DLL @@ -451,46 +451,46 @@ CUDPPResult cudppDestroyPlan(CUDPPHandle plan); CUDPP_DLL CUDPPResult cudppScan(CUDPPHandle planHandle, - void *d_out, - const void *d_in, + void *d_out, + const void *d_in, size_t numElements); CUDPP_DLL CUDPPResult cudppMultiScan(CUDPPHandle planHandle, - void *d_out, - const void *d_in, + void *d_out, + const void *d_in, size_t numElements, size_t numRows); CUDPP_DLL CUDPPResult cudppSegmentedScan(CUDPPHandle planHandle, - void *d_out, + void *d_out, const void *d_idata, const unsigned int *d_iflags, size_t numElements); CUDPP_DLL CUDPPResult cudppCompact(CUDPPHandle planHandle, - void *d_out, + void *d_out, size_t *d_numValidElements, - const void *d_in, + const void *d_in, const unsigned int *d_isValid, size_t numElements); CUDPP_DLL CUDPPResult cudppSort(CUDPPHandle planHandle, - void *d_keys, - void *d_values, + void *d_keys, + void *d_values, int keybits, size_t numElements); // Sparse matrix allocation CUDPP_DLL -CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, - CUDPPConfiguration config, - size_t n, - size_t rows, +CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, + CUDPPConfiguration config, + size_t n, + size_t rows, const void *A, const unsigned int *h_rowIndices, const unsigned int *h_indices); diff --git a/lib/gpu/cudpp_mini/cudpp_globals.h b/lib/gpu/cudpp_mini/cudpp_globals.h index b0db9cf922..162aef6eb9 100644 --- a/lib/gpu/cudpp_mini/cudpp_globals.h +++ b/lib/gpu/cudpp_mini/cudpp_globals.h @@ -3,17 +3,17 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt in // the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * cudpp_globals.h * * @brief Global declarations defining machine characteristics of GPU target - * These are currently set for best performance on G8X GPUs. The optimal + * These are currently set for best performance on G8X GPUs. The optimal * parameters may change on future GPUs. In the future, we hope to make * CUDPP a self-tuning library. */ @@ -31,7 +31,7 @@ const int LOG_SIZEOF_FLOAT = 2; /**< log_2(sizeof(float)) */ const int SCAN_ELTS_PER_THREAD = 8; /**< Number of elements per scan thread */ const int SEGSCAN_ELTS_PER_THREAD = 8; /**< Number of elements per segmented scan thread */ -const int maxSharedMemoryPerBlock = 16384; /**< Number of bytes of shared +const int maxSharedMemoryPerBlock = 16384; /**< Number of bytes of shared memory in each block */ const int maxThreadsPerBlock = CTA_SIZE; /**< Maximum number of * threads in a CTA */ diff --git a/lib/gpu/cudpp_mini/cudpp_maximal_launch.cpp b/lib/gpu/cudpp_mini/cudpp_maximal_launch.cpp index 1a7542e68c..f8c54edb58 100644 --- a/lib/gpu/cudpp_mini/cudpp_maximal_launch.cpp +++ b/lib/gpu/cudpp_mini/cudpp_maximal_launch.cpp @@ -3,10 +3,10 @@ // ------------------------------------------------------------- // $Revision$ // $Date$ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #include "cudpp_maximal_launch.h" #include @@ -25,12 +25,12 @@ inline size_t ceiling(size_t x, size_t f) } extern "C" -size_t maxBlocks(cudaFuncAttributes &attribs, - cudaDeviceProp &devprop, +size_t maxBlocks(cudaFuncAttributes &attribs, + cudaDeviceProp &devprop, size_t bytesDynamicSharedMem, size_t threadsPerBlock) { - + // Determine the maximum number of CTAs that can be run simultaneously for each kernel // This is equivalent to the calculation done in the CUDA Occupancy Calculator spreadsheet const unsigned int regAllocationUnit = (devprop.major < 2 && devprop.minor < 2) ? 256 : 512; // in registers @@ -48,7 +48,7 @@ size_t maxBlocks(cudaFuncAttributes &attribs, size_t regsPerCTA = attribs.numRegs * devprop.warpSize * numWarps; // Round up to multiple of register allocation unit size regsPerCTA = ceiling(regsPerCTA, regAllocationUnit); - + size_t smemBytes = attribs.sharedSizeBytes + bytesDynamicSharedMem; size_t smemPerCTA = ceiling(smemBytes, smemAllocationUnit); @@ -60,7 +60,7 @@ size_t maxBlocks(cudaFuncAttributes &attribs, } extern "C" -size_t maxBlocksFromPointer(void* kernel, +size_t maxBlocksFromPointer(void* kernel, size_t bytesDynamicSharedMem, size_t threadsPerBlock) { diff --git a/lib/gpu/cudpp_mini/cudpp_maximal_launch.h b/lib/gpu/cudpp_mini/cudpp_maximal_launch.h index a8ffc3f978..85d21f1dbe 100644 --- a/lib/gpu/cudpp_mini/cudpp_maximal_launch.h +++ b/lib/gpu/cudpp_mini/cudpp_maximal_launch.h @@ -3,30 +3,30 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #ifndef _MAXIMAL_LAUNCH_H_ #define _MAXIMAL_LAUNCH_H_ - + #include "cuda_runtime.h" extern "C" -size_t maxBlocks(cudaFuncAttributes &attribs, - cudaDeviceProp &devprop, +size_t maxBlocks(cudaFuncAttributes &attribs, + cudaDeviceProp &devprop, size_t bytesDynamicSharedMem, size_t threadsPerBlock); extern "C" -size_t maxBlocksFromPointer(void* kernel, +size_t maxBlocksFromPointer(void* kernel, size_t bytesDynamicSharedMem, size_t threadsPerBlock); #ifdef __cplusplus template -size_t maxBlocks(T kernel, +size_t maxBlocks(T kernel, size_t bytesDynamicSharedMem, size_t threadsPerBlock) { diff --git a/lib/gpu/cudpp_mini/cudpp_plan.cpp b/lib/gpu/cudpp_mini/cudpp_plan.cpp index 8ea99a23fe..e1c9f649bf 100644 --- a/lib/gpu/cudpp_mini/cudpp_plan.cpp +++ b/lib/gpu/cudpp_mini/cudpp_plan.cpp @@ -3,11 +3,11 @@ // ------------------------------------------------------------- // $Revision: 3572$ // $Date: 2007-11-19 13:58:06 +0000 (Mon, 19 Nov 2007) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + #include "cudpp.h" #include "cudpp_plan_manager.h" #include "cudpp_scan.h" @@ -43,21 +43,21 @@ CUDPPResult validateOptions(CUDPPConfiguration config, size_t /*numElements*/, s */ -/** @brief Create a CUDPP plan - * +/** @brief Create a CUDPP plan + * * A plan is a data structure containing state and intermediate storage space - * that CUDPP uses to execute algorithms on data. A plan is created by + * that CUDPP uses to execute algorithms on data. A plan is created by * passing to cudppPlan() a CUDPPConfiguration that specifies the algorithm, * operator, datatype, and options. The size of the data must also be passed - * to cudppPlan(), in the \a numElements, \a numRows, and \a rowPitch + * to cudppPlan(), in the \a numElements, \a numRows, and \a rowPitch * arguments. These sizes are used to allocate internal storage space at the * time the plan is created. The CUDPP planner may use the sizes, options, * and information about the present hardware to choose optimal settings. * * Note that \a numElements is the maximum size of the array to be processed - * with this plan. That means that a plan may be re-used to process (for - * example, to sort or scan) smaller arrays. - * + * with this plan. That means that a plan may be re-used to process (for + * example, to sort or scan) smaller arrays. + * * @param[out] planHandle A pointer to an opaque handle to the internal plan * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be processed @@ -65,10 +65,10 @@ CUDPPResult validateOptions(CUDPPConfiguration config, size_t /*numElements*/, s * @param[in] rowPitch The pitch of the rows of input data, in elements */ CUDPP_DLL -CUDPPResult cudppPlan(CUDPPHandle *planHandle, - CUDPPConfiguration config, - size_t numElements, - size_t numRows, +CUDPPResult cudppPlan(CUDPPHandle *planHandle, + CUDPPConfiguration config, + size_t numElements, + size_t numRows, size_t rowPitch) { CUDPPResult result = CUDPP_SUCCESS; @@ -114,7 +114,7 @@ CUDPPResult cudppPlan(CUDPPHandle *planHandle, case CUDPP_REDUCE:*/ default: //! @todo: implement cudppReduce() - return CUDPP_ERROR_ILLEGAL_CONFIGURATION; + return CUDPP_ERROR_ILLEGAL_CONFIGURATION; break; } @@ -129,7 +129,7 @@ CUDPPResult cudppPlan(CUDPPHandle *planHandle, * * Deletes the plan referred to by \a planHandle and all associated internal * storage. - * + * * @param[in] planHandle The CUDPPHandle to the plan to be destroyed */ CUDPP_DLL @@ -141,29 +141,29 @@ CUDPPResult cudppDestroyPlan(CUDPPHandle planHandle) return CUDPP_SUCCESS; } -/** @brief Create a CUDPP Sparse Matrix Object +/** @brief Create a CUDPP Sparse Matrix Object * * The sparse matrix plan is a data structure containing state and intermediate storage space - * that CUDPP uses to perform sparse matrix dense vector multiply. This plan is created by - * passing to CUDPPSparseMatrixVectorMultiplyPlan() a CUDPPConfiguration that specifies the + * that CUDPP uses to perform sparse matrix dense vector multiply. This plan is created by + * passing to CUDPPSparseMatrixVectorMultiplyPlan() a CUDPPConfiguration that specifies the * algorithm (sprarse matrix-dense vector multiply) and datatype, along with the sparse matrix * itself in CSR format. The number of non-zero elements in the sparse matrix must also be passed - * as \a numNonZeroElements. This is used to allocate internal storage space at the time the + * as \a numNonZeroElements. This is used to allocate internal storage space at the time the * sparse matrix plan is created. * * @param[out] sparseMatrixHandle A pointer to an opaque handle to the sparse matrix object * @param[in] config The configuration struct specifying algorithm and options - * @param[in] numNonZeroElements The number of non zero elements in the sparse matrix + * @param[in] numNonZeroElements The number of non zero elements in the sparse matrix * @param[in] numRows This is the number of rows in y, x and A for y = A * x * @param[in] A The matrix data * @param[in] h_rowIndices An array containing the index of the start of each row in \a A * @param[in] h_indices An array containing the index of each nonzero element in \a A - + CUDPP_DLL -CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, - CUDPPConfiguration config, - size_t numNonZeroElements, - size_t numRows, +CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, + CUDPPConfiguration config, + size_t numNonZeroElements, + size_t numRows, const void *A, const unsigned int *h_rowIndices, const unsigned int *h_indices) @@ -172,7 +172,7 @@ CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, CUDPPPlan *sparseMatrix; - if ((config.algorithm != CUDPP_SPMVMULT) || + if ((config.algorithm != CUDPP_SPMVMULT) || (numNonZeroElements <= 0) || (numRows <= 0)) { result = CUDPP_ERROR_ILLEGAL_CONFIGURATION; @@ -184,8 +184,8 @@ CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, return result; } - sparseMatrix = - new CUDPPSparseMatrixVectorMultiplyPlan(config, numNonZeroElements, A, + sparseMatrix = + new CUDPPSparseMatrixVectorMultiplyPlan(config, numNonZeroElements, A, h_rowIndices, h_indices, numRows); *sparseMatrixHandle = CUDPPPlanManager::AddPlan(sparseMatrix); @@ -197,11 +197,11 @@ CUDPPResult cudppSparseMatrix(CUDPPHandle *sparseMatrixHandle, */ /** @brief Destroy a CUDPP Sparse Matrix Object * - * Deletes the sparse matrix data and plan referred to by \a sparseMatrixHandle + * Deletes the sparse matrix data and plan referred to by \a sparseMatrixHandle * and all associated internal storage. - * + * * @param[in] sparseMatrixHandle The CUDPPHandle to the matrix object to be destroyed - + CUDPP_DLL CUDPPResult cudppDestroySparseMatrix(CUDPPHandle sparseMatrixHandle) { @@ -213,15 +213,15 @@ CUDPPResult cudppDestroySparseMatrix(CUDPPHandle sparseMatrixHandle) /** @brief Plan base class constructor - * + * * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be processed * @param[in] numRows The number of rows (for 2D operations) to be processed * @param[in] rowPitch The pitch of the rows of input data, in elements */ -CUDPPPlan::CUDPPPlan(CUDPPConfiguration config, - size_t numElements, - size_t numRows, +CUDPPPlan::CUDPPPlan(CUDPPConfiguration config, + size_t numElements, + size_t numRows, size_t rowPitch) : m_config(config), m_numElements(numElements), @@ -231,15 +231,15 @@ CUDPPPlan::CUDPPPlan(CUDPPConfiguration config, } /** @brief Scan Plan constructor -* +* * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be scanned * @param[in] numRows The maximum number of rows (for 2D operations) to be scanned * @param[in] rowPitch The pitch of the rows of input data, in elements */ -CUDPPScanPlan::CUDPPScanPlan(CUDPPConfiguration config, - size_t numElements, - size_t numRows, +CUDPPScanPlan::CUDPPScanPlan(CUDPPConfiguration config, + size_t numElements, + size_t numRows, size_t rowPitch) : CUDPPPlan(config, numElements, numRows, rowPitch), m_blockSums(0), @@ -258,11 +258,11 @@ CUDPPScanPlan::~CUDPPScanPlan() } /** @brief SegmentedScan Plan constructor -* +* * @param[in] config The configuration struct specifying options * @param[in] numElements The maximum number of elements to be scanned -CUDPPSegmentedScanPlan::CUDPPSegmentedScanPlan(CUDPPConfiguration config, +CUDPPSegmentedScanPlan::CUDPPSegmentedScanPlan(CUDPPConfiguration config, size_t numElements) : CUDPPPlan(config, numElements, 1, 0), m_blockSums(0), @@ -274,43 +274,43 @@ CUDPPSegmentedScanPlan::CUDPPSegmentedScanPlan(CUDPPConfiguration config, allocSegmentedScanStorage(this); } */ -/** @brief SegmentedScan plan destructor +/** @brief SegmentedScan plan destructor CUDPPSegmentedScanPlan::~CUDPPSegmentedScanPlan() { freeSegmentedScanStorage(this); } */ /** @brief Compact Plan constructor -* +* * @param[in] config The configuration struct specifying options * @param[in] numElements The maximum number of elements to be compacted * @param[in] numRows The number of rows (for 2D operations) to be compacted * @param[in] rowPitch The pitch of the rows of input data, in elements -CUDPPCompactPlan::CUDPPCompactPlan(CUDPPConfiguration config, - size_t numElements, - size_t numRows, +CUDPPCompactPlan::CUDPPCompactPlan(CUDPPConfiguration config, + size_t numElements, + size_t numRows, size_t rowPitch) : CUDPPPlan(config, numElements, numRows, rowPitch), m_d_outputIndices(0) { assert(numRows == 1); //!< @todo Add support for multirow compaction - CUDPPConfiguration scanConfig = - { - CUDPP_SCAN, - CUDPP_ADD, - CUDPP_UINT, - (config.options & CUDPP_OPTION_BACKWARD) ? - CUDPP_OPTION_BACKWARD | CUDPP_OPTION_EXCLUSIVE : - CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE + CUDPPConfiguration scanConfig = + { + CUDPP_SCAN, + CUDPP_ADD, + CUDPP_UINT, + (config.options & CUDPP_OPTION_BACKWARD) ? + CUDPP_OPTION_BACKWARD | CUDPP_OPTION_EXCLUSIVE : + CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE }; m_scanPlan = new CUDPPScanPlan(scanConfig, numElements, numRows, rowPitch); allocCompactStorage(this); } */ -/** @brief Compact plan destructor +/** @brief Compact plan destructor CUDPPCompactPlan::~CUDPPCompactPlan() { delete m_scanPlan; @@ -318,7 +318,7 @@ CUDPPCompactPlan::~CUDPPCompactPlan() } */ /** @brief Sort Plan constructor -* +* * @param[in] config The configuration struct specifying algorithm and options * @param[in] numElements The maximum number of elements to be sorted */ @@ -328,12 +328,12 @@ CUDPPCompactPlan::~CUDPPCompactPlan() m_d_temp(0), m_d_tempAddress(0) { - CUDPPConfiguration scanConfig = - { - CUDPP_SCAN, - CUDPP_ADD, - CUDPP_UINT, - CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE + CUDPPConfiguration scanConfig = + { + CUDPP_SCAN, + CUDPP_ADD, + CUDPP_UINT, + CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE }; //if (config.algorithm == CUDPP_SORT_RADIX_GLOBAL) @@ -354,31 +354,31 @@ CUDPPCompactPlan::~CUDPPCompactPlan() CUDPPRadixSortPlan::CUDPPRadixSortPlan(CUDPPConfiguration config, size_t numElements) : CUDPPPlan(config, numElements, 1, 0), m_scanPlan(0), - m_tempKeys(0), + m_tempKeys(0), m_tempValues(0), m_counters(0), m_countersSum(0), - m_blockOffsets(0) + m_blockOffsets(0) { size_t numBlocks2 = ((numElements % (SORT_CTA_SIZE * 2)) == 0) ? (numElements / (SORT_CTA_SIZE * 2)) : (numElements / (SORT_CTA_SIZE * 2) + 1); - CUDPPConfiguration scanConfig = - { - CUDPP_SCAN, - CUDPP_ADD, - CUDPP_UINT, - CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE - }; + CUDPPConfiguration scanConfig = + { + CUDPP_SCAN, + CUDPP_ADD, + CUDPP_UINT, + CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE + }; if(m_config.options == CUDPP_OPTION_KEYS_ONLY) m_bKeysOnly = true; else m_bKeysOnly = false; - m_scanPlan = new CUDPPScanPlan(scanConfig, numBlocks2*16, 1, 0); - - allocRadixSortStorage(this); + m_scanPlan = new CUDPPScanPlan(scanConfig, numBlocks2*16, 1, 0); + + allocRadixSortStorage(this); } CUDPPRadixSortPlan::~CUDPPRadixSortPlan() @@ -388,11 +388,11 @@ CUDPPRadixSortPlan::~CUDPPRadixSortPlan() } /** @brief SparseMatrixVectorMultiply Plan constructor -* +* * @param[in] config The configuration struct specifying options * @param[in] numNonZeroElements The number of non-zero elements in sparse matrix * @param[in] A Array of non-zero matrix elements -* @param[in] rowIndex Array of indices of the first element of each row +* @param[in] rowIndex Array of indices of the first element of each row * in the "flattened" version of the sparse matrix * @param[in] index Array of indices of non-zero elements in the matrix * @param[in] numRows The number of rows in the sparse matrix @@ -412,14 +412,14 @@ CUDPPSparseMatrixVectorMultiplyPlan::CUDPPSparseMatrixVectorMultiplyPlan( m_d_rowFinalIndex(0), m_rowFinalIndex(0), m_numRows(numRows), - m_numNonZeroElements(numNonZeroElements) + m_numNonZeroElements(numNonZeroElements) { - CUDPPConfiguration segScanConfig = - { - CUDPP_SEGMENTED_SCAN, - CUDPP_ADD, - config.datatype, - (CUDPP_OPTION_FORWARD | CUDPP_OPTION_INCLUSIVE) + CUDPPConfiguration segScanConfig = + { + CUDPP_SEGMENTED_SCAN, + CUDPP_ADD, + config.datatype, + (CUDPP_OPTION_FORWARD | CUDPP_OPTION_INCLUSIVE) }; m_segmentedScanPlan = new CUDPPSegmentedScanPlan(segScanConfig, m_numNonZeroElements); @@ -437,7 +437,7 @@ CUDPPSparseMatrixVectorMultiplyPlan::CUDPPSparseMatrixVectorMultiplyPlan( allocSparseMatrixVectorMultiplyStorage(this, A, rowIndex, index); } */ -/** @brief Sparse matrix-vector plan destructor +/** @brief Sparse matrix-vector plan destructor CUDPPSparseMatrixVectorMultiplyPlan::~CUDPPSparseMatrixVectorMultiplyPlan() { freeSparseMatrixVectorMultiplyStorage(this); @@ -448,12 +448,12 @@ CUDPPSparseMatrixVectorMultiplyPlan::~CUDPPSparseMatrixVectorMultiplyPlan() /** @brief CUDPP Rand Plan Constructor * @param[in] config The configuration struct specifying options * @param[in] num_elements The number of elements to generate random bits for - -CUDPPRandPlan::CUDPPRandPlan(CUDPPConfiguration config, size_t num_elements) + +CUDPPRandPlan::CUDPPRandPlan(CUDPPConfiguration config, size_t num_elements) : CUDPPPlan(config, num_elements, 1, 0), m_seed(0) { - + } */ diff --git a/lib/gpu/cudpp_mini/cudpp_plan.h b/lib/gpu/cudpp_mini/cudpp_plan.h index 675adbecf3..86bce747ba 100644 --- a/lib/gpu/cudpp_mini/cudpp_plan.h +++ b/lib/gpu/cudpp_mini/cudpp_plan.h @@ -99,7 +99,7 @@ class CUDPPRadixSortPlan : public CUDPPPlan public: CUDPPRadixSortPlan(CUDPPConfiguration config, size_t numElements); virtual ~CUDPPRadixSortPlan(); - + bool m_bKeysOnly; bool m_bManualCoalesce; bool m_bUsePersistentCTAs; diff --git a/lib/gpu/cudpp_mini/cudpp_plan_manager.cpp b/lib/gpu/cudpp_mini/cudpp_plan_manager.cpp index 33c8621d29..202a33dc32 100644 --- a/lib/gpu/cudpp_mini/cudpp_plan_manager.cpp +++ b/lib/gpu/cudpp_mini/cudpp_plan_manager.cpp @@ -3,20 +3,20 @@ // ------------------------------------------------------------- // $Revision: 3572$ // $Date: 2007-11-19 13:58:06 +0000 (Mon, 19 Nov 2007) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #include "cudpp.h" #include "cudpp_plan.h" #include "cudpp_plan_manager.h" #include "cudpp_maximal_launch.h" - + typedef void* KernelPointer; extern "C" size_t getNumCTAs(KernelPointer kernel) { - return CUDPPPlanManager::numCTAs(kernel); + return CUDPPPlanManager::numCTAs(kernel); } extern "C" void compNumCTAs(KernelPointer kernel, size_t bytesDynamicSharedMem, size_t threadsPerBlock) { @@ -24,23 +24,23 @@ extern "C" void compNumCTAs(KernelPointer kernel, size_t bytesDynamicSharedMem, } //! @internal Instantiate the plan manager singleton object -void CUDPPPlanManager::Instantiate() -{ - if (nullptr == m_instance) - m_instance = new CUDPPPlanManager; +void CUDPPPlanManager::Instantiate() +{ + if (nullptr == m_instance) + m_instance = new CUDPPPlanManager; } //! @internal Destroy the plan manager singleton object -void CUDPPPlanManager::Destroy() -{ - if (nullptr != m_instance) - { - delete m_instance; - m_instance = nullptr; - } +void CUDPPPlanManager::Destroy() +{ + if (nullptr != m_instance) + { + delete m_instance; + m_instance = nullptr; + } } -/** @brief Plan Manager destructor +/** @brief Plan Manager destructor * Destroys all plans as well as the plan manager. */ CUDPPPlanManager::~CUDPPPlanManager() @@ -59,8 +59,8 @@ CUDPPPlanManager::~CUDPPPlanManager() } /** @brief Add a plan to the plan manager -* -* @returns a valid CUDPPHandle if the plan was successfully added, or +* +* @returns a valid CUDPPHandle if the plan was successfully added, or * CUDPP_INVALID_HANDLE otherwise * @param[in] plan The plan to add */ @@ -75,11 +75,11 @@ CUDPPHandle CUDPPPlanManager::AddPlan(CUDPPPlan* plan) if (ret.second == true) return handle; else - return CUDPP_INVALID_HANDLE; + return CUDPP_INVALID_HANDLE; } /** @brief Remove a plan from the plan manager -* +* * @returns true if the plan was successfully removed, false otherwise * @param[in] handle The handle to the plan to remove */ @@ -106,15 +106,15 @@ bool CUDPPPlanManager::RemovePlan(CUDPPHandle handle) } return true; - } + } else { return false; - } + } } /** @brief Get a plan from the plan manager by handle -* +* * @returns A pointer to the plan if found, or nullptr otherwise * @param handle The handle to the requested plan */ diff --git a/lib/gpu/cudpp_mini/cudpp_plan_manager.h b/lib/gpu/cudpp_mini/cudpp_plan_manager.h index 1ccdca5168..68164921b3 100644 --- a/lib/gpu/cudpp_mini/cudpp_plan_manager.h +++ b/lib/gpu/cudpp_mini/cudpp_plan_manager.h @@ -3,20 +3,20 @@ // ------------------------------------------------------------- // $Revision: 3572$ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #ifndef __CUDPP_PLAN_MANAGER_H__ #define __CUDPP_PLAN_MANAGER_H__ - + #include class CUDPPPlan; typedef void* KernelPointer; /** @brief Singleton manager class for CUDPPPlan objects - * + * * This class manages all active plans in CUDPP. It is a singleton class, * meaning that only one instance can exist. It is created automatically the * first time AddPlan() is called, and destroyed when the last plan is removed @@ -28,19 +28,19 @@ public: static CUDPPHandle AddPlan(CUDPPPlan* plan); static bool RemovePlan(CUDPPHandle handle); static CUDPPPlan* GetPlan(CUDPPHandle handle); - + static size_t numCTAs(KernelPointer kernel); - static void computeNumCTAs(KernelPointer kernel, - size_t bytesDynamicSharedMem, + static void computeNumCTAs(KernelPointer kernel, + size_t bytesDynamicSharedMem, size_t threadsPerBlock); - + protected: static CUDPPPlanManager* m_instance; std::map plans; std::map numCTAsTable; private: - + //! @internal Instantiate the plan manager singleton object static void Instantiate(); diff --git a/lib/gpu/cudpp_mini/cudpp_radixsort.h b/lib/gpu/cudpp_mini/cudpp_radixsort.h index b977017d30..58c4ff2848 100644 --- a/lib/gpu/cudpp_mini/cudpp_radixsort.h +++ b/lib/gpu/cudpp_mini/cudpp_radixsort.h @@ -3,14 +3,14 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- +// ------------------------------------------------------------- #ifndef __RADIXSORT_H__ #define __RADIXSORT_H__ - -#define SORT_CTA_SIZE 256 //This CTA_SIZE must equal 16 * number of radices + +#define SORT_CTA_SIZE 256 //This CTA_SIZE must equal 16 * number of radices #include "cudpp_globals.h" #include "cudpp.h" diff --git a/lib/gpu/cudpp_mini/cudpp_scan.h b/lib/gpu/cudpp_mini/cudpp_scan.h index af4729b297..932b019e2f 100644 --- a/lib/gpu/cudpp_mini/cudpp_scan.h +++ b/lib/gpu/cudpp_mini/cudpp_scan.h @@ -3,11 +3,11 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- -// This source code is distributed under the terms of license.txt +// ------------------------------------------------------------- +// This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * cudpp_scan.h @@ -27,8 +27,8 @@ extern "C" void freeScanStorage(CUDPPScanPlan *plan); extern "C" -void cudppScanDispatch(void *d_out, - const void *d_in, +void cudppScanDispatch(void *d_out, + const void *d_in, size_t numElements, size_t numRows, const CUDPPScanPlan *plan); diff --git a/lib/gpu/cudpp_mini/cudpp_util.h b/lib/gpu/cudpp_mini/cudpp_util.h index e1c21f3fe6..1b04a1df2f 100644 --- a/lib/gpu/cudpp_mini/cudpp_util.h +++ b/lib/gpu/cudpp_mini/cudpp_util.h @@ -3,11 +3,11 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- +// ------------------------------------------------------------- // This source code is distributed under the terms of license.txt in // the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * cudpp_util.h @@ -40,7 +40,7 @@ * @param n Value to be checked to see if it is a power of two * @returns True if \a n is a power of two, false otherwise */ -inline bool +inline bool isPowerOfTwo(int n) { return ((n&(n-1))==0) ; @@ -64,8 +64,8 @@ isMultiple(int n, int f) * @param n Input value * @returns The smallest power f two larger than \a n */ -inline int -ceilPow2(int n) +inline int +ceilPow2(int n) { double log2n = log2((double)n); if (isPowerOfTwo(n)) @@ -78,7 +78,7 @@ ceilPow2(int n) * @param n Input value * @returns The largest power of two smaller than \a n. */ -inline int +inline int floorPow2(int n) { #ifdef WIN32 @@ -93,16 +93,16 @@ floorPow2(int n) } /** @brief Returns the maximum value for type \a T. - * + * * Implemented using template specialization on \a T. */ -template +template __host__ __device__ inline T getMax() { return 0; } /** @brief Returns the minimum value for type \a T. -* +* * Implemented using template specialization on \a T. */ -template +template __host__ __device__ inline T getMin() { return 0; } // type specializations for the above // getMax @@ -118,22 +118,22 @@ template <> __host__ __device__ inline float getMin() { return -FLT_MAX; } template <> __host__ __device__ inline char getMin() { return (char)INT_MIN; } template <> __host__ __device__ inline unsigned char getMin() { return (unsigned char)0; } -/** @brief Returns the maximum of three values. - * @param a First value. - * @param b Second value. - * @param c Third value. +/** @brief Returns the maximum of three values. + * @param a First value. + * @param b Second value. + * @param c Third value. * @returns The maximum of \a a, \a b and \a c. */ template inline int max3(T a, T b, T c) -{ +{ return (a > b) ? ((a > c)? a : c) : ((b > c) ? b : c); } /** @brief Utility template struct for generating small vector types from scalar types * - * Given a base scalar type (\c int, \c float, etc.) and a vector length (1 through 4) as - * template parameters, this struct defines a vector type (\c float3, \c int4, etc.) of the + * Given a base scalar type (\c int, \c float, etc.) and a vector length (1 through 4) as + * template parameters, this struct defines a vector type (\c float3, \c int4, etc.) of the * specified length and base type. For example: * \code * template @@ -145,8 +145,8 @@ inline int max3(T a, T b, T c) * \endcode * * This functionality is implemented using template specialization. Currently specializations - * for int, float, and unsigned int vectors of lengths 2-4 are defined. Note that this results - * in types being generated at compile time -- there is no runtime cost. typeToVector is used by + * for int, float, and unsigned int vectors of lengths 2-4 are defined. Note that this results + * in types being generated at compile time -- there is no runtime cost. typeToVector is used by * the optimized scan \c __device__ functions in scan_cta.cu. */ template @@ -202,15 +202,15 @@ struct typeToVector }; /** @brief Templatized operator class used by scan and segmented scan - * - * This Operator class is used to allow generic support of binary - * associative operators in scan. It defines two member functions, - * op() and identity(), that are used in place of + and 0 (for - * example) in the scan and segmented scan code. Because this is - * template code, all decisions in the code are made at compile - * time, resulting in optimal operator code. Currently the operators - * CUDPP_ADD, CUDPP_MULTIPLY, CUDPP_MIN, and CUDPP_MAX are supported. - * Operator is implemented using template specialization for the + * + * This Operator class is used to allow generic support of binary + * associative operators in scan. It defines two member functions, + * op() and identity(), that are used in place of + and 0 (for + * example) in the scan and segmented scan code. Because this is + * template code, all decisions in the code are made at compile + * time, resulting in optimal operator code. Currently the operators + * CUDPP_ADD, CUDPP_MULTIPLY, CUDPP_MIN, and CUDPP_MAX are supported. + * Operator is implemented using template specialization for the * types \c int, \c unsigned int, and \c float. */ template @@ -226,15 +226,15 @@ public: { switch (oper) { - case CUDPP_ADD: + case CUDPP_ADD: return a + b; case CUDPP_MULTIPLY: return a * b; case CUDPP_MIN: return min(a, b); - case CUDPP_MAX: + case CUDPP_MAX: return max(a, b); - } + } } /** Returns the identity element defined for type \a T */ @@ -251,15 +251,15 @@ public: switch (oper) { default: - case CUDPP_ADD: + case CUDPP_ADD: return a + b; case CUDPP_MULTIPLY: return a * b; case CUDPP_MIN: return min(a, b); - case CUDPP_MAX: + case CUDPP_MAX: return max(a, b); - } + } } static __device__ int identity() @@ -288,15 +288,15 @@ public: switch (oper) { default: - case CUDPP_ADD: + case CUDPP_ADD: return a + b; case CUDPP_MULTIPLY: return a * b; case CUDPP_MIN: return min(a, b); - case CUDPP_MAX: + case CUDPP_MAX: return max(a, b); - } + } } static __device__ unsigned int identity() @@ -326,15 +326,15 @@ public: switch (oper) { default: - case CUDPP_ADD: + case CUDPP_ADD: return a + b; case CUDPP_MULTIPLY: return a * b; case CUDPP_MIN: return min(a, b); - case CUDPP_MAX: + case CUDPP_MAX: return max(a, b); - } + } } static __device__ float identity() diff --git a/lib/gpu/cudpp_mini/sharedmem.h b/lib/gpu/cudpp_mini/sharedmem.h index 14721cfd30..82de5d6466 100644 --- a/lib/gpu/cudpp_mini/sharedmem.h +++ b/lib/gpu/cudpp_mini/sharedmem.h @@ -3,11 +3,11 @@ // ------------------------------------------------------------- // $Revision: 5289 $ // $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $ -// ------------------------------------------------------------- -// This source code is distributed under the terms of license.txt +// ------------------------------------------------------------- +// This source code is distributed under the terms of license.txt // in the root directory of this source distribution. -// ------------------------------------------------------------- - +// ------------------------------------------------------------- + /** * @file * sharedmem.h @@ -15,18 +15,18 @@ * @brief Shared memory declaration struct for templatized types. * * Because dynamically sized shared memory arrays are declared "extern" in CUDA, - * we can't templatize their types directly. To get around this, we declare a - * simple wrapper struct that will declare the extern array with a different + * we can't templatize their types directly. To get around this, we declare a + * simple wrapper struct that will declare the extern array with a different * name depending on the type. This avoids linker errors about multiple * definitions. - * - * To use dynamically allocated shared memory in a templatized __global__ or + * + * To use dynamically allocated shared memory in a templatized __global__ or * __device__ function, just replace code like this: * *
  *  template
  *  __global__ void
- *  foo( T* d_out, T* d_in) 
+ *  foo( T* d_out, T* d_in)
  *  {
  *      // Shared mem size is determined by the host app at run time
  *      extern __shared__  T sdata[];
@@ -35,12 +35,12 @@
  *      ...
  *  }
  * 
- * + * * With this *
  *  template
  *  __global__ void
- *  foo( T* d_out, T* d_in) 
+ *  foo( T* d_out, T* d_in)
  *  {
  *      // Shared mem size is determined by the host app at run time
  *      SharedMemory smem;
@@ -57,13 +57,13 @@
 
 
 /** @brief Wrapper class for templatized dynamic shared memory arrays.
-  * 
+  *
   * This struct uses template specialization on the type \a T to declare
   * a differently named dynamic shared memory array for each type
   * (\code extern __shared__ T s_type[] \endcode).
-  * 
+  *
   * Currently there are specializations for the following types:
-  * \c int, \c uint, \c char, \c uchar, \c short, \c ushort, \c long, 
+  * \c int, \c uint, \c char, \c uchar, \c short, \c ushort, \c long,
   * \c unsigned long, \c bool, \c float, and \c double. One can also specialize it
   * for user defined types.
   */
@@ -71,8 +71,8 @@ template 
 struct SharedMemory
 {
     /** Return a pointer to the runtime-sized shared memory array. **/
-    __device__ T* getPointer() 
-    { 
+    __device__ T* getPointer()
+    {
         extern __device__ void Error_UnsupportedType(); // Ensure that we won't compile any un-specialized types
         Error_UnsupportedType();
         return (T*)0;
@@ -87,73 +87,73 @@ struct SharedMemory
 template <>
 struct SharedMemory 
 {
-    __device__ int* getPointer() { extern __shared__ int s_int[]; return s_int; }      
+    __device__ int* getPointer() { extern __shared__ int s_int[]; return s_int; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ unsigned int* getPointer() { extern __shared__ unsigned int s_uint[]; return s_uint; }    
+    __device__ unsigned int* getPointer() { extern __shared__ unsigned int s_uint[]; return s_uint; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ char* getPointer() { extern __shared__ char s_char[]; return s_char; }    
+    __device__ char* getPointer() { extern __shared__ char s_char[]; return s_char; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ unsigned char* getPointer() { extern __shared__ unsigned char s_uchar[]; return s_uchar; }    
+    __device__ unsigned char* getPointer() { extern __shared__ unsigned char s_uchar[]; return s_uchar; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ short* getPointer() { extern __shared__ short s_short[]; return s_short; }    
+    __device__ short* getPointer() { extern __shared__ short s_short[]; return s_short; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ unsigned short* getPointer() { extern __shared__ unsigned short s_ushort[]; return s_ushort; }    
+    __device__ unsigned short* getPointer() { extern __shared__ unsigned short s_ushort[]; return s_ushort; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ long* getPointer() { extern __shared__ long s_long[]; return s_long; }    
+    __device__ long* getPointer() { extern __shared__ long s_long[]; return s_long; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ unsigned long* getPointer() { extern __shared__ unsigned long s_ulong[]; return s_ulong; }    
+    __device__ unsigned long* getPointer() { extern __shared__ unsigned long s_ulong[]; return s_ulong; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ bool* getPointer() { extern __shared__ bool s_bool[]; return s_bool; }    
+    __device__ bool* getPointer() { extern __shared__ bool s_bool[]; return s_bool; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ float* getPointer() { extern __shared__ float s_float[]; return s_float; }    
+    __device__ float* getPointer() { extern __shared__ float s_float[]; return s_float; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ double* getPointer() { extern __shared__ double s_double[]; return s_double; }    
+    __device__ double* getPointer() { extern __shared__ double s_double[]; return s_double; }
 };
 
 template <>
 struct SharedMemory 
 {
-    __device__ uchar4* getPointer() { extern __shared__ uchar4 s_uchar4[]; return s_uchar4; }    
+    __device__ uchar4* getPointer() { extern __shared__ uchar4 s_uchar4[]; return s_uchar4; }
 };
 
 
diff --git a/lib/gpu/geryon/README b/lib/gpu/geryon/README
index 018e9cff7f..df236bad85 100644
--- a/lib/gpu/geryon/README
+++ b/lib/gpu/geryon/README
@@ -6,7 +6,7 @@ Geryon
 
    Copyright (2010) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
+   certain rights in this software.  This software is distributed under
    the Simplified BSD License.
 
 Geryon is intended to be a simple library for managing the CUDA Runtime,
@@ -21,11 +21,11 @@ CUDA Driver, and OpenCL APIs with a consistent interface:
     * Simple routines for data I/O
     * Simple classes for managing device timing
     * Simple classes for managing kernel compilation and execution
-    
-Geryon does not require building (although a Makefile is provided for testing 
-purposes). The library is a set of header files that can be included with 
+
+Geryon does not require building (although a Makefile is provided for testing
+purposes). The library is a set of header files that can be included with
 your code.
 
-Documentation and examples are provided at 
+Documentation and examples are provided at
 
 http://users.nccs.gov/~wb8/geryon/index.htm
diff --git a/lib/gpu/geryon/file_to_cstr.sh b/lib/gpu/geryon/file_to_cstr.sh
index b0f6428b34..bd51603618 100755
--- a/lib/gpu/geryon/file_to_cstr.sh
+++ b/lib/gpu/geryon/file_to_cstr.sh
@@ -1,12 +1,12 @@
 #!/bin/sh
 
-# convert ptx assembly output into 
+# convert ptx assembly output into
 # a c-style string constant written
 # in portable posix shell script.
 # requires: sed, rm, mv
 #
 # Author: Axel Kohlmeyer, Temple University
- 
+
 num_args=$#
 
 # Check command-line arguments
@@ -26,14 +26,14 @@ string_name=$1
 eval output=\${$num_args}
 shift
 
-# remove temporary file in case we're interrupted. 
+# remove temporary file in case we're interrupted.
 cleanup () {
   rm -f $output
 }
 trap cleanup INT QUIT TERM
 
-# loop over arguments and convert to 
-# string constant. 
+# loop over arguments and convert to
+# string constant.
 i=2
 echo "const char * $string_name = " > $output
 while [ $i -lt $num_args ]
diff --git a/lib/gpu/geryon/hip_device.h b/lib/gpu/geryon/hip_device.h
index 11100cbea1..bcfd880712 100644
--- a/lib/gpu/geryon/hip_device.h
+++ b/lib/gpu/geryon/hip_device.h
@@ -233,13 +233,13 @@ class UCL_Device {
   /// Get the maximum number of threads per block in dimension 'dim'
   inline size_t group_size_dim(const int i, const int dim)
     { return _properties[i].maxThreadsDim[dim];}
-  
+
   /// Get the shared local memory size in bytes
   inline size_t slm_size() { return slm_size(_device); }
   /// Get the shared local memory size in bytes
   inline size_t slm_size(const int i)
     { return _properties[i].sharedMemPerBlock; }
- 
+
   /// Return the maximum memory pitch in bytes for current device
   inline size_t max_pitch() { return max_pitch(_device); }
   /// Return the maximum memory pitch in bytes
diff --git a/lib/gpu/geryon/hip_kernel.h b/lib/gpu/geryon/hip_kernel.h
index fbb08e12b1..d03f99d1cf 100644
--- a/lib/gpu/geryon/hip_kernel.h
+++ b/lib/gpu/geryon/hip_kernel.h
@@ -162,7 +162,7 @@ class UCL_Kernel {
     const auto aligned_size = (old_size+alignof(dtype)-1) & ~(alignof(dtype)-1);
     const auto arg_size = sizeof(dtype);
     _hip_kernel_args.resize(aligned_size + arg_size);
-    *((dtype*)(&_hip_kernel_args[aligned_size])) = *arg; 
+    *((dtype*)(&_hip_kernel_args[aligned_size])) = *arg;
     _num_args++;
     if (_num_args>UCL_MAX_KERNEL_ARGS) assert(0==1);
   }
@@ -195,7 +195,7 @@ class UCL_Kernel {
     _num_blocks[0]=num_blocks;
     _num_blocks[1]=1;
     _num_blocks[2]=1;
-    
+
     _block_size[0]=block_size;
     _block_size[1]=1;
     _block_size[2]=1;
diff --git a/lib/gpu/geryon/hip_texture.h b/lib/gpu/geryon/hip_texture.h
index 8738f6e2ea..3c2db98323 100644
--- a/lib/gpu/geryon/hip_texture.h
+++ b/lib/gpu/geryon/hip_texture.h
@@ -17,7 +17,7 @@ namespace ucl_hip {
 
 #ifdef __HIP_PLATFORM_NVCC__
 inline hipError_t hipModuleGetTexRef(CUtexref* texRef, hipModule_t hmod, const char* name){
-  return hipCUResultTohipError(cuModuleGetTexRef(texRef, hmod, name)); 
+  return hipCUResultTohipError(cuModuleGetTexRef(texRef, hmod, name));
 }
 inline hipError_t hipTexRefSetFormat(CUtexref tex, hipArray_Format fmt, int NumPackedComponents) {
     return hipCUResultTohipError(cuTexRefSetFormat(tex, (CUarray_format)fmt, NumPackedComponents ));
@@ -37,9 +37,9 @@ class UCL_Texture {
     { get_texture(prog,texture_name); }
   /// Set the texture reference for this object
   inline void get_texture(UCL_Program &prog, const char *texture_name)
-    { 
+    {
   #ifdef __HIP_PLATFORM_NVCC__
-      CU_SAFE_CALL(hipModuleGetTexRef(&_tex, prog._module, texture_name)); 
+      CU_SAFE_CALL(hipModuleGetTexRef(&_tex, prog._module, texture_name));
   #else
       size_t _global_var_size;
       CU_SAFE_CALL(hipModuleGetGlobal(&_device_ptr_to_global_var, &_global_var_size, prog._module, texture_name));
@@ -119,13 +119,13 @@ class UCL_Const {
   inline void get_global(UCL_Program &prog, const char *global_name) {
     _cq=prog.cq();
     CU_SAFE_CALL(hipModuleGetGlobal(&_global, &_global_bytes, prog._module,
-				    global_name)); 
+                                    global_name));
   }
   /// Copy from array on host to const memory
   template 
   inline void update_device(UCL_H_Vec &src, const int numel) {
     CU_SAFE_CALL(hipMemcpyHtoDAsync(_global, src.begin(), numel*sizeof(numtyp),
-				    _cq));
+                                    _cq));
   }
   /// Get device ptr associated with object
   inline const hipDeviceptr_t * begin() const { return &_global; }
diff --git a/lib/gpu/geryon/nvd_device.h b/lib/gpu/geryon/nvd_device.h
index 52b2ed478e..d5963fd39f 100644
--- a/lib/gpu/geryon/nvd_device.h
+++ b/lib/gpu/geryon/nvd_device.h
@@ -247,7 +247,7 @@ class UCL_Device {
   /// Get the maximum number of threads per block in dimension 'dim'
   inline size_t group_size_dim(const int i, const int dim)
     { return _properties[i].maxThreadsDim[dim]; }
-  
+
   /// Get the shared local memory size in bytes
   inline size_t slm_size() { return slm_size(_device); }
   /// Get the shared local memory size in bytes
diff --git a/lib/gpu/geryon/nvd_texture.h b/lib/gpu/geryon/nvd_texture.h
index 65f4ad9ef5..d7d65da903 100644
--- a/lib/gpu/geryon/nvd_texture.h
+++ b/lib/gpu/geryon/nvd_texture.h
@@ -113,13 +113,13 @@ class UCL_Const {
   inline void get_global(UCL_Program &prog, const char *global_name) {
     _cq=prog.cq();
     CU_SAFE_CALL(cuModuleGetGlobal(&_global, &_global_bytes, prog._module,
-				   global_name)); 
+                                   global_name));
   }
   /// Copy from array on host to const memory
   template 
   inline void update_device(UCL_H_Vec &src, const int numel) {
     CU_SAFE_CALL(cuMemcpyHtoDAsync(_global, src.begin(), numel*sizeof(numtyp),
-				   _cq));
+                                   _cq));
   }
   /// Get device ptr associated with object
   inline const CUdeviceptr * begin() const { return &_global; }
diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h
index a8e5020f00..1847b0463b 100644
--- a/lib/gpu/geryon/ocl_device.h
+++ b/lib/gpu/geryon/ocl_device.h
@@ -71,7 +71,7 @@ inline bool _shared_mem_device(cl_device_id &device) {
   #else
   cl_device_type device_type;
   CL_SAFE_CALL(clGetDeviceInfo(device,CL_DEVICE_TYPE,
-			       sizeof(device_type),&device_type,NULL));
+                               sizeof(device_type),&device_type,NULL));
   return (device_type==CL_DEVICE_TYPE_CPU);
   #endif
 }
@@ -221,7 +221,7 @@ class UCL_Device {
   /// Returns preferred vector width
   inline int preferred_fp64_width(const int i)
     {return _properties[i].preferred_vector_width64;}
-  
+
   /// Returns true if double precision is support for the current device
   inline bool double_precision() { return double_precision(_device); }
   /// Returns true if double precision is support for the device
@@ -356,12 +356,12 @@ class UCL_Device {
 
   /// Automatically set the platform by type, vendor, and/or CU count
   /** If first_device is positive, search restricted to platforms containing
-    * this device IDs. If ndevices is positive, search is restricted 
+    * this device IDs. If ndevices is positive, search is restricted
     * to platforms with at least that many devices  **/
   inline int auto_set_platform(const enum UCL_DEVICE_TYPE type=UCL_GPU,
-			       const std::string vendor="",
-			       const int ndevices=-1,
-			       const int first_device=-1);
+                               const std::string vendor="",
+                               const int ndevices=-1,
+                               const int first_device=-1);
 
  private:
   int _num_platforms;          // Number of platforms
@@ -467,9 +467,9 @@ int UCL_Device::set_platform(int pid) {
     #ifdef CL_VERSION_1_2
     cl_device_affinity_domain adomain;
     CL_SAFE_CALL(clGetDeviceInfo(device_list[i],
-				 CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
-				 sizeof(cl_device_affinity_domain),
-				 &adomain,NULL));
+                                 CL_DEVICE_PARTITION_AFFINITY_DOMAIN,
+                                 sizeof(cl_device_affinity_domain),
+                                 &adomain,NULL));
 
     cl_device_partition_property props[3];
     props[0]=CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN;
@@ -477,11 +477,11 @@ int UCL_Device::set_platform(int pid) {
     props[2]=0;
     if (adomain & CL_DEVICE_AFFINITY_DOMAIN_NUMA)
       CL_SAFE_CALL(clCreateSubDevices(device_list[i], props, 0, NULL,
-				      &num_subdevices));
+                                      &num_subdevices));
     if (num_subdevices > 1) {
       subdevice_list = new cl_device_id[num_subdevices];
       CL_SAFE_CALL(clCreateSubDevices(device_list[i], props, num_subdevices,
-				      subdevice_list, &num_subdevices));
+                                      subdevice_list, &num_subdevices));
     }
     #endif
 
@@ -596,8 +596,8 @@ void UCL_Device::add_properties(cl_device_id device_list) {
 
   cl_device_partition_property pinfo[4];
   CL_SAFE_CALL(clGetDeviceInfo(device_list, CL_DEVICE_PARTITION_TYPE,
-			       4*sizeof(cl_device_partition_property),
-			       &pinfo, &return_bytes));
+                               4*sizeof(cl_device_partition_property),
+                               &pinfo, &return_bytes));
   if (return_bytes == 0) op.is_subdevice=false;
   else if (pinfo[0]) op.is_subdevice=true;
   else op.is_subdevice=false;
@@ -627,10 +627,10 @@ void UCL_Device::add_properties(cl_device_id device_list) {
 
   size_t ext_str_size_ret;
   CL_SAFE_CALL(clGetDeviceInfo(device_list, CL_DEVICE_EXTENSIONS, 0, nullptr,
-			       &ext_str_size_ret));
+                               &ext_str_size_ret));
   char buffer2[ext_str_size_ret];
   CL_SAFE_CALL(clGetDeviceInfo(device_list, CL_DEVICE_EXTENSIONS,
-			       ext_str_size_ret, buffer2, nullptr));
+                               ext_str_size_ret, buffer2, nullptr));
   #if defined(CL_VERSION_2_1) || defined(CL_VERSION_3_0)
   if (op.cl_device_version >= 210) {
     if ((std::string(buffer2).find("cl_khr_subgroups") != std::string::npos) ||
@@ -650,10 +650,10 @@ void UCL_Device::add_properties(cl_device_id device_list) {
     #endif
     cl_uint major, minor;
     CL_SAFE_CALL(clGetDeviceInfo(device_list,
-				 CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV,
+                                 CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV,
                                  sizeof(cl_uint), &major, nullptr));
     CL_SAFE_CALL(clGetDeviceInfo(device_list,
-				 CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV,
+                                 CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV,
                                  sizeof(cl_uint), &minor, nullptr));
     double arch = static_cast(minor)/10+major;
     if (arch >= 3.0)
@@ -730,12 +730,12 @@ void UCL_Device::print_all(std::ostream &out) {
           << device_type_name(i).c_str() << std::endl;
       out << "  Supported OpenCL Version:                      "
           << _properties[i].cl_device_version / 100 << "."
-	  << _properties[i].cl_device_version % 100 << std::endl;
+          << _properties[i].cl_device_version % 100 << std::endl;
       out << "  Is a subdevice:                                ";
       if (is_subdevice(i))
-	out << "Yes\n";
+        out << "Yes\n";
       else
-	out << "No\n";
+        out << "No\n";
       out << "  Double precision support:                      ";
       if (double_precision(i))
         out << "Yes\n";
@@ -814,9 +814,9 @@ void UCL_Device::print_all(std::ostream &out) {
 }
 
 int UCL_Device::auto_set_platform(const enum UCL_DEVICE_TYPE type,
-				  const std::string vendor,
-				  const int ndevices,
-				  const int first_device) {
+                                  const std::string vendor,
+                                  const int ndevices,
+                                  const int first_device) {
   if (_num_platforms < 2) return set_platform(0);
 
   int last_device = -1;
@@ -826,7 +826,7 @@ int UCL_Device::auto_set_platform(const enum UCL_DEVICE_TYPE type,
     else
       last_device = first_device;
   }
-  
+
   bool vendor_match=false;
   bool type_match=false;
   int max_cus=0;
@@ -852,39 +852,39 @@ int UCL_Device::auto_set_platform(const enum UCL_DEVICE_TYPE type,
     if (vendor_upper!="") {
       std::string pname = platform_name();
       for (int i=0; i='a')
-	  pname[i]=toupper(pname[i]);
+        if (pname[i]<='z' && pname[i]>='a')
+          pname[i]=toupper(pname[i]);
 
       if (pname.find(vendor_upper)!=std::string::npos) {
-	if (vendor_match == false) {
-	  best_platform=n;
-	  max_cus=0;
-	  vendor_match=true;
-	}
+        if (vendor_match == false) {
+          best_platform=n;
+          max_cus=0;
+          vendor_match=true;
+        }
       } else if (vendor_match)
-	continue;
+        continue;
     }
 
     if (type != UCL_DEFAULT) {
       bool ptype_matched=false;
       for (int d=first_id; d<=last_id; d++) {
-	if (type==device_type(d)) {
-	  if (type_match == false) {
-	    best_platform=n;
-	    max_cus=0;
-	    type_match=true;
-	    ptype_matched=true;
-	  }
-	}
+        if (type==device_type(d)) {
+          if (type_match == false) {
+            best_platform=n;
+            max_cus=0;
+            type_match=true;
+            ptype_matched=true;
+          }
+        }
       }
       if (type_match==true && ptype_matched==false)
-	continue;
+        continue;
     }
 
     for (int d=first_id; d<=last_id; d++) {
       if (cus(d) > max_cus) {
-	best_platform=n;
-	max_cus=cus(d);
+        best_platform=n;
+        max_cus=cus(d);
       }
     }
   }
diff --git a/lib/gpu/geryon/ocl_kernel.h b/lib/gpu/geryon/ocl_kernel.h
index 23f9baa09e..14a319f391 100644
--- a/lib/gpu/geryon/ocl_kernel.h
+++ b/lib/gpu/geryon/ocl_kernel.h
@@ -113,31 +113,31 @@ class UCL_Program {
     {
       size_t ms;
       CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,
-					 0,NULL,&ms));
+                                         0,NULL,&ms));
       char *build_log = new char[ms];
       CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,
-					 ms,build_log, NULL));
+                                         ms,build_log, NULL));
       std::cout << std::endl << std::endl
-		<< "--------------------------------------------------------\n"
-		<< "   UCL PROGRAM DUMP\n"
-		<< "--------------------------------------------------------\n"
-		<< flags << std::endl
-		<< "--------------------------------------------------------\n"
-		<< prog << std::endl
-		<< "--------------------------------------------------------\n"
-		<< build_log
-		<< "--------------------------------------------------------\n"
-		<< std::endl << std::endl;
+                << "--------------------------------------------------------\n"
+                << "   UCL PROGRAM DUMP\n"
+                << "--------------------------------------------------------\n"
+                << flags << std::endl
+                << "--------------------------------------------------------\n"
+                << prog << std::endl
+                << "--------------------------------------------------------\n"
+                << build_log
+                << "--------------------------------------------------------\n"
+                << std::endl << std::endl;
     }
     #endif
-    
+
     if (build_status != CL_SUCCESS || log!=NULL) {
       size_t ms;
       CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,
-					 0,NULL,&ms));
+                                         0,NULL,&ms));
       char *build_log = new char[ms];
       CL_SAFE_CALL(clGetProgramBuildInfo(_program,_device,CL_PROGRAM_BUILD_LOG,
-					 ms,build_log, NULL));
+                                         ms,build_log, NULL));
 
       if (log!=nullptr)
         *log=std::string(build_log);
@@ -150,25 +150,25 @@ class UCL_Program {
           << build_status << ") ...\n"
           << "----------------------------------------------------------\n";
         std::cerr << build_log << std::endl;
-	std::cerr <<
-	  "----------------------------------------------------------\n"
-	  << std::endl << std::endl;
+        std::cerr <<
+          "----------------------------------------------------------\n"
+          << std::endl << std::endl;
         #endif
-	if (foutput != NULL) {
-	  fprintf(foutput,"\n\n");
-	  fprintf(foutput,
-	    "----------------------------------------------------------\n");
-	  fprintf(foutput,
-		  " UCL Error: Error compiling OpenCL Program (%d) ...\n",
-		  build_status);
-	  fprintf(foutput,
-	    "----------------------------------------------------------\n");
-	  fprintf(foutput,"%s\n",build_log);
-	  fprintf(foutput,
-	    "----------------------------------------------------------\n");
-	  fprintf(foutput,"\n\n");
-	}
-	delete[] build_log;
+        if (foutput != NULL) {
+          fprintf(foutput,"\n\n");
+          fprintf(foutput,
+            "----------------------------------------------------------\n");
+          fprintf(foutput,
+                  " UCL Error: Error compiling OpenCL Program (%d) ...\n",
+                  build_status);
+          fprintf(foutput,
+            "----------------------------------------------------------\n");
+          fprintf(foutput,"%s\n",build_log);
+          fprintf(foutput,
+            "----------------------------------------------------------\n");
+          fprintf(foutput,"\n\n");
+        }
+        delete[] build_log;
         return UCL_COMPILE_ERROR;
       } else delete[] build_log;
     }
diff --git a/lib/gpu/geryon/ucl_get_devices.cpp b/lib/gpu/geryon/ucl_get_devices.cpp
index 5654bb40bd..994554a252 100644
--- a/lib/gpu/geryon/ucl_get_devices.cpp
+++ b/lib/gpu/geryon/ucl_get_devices.cpp
@@ -17,7 +17,7 @@
 /* -----------------------------------------------------------------------
    Copyright (2009) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
+   certain rights in this software.  This software is distributed under
    the Simplified BSD License.
    ----------------------------------------------------------------------- */
 
diff --git a/lib/gpu/geryon/ucl_vector.h b/lib/gpu/geryon/ucl_vector.h
index c03fd31fce..0939bae31e 100644
--- a/lib/gpu/geryon/ucl_vector.h
+++ b/lib/gpu/geryon/ucl_vector.h
@@ -164,7 +164,7 @@ class UCL_Vector {
   inline void sync() { host.sync(); }
   /// Assert that any ops in associate command queue have been issued to device
   inline void flush() { ucl_flush(host.cq()); }
-  
+
   ///Get the size of a row on the host (including any padding) in elements
   inline size_t row_size() const { return host.row_size(); }
   /// Get the size of a row on the host(including any padding) in bytes
diff --git a/lib/gpu/lal_lj_smooth.cpp b/lib/gpu/lal_lj_smooth.cpp
index 42ffdabcf2..8391b46b2c 100644
--- a/lib/gpu/lal_lj_smooth.cpp
+++ b/lib/gpu/lal_lj_smooth.cpp
@@ -96,11 +96,11 @@ int LJSMOOTHT::init(const int ntypes,
   lj3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
   this->atom->type_pack4(ntypes,lj_types,lj3,host_write,host_lj3,host_lj4,
                          host_offset);
-  
+
   ljsw.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
   this->atom->type_pack4(ntypes,lj_types,ljsw,host_write,host_ljsw1,host_ljsw2,
                          host_ljsw3,host_ljsw4);
-  
+
   ljsw0.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
   this->atom->type_pack2(ntypes,lj_types,ljsw0,host_write,host_ljsw0,cut_inner);
 
diff --git a/lib/gpu/lal_lj_smooth.h b/lib/gpu/lal_lj_smooth.h
index 1ab517ece6..b33d17ca3d 100644
--- a/lib/gpu/lal_lj_smooth.h
+++ b/lib/gpu/lal_lj_smooth.h
@@ -40,7 +40,7 @@ class LJSMOOTH : public BaseAtomic {
            const int nlocal, const int nall, const int max_nbors,
            const int maxspecial, const double cell_size,
            const double gpu_split, FILE *screen,
-           double **host_ljsw0, double **host_ljsw1, double **host_ljsw2, 
+           double **host_ljsw0, double **host_ljsw1, double **host_ljsw2,
            double **host_ljsw3, double **host_ljsw4,
            double **cut_inner, double **cut_inner_sq);
 
@@ -48,7 +48,7 @@ class LJSMOOTH : public BaseAtomic {
   void reinit(const int ntypes, double **host_cutsq,
               double **host_lj1, double **host_lj2, double **host_lj3,
               double **host_lj4, double **host_offset,
-              double **host_ljsw0, double **host_ljsw1, double **host_ljsw2, 
+              double **host_ljsw0, double **host_ljsw1, double **host_ljsw2,
               double **host_ljsw3, double **host_ljsw4,
               double **cut_inner, double **cut_inner_sq);
 
diff --git a/lib/h5md/README b/lib/h5md/README
index a6d4d8206b..dd19e98c31 100644
--- a/lib/h5md/README
+++ b/lib/h5md/README
@@ -26,7 +26,7 @@ To use the h5md dump style in lammps, execute
 make -f Makefile.h5cc
 in this directory then
 make yes-h5md
-in the src directory of LAMMPS to rebuild LAMMPS. 
+in the src directory of LAMMPS to rebuild LAMMPS.
 
 Note that you must have the h5cc compiler installed to use
 Makefile.h5cc.  It should be part
diff --git a/lib/latte/README b/lib/latte/README
index bdf67dd59c..efd37b9ff0 100644
--- a/lib/latte/README
+++ b/lib/latte/README
@@ -23,7 +23,7 @@ Instructions:
    or tarball, unpack the tarball either in this /lib/latte
    directory or somewhere else on your system.
 
-2. Modify the makefile.CHOICES according to your system architecture 
+2. Modify the makefile.CHOICES according to your system architecture
    and compilers.  Check that the MAKELIB flag is ON in makefile.CHOICES
    and finally, build the code via the make command
    % make
diff --git a/lib/mdi/.gitignore b/lib/mdi/.gitignore
index 7fcc712431..c9c23624e1 100644
--- a/lib/mdi/.gitignore
+++ b/lib/mdi/.gitignore
@@ -66,4 +66,4 @@ build/
 libmdi.a
 mdi.h
 includelink
-liblink
\ No newline at end of file
+liblink
diff --git a/lib/mesont/README b/lib/mesont/README
index 3ed47bf218..1884cdb7e9 100644
--- a/lib/mesont/README
+++ b/lib/mesont/README
@@ -1,67 +1,67 @@
-MESONT is a LAMMPS package for simulation of nanomechanics of carbon 
-nanotubes (CNTs). The model is based on a coarse-grained representation 
-of CNTs as "flexible cylinders" consisting of a variable number of 
-segments. Internal interactions within a CNT and the van der Waals 
-interaction between the tubes are described by a mesoscopic force 
-field designed and parameterized based on the results of atomic-level 
-molecular dynamics simulations. The description of the force field 
+MESONT is a LAMMPS package for simulation of nanomechanics of carbon
+nanotubes (CNTs). The model is based on a coarse-grained representation
+of CNTs as "flexible cylinders" consisting of a variable number of
+segments. Internal interactions within a CNT and the van der Waals
+interaction between the tubes are described by a mesoscopic force
+field designed and parameterized based on the results of atomic-level
+molecular dynamics simulations. The description of the force field
 is provided in the papers listed below.
 
-This folder contains a Fortran library implementing basic level functions 
-describing stretching, bending, and intertube components of the CNT tubular 
+This folder contains a Fortran library implementing basic level functions
+describing stretching, bending, and intertube components of the CNT tubular
 potential model (TPM) mesoscopic force field.
 
-This library was created by Alexey N. Volkov, University of Alabama, 
+This library was created by Alexey N. Volkov, University of Alabama,
 avolkov1@ua.edu.
 
 --
 
 References:
 
-L. V. Zhigilei, C. Wei, and D. Srivastava, Mesoscopic model for dynamic 
+L. V. Zhigilei, C. Wei, and D. Srivastava, Mesoscopic model for dynamic
 simulations of carbon nanotubes, Phys. Rev. B 71, 165417, 2005.
 
-A. N. Volkov and L. V. Zhigilei, Structural stability of carbon nanotube 
+A. N. Volkov and L. V. Zhigilei, Structural stability of carbon nanotube
 films: The role of bending buckling, ACS Nano 4, 6187-6195, 2010.
 
-A. N. Volkov, K. R. Simov, and L. V. Zhigilei, Mesoscopic model for simulation 
-of CNT-based materials, Proceedings of the ASME International Mechanical 
-Engineering Congress and Exposition (IMECE2008), ASME paper IMECE2008-68021, 
+A. N. Volkov, K. R. Simov, and L. V. Zhigilei, Mesoscopic model for simulation
+of CNT-based materials, Proceedings of the ASME International Mechanical
+Engineering Congress and Exposition (IMECE2008), ASME paper IMECE2008-68021,
 2008.
 
-A. N. Volkov and L. V. Zhigilei, Mesoscopic interaction potential for carbon 
-nanotubes of arbitrary length and orientation, J. Phys. Chem. C 114, 5513-5531, 
+A. N. Volkov and L. V. Zhigilei, Mesoscopic interaction potential for carbon
+nanotubes of arbitrary length and orientation, J. Phys. Chem. C 114, 5513-5531,
 2010.
 
-B. K. Wittmaack, A. H. Banna, A. N. Volkov, L. V. Zhigilei, Mesoscopic 
-modeling of structural self-organization of carbon nanotubes into vertically 
+B. K. Wittmaack, A. H. Banna, A. N. Volkov, L. V. Zhigilei, Mesoscopic
+modeling of structural self-organization of carbon nanotubes into vertically
 aligned networks of nanotube bundles, Carbon 130, 69-86, 2018.
 
-B. K. Wittmaack, A. N. Volkov, L. V. Zhigilei, Mesoscopic modeling of the 
-uniaxial compression and recovery of vertically aligned carbon nanotube 
+B. K. Wittmaack, A. N. Volkov, L. V. Zhigilei, Mesoscopic modeling of the
+uniaxial compression and recovery of vertically aligned carbon nanotube
 forests, Compos. Sci. Technol. 166, 66-85, 2018.
 
-B. K. Wittmaack, A. N. Volkov, L. V. Zhigilei, Phase transformation as the 
-mechanism of mechanical deformation of vertically aligned carbon nanotube 
+B. K. Wittmaack, A. N. Volkov, L. V. Zhigilei, Phase transformation as the
+mechanism of mechanical deformation of vertically aligned carbon nanotube
 arrays: Insights from mesoscopic modeling, Carbon 143, 587-597, 2019.
 
-A. N. Volkov and L. V. Zhigilei, Scaling laws and mesoscopic modeling of 
-thermal conductivity in carbon nanotube materials, Phys. Rev. Lett. 104, 
+A. N. Volkov and L. V. Zhigilei, Scaling laws and mesoscopic modeling of
+thermal conductivity in carbon nanotube materials, Phys. Rev. Lett. 104,
 215902, 2010.
 
-A. N. Volkov, T. Shiga, D. Nicholson, J. Shiomi, and L. V. Zhigilei, Effect 
-of bending buckling of carbon nanotubes on thermal conductivity of carbon 
+A. N. Volkov, T. Shiga, D. Nicholson, J. Shiomi, and L. V. Zhigilei, Effect
+of bending buckling of carbon nanotubes on thermal conductivity of carbon
 nanotube materials, J. Appl. Phys. 111, 053501, 2012.
 
-A. N. Volkov and L. V. Zhigilei, Heat conduction in carbon nanotube materials: 
-Strong effect of intrinsic thermal conductivity of carbon nanotubes, Appl. 
+A. N. Volkov and L. V. Zhigilei, Heat conduction in carbon nanotube materials:
+Strong effect of intrinsic thermal conductivity of carbon nanotubes, Appl.
 Phys. Lett. 101, 043113, 2012.
 
-W. M. Jacobs, D. A. Nicholson, H. Zemer, A. N. Volkov, and L. V. Zhigilei, 
-Acoustic energy dissipation and thermalization in carbon nanotubes: Atomistic 
+W. M. Jacobs, D. A. Nicholson, H. Zemer, A. N. Volkov, and L. V. Zhigilei,
+Acoustic energy dissipation and thermalization in carbon nanotubes: Atomistic
 modeling and mesoscopic description, Phys. Rev. B 86, 165414, 2012.
 
-A. N. Volkov and A. H. Banna, Mesoscopic computational model of covalent 
-cross-links and mechanisms of load transfer in cross-linked carbon nanotube 
+A. N. Volkov and A. H. Banna, Mesoscopic computational model of covalent
+cross-links and mechanisms of load transfer in cross-linked carbon nanotube
 films with continuous networks of bundles, Comp. Mater. Sci. 176, 109410, 2020.
 
diff --git a/lib/message/Install.py b/lib/message/Install.py
index 829d58b5f8..0aa433d6ec 100644
--- a/lib/message/Install.py
+++ b/lib/message/Install.py
@@ -21,7 +21,7 @@ HELP = """
 Syntax from src dir: make lib-message args="-m"
                  or: make lib-message args="-s -z"
 Syntax from lib dir: python Install.py -m
-                 or: python Install.py -s -z 
+                 or: python Install.py -s -z
 
 Example:
 
diff --git a/lib/message/cslib/src/cslib.cpp b/lib/message/cslib/src/cslib.cpp
index 0bc9648a09..7e19c83f6b 100644
--- a/lib/message/cslib/src/cslib.cpp
+++ b/lib/message/cslib/src/cslib.cpp
@@ -40,14 +40,14 @@ CSlib::CSlib(int csflag, const char *mode, const void *ptr, const void *pcomm)
   else myworld = 0;
 
 #ifdef MPI_NO
-  if (pcomm) 
+  if (pcomm)
     error_all("constructor(): CSlib invoked with MPI_Comm "
               "but built w/out MPI support");
 #endif
 #ifdef MPI_YES              // NOTE: this could be OK to allow ??
                             // would allow a parallel app to invoke CSlib
                             //   in parallel and/or in serial
-  if (!pcomm) 
+  if (!pcomm)
     error_all("constructor(): CSlib invoked w/out MPI_Comm "
               "but built with MPI support");
 #endif
@@ -63,7 +63,7 @@ CSlib::CSlib(int csflag, const char *mode, const void *ptr, const void *pcomm)
 
     if (strcmp(mode,"file") == 0) msg = new MsgFile(csflag,ptr);
     else if (strcmp(mode,"zmq") == 0) msg = new MsgZMQ(csflag,ptr);
-    else if (strcmp(mode,"mpi/one") == 0) 
+    else if (strcmp(mode,"mpi/one") == 0)
       error_all("constructor(): No mpi/one mode for serial lib usage");
     else if (strcmp(mode,"mpi/two") == 0)
       error_all("constructor(): No mpi/two mode for serial lib usage");
@@ -93,9 +93,9 @@ CSlib::CSlib(int csflag, const char *mode, const void *ptr, const void *pcomm)
   allids = nullptr;
   maxfieldbytes = 0;
   fielddata = nullptr;
-  
+
   pad = "\0\0\0\0\0\0\0";    // just length 7 since will have trailing nullptr
-  
+
   nsend = nrecv = 0;
 }
 
@@ -106,7 +106,7 @@ CSlib::~CSlib()
   deallocate_fields();
   sfree(header);
   sfree(buf);
-  
+
   sfree(recvcounts);
   sfree(displs);
   sfree(allids);
@@ -127,7 +127,7 @@ void CSlib::send(int msgID_caller, int nfield_caller)
 
   fieldcount = 0;
   nbuf = 0;
-  
+
   if (fieldcount == nfield) send_message();
 }
 
@@ -174,7 +174,7 @@ void CSlib::pack(int id, int ftype, int flen, void *data)
     error_all("pack(): Reuse of field ID");
   if (ftype < 1 || ftype > MAXTYPE) error_all("pack(): Invalid ftype");
   if (flen < 0) error_all("pack(): Invalid flen");
-    
+
   fieldID[fieldcount] = id;
   fieldtype[fieldcount] = ftype;
   fieldlen[fieldcount] = flen;
@@ -185,7 +185,7 @@ void CSlib::pack(int id, int ftype, int flen, void *data)
   memcpy(&buf[nbuf],data,nbytes);
   memcpy(&buf[nbuf+nbytes],pad,nbytesround-nbytes);
   nbuf += nbytesround;
-  
+
   fieldcount++;
   if (fieldcount == nfield) send_message();
 }
@@ -193,7 +193,7 @@ void CSlib::pack(int id, int ftype, int flen, void *data)
 /* ---------------------------------------------------------------------- */
 
 void CSlib::pack_parallel(int id, int ftype,
-			  int nlocal, int *ids, int nper, void *data)
+                          int nlocal, int *ids, int nper, void *data)
 {
   int i,j,k,m;
 
@@ -214,7 +214,7 @@ void CSlib::pack_parallel(int id, int ftype,
   fieldID[fieldcount] = id;
   fieldtype[fieldcount] = ftype;
   fieldlen[fieldcount] = flen;
-  
+
   // nlocal datums, each of nper length, from all procs
   // final data in buf = datums for all natoms, ordered by ids
 
@@ -238,7 +238,7 @@ void CSlib::pack_parallel(int id, int ftype,
 
   MPI_Allgatherv(ids,nlocal,MPI_INT,allids,
                  recvcounts,displs,MPI_INT,world);
-  
+
   int nlocalsize = nper*nlocal;
   MPI_Allgather(&nlocalsize,1,MPI_INT,recvcounts,1,MPI_INT,world);
 
@@ -254,22 +254,22 @@ void CSlib::pack_parallel(int id, int ftype,
     if (ids) {
       if (nbytes > maxfieldbytes) {
         sfree(fielddata);
-        maxfieldbytes = nbytes;   
+        maxfieldbytes = nbytes;
         fielddata = (char *) smalloc(maxfieldbytes);
       }
       alldata = (int *) fielddata;
     } else alldata = (int *) &buf[nbuf];
     MPI_Allgatherv(data,nlocalsize,MPI_INT,alldata,
-		   recvcounts,displs,MPI_INT,world);
+                   recvcounts,displs,MPI_INT,world);
     if (ids) {
       int *bufptr = (int *) &buf[nbuf];
       m = 0;
       for (i = 0; i < nglobal; i++) {
-	j = (allids[i]-1) * nper;
-	if (nper == 1) bufptr[j] = alldata[m++];
-	else
-	  for (k = 0; k < nper; k++)
-	    bufptr[j++] = alldata[m++];
+        j = (allids[i]-1) * nper;
+        if (nper == 1) bufptr[j] = alldata[m++];
+        else
+          for (k = 0; k < nper; k++)
+            bufptr[j++] = alldata[m++];
       }
     }
 
@@ -278,32 +278,32 @@ void CSlib::pack_parallel(int id, int ftype,
     if (ids) {
       if (nbytes > maxfieldbytes) {
         sfree(fielddata);
-        maxfieldbytes = nbytes;   
+        maxfieldbytes = nbytes;
         fielddata = (char *) smalloc(maxfieldbytes);
       }
       alldata = (int64_t *) fielddata;
     } else alldata = (int64_t *) &buf[nbuf];
     // NOTE: may be just MPI_LONG on some machines
     MPI_Allgatherv(data,nlocalsize,MPI_LONG_LONG,alldata,
-		   recvcounts,displs,MPI_LONG_LONG,world);
+                   recvcounts,displs,MPI_LONG_LONG,world);
     if (ids) {
       int64_t *bufptr = (int64_t *) &buf[nbuf];
       m = 0;
       for (i = 0; i < nglobal; i++) {
-	j = (allids[i]-1) * nper;
-	if (nper == 1) bufptr[j] = alldata[m++];
-	else
-	  for (k = 0; k < nper; k++)
-	    bufptr[j++] = alldata[m++];
+        j = (allids[i]-1) * nper;
+        if (nper == 1) bufptr[j] = alldata[m++];
+        else
+          for (k = 0; k < nper; k++)
+            bufptr[j++] = alldata[m++];
       }
     }
-    
+
   } else if (ftype == 3) {
     float *alldata;
     if (ids) {
       if (nbytes > maxfieldbytes) {
         sfree(fielddata);
-        maxfieldbytes = nbytes;   
+        maxfieldbytes = nbytes;
         fielddata = (char *) smalloc(maxfieldbytes);
       }
       alldata = (float *) fielddata;
@@ -314,11 +314,11 @@ void CSlib::pack_parallel(int id, int ftype,
       float *bufptr = (float *) &buf[nbuf];
       m = 0;
       for (i = 0; i < nglobal; i++) {
-	j = (allids[i]-1) * nper;
-	if (nper == 1) bufptr[j] = alldata[m++];
-	else
-	  for (k = 0; k < nper; k++)
-	    bufptr[j++] = alldata[m++];
+        j = (allids[i]-1) * nper;
+        if (nper == 1) bufptr[j] = alldata[m++];
+        else
+          for (k = 0; k < nper; k++)
+            bufptr[j++] = alldata[m++];
       }
     }
 
@@ -327,7 +327,7 @@ void CSlib::pack_parallel(int id, int ftype,
     if (ids) {
       if (nbytes > maxfieldbytes) {
         sfree(fielddata);
-        maxfieldbytes = nbytes;   
+        maxfieldbytes = nbytes;
         fielddata = (char *) smalloc(maxfieldbytes);
       }
       alldata = (double *) fielddata;
@@ -338,11 +338,11 @@ void CSlib::pack_parallel(int id, int ftype,
       double *bufptr = (double *) &buf[nbuf];
       m = 0;
       for (i = 0; i < nglobal; i++) {
-	j = (allids[i]-1) * nper;
-	if (nper == 1) bufptr[j] = alldata[m++];
-	else
-	  for (k = 0; k < nper; k++)
-	    bufptr[j++] = alldata[m++];
+        j = (allids[i]-1) * nper;
+        if (nper == 1) bufptr[j] = alldata[m++];
+        else
+          for (k = 0; k < nper; k++)
+            bufptr[j++] = alldata[m++];
       }
     }
 
@@ -352,7 +352,7 @@ void CSlib::pack_parallel(int id, int ftype,
     if (ids) {
       if (nbytes > maxfieldbytes) {
         sfree(fielddata);
-        maxfieldbytes = nbytes;   
+        maxfieldbytes = nbytes;
         fielddata = (char *) smalloc(maxfieldbytes);
       }
       alldata = (char *) fielddata;
@@ -363,9 +363,9 @@ void CSlib::pack_parallel(int id, int ftype,
       char *bufptr = (char *) &buf[nbuf];
       m = 0;
       for (i = 0; i < nglobal; i++) {
-	j = (allids[i]-1) * nper;
-	memcpy(&bufptr[j],&alldata[m],nper);
-	m += nper;
+        j = (allids[i]-1) * nper;
+        memcpy(&bufptr[j],&alldata[m],nper);
+        m += nper;
       }
     }
     */
@@ -399,14 +399,14 @@ void CSlib::send_message()
 
 /* ---------------------------------------------------------------------- */
 
-int CSlib::recv(int &nfield_caller, int *&fieldID_caller, 
-		int *&fieldtype_caller, int *&fieldlen_caller)
+int CSlib::recv(int &nfield_caller, int *&fieldID_caller,
+                int *&fieldtype_caller, int *&fieldlen_caller)
 {
   msg->recv(maxheader,header,maxbuf,buf);
   nrecv++;
 
   // unpack header message
-  
+
   int m = 0;
   msgID = header[m++];
   nfield = header[m++];
@@ -423,7 +423,7 @@ int CSlib::recv(int &nfield_caller, int *&fieldID_caller,
     onefield(fieldtype[ifield],fieldlen[ifield],nbytes,nbytesround);
     nbuf += nbytesround;
   }
-  
+
   // return message parameters
 
   nfield_caller = nfield;
@@ -513,7 +513,7 @@ void CSlib::unpack(int id, void *data)
 {
   int ifield = find_field(id,nfield);
   if (ifield < 0) error_all("unpack(): Unknown field ID");
-  
+
   int ftype = fieldtype[ifield];
   int nbytes = fieldlen[ifield];
   if (ftype == 1) nbytes *= sizeof(int);
@@ -541,7 +541,7 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     MPI_Scan(&nlocal,&upto,1,MPI_INT,MPI_SUM,world);
     upto -= nlocal;
   }
-  
+
   if (fieldtype[ifield] == 1) {
     int *local = (int *) data;
     int *global = (int *) &buf[fieldoffset[ifield]];
@@ -549,13 +549,13 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     else {
       m = 0;
       for (i = 0; i < nlocal; i++) {
-	j = (ids[i]-1) * nper;
-	if (nper == 1) local[m++] = global[j];
-	else
-	  for (k = 0; k < nper; k++)
-	    local[m++] = global[j++];
+        j = (ids[i]-1) * nper;
+        if (nper == 1) local[m++] = global[j];
+        else
+          for (k = 0; k < nper; k++)
+            local[m++] = global[j++];
       }
-    } 
+    }
 
   } else if (fieldtype[ifield] == 2) {
     int64_t *local = (int64_t *) data;
@@ -564,11 +564,11 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     else {
       m = 0;
       for (i = 0; i < nlocal; i++) {
-	j = (ids[i]-1) * nper;
-	if (nper == 1) local[m++] = global[j];
-	else
-	  for (k = 0; k < nper; k++)
-	    local[m++] = global[j++];
+        j = (ids[i]-1) * nper;
+        if (nper == 1) local[m++] = global[j];
+        else
+          for (k = 0; k < nper; k++)
+            local[m++] = global[j++];
       }
     }
 
@@ -579,14 +579,14 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     else {
       m = 0;
       for (i = 0; i < nlocal; i++) {
-	j = (ids[i]-1) * nper;
-	if (nper == 1) local[m++] = global[j];
-	else
-	  for (k = 0; k < nper; k++)
-	    local[m++] = global[j++];
+        j = (ids[i]-1) * nper;
+        if (nper == 1) local[m++] = global[j];
+        else
+          for (k = 0; k < nper; k++)
+            local[m++] = global[j++];
       }
     }
-    
+
   } else if (fieldtype[ifield] == 4) {
     double *local = (double *) data;
     double *global = (double *) &buf[fieldoffset[ifield]];
@@ -594,14 +594,14 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     else {
       m = 0;
       for (i = 0; i < nlocal; i++) {
-	j = (ids[i]-1) * nper;
-	if (nper == 1) local[m++] = global[j];
-	else
-	  for (k = 0; k < nper; k++)
-	    local[m++] = global[j++];
+        j = (ids[i]-1) * nper;
+        if (nper == 1) local[m++] = global[j];
+        else
+          for (k = 0; k < nper; k++)
+            local[m++] = global[j++];
       }
     }
-    
+
     /* eventually ftype = BYTE, but not yet
   } else if (fieldtype[ifield] == 5) {
     char *local = (char *) data;
@@ -610,9 +610,9 @@ void CSlib::unpack_parallel(int id, int nlocal, int *ids, int nper, void *data)
     else {
       m = 0;
       for (i = 0; i < nlocal; i++) {
-	j = (ids[i]-1) * nper;
-	memcpy(&local[m],&global[j],nper);
-	m += nper;
+        j = (ids[i]-1) * nper;
+        memcpy(&local[m],&global[j],nper);
+        m += nper;
       }
     }
     */
@@ -635,7 +635,7 @@ void CSlib::onefield(int ftype, int flen, int &nbytes, int &nbytesround)
 {
   int64_t bigbytes,bigbytesround;
   int64_t biglen = flen;
-  
+
   if (ftype == 1) bigbytes = biglen * sizeof(int);
   else if (ftype == 2) bigbytes = biglen * sizeof(int64_t);
   else if (ftype == 3) bigbytes = biglen * sizeof(float);
@@ -675,7 +675,7 @@ void CSlib::allocate_fields()
 
   nheader = 2;
   nheader += 3 * nfield;
-  
+
   if (nfield > maxfield) {
     deallocate_fields();
     maxfield = nfield;
@@ -684,7 +684,7 @@ void CSlib::allocate_fields()
     fieldlen = new int[maxfield];
     fieldoffset = new int[maxfield];
   }
-  
+
   if (nheader > maxheader) {
     sfree(header);
     maxheader = nheader;
@@ -724,7 +724,7 @@ void *CSlib::srealloc(void *ptr, int nbytes)
     sfree(ptr);
     return nullptr;
   }
-  
+
   ptr = realloc(ptr,nbytes);
   if (ptr == nullptr) {
     char str[128];
diff --git a/lib/message/cslib/src/cslib.h b/lib/message/cslib/src/cslib.h
index f2bf006881..ad7c853344 100644
--- a/lib/message/cslib/src/cslib.h
+++ b/lib/message/cslib/src/cslib.h
@@ -52,7 +52,7 @@ class CSlib {
   void unpack_parallel(int, int, int *, int, void *);
 
   int extract(int);
-  
+
  private:
   uint64_t myworld;    // really MPI_Comm, but avoids use of mpi.h in this file
                        // so apps can include this file w/ no MPI on system
diff --git a/lib/message/cslib/src/cslib.py b/lib/message/cslib/src/cslib.py
index 0ba3516255..673c524a3f 100644
--- a/lib/message/cslib/src/cslib.py
+++ b/lib/message/cslib/src/cslib.py
@@ -42,11 +42,11 @@ except:
 class CSlib:
 
   # instantiate CSlib thru its C-interface
-  
+
   def __init__(self,csflag,mode,ptr,comm):
 
     # load libcslib.so
-    
+
     try:
       if comm: self.lib = CDLL("libcsmpi.so",RTLD_GLOBAL)
       else: self.lib = CDLL("libcsnompi.so",RTLD_GLOBAL)
@@ -66,35 +66,35 @@ class CSlib:
 
     self.lib.cslib_send.argtypes = [c_void_p,c_int,c_int]
     self.lib.cslib_send.restype = None
-    
+
     self.lib.cslib_pack_int.argtypes = [c_void_p,c_int,c_int]
     self.lib.cslib_pack_int.restype = None
-    
+
     self.lib.cslib_pack_int64.argtypes = [c_void_p,c_int,c_longlong]
     self.lib.cslib_pack_int64.restype = None
-    
+
     self.lib.cslib_pack_float.argtypes = [c_void_p,c_int,c_float]
     self.lib.cslib_pack_float.restype = None
-    
+
     self.lib.cslib_pack_double.argtypes = [c_void_p,c_int,c_double]
     self.lib.cslib_pack_double.restype = None
-    
+
     self.lib.cslib_pack_string.argtypes = [c_void_p,c_int,c_char_p]
     self.lib.cslib_pack_string.restype = None
-    
+
     self.lib.cslib_pack.argtypes = [c_void_p,c_int,c_int,c_int,c_void_p]
     self.lib.cslib_pack.restype = None
-    
+
     self.lib.cslib_pack_parallel.argtypes = [c_void_p,c_int,c_int,c_int,
                                              POINTER(c_int),c_int,c_void_p]
     self.lib.cslib_pack_parallel.restype = None
-    
+
     self.lib.cslib_recv.argtypes = [c_void_p,POINTER(c_int),
                                     POINTER(POINTER(c_int)),
                                     POINTER(POINTER(c_int)),
                                     POINTER(POINTER(c_int))]
     self.lib.cslib_recv.restype = c_int
-    
+
     self.lib.cslib_unpack_int.argtypes = [c_void_p,c_int]
     self.lib.cslib_unpack_int.restype = c_int
 
@@ -128,7 +128,7 @@ class CSlib:
     # create an instance of CSlib with or w/out MPI communicator
 
     self.cs = c_void_p()
-    
+
     if not comm:
       self.lib.cslib_open(csflag,mode,ptr,None,byref(self.cs))
     elif not mpi4pyflag:
@@ -144,7 +144,7 @@ class CSlib:
       self.lib.cslib_open(csflag,mode,ptrcopy,comm_ptr,byref(self.cs))
 
   # destroy instance of CSlib
-  
+
   def __del__(self):
     if self.cs: self.lib.cslib_close(self.cs)
 
@@ -153,13 +153,13 @@ class CSlib:
     self.lib = None
 
   # send a message
-  
+
   def send(self,msgID,nfield):
     self.nfield = nfield
     self.lib.cslib_send(self.cs,msgID,nfield)
 
   # pack one field of message
-  
+
   def pack_int(self,id,value):
     self.lib.cslib_pack_int(self.cs,id,value)
 
@@ -185,24 +185,24 @@ class CSlib:
     self.lib.cslib_pack_parallel(self.cs,id,ftype,nlocal,cids,nper,cdata)
 
   # convert input data to a ctypes vector to pass to CSlib
-  
+
   def data_convert(self,ftype,flen,data):
-       
+
     # tflag = type of data
     # tflag = 1 if data is list or tuple
     # tflag = 2 if data is Numpy array
     # tflag = 3 if data is ctypes vector
     # same usage of tflag as in unpack function
-    
+
     txttype = str(type(data))
     if "numpy" in txttype: tflag = 2
     elif "c_" in txttype: tflag = 3
     else: tflag = 1
-    
+
     # create ctypes vector out of data to pass to lib
     # cdata = ctypes vector to return
     # NOTE: error check on ftype and tflag everywhere, also flen
-    
+
     if ftype == 1:
       if tflag == 1: cdata = (flen * c_int)(*data)
       elif tflag == 2: cdata = data.ctypes.data_as(POINTER(c_int))
@@ -223,7 +223,7 @@ class CSlib:
     return cdata
 
   # receive a message
-  
+
   def recv(self):
     self.lib.cslib_recv.restype = c_int
     nfield = c_int()
@@ -235,18 +235,18 @@ class CSlib:
 
     # copy returned C args to native Python int and lists
     # store them in class so unpack() methods can access the info
-    
+
     self.nfield = nfield = nfield.value
     self.fieldID = fieldID[:nfield]
     self.fieldtype = fieldtype[:nfield]
     self.fieldlen = fieldlen[:nfield]
-    
+
     return msgID,self.nfield,self.fieldID,self.fieldtype,self.fieldlen
 
   # unpack one field of message
   # tflag = type of data to return
   # 3 = ctypes vector is default, since no conversion required
-  
+
   def unpack_int(self,id):
     return self.lib.cslib_unpack_int(self.cs,id)
 
@@ -267,7 +267,7 @@ class CSlib:
 
     # reset data type of return so can morph by tflag
     # cannot do this for the generic c_void_p returned by CSlib
-    
+
     if self.fieldtype[index] == 1:
       self.lib.cslib_unpack.restype = POINTER(c_int)
     elif self.fieldtype[index] == 2:
@@ -287,7 +287,7 @@ class CSlib:
     # tflag = 3 to return data as ctypes vector
     # same usage of tflag as in pack functions
     # tflag = 2,3 should NOT perform a data copy
-    
+
     if tflag == 1:
       data = cdata[:self.fieldlen[index]]
     elif tflag == 2:
@@ -297,11 +297,11 @@ class CSlib:
       data = np.ctypeslib.as_array(cdata,shape=(self.fieldlen[index],))
     elif tflag == 3:
       data = cdata
-      
+
     return data
 
   # handle data array like pack() or unpack_parallel() ??
-  
+
   def unpack_data(self,id,tflag=3):
     index = self.fieldID.index(id)
 
@@ -312,14 +312,14 @@ class CSlib:
   #       as opposed to creating this cdata
   #       does that make any performance difference ?
   #       e.g. should we allow CSlib to populate an existing Numpy array's memory
-  
+
   def unpack_parallel(self,id,nlocal,ids,nper,tflag=3):
     cids = self.data_convert(1,nlocal,ids)
 
     # allocate memory for the returned data
     # pass cdata ptr to the memory to CSlib unpack_parallel()
     # this resets data type of last unpack_parallel() arg
-    
+
     index = self.fieldID.index(id)
     if self.fieldtype[index] == 1: cdata = (nper*nlocal * c_int)()
     elif self.fieldtype[index] == 2: cdata = (nlocal*nper * c_longlong)()
@@ -334,7 +334,7 @@ class CSlib:
     # tflag = 2 to return data as Numpy array
     # tflag = 3 to return data as ctypes vector
     # same usage of tflag as in pack functions
-    
+
     if tflag == 1:
       data = cdata[:nper*nlocal]
     elif tflag == 2:
@@ -353,10 +353,10 @@ class CSlib:
       data = np.ctypeslib.as_array(cdata,shape=(nlocal*nper,))
     elif tflag == 3:
       data = cdata
-      
+
     return data
 
   # extract a library value
-  
+
   def extract(self,flag):
    return self.lib.cslib_extract(self.cs,flag)
diff --git a/lib/message/cslib/src/cslib_wrap.cpp b/lib/message/cslib/src/cslib_wrap.cpp
index 44f5047037..08a768a3ac 100644
--- a/lib/message/cslib/src/cslib_wrap.cpp
+++ b/lib/message/cslib/src/cslib_wrap.cpp
@@ -31,7 +31,7 @@ using namespace CSLIB_NS;
 
 // ----------------------------------------------------------------------
 
-void cslib_open(int csflag, const char *mode, const void *ptr, 
+void cslib_open(int csflag, const char *mode, const void *ptr,
                 const void *pcomm, void **csptr)
 {
   CSlib *cs = new CSlib(csflag,mode,ptr,pcomm);
@@ -40,7 +40,7 @@ void cslib_open(int csflag, const char *mode, const void *ptr,
 
 // ----------------------------------------------------------------------
 
-void cslib_open_fortran(int csflag, const char *mode, const char *str, 
+void cslib_open_fortran(int csflag, const char *mode, const char *str,
                         const void *pcomm, void **csptr)
 {
   MPI_Comm ccomm;
@@ -48,7 +48,7 @@ void cslib_open_fortran(int csflag, const char *mode, const char *str,
 
   if (pcomm) {
     MPI_Fint *fcomm = (MPI_Fint *) pcomm;
-    ccomm = MPI_Comm_f2c(*fcomm); 
+    ccomm = MPI_Comm_f2c(*fcomm);
     pccomm = &ccomm;
   }
 
@@ -58,7 +58,7 @@ void cslib_open_fortran(int csflag, const char *mode, const char *str,
 
 // ----------------------------------------------------------------------
 
-void cslib_open_fortran_mpi_one(int csflag, const char *mode, 
+void cslib_open_fortran_mpi_one(int csflag, const char *mode,
                                 const void *pboth, const void *pcomm,
                                 void **csptr)
 {
@@ -66,11 +66,11 @@ void cslib_open_fortran_mpi_one(int csflag, const char *mode,
   void *pccomm,*pcboth;
 
   MPI_Fint *fcomm = (MPI_Fint *) pcomm;
-  ccomm = MPI_Comm_f2c(*fcomm); 
+  ccomm = MPI_Comm_f2c(*fcomm);
   pccomm = &ccomm;
 
   MPI_Fint *fboth = (MPI_Fint *) pboth;
-  cboth = MPI_Comm_f2c(*fboth); 
+  cboth = MPI_Comm_f2c(*fboth);
   pcboth = &cboth;
 
   CSlib *cs = new CSlib(csflag,mode,pcboth,pccomm);
@@ -152,8 +152,8 @@ void cslib_pack_parallel(void *ptr, int id, int ftype,
 
 // ----------------------------------------------------------------------
 
-int cslib_recv(void *ptr, int *nfield_caller, 
-	       int **fieldID_caller, int **fieldtype_caller, 
+int cslib_recv(void *ptr, int *nfield_caller,
+	       int **fieldID_caller, int **fieldtype_caller,
 	       int **fieldlen_caller)
 {
   CSlib *cs = (CSlib *) ptr;
@@ -227,7 +227,7 @@ void cslib_unpack_data(void *ptr, int id, void *data)
 
 // ----------------------------------------------------------------------
 
-void cslib_unpack_parallel(void *ptr, int id, int nlocal, int *ids, 
+void cslib_unpack_parallel(void *ptr, int id, int nlocal, int *ids,
 			   int nper, void *data)
 {
   CSlib *cs = (CSlib *) ptr;
diff --git a/lib/message/cslib/src/cslib_wrap.h b/lib/message/cslib/src/cslib_wrap.h
index bf7df029c3..a5a80c0fa3 100644
--- a/lib/message/cslib/src/cslib_wrap.h
+++ b/lib/message/cslib/src/cslib_wrap.h
@@ -22,7 +22,7 @@ extern "C" {
 
 void cslib_open(int, const char *, const void *, const void *, void **);
 void cslib_open_fortran(int, const char *, const char *, const void *, void **);
-void cslib_open_fortran_mpi_one(int, const char *, const void *, 
+void cslib_open_fortran_mpi_one(int, const char *, const void *,
                                 const void *, void **);
 void cslib_close(void *);
 
@@ -48,7 +48,7 @@ void cslib_unpack_data(void *, int, void *);
 void cslib_unpack_parallel(void *, int, int, int *, int, void *);
 
 int cslib_extract(void *, int);
-  
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/message/cslib/src/msg_file.cpp b/lib/message/cslib/src/msg_file.cpp
index 83423e7223..51c3db4c1e 100644
--- a/lib/message/cslib/src/msg_file.cpp
+++ b/lib/message/cslib/src/msg_file.cpp
@@ -32,7 +32,7 @@ using namespace CSLIB_NS;
 
 /* ---------------------------------------------------------------------- */
 
-MsgFile::MsgFile(int csflag, const void *ptr, MPI_Comm cworld) : 
+MsgFile::MsgFile(int csflag, const void *ptr, MPI_Comm cworld) :
   Msg(csflag, ptr, cworld)
 {
   char *filename = (char *) ptr;
@@ -68,14 +68,14 @@ void MsgFile::init(char *filename)
 void MsgFile::send(int nheader, int *header, int nbuf, char *buf)
 {
   char filename[MAXLINE];
-  
+
   lengths[0] = nheader;
   lengths[1] = nbuf;
-  
+
   if (me == 0) {
     if (client) sprintf(filename,"%s.%s",fileroot,"client");
     else if (server) sprintf(filename,"%s.%s",fileroot,"server");
-    
+
     fp = fopen(filename,"wb");
     if (!fp) error_one("send(): Could not open send message file");
     fwrite(lengths,sizeof(int),2,fp);
@@ -83,7 +83,7 @@ void MsgFile::send(int nheader, int *header, int nbuf, char *buf)
     fwrite(buf,1,nbuf,fp);
     fclose(fp);
   }
-  
+
   // create empty signal file
 
   if (me == 0) {
@@ -113,7 +113,7 @@ void MsgFile::recv(int &maxheader, int *&header, int &maxbuf, char *&buf)
       usleep(delay);
     }
     fclose(fp);
-  
+
     if (client) sprintf(filename,"%s.%s",fileroot,"server");
     else if (server) sprintf(filename,"%s.%s",fileroot,"client");
     fp = fopen(filename,"rb");
@@ -121,14 +121,14 @@ void MsgFile::recv(int &maxheader, int *&header, int &maxbuf, char *&buf)
   }
 
   // read and broadcast data
-  
+
   if (me == 0) fread(lengths,sizeof(int),2,fp);
   if (nprocs > 1) MPI_Bcast(lengths,2,MPI_INT,0,world);
 
   int nheader = lengths[0];
   int nbuf = lengths[1];
   allocate(nheader,maxheader,header,nbuf,maxbuf,buf);
-  
+
   if (me == 0) fread(header,sizeof(int),nheader,fp);
   if (nprocs > 1) MPI_Bcast(header,nheader,MPI_INT,0,world);
 
diff --git a/lib/message/cslib/src/msg_mpi_one.cpp b/lib/message/cslib/src/msg_mpi_one.cpp
index 1837c06ce7..3c9d6bab14 100644
--- a/lib/message/cslib/src/msg_mpi_one.cpp
+++ b/lib/message/cslib/src/msg_mpi_one.cpp
@@ -29,7 +29,7 @@ using namespace CSLIB_NS;
 
 /* ---------------------------------------------------------------------- */
 
-MsgMPIOne::MsgMPIOne(int csflag, const void *ptr, MPI_Comm cworld) : 
+MsgMPIOne::MsgMPIOne(int csflag, const void *ptr, MPI_Comm cworld) :
   Msg(csflag, ptr, cworld)
 {
   // NOTE: ideally would skip this call if mpi/two
diff --git a/lib/message/cslib/src/msg_mpi_two.cpp b/lib/message/cslib/src/msg_mpi_two.cpp
index fefdb42ec9..cd70cd9f66 100644
--- a/lib/message/cslib/src/msg_mpi_two.cpp
+++ b/lib/message/cslib/src/msg_mpi_two.cpp
@@ -29,7 +29,7 @@ using namespace CSLIB_NS;
 
 /* ---------------------------------------------------------------------- */
 
-MsgMPITwo::MsgMPITwo(int csflag, const void *ptr, MPI_Comm cworld) : 
+MsgMPITwo::MsgMPITwo(int csflag, const void *ptr, MPI_Comm cworld) :
   MsgMPIOne(csflag, ptr, cworld)
 {
   char *filename = (char *) ptr;
@@ -61,14 +61,14 @@ void MsgMPITwo::init(char *filename)
       //printf("Client port: %s\n",port);
       fclose(fp);
     }
-  
+
     MPI_Bcast(port,MPI_MAX_PORT_NAME,MPI_CHAR,0,world);
-    MPI_Comm_connect(port,MPI_INFO_NULL,0,world,&bothcomm); 
+    MPI_Comm_connect(port,MPI_INFO_NULL,0,world,&bothcomm);
     //if (me == 0) printf("CLIENT comm connect\n");
     if (me == 0) unlink(filename);
 
   } else if (server) {
-    MPI_Open_port(MPI_INFO_NULL,port); 
+    MPI_Open_port(MPI_INFO_NULL,port);
 
     if (me == 0) {
       //printf("Server name: %s\n",port);
@@ -76,8 +76,8 @@ void MsgMPITwo::init(char *filename)
       fprintf(fp,"%s",port);
       fclose(fp);
     }
-    
-    MPI_Comm_accept(port,MPI_INFO_NULL,0,world,&bothcomm); 
+
+    MPI_Comm_accept(port,MPI_INFO_NULL,0,world,&bothcomm);
     //if (me == 0) printf("SERVER comm accept\n");
   }
 
diff --git a/lib/message/cslib/src/msg_zmq.cpp b/lib/message/cslib/src/msg_zmq.cpp
index 5e57548b69..76875e5051 100644
--- a/lib/message/cslib/src/msg_zmq.cpp
+++ b/lib/message/cslib/src/msg_zmq.cpp
@@ -65,7 +65,7 @@ void MsgZMQ::init(char *port)
     char *socket_name = new char[n];
     strcpy(socket_name,"tcp://");
     strcat(socket_name,port);
-  
+
     if (client) {
       context = zmq_ctx_new();
       socket = zmq_socket(context,ZMQ_REQ);
diff --git a/lib/molfile/README b/lib/molfile/README
index 9960b5a836..ccdce2fc7f 100644
--- a/lib/molfile/README
+++ b/lib/molfile/README
@@ -10,7 +10,7 @@ NOTE: while the programming interface (API) of the VMD molfile plugins
 is backward compatible (i.e. you can expect to be able to compile this
 package for plugins from newer VMD packages), the binary interface
 (ABI) is not.  So it is necessary to compile this package with the
-VMD molfile plugin header files (vmdplugin.h and molfile_plugin.h) 
+VMD molfile plugin header files (vmdplugin.h and molfile_plugin.h)
 matching VMD installation that the (binary) plugin files are taken from.
 These header files can be found inside the VMD installation tree under
 "plugins/include". For convenience, this package includes a set of
diff --git a/lib/pace/Install.py b/lib/pace/Install.py
index 140d65c819..e90ae8c312 100644
--- a/lib/pace/Install.py
+++ b/lib/pace/Install.py
@@ -19,8 +19,8 @@ version = 'v.2021.4.9'
 
 # known checksums for different PACE versions. used to validate the download.
 checksums = { \
-        'v.2021.2.3.upd2' : '8fd1162724d349b930e474927197f20d', 
-        'v.2021.4.9'      : '4db54962fbd6adcf8c18d46e1798ceb5',          
+        'v.2021.2.3.upd2' : '8fd1162724d349b930e474927197f20d',
+        'v.2021.4.9'      : '4db54962fbd6adcf8c18d46e1798ceb5',
         }
 
 
@@ -33,8 +33,8 @@ parser = ArgumentParser(prog='Install.py',
 HELP = """
 Syntax from src dir: make lib-pace args="-b"
                  or: make lib-pace args="-b -v version"
-Syntax from lib dir: python Install.py -b 
-                 or: python Install.py -b -v version 
+Syntax from lib dir: python Install.py -b
+                 or: python Install.py -b -v version
 
 Examples:
 
diff --git a/lib/poems/README b/lib/poems/README
index e0ded85e46..1db3a66e89 100644
--- a/lib/poems/README
+++ b/lib/poems/README
@@ -27,7 +27,7 @@ Rudranarayan Mukherjee (mukher@rpi.edu) - include "[POEMS]" in the subject
 
 or by mail:
 Prof. Kurt S. Anderson
-4006 Jonsson Engineering Center 	
+4006 Jonsson Engineering Center
 Rensselaer Polytechnic Institute
 110 8th Street,
 Troy, NY 12180-3510, U.S.A.
@@ -53,8 +53,8 @@ make -f Makefile.g++
 When you are done building this library, two files should
 exist in this directory:
 
-libpoems.a		the library LAMMPS will link against
-Makefile.lammps		settings the LAMMPS Makefile will import
+libpoems.a              the library LAMMPS will link against
+Makefile.lammps         settings the LAMMPS Makefile will import
 
 Makefile.lammps is created by the make command, by copying one of the
 Makefile.lammps.* files.  See the EXTRAMAKE setting at the top of the
diff --git a/lib/poems/bodies.h b/lib/poems/bodies.h
index e47a4c80e5..8169cc0ae6 100644
--- a/lib/poems/bodies.h
+++ b/lib/poems/bodies.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: bodies.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/body.cpp b/lib/poems/body.cpp
index 4ef05dd1e6..1fc31243c8 100644
--- a/lib/poems/body.cpp
+++ b/lib/poems/body.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: body.cpp                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 #include "bodies.h"
 #include "point.h"
 
diff --git a/lib/poems/body.h b/lib/poems/body.h
index f8e0f6a5a3..b8c045094d 100644
--- a/lib/poems/body.h
+++ b/lib/poems/body.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: body.h                                                  *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 
 #ifndef BODY_H
 #define BODY_H
@@ -33,7 +33,7 @@ enum BodyType {
   PARTICLE = 1,
   RIGIDBODY = 2
 };
-  
+
 class Point;
 class Joint;
 class CompBody;
@@ -42,7 +42,7 @@ class Body : public POEMSObject {
 public:
   double mass;
   Mat3x3 inertia;
-  
+
   Vect3 r;
   Vect3 v;
   Vect3 v_k;
@@ -54,13 +54,13 @@ public:
   Vect3 alpha;
   Vect3 alpha_t;
   double KE;
-  
+
 
   List joints;
   List points;
 
   Body();
-  
+
   bool ReadIn(std::istream& in);
   void WriteOut(std::ostream& out);
   bool ReadInPoints(std::istream& in);
@@ -68,7 +68,7 @@ public:
   Point* GetPoint(int p);
   void AddJoint(Joint* joint);
   void AddPoint(Point* point);
-  
+
   virtual bool ReadInBodyData(std::istream& in) = 0;
   virtual void WriteOutBodyData(std::ostream& out) = 0;
   virtual ~Body();
diff --git a/lib/poems/body23joint.cpp b/lib/poems/body23joint.cpp
index 8cd0a95bca..2f024a9a58 100644
--- a/lib/poems/body23joint.cpp
+++ b/lib/poems/body23joint.cpp
@@ -2,8 +2,8 @@
  *_________________________________________________________________________*
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
- *      FILE NAME: body23joint.cpp			                                       *
- *      AUTHORS: See Author List                                           * 
+ *      FILE NAME: body23joint.cpp                                         *
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 
 #include "body23joint.h"
 #include "point.h"
@@ -45,15 +45,15 @@ void Body23Joint::WriteOutJointData(std::ostream& out){
 }
 
 Matrix Body23Joint::GetForward_sP(){
-	Vect3 temp = -(point2->position);  // This is vector from joint to CM
-	Matrix sP(6,2);
-	sP.Zeros();
-	
-	sP(2,1) =1.0;
-	sP(3,2) =1.0;	
-	sP(5,2) = temp(1);
-	sP(6,1) = -temp(1);	
-	return sP;    
+  Vect3 temp = -(point2->position);  // This is vector from joint to CM
+  Matrix sP(6,2);
+  sP.Zeros();
+
+  sP(2,1) =1.0;
+  sP(3,2) =1.0;
+  sP(5,2) = temp(1);
+  sP(6,1) = -temp(1);
+  return sP;
 }
 
 void Body23Joint::UpdateForward_sP( Matrix& sP){
@@ -62,132 +62,132 @@ void Body23Joint::UpdateForward_sP( Matrix& sP){
 }
 
 Matrix Body23Joint::GetBackward_sP(){
-	cout<<" -----------"<position);  // This is vector from CM to joint 
-	Matrix sP(6,2);
-	sP.Zeros();
-	sP(2,1) =1.0;
-	sP(3,2) =1.0;
-	
-	sP(5,2) = temp(1);
-	sP(6,1) = -temp(1);
-	
-	return sP;    
+  cout<<" -----------"<position);  // This is vector from CM to joint
+  Matrix sP(6,2);
+  sP.Zeros();
+  sP(2,1) =1.0;
+  sP(3,2) =1.0;
+
+  sP(5,2) = temp(1);
+  sP(6,1) = -temp(1);
+
+  return sP;
 }
 
-void Body23Joint::UpdateBackward_sP( Matrix& sP){  
+void Body23Joint::UpdateBackward_sP( Matrix& sP){
   // sP is constant, do nothing.
 }
 
 void Body23Joint::ComputeLocalTransform(){
-	Mat3x3 ko_C_k;
-	// Obtain the transformation matrix from euler parameters
-	EP_Transformation(q, ko_C_k);
-	FastMult(pk_C_ko,ko_C_k,pk_C_k);
-	}  
+  Mat3x3 ko_C_k;
+  // Obtain the transformation matrix from euler parameters
+  EP_Transformation(q, ko_C_k);
+  FastMult(pk_C_ko,ko_C_k,pk_C_k);
+  }
 
 
 void Body23Joint::ForwardKinematics(){
   Vect3 result1,result2,result3,result4,result5;
   Vect3 pk_w_k;
-  
-  
+
+
   //cout<<"Check in spherical "<position,result1); // parents basis      
-  FastAdd(result1,point1->position,r12);      
-  
-  // compute position vector r21 
-  FastNegMult(k_C_pk,r12,r21); 
+  ComputeForwardTransforms();
+
 
-  
   //----------------------------------//
-  // COMPUTE GLOBAL LOCATION  
-  FastMult(body1->n_C_k,(body1->GetPoint(2))->position,result1);    
-  FastAdd(result1,body1->r,result1);  
-  FastNegMult(body2->n_C_k,(body2->GetPoint(1))->position,result2);  
-  FastAdd(result1,result2,body2->r);  
-    
+  // COMPUTE POSITION VECTOR R12 aka GAMMA
+
+  FastNegMult(pk_C_k,point2->position,result1); // parents basis
+  FastAdd(result1,point1->position,r12);
+
+  // compute position vector r21
+  FastNegMult(k_C_pk,r12,r21);
+
+
+  //----------------------------------//
+  // COMPUTE GLOBAL LOCATION
+  FastMult(body1->n_C_k,(body1->GetPoint(2))->position,result1);
+  FastAdd(result1,body1->r,result1);
+  FastNegMult(body2->n_C_k,(body2->GetPoint(1))->position,result2);
+  FastAdd(result1,result2,body2->r);
+
   ColMatrix temp_u(3);
-  qdot_to_u(q, temp_u, qdot);  
-  
-  temp_u(1)=0.0; 
+  qdot_to_u(q, temp_u, qdot);
+
+  temp_u(1)=0.0;
   u(1) = temp_u(2);
   u(2) = temp_u(3);
-  
 
-  //-----------------------------------  
-  // angular velocities  
-  
+
+  //-----------------------------------
+  // angular velocities
+
   FastAssign(temp_u,pk_w_k);
-  FastTMult(pk_C_k,body1->omega_k,result1);        
+  FastTMult(pk_C_k,body1->omega_k,result1);
   FastAdd(result1,pk_w_k,body2->omega_k);
-  FastMult(body2->n_C_k,body2->omega_k,body2->omega);  // June 1 checked with Lammps       
-  //-----------------------------------  
-  
-  // compute velocities  
-  FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);  
+  FastMult(body2->n_C_k,body2->omega_k,body2->omega);  // June 1 checked with Lammps
+  //-----------------------------------
+
+  // compute velocities
+  FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);
   FastAdd(body1->v_k,result1,result2);
-  FastTMult(pk_C_k,result2,result1); // In body basis  
-  
-  FastCross((body2->GetPoint(1))->position,body2->omega_k,result2);                   
-  FastAdd(result1,result2,body2->v_k);    // In body basis   
-  FastMult(body2->n_C_k,body2->v_k,body2->v); 
-  
+  FastTMult(pk_C_k,result2,result1); // In body basis
+
+  FastCross((body2->GetPoint(1))->position,body2->omega_k,result2);
+  FastAdd(result1,result2,body2->v_k);    // In body basis
+  FastMult(body2->n_C_k,body2->v_k,body2->v);
+
   //------------------------------------------
-  //Compute the KE   
+  //Compute the KE
   Matrix tempke;
-  tempke = T(body2->v_k)*(body2->v_k);    
+  tempke = T(body2->v_k)*(body2->v_k);
   double ke = 0.0;
-  ke = body2->mass*tempke(1,1);    
+  ke = body2->mass*tempke(1,1);
   FastMult(body2->inertia,body2->omega_k,result1);
-  tempke= T(body2->omega_k)*result1;  
+  tempke= T(body2->omega_k)*result1;
   ke = 0.5*ke + 0.5*tempke(1,1);
   body2->KE=ke;
-  
-  //-----------------------------------  
-  // compute state explicit angular acceleration  // Has to be in body basis    
-  FastTMult(pk_C_k,body1->alpha_t,result2);  
+
+  //-----------------------------------
+  // compute state explicit angular acceleration  // Has to be in body basis
+  FastTMult(pk_C_k,body1->alpha_t,result2);
   FastCross(body2->omega_k,pk_w_k,result1);
-  FastAdd(result1,result2,body2->alpha_t); 
-   
-  //-----------------------------------  
-  // compute state explicit acceleration   
-  // NEED TO DO THIS COMPLETELY IN BODY BASIS 
-  
+  FastAdd(result1,result2,body2->alpha_t);
+
+  //-----------------------------------
+  // compute state explicit acceleration
+  // NEED TO DO THIS COMPLETELY IN BODY BASIS
+
   FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);
-  FastCross(body1->omega_k,result1,result2); 
-  FastTMult(pk_C_k,result2,result1); 
-  
-  //FastCross(body2->omega_k,-(body2->GetPoint(1))->position,result3);  
-  FastCross((body2->GetPoint(1))->position,body2->omega_k,result3);  
-  FastCross(body2->omega_k,result3,result2);    
-  FastAdd(result1,result2,result3); //wxwxr in body basis  
-  
-  FastCross(body1->alpha_t,(body1->GetPoint(2))->position,result4); 
-    
-  FastTMult(pk_C_k,result4,result5);  
+  FastCross(body1->omega_k,result1,result2);
+  FastTMult(pk_C_k,result2,result1);
+
+  //FastCross(body2->omega_k,-(body2->GetPoint(1))->position,result3);
+  FastCross((body2->GetPoint(1))->position,body2->omega_k,result3);
+  FastCross(body2->omega_k,result3,result2);
+  FastAdd(result1,result2,result3); //wxwxr in body basis
+
+  FastCross(body1->alpha_t,(body1->GetPoint(2))->position,result4);
+
+  FastTMult(pk_C_k,result4,result5);
   FastAssign(result5,result4);
-  
-  FastCross((body2->GetPoint(1))->position,body2->alpha_t,result2);   
-  FastAdd(result2,result4,result1); //alphaxr in body basis  
-  
+
+  FastCross((body2->GetPoint(1))->position,body2->alpha_t,result2);
+  FastAdd(result2,result4,result1); //alphaxr in body basis
+
   FastTMult(pk_C_k,body1->a_t,result2);
-  FastTripleSum(result3,result1,result2,body2->a_t);     // in body basis  
-  
-  
-  //-----------------------------------    
+  FastTripleSum(result3,result1,result2,body2->a_t);     // in body basis
+
+
+  //-----------------------------------
 }
 
 // NOTE: NOT USING BACKWARDKINEMATICS AT PRESENT
@@ -198,13 +198,13 @@ void Body23Joint::BackwardKinematics(){
 
   // orientations
   ComputeBackwardTransforms();
-  
+
 
   // compute position vector r21
   //r21 = point2->position - k_C_pk * point1->position;
   FastMult(k_C_pk,point1->position,result1);
   FastSubt(point2->position,result1,r21);
-  
+
 
   // compute position vector r21
   FastNegMult(pk_C_k,r21,r12);
@@ -223,7 +223,7 @@ void Body23Joint::BackwardKinematics(){
   EP_Derivatives(q,u,qdot);
 
   // angular velocities
- 
+
   FastMult(body2->n_C_k,u,result2);
   FastAdd(body2->omega,result2,body1->omega);
   FastAssign(u,k_w_pk);
@@ -243,7 +243,7 @@ void Body23Joint::BackwardKinematics(){
   FastCross(body1->omega_k,k_w_pk,result1);
   FastMult(pk_C_k,body2->alpha_t,result2);
   FastAdd(result1,result2,body1->alpha_t);
-  
+
   // compute state explicit acceleration
   FastCross(body2->alpha_t,point2->position,result1);
   FastCross(body2->omega_k,point2->position,result2);
@@ -256,5 +256,5 @@ void Body23Joint::BackwardKinematics(){
   FastCross(body1->omega_k,result2,result3);
 
   FastTripleSum(result5,result1,result3,body1->a_t);
-  
+
 }
diff --git a/lib/poems/colmatmap.cpp b/lib/poems/colmatmap.cpp
index 1954e7ff15..69ec4ec1b0 100644
--- a/lib/poems/colmatmap.cpp
+++ b/lib/poems/colmatmap.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: colmatmap.cpp                                           *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -23,28 +23,28 @@
 using namespace std;
 
 ColMatMap::ColMatMap(){
-	numrows = 0;
-	elements = 0;
+  numrows = 0;
+  elements = 0;
 }
 
 ColMatMap::~ColMatMap(){
-	delete [] elements;
+  delete [] elements;
 }
 
 ColMatMap::ColMatMap(const ColMatMap& A){  // copy constructor
-	numrows = 0;
-	elements = 0;
-	Dim(A.numrows);
-	for(int i=0;inumrows) || (i<1)){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
-	return *(elements[i-1]);
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
+  return *(elements[i-1]);
 }
 
 double ColMatMap::Get_1int(int i) const{
-	if((i>numrows) || (i<1)){
-		cerr << "matrix index exceeded in Get" << endl;
-		exit(1);
-	}
-	return *(elements[i-1]);
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index exceeded in Get" << endl;
+    exit(1);
+  }
+  return *(elements[i-1]);
 }
 
 void ColMatMap::Set_1int(int i, double value){
-	if((i>numrows) || (i<1)){
-		cerr << "matrix index exceeded in Set" << endl;
-		exit(1);
-	}
-	*(elements[i-1]) = value;
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index exceeded in Set" << endl;
+    exit(1);
+  }
+  *(elements[i-1]) = value;
 }
 
 double ColMatMap::BasicGet_1int(int i) const{
-	return *(elements[i]);
+  return *(elements[i]);
 }
 
 void ColMatMap::SetElementPointer(int i, double* p){
-	elements[i] = p;
+  elements[i] = p;
 }
 
 double* ColMatMap::GetElementPointer(int i){
-	return elements[i];
+  return elements[i];
 }
 
 void ColMatMap::BasicSet_1int(int i, double value){
-	*(elements[i]) = value;
+  *(elements[i]) = value;
 }
 
 void ColMatMap::BasicIncrement_1int(int i, double value){
-	*(elements[i]) += value;
+  *(elements[i]) += value;
 }
 
 void ColMatMap::AssignVM(const VirtualMatrix& A){
-	if(A.GetNumRows() != numrows){
-		cerr << "dimension mismatch in ColMatMap assignment" << endl;
-		exit(0);
-	}
-	if( A.GetNumCols() != 1 ){
-		cerr << "error trying to write a 2D matrix to a collumn" << endl;
-		exit(1);
-	}
-	for(int i=0;i> n;
-	Dim(n);
-	for(int i=0;i> elements[i];
-	return c;
+  int n;
+  c >> n;
+  Dim(n);
+  for(int i=0;i> elements[i];
+  return c;
 }
 
 ostream& ColMatrix::WriteData(ostream& c) const{  //output
-	c << numrows << ' ';
-	for(int i=0;inumrows) || (i<1)){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
-	return elements[i-1];
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
+  return elements[i-1];
 }
 
 double ColMatrix::Get_1int(int i) const{
-	if((i>numrows) || (i<1)){
-		cerr << "matrix index exceeded in Get" << endl;
-		exit(1);
-	}
-	return elements[i-1];
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index exceeded in Get" << endl;
+    exit(1);
+  }
+  return elements[i-1];
 }
 
 void ColMatrix::Set_1int(int i, double value){
-	if((i>numrows) || (i<1)){
-		cerr << "matrix index exceeded in Set" << endl;
-		exit(1);
-	}
-	elements[i-1] = value;
+  if((i>numrows) || (i<1)){
+    cerr << "matrix index exceeded in Set" << endl;
+    exit(1);
+  }
+  elements[i-1] = value;
 }
 
 double ColMatrix::BasicGet_1int(int i) const{
-	return elements[i];
+  return elements[i];
 }
 
 double* ColMatrix::GetElementPointer(int i){
-	return &(elements[i]);
+  return &(elements[i]);
 }
 
 void ColMatrix::BasicSet_1int(int i, double value){
-	elements[i] = value;
+  elements[i] = value;
 }
 
 void ColMatrix::BasicIncrement_1int(int i, double value){
-	elements[i] += value;
+  elements[i] += value;
 }
 
 void ColMatrix::AssignVM(const VirtualMatrix& A){
-	if( A.GetNumCols() != 1 ){
-		cerr << "error trying to write a 2D matrix to a collumn" << endl;
-		exit(1);
-	}
-	Dim( A.GetNumRows() );
-	for(int i=0;i value){
-			value = elements[i];
-			index = i;
-		}
+  value = elements[0];
+  index = 0;
+  for(int i=1;i value){
+      value = elements[i];
+      index = i;
+    }
 }
 
 void ColMatrix::BasicMin(double& value, int& index){
-	value = elements[0];
-	index = 0;
-	for(int i=1;i=0;i--){
-		temp=C.rows[i][k];
-		for (j=i+1;j=0;i--){
+    temp=C.rows[i][k];
+    for (j=i+1;j=0;i--){
-		temp=C.rows[i][k];
-		for (j=i+1;j=0;i--){
+    temp=C.rows[i][k];
+    for (j=i+1;j=0;i--){
-		temp=C.rows[i][k];
-		for (j=i+1;j=0;i--){
+    temp=C.rows[i][k];
+    for (j=i+1;j=0;i--){
-		temp=C.rows[i][k];
-		for (j=i+1;j=0;i--){
+    temp=C.rows[i][k];
+    for (j=i+1;j=0;i--){
-		temp=C_temp.rows[k][i];
-		for (j=i+1;j=0;i--){
+    temp=C_temp.rows[k][i];
+    for (j=i+1;j
-   
+
 
 FreeBodyJoint::FreeBodyJoint(){
-  DimQandU(7,6);  
+  DimQandU(7,6);
 }
 
 FreeBodyJoint::~FreeBodyJoint(){
@@ -45,112 +45,112 @@ void FreeBodyJoint::WriteOutJointData(std::ostream& out){
 }
 
 void FreeBodyJoint::ComputeLocalTransform(){
-  Mat3x3 ko_C_k;  
-  EP_Transformation(q, ko_C_k);   
-  FastMult(pk_C_ko,ko_C_k,pk_C_k);  
+  Mat3x3 ko_C_k;
+  EP_Transformation(q, ko_C_k);
+  FastMult(pk_C_ko,ko_C_k,pk_C_k);
 }
 
 Matrix FreeBodyJoint::GetForward_sP(){
   Mat6x6 sP;
-  //sP.Identity();      
-  
-  sP.Zeros();  
+  //sP.Identity();
+
+  sP.Zeros();
   Mat3x3 temp0=T(pk_C_k);
   for(int i=1;i<4;i++){
-	  sP(i,i)=1.0;
-	  for(int j=1;j<4;j++){
-		  sP(3+i,3+j)=temp0(i,j);
-		  }
-	  } 	  	  
-  return sP;    
+    sP(i,i)=1.0;
+    for(int j=1;j<4;j++){
+      sP(3+i,3+j)=temp0(i,j);
+      }
+    }
+  return sP;
 }
 
 Matrix FreeBodyJoint::GetBackward_sP(){
   Mat6x6 sP;
-  sP.Identity();        
+  sP.Identity();
   sP =-1.0*sP;
   cout<<"Did I come here in "<r);  
-    
-  //COMMENT STEP3: CALCULATE QDOT  
+
+  FastAssign(r12,body2->r);
+
+  //COMMENT STEP3: CALCULATE QDOT
   qdot_to_u(q, u, qdot);
-  
-  
+
+
   Vect3 WN;
   WN.BasicSet(0,u.BasicGet(0));
   WN.BasicSet(1,u.BasicGet(1));
   WN.BasicSet(2,u.BasicGet(2));
-    
-  Vect3 VN; 
+
+  Vect3 VN;
   VN.BasicSet(0,u.BasicGet(3));
   VN.BasicSet(1,u.BasicGet(4));
-  VN.BasicSet(2,u.BasicGet(5));  
-    
-  FastAssign(WN,body2->omega_k);  
- 
-  Vect3 pk_w_k;
-  FastMult(body2->n_C_k,WN,pk_w_k);      
-  FastAssign(pk_w_k,body2->omega);
-  
+  VN.BasicSet(2,u.BasicGet(5));
+
+  FastAssign(WN,body2->omega_k);
+
+  Vect3 pk_w_k;
+  FastMult(body2->n_C_k,WN,pk_w_k);
+  FastAssign(pk_w_k,body2->omega);
+
+
+
+  //COMMENT STEP5: CALCULATE VELOCITES
+  FastAssign(VN,body2->v);
+  FastTMult(body2->n_C_k,body2->v,body2->v_k);
+
+
+  //CALCULATE KE
 
-  
-  //COMMENT STEP5: CALCULATE VELOCITES        
-  FastAssign(VN,body2->v);    
-  FastTMult(body2->n_C_k,body2->v,body2->v_k);        
-  
-  
-  //CALCULATE KE          
- 
   Matrix tempke;
-  tempke = T(body2->v)*(body2->v);    
+  tempke = T(body2->v)*(body2->v);
   double ke = 0.0;
-  ke = body2->mass*tempke(1,1);  
+  ke = body2->mass*tempke(1,1);
   FastMult(body2->inertia,body2->omega_k,result1);
-  tempke= T(body2->omega_k)*result1;  
+  tempke= T(body2->omega_k)*result1;
   ke = 0.5*ke + 0.5*tempke(1,1);
   body2->KE=ke;
- 
-  
+
+
   //COMMENT STEP6: CALCULATE STATE EXPLICIT ANGULAR ACCELERATIONS
   body2->alpha_t.Zeros();
-    
-    
+
+
   //COMMENT STEP7: CALCULATE STATE EXPLICIT ACCELERATIONS
-  body2->a_t.Zeros();   
-  
+  body2->a_t.Zeros();
+
   }
 
 void FreeBodyJoint::BackwardKinematics(){
 cout<<"Did I come here "<>setprecision(20)>> qo >> setprecision(20)>>qdoto >> setprecision(20)>>pk_C_ko; 
+  in >>setprecision(20)>> qo >> setprecision(20)>>qdoto >> setprecision(20)>>pk_C_ko;
   q = qo;
   qdot = qdoto;
   EP_Normalize(q);
-  
+
   return ReadInJointData(in);
 }
 
 void Joint::ResetQdot(){
-  //EP_Derivatives(q,u,qdot);  
+  //EP_Derivatives(q,u,qdot);
   qdot_to_u(q,u,qdot);
 }
 
 void Joint::ResetQ(){
-  EP_Normalize(q); 
+  EP_Normalize(q);
 }
 
 void Joint::SetInitialState(ColMatrix& a, ColMatrix& adot){
   if( (qo.GetNumRows() != a.GetNumRows()) || (qdoto.GetNumRows() != adot.GetNumRows()) ){
-	  cout<n_C_k = body1->n_C_k * pk_C_k;
-  FastMult(body1->n_C_k,pk_C_k,body2->n_C_k);   
+  FastMult(body1->n_C_k,pk_C_k,body2->n_C_k);
   }
 
 void Joint::ComputeBackwardGlobalTransform(){
@@ -241,8 +241,8 @@ Joint* NewJoint(int type){
     case REVOLUTEJOINT : return new RevoluteJoint;
     case PRISMATICJOINT : return new PrismaticJoint;
     case SPHERICALJOINT : return new SphericalJoint;
-	 case BODY23JOINT : return new Body23Joint;
-	 case MIXEDJOINT : return new MixedJoint;
+   case BODY23JOINT : return new Body23Joint;
+   case MIXEDJOINT : return new MixedJoint;
     default : return 0; // error
   }
 }
diff --git a/lib/poems/joints.h b/lib/poems/joints.h
index 240a272bdd..0d8dc71626 100644
--- a/lib/poems/joints.h
+++ b/lib/poems/joints.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: joints.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/mat3x3.cpp b/lib/poems/mat3x3.cpp
index df24d4b108..f8dc8928bb 100644
--- a/lib/poems/mat3x3.cpp
+++ b/lib/poems/mat3x3.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat3x3.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -42,7 +42,7 @@ Mat3x3::Mat3x3(const VirtualMatrix& A){
     cerr << "illegal matrix size" << endl;
     exit(0);
   }
-  
+
   for(int i=0;i<3;i++)
     for(int j=0;j<3;j++)
       elements[i][j] = A.BasicGet(i,j);
diff --git a/lib/poems/mat3x3.h b/lib/poems/mat3x3.h
index 4362b3ad9c..b7c0e2dffa 100644
--- a/lib/poems/mat3x3.h
+++ b/lib/poems/mat3x3.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat3x3.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -68,16 +68,16 @@ public:
   friend void FastMult(Mat3x3& A, Mat3x3& B, Mat3x3& C);
   friend void FastMultT(Mat3x3& A, Mat3x3& B, Mat3x3& C);
   friend void FastAssignT(Mat3x3& A, Mat3x3& C);
-  friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C);  
-  
+  friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C);
+
   friend void OnPopulateSC(Vect3& gamma, Mat3x3& C, Mat6x6& SC);
   friend void OnPopulateSI(Mat3x3& inertia, double mass, Mat6x6& sI);
 
   friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C);
-  
+
   friend void EP_Transformation(ColMatrix& q, Mat3x3& C);
   friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C);
-  
+
 };
 
 #endif
diff --git a/lib/poems/mat4x4.cpp b/lib/poems/mat4x4.cpp
index 4a611a6796..086637282b 100644
--- a/lib/poems/mat4x4.cpp
+++ b/lib/poems/mat4x4.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat4x4.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -42,7 +42,7 @@ Mat4x4::Mat4x4(const VirtualMatrix& A){
     cerr << "illegal matrix size" << endl;
     exit(0);
   }
-  
+
   for(int i=0;i<4;i++)
     for(int j=0;j<4;j++)
       elements[i][j] = A.BasicGet(i,j);
diff --git a/lib/poems/mat4x4.h b/lib/poems/mat4x4.h
index d7942b248e..aac09a67af 100644
--- a/lib/poems/mat4x4.h
+++ b/lib/poems/mat4x4.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat4x4.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -26,12 +26,12 @@ class Vect4;
 
 class Mat4x4 : public VirtualMatrix  {
   double elements[4][4];
-public: 
+public:
   Mat4x4();
   ~Mat4x4();
   Mat4x4(const Mat4x4& A);  // copy constructor
   Mat4x4(const VirtualMatrix& A);  // copy constructor
-  
+
   double& operator_2int (int i, int j); // array access
   double Get_2int(int i, int j) const;
   void Set_2int(int i, int j, double value);
diff --git a/lib/poems/mat6x6.cpp b/lib/poems/mat6x6.cpp
index 16bffc5026..b79c0490fc 100644
--- a/lib/poems/mat6x6.cpp
+++ b/lib/poems/mat6x6.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat6x6.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/mat6x6.h b/lib/poems/mat6x6.h
index 11951b0442..35f0974657 100644
--- a/lib/poems/mat6x6.h
+++ b/lib/poems/mat6x6.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: mat6x6.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/matrices.h b/lib/poems/matrices.h
index 7a7e2c4b58..ff7dddd3e6 100644
--- a/lib/poems/matrices.h
+++ b/lib/poems/matrices.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: matrices.h                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/matrix.cpp b/lib/poems/matrix.cpp
index f05d6f815c..31c141bff7 100644
--- a/lib/poems/matrix.cpp
+++ b/lib/poems/matrix.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: matrix.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/matrix.h b/lib/poems/matrix.h
index 63699b9835..c34f8677cc 100644
--- a/lib/poems/matrix.h
+++ b/lib/poems/matrix.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: matrix.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -71,7 +71,7 @@ public:
   friend void FastMult(Mat6x6& A, Matrix& B, Matrix& C);
   friend void FastMult(Matrix& A, ColMatrix& B, Vect6& C);
   friend void FastMultT(Matrix& A, Matrix& B, Mat6x6& C);
-  
+
 };
 
 #endif
diff --git a/lib/poems/matrixfun.cpp b/lib/poems/matrixfun.cpp
index 9aa2818555..9c20d7cac9 100644
--- a/lib/poems/matrixfun.cpp
+++ b/lib/poems/matrixfun.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: matrixfun.cpp                                           *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -31,11 +31,11 @@ VirtualMatrix* NewMatrix(int type){
     {
       case MATRIX : return new Matrix;
       case COLMATRIX : return new ColMatrix;
-      case ROWMATRIX : return new RowMatrix;		
+      case ROWMATRIX : return new RowMatrix;
       case MAT3X3 : return new Mat3x3;
-		case MAT4X4 : return new Mat4x4;
+    case MAT4X4 : return new Mat4x4;
       case VECT3 : return new Vect3;
-		case VECT4 : return new Vect4;
+    case VECT4 : return new Vect4;
       default  : return 0; // error!
     }
 }
@@ -45,76 +45,76 @@ VirtualMatrix* NewMatrix(int type){
 //
 
 Matrix T(const VirtualMatrix& A){
-	int numrows = A.GetNumRows();
-	int numcols = A.GetNumCols();
-	Matrix C(numcols,numrows);
-	for(int i=0;i 1)
-		EP_Normalize(q);
+}
+
+void MixedJoint::ForwardKinematics(){
+  if(numrots > 1)
+    EP_Normalize(q);
 
   // COMMENT STEP1: CALCULATE ORIENTATIONS
-  ComputeForwardTransforms();  
-  
-    
+  ComputeForwardTransforms();
+
+
   //COMMENT STEP2: CALCULATE POSITION VECTORS
-  Vect3 result1, result2, result3, result4;   
+  Vect3 result1, result2, result3, result4;
   result1.Zeros();
   for (int k=0; k<3; k++){
-	  if( dofs(3+k) != 0.0 ){
-		  if (numrots > 1)
-			  result1.BasicSet(k,q.BasicGet(4 + k));
-		  else
-			  result1.BasicSet(k,q.BasicGet(numrots + k));
-	  }  
+    if( dofs(3+k) != 0.0 ){
+      if (numrots > 1)
+        result1.BasicSet(k,q.BasicGet(4 + k));
+      else
+        result1.BasicSet(k,q.BasicGet(numrots + k));
+    }
   }
-    
-  
-  
-  FastAssign(result1,r12);     // r12 in parents basis  i.e. Newtonian  
-  FastNegMult(k_C_pk,r12,r21);	    // r21 in body basis           
-  
-  FastAssign(r12,body2->r);  // This is right     
-    
-  //COMMENT STEP3: CALCULATE QDOT  
+
+
+
+  FastAssign(result1,r12);     // r12 in parents basis  i.e. Newtonian
+  FastNegMult(k_C_pk,r12,r21);      // r21 in body basis
+
+  FastAssign(r12,body2->r);  // This is right
+
+  //COMMENT STEP3: CALCULATE QDOT
   int pp = 0;
   if (numrots > 1){
-	  ColMatrix temp_u(3+numtrans);
-	  qdot_to_u(q,temp_u,qdot);
-	  for (int k=1;k<=6;k++){
-		  if(dofs(k) != 0.0){
-			  u.BasicSet(pp,temp_u.BasicGet(k-1));			  
-			  pp = pp+1;
-		  }		  
-	  }
+    ColMatrix temp_u(3+numtrans);
+    qdot_to_u(q,temp_u,qdot);
+    for (int k=1;k<=6;k++){
+      if(dofs(k) != 0.0){
+        u.BasicSet(pp,temp_u.BasicGet(k-1));
+        pp = pp+1;
+      }
+    }
   }
   else u = qdot;
 
-  
-  
+
+
   Vect3 WN; WN.Zeros();
   int p = 0;
   for (int k=0;k<3;k++){
-	  if(dofs(k+1) != 0.0){
-		  WN.BasicSet(k,u.BasicGet(p));
-		  p=p+1;
-	  }
+    if(dofs(k+1) != 0.0){
+      WN.BasicSet(k,u.BasicGet(p));
+      p=p+1;
+    }
   }// WN is in body basis
 
-  
-  Vect3 VN; VN.Zeros();  
-  for (int k=0;k<3;k++){
-	  if( dofs(3+k+1) != 0.0 ) {
-		  VN.BasicSet(k,u.BasicGet(p));
-		  p=p+1;
-	  }
-  }// VN is the vector of translational velocities in Newtonian basis
-    
-  FastAssign(WN,body2->omega_k);  
 
-  // cout<<"Angular Velocity "<omega_k);
+
+  // cout<<"Angular Velocity "<n_C_k,WN,pk_w_k);      
+  FastMult(body2->n_C_k,WN,pk_w_k);
   FastAssign(pk_w_k,body2->omega);
-  
-  
-  
-  //COMMENT STEP5: CALCULATE VELOCITES        
-  FastAssign(VN,body2->v);    
-  FastTMult(body2->n_C_k,body2->v,body2->v_k);        
-  
-  
-  //CALCULATE KE          
- 
+
+
+
+  //COMMENT STEP5: CALCULATE VELOCITES
+  FastAssign(VN,body2->v);
+  FastTMult(body2->n_C_k,body2->v,body2->v_k);
+
+
+  //CALCULATE KE
+
   Matrix tempke;
-  tempke = T(body2->v)*(body2->v);    
+  tempke = T(body2->v)*(body2->v);
   double ke = 0.0;
-  ke = body2->mass*tempke(1,1);    
+  ke = body2->mass*tempke(1,1);
   FastMult(body2->inertia,body2->omega_k,result1);
-  tempke= T(body2->omega_k)*result1;  
+  tempke= T(body2->omega_k)*result1;
   ke = 0.5*ke + 0.5*tempke(1,1);
   body2->KE=ke;
-  
-  
+
+
   //COMMENT STEP6: CALCULATE STATE EXPLICIT ANGULAR ACCELERATIONS
   body2->alpha_t.Zeros();
-      
-    
+
+
   //COMMENT STEP7: CALCULATE STATE EXPLICIT ACCELERATIONS
-  body2->a_t.Zeros();   
-  
+  body2->a_t.Zeros();
+
   }
 
 void MixedJoint::BackwardKinematics(){
 cout<<"Did I come here "<GetID() ) return 0;
   ID++;
-  system_body->SetID(ID);  
+  system_body->SetID(ID);
 
   // setup inertial frame
   SetupInertialFrame();
@@ -68,7 +68,7 @@ int OnBody::RecursiveSetup (InertialFrame* basebody){
     tempID = child->RecursiveSetup(ID,this,joint);
     if( tempID ){
       children.Append(child);
-      ID = tempID;      
+      ID = tempID;
     }
     else delete child;
 
@@ -80,14 +80,14 @@ int OnBody::RecursiveSetup (InertialFrame* basebody){
 
 int OnBody::RecursiveSetup(int ID, OnBody* parentbody, Joint* sys_joint){
   // initialize the topology and system analogs
-  parent = parentbody;  
+  parent = parentbody;
   system_joint = sys_joint;
   system_body = system_joint->OtherBody(parentbody->system_body);
-  
-    
+
+
   // record that the traversal algorithm has been here
   if( system_body->GetID() ) return 0;
-  ID++;  
+  ID++;
 
   // perform the local setup operations
   Setup();
@@ -114,7 +114,7 @@ int OnBody::RecursiveSetup(int ID, OnBody* parentbody, Joint* sys_joint){
     ele = ele->next;
   }
 
-  return ID;  
+  return ID;
 }
 
 void OnBody::SetupInertialFrame(){
@@ -123,26 +123,26 @@ void OnBody::SetupInertialFrame(){
     cerr << "ERROR: attempting to setup inertial frame for non-inertial body" << endl;
     exit(1);
   }
-  
+
   // setup gravity
-  Vect3 neg_gravity = -((InertialFrame*) system_body)->GetGravity();  
+  Vect3 neg_gravity = -((InertialFrame*) system_body)->GetGravity();
   sAhat.Zeros();
   Set6DLinearVector(sAhat,neg_gravity);
-  
+
 }
 
 
-void OnBody::Setup(){  
-  
+void OnBody::Setup(){
+
   // get the direction of the joint
   if( system_joint->GetBody2() == system_body ) joint_dir = FORWARD;
   else joint_dir = BACKWARD;
 
   // set the function pointers for the joint direction
-  if( joint_dir == FORWARD ){    
+  if( joint_dir == FORWARD ){
     kinfun = &Joint::ForwardKinematics;
     updatesP = &Joint::UpdateForward_sP;
-    gamma = system_joint->GetR12(); 
+    gamma = system_joint->GetR12();
     pk_C_k = system_joint->Get_pkCk();
   } else {
     kinfun = &Joint::BackwardKinematics;
@@ -155,7 +155,7 @@ void OnBody::Setup(){
 
   // sI
   OnPopulateSI(system_body->inertia, system_body->mass, sI);
-	
+
   // sP
   if( joint_dir == FORWARD )
     sP = system_joint->GetForward_sP();
@@ -167,12 +167,12 @@ void OnBody::Setup(){
   sMinv = sM;
   sPsMinv = sP;
   sIhatsP = sP;
-  
+
 
   // get the state and state derivative column matrix pointers
   q = system_joint->GetQ();
   u = system_joint->GetU();
-  qdot = system_joint->GetQdot();  
+  qdot = system_joint->GetQdot();
   udot = system_joint->GetUdot();
   qdotdot = system_joint->GetQdotdot();
   }
@@ -182,13 +182,13 @@ void OnBody::RecursiveKinematics(){
   // Perform local kinematics recursively outward
   ListElement* ele = children.GetHeadElement();
   while(ele){
-    child = ele->value;    
+    child = ele->value;
     child->LocalKinematics();
     child->RecursiveKinematics();
-    Mat3x3 result=*child->pk_C_k;           
+    Mat3x3 result=*child->pk_C_k;
     ele = ele->next;
   }
-  
+
 }
 
 void OnBody::RecursiveTriangularization(){
@@ -221,7 +221,7 @@ void OnBody::LocalKinematics(){
   // do the directional kinematics
   (system_joint->*kinfun)();
   (system_joint->*updatesP)( sP );
-  OnPopulateSC( *gamma, *pk_C_k, sSC );      
+  OnPopulateSC( *gamma, *pk_C_k, sSC );
 }
 
 Mat3x3 OnBody::GetN_C_K(){
@@ -229,171 +229,171 @@ Mat3x3 nck=system_body->n_C_k;
 return nck;
 }
 
- 
+
 int OnBody::GetBodyID(){
 int ID=system_body->GetID();
 return ID;
 }
 
-Vect3 OnBody::LocalCart(){  
-  (system_joint->*kinfun)();  
-  Vect3 RR=system_body->r;  
+Vect3 OnBody::LocalCart(){
+  (system_joint->*kinfun)();
+  Vect3 RR=system_body->r;
   return RR;
 }
 
-  
-  
-void OnBody::LocalTriangularization(Vect3& Torque, Vect3& Force){	  
 
-	Vect3 Iw,wIw,Ialpha,wIwIalpha,ma,Bforce,Bforce_ma,Btorque,Btorque_wIwIalpha;
+
+void OnBody::LocalTriangularization(Vect3& Torque, Vect3& Force){
+
+  Vect3 Iw,wIw,Ialpha,wIwIalpha,ma,Bforce,Bforce_ma,Btorque,Btorque_wIwIalpha;
   Iw.Zeros();wIw.Zeros();wIwIalpha.Zeros();ma.Zeros();
-	Bforce.Zeros();Bforce_ma.Zeros();Btorque.Zeros();Btorque_wIwIalpha.Zeros();
-     
-	FastMult(system_body->inertia,system_body->omega_k,Iw);  
-	FastCross(Iw,system_body->omega_k,wIw);  
-  
-	FastMult(system_body->inertia, system_body->alpha_t, Ialpha);    
-	FastSubt(wIw,Ialpha,wIwIalpha); 
-	FastMult(-system_body->mass,system_body->a_t,ma);    
-	
-	
-	Mat3x3 k_C_n=T(system_body->n_C_k);      
-	Bforce=k_C_n*Force;
-	Btorque=k_C_n*Torque;  
-	
-	FastAdd(Bforce,ma,Bforce_ma);       
-	FastAdd(Btorque,wIwIalpha,Btorque_wIwIalpha);	  
-	OnPopulateSVect(Btorque_wIwIalpha,Bforce_ma,sF);
-  
-  
-	sIhat = sI;    
-	sFhat = sF;     
-	Mat6x6 sPsMinvsPT;
-	Mat6x6 sIhatsPsMsPT;
-	Mat6x6 sUsIhatsPsMsPT;
-	Mat6x6 sTsIhat;
-	Mat6x6 sTsIhatsSCT;
-	Vect6 sTsFhat;
-	Mat6x6 sU;
-	sU.Identity();  
-  
-	OnBody* child;
-	ListElement* ele = children.GetHeadElement();
-  
-	while(ele){
-		child = ele->value;
-    
-		FastMultT(child->sIhatsP,child->sPsMinv,sIhatsPsMsPT); 
-		FastSubt(sU,sIhatsPsMsPT,sUsIhatsPsMsPT);              
-		FastMult(child->sSC,sUsIhatsPsMsPT,child->sT);         
-        
-		FastMult(child->sT,child->sIhat,sTsIhat);
-		FastMultT(sTsIhat,child->sSC,sTsIhatsSCT); 
-		FastAdd(sIhat,sTsIhatsSCT,sIhat);
-    
-		FastMult(child->sT,child->sFhat,sTsFhat);
-		FastAdd(sFhat,sTsFhat,sFhat);            
-		ele = ele->next;
-	}  
-  
-	FastMult(sIhat,sP,sIhatsP);   
-	FastTMult(sP,sIhatsP,sM);       
-	sMinv=SymInverse(sM);    
-	FastMult(sP,sMinv,sPsMinv);	
+  Bforce.Zeros();Bforce_ma.Zeros();Btorque.Zeros();Btorque_wIwIalpha.Zeros();
+
+  FastMult(system_body->inertia,system_body->omega_k,Iw);
+  FastCross(Iw,system_body->omega_k,wIw);
+
+  FastMult(system_body->inertia, system_body->alpha_t, Ialpha);
+  FastSubt(wIw,Ialpha,wIwIalpha);
+  FastMult(-system_body->mass,system_body->a_t,ma);
+
+
+  Mat3x3 k_C_n=T(system_body->n_C_k);
+  Bforce=k_C_n*Force;
+  Btorque=k_C_n*Torque;
+
+  FastAdd(Bforce,ma,Bforce_ma);
+  FastAdd(Btorque,wIwIalpha,Btorque_wIwIalpha);
+  OnPopulateSVect(Btorque_wIwIalpha,Bforce_ma,sF);
+
+
+  sIhat = sI;
+  sFhat = sF;
+  Mat6x6 sPsMinvsPT;
+  Mat6x6 sIhatsPsMsPT;
+  Mat6x6 sUsIhatsPsMsPT;
+  Mat6x6 sTsIhat;
+  Mat6x6 sTsIhatsSCT;
+  Vect6 sTsFhat;
+  Mat6x6 sU;
+  sU.Identity();
+
+  OnBody* child;
+  ListElement* ele = children.GetHeadElement();
+
+  while(ele){
+    child = ele->value;
+
+    FastMultT(child->sIhatsP,child->sPsMinv,sIhatsPsMsPT);
+    FastSubt(sU,sIhatsPsMsPT,sUsIhatsPsMsPT);
+    FastMult(child->sSC,sUsIhatsPsMsPT,child->sT);
+
+    FastMult(child->sT,child->sIhat,sTsIhat);
+    FastMultT(sTsIhat,child->sSC,sTsIhatsSCT);
+    FastAdd(sIhat,sTsIhatsSCT,sIhat);
+
+    FastMult(child->sT,child->sFhat,sTsFhat);
+    FastAdd(sFhat,sTsFhat,sFhat);
+    ele = ele->next;
+  }
+
+  FastMult(sIhat,sP,sIhatsP);
+  FastTMult(sP,sIhatsP,sM);
+  sMinv=SymInverse(sM);
+  FastMult(sP,sMinv,sPsMinv);
 }
 
-void OnBody::LocalForwardSubstitution(){  
-	Vect6 sSCTsAhat;
-	Vect6 sIhatsSCTsAhat;
-	Vect6 sFsIhatsSCTsAhat;
-	Vect6 sPudot;
-	int type = system_joint->GetType();
-	if(type == 1){
-		FastTMult(sSC,parent->sAhat,sSCTsAhat);
-		FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);       
-		FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
-		FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);		
-  
-		ColMatrix result1=*udot;      
-		ColMatrix result2=*qdot;
-		ColMatrix result3=*q;
-		int num=result1.GetNumRows();
-		ColMatrix result4(num+1);
-		result4.Zeros();		
-		EPdotdot_udot(result1, result2, result3, result4);
-		FastAssign(result4, *qdotdot);    
-		FastMult(sP,*udot,sPudot);      
-		FastAdd(sSCTsAhat,sPudot,sAhat);		
-	}
-	else if (type == 4){		
-		FastTMult(sSC,parent->sAhat,sSCTsAhat);
-		FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);       
-		FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
-		FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);
-		
-		ColMatrix result1=*udot;      		
-		ColMatrix result2=*qdot;
-		ColMatrix result3=*q;
-		int num=result1.GetNumRows();
-		ColMatrix result4(num+1);
-		result4.Zeros();
-		
-		EPdotdot_udot(result1, result2, result3, result4);
-		FastAssign(result4, *qdotdot);    
-		FastMult(sP,*udot,sPudot);      
-		FastAdd(sSCTsAhat,sPudot,sAhat);
-	}	
-	else if (type == 5){		
-		FastTMult(sSC,parent->sAhat,sSCTsAhat);
-		FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);       
-		FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
-		FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);				
-		ColMatrix temp_u = *udot;
-		
-		ColMatrix result1(3);		
-		result1(1)=0.0;
-		result1(2)=temp_u(1);      		
-		result1(3)=temp_u(2); 		
-		ColMatrix result2=*qdot;
-		ColMatrix result3=*q;
-		int num=result1.GetNumRows();
-		ColMatrix result4(num+1);
-		result4.Zeros();
-		
-		EPdotdot_udot(result1, result2, result3, result4);		
-		FastAssign(result4, *qdotdot);    
-		FastMult(sP,*udot,sPudot);      
-		FastAdd(sSCTsAhat,sPudot,sAhat);
-	}
-	else if (type == 6){		
-		FastTMult(sSC,parent->sAhat,sSCTsAhat);
-		FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);       
-		FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
-		FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);				
-		ColMatrix temp_u = *udot;
-		int tt = temp_u.GetNumRows() + 1;
-		ColMatrix result1(tt);				
-		result1(1)=0.0;
-		for (int k =2; k<=tt; k++){
-			result1(k)=temp_u(k-1);      				
-		}			
-		ColMatrix result2=*qdot;
-		ColMatrix result3=*q;
-		int num=result1.GetNumRows();
-		ColMatrix result4(num+1);
-		result4.Zeros();
-		
-		EPdotdot_udot(result1, result2, result3, result4);		
-		FastAssign(result4, *qdotdot);    
-		FastMult(sP,*udot,sPudot);      
-		FastAdd(sSCTsAhat,sPudot,sAhat);
-	}		
-	else{
-		cout<<"Joint type not recognized in onbody.cpp LocalForwardSubsitution() "<GetType();
+  if(type == 1){
+    FastTMult(sSC,parent->sAhat,sSCTsAhat);
+    FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);
+    FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
+    FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);
+
+    ColMatrix result1=*udot;
+    ColMatrix result2=*qdot;
+    ColMatrix result3=*q;
+    int num=result1.GetNumRows();
+    ColMatrix result4(num+1);
+    result4.Zeros();
+    EPdotdot_udot(result1, result2, result3, result4);
+    FastAssign(result4, *qdotdot);
+    FastMult(sP,*udot,sPudot);
+    FastAdd(sSCTsAhat,sPudot,sAhat);
+  }
+  else if (type == 4){
+    FastTMult(sSC,parent->sAhat,sSCTsAhat);
+    FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);
+    FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
+    FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);
+
+    ColMatrix result1=*udot;
+    ColMatrix result2=*qdot;
+    ColMatrix result3=*q;
+    int num=result1.GetNumRows();
+    ColMatrix result4(num+1);
+    result4.Zeros();
+
+    EPdotdot_udot(result1, result2, result3, result4);
+    FastAssign(result4, *qdotdot);
+    FastMult(sP,*udot,sPudot);
+    FastAdd(sSCTsAhat,sPudot,sAhat);
+  }
+  else if (type == 5){
+    FastTMult(sSC,parent->sAhat,sSCTsAhat);
+    FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);
+    FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
+    FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);
+    ColMatrix temp_u = *udot;
+
+    ColMatrix result1(3);
+    result1(1)=0.0;
+    result1(2)=temp_u(1);
+    result1(3)=temp_u(2);
+    ColMatrix result2=*qdot;
+    ColMatrix result3=*q;
+    int num=result1.GetNumRows();
+    ColMatrix result4(num+1);
+    result4.Zeros();
+
+    EPdotdot_udot(result1, result2, result3, result4);
+    FastAssign(result4, *qdotdot);
+    FastMult(sP,*udot,sPudot);
+    FastAdd(sSCTsAhat,sPudot,sAhat);
+  }
+  else if (type == 6){
+    FastTMult(sSC,parent->sAhat,sSCTsAhat);
+    FastMult(sIhat,sSCTsAhat,sIhatsSCTsAhat);
+    FastSubt(sFhat,sIhatsSCTsAhat,sFsIhatsSCTsAhat);
+    FastTMult(sPsMinv,sFsIhatsSCTsAhat,*udot);
+    ColMatrix temp_u = *udot;
+    int tt = temp_u.GetNumRows() + 1;
+    ColMatrix result1(tt);
+    result1(1)=0.0;
+    for (int k =2; k<=tt; k++){
+      result1(k)=temp_u(k-1);
+    }
+    ColMatrix result2=*qdot;
+    ColMatrix result3=*q;
+    int num=result1.GetNumRows();
+    ColMatrix result4(num+1);
+    result4.Zeros();
+
+    EPdotdot_udot(result1, result2, result3, result4);
+    FastAssign(result4, *qdotdot);
+    FastMult(sP,*udot,sPudot);
+    FastAdd(sSCTsAhat,sPudot,sAhat);
+  }
+  else{
+    cout<<"Joint type not recognized in onbody.cpp LocalForwardSubsitution() "<ClearBodyIDs();
-  
+
 
   // error check for inertial frame
   Body* sysbasebody = system->bodies.GetHeadElement()->value;
@@ -72,77 +72,77 @@ void OnSolver::CreateModel(){
     cerr << "ERROR: unable to create O(n) model" << endl;
     exit(1);
   }
-  
-  
-  
+
+
+
   bodyarray = new OnBody* [numbodies];
-  
-  CreateTopologyArray(0,&inertialframe);	  
-  
-  CreateStateMatrixMaps();  
+
+  CreateTopologyArray(0,&inertialframe);
+
+  CreateStateMatrixMaps();
 }
 
 int OnSolver::CreateTopologyArray(int num, OnBody* body){
   int i = num;
-  bodyarray[i] = body;    
+  bodyarray[i] = body;
   i++;
 
-  
+
   OnBody* child;
-  ListElement* ele = body->children.GetHeadElement();    
-  
+  ListElement* ele = body->children.GetHeadElement();
+
   while(ele){
-    child = ele->value;    
+    child = ele->value;
     i = CreateTopologyArray(i,child);
-    ele = ele->next;        
-  }  
-  return i;  
+    ele = ele->next;
+  }
+  return i;
 }
 
 void OnSolver::CreateStateMatrixMaps(){
-  
-	
+
+
   int numstates=0;
-  for(int i=1;iq->GetNumRows();       
-  
+  for(int i=1;iq->GetNumRows();
+
   state.Dim(numstates);
   statedot.Dim(numstates);
-  statedoubledot.Dim(numstates); 
+  statedoubledot.Dim(numstates);
+
 
-  
   int count=0;
-  
+
   for(int i=1;iq->GetNumRows();j++){
-		  state.SetElementPointer(count,bodyarray[i]->q->GetElementPointer(j));      
-		  statedot.SetElementPointer(count,bodyarray[i]->qdot->GetElementPointer(j));        	
-		  statedoubledot.SetElementPointer(count,bodyarray[i]->qdotdot->GetElementPointer(j));       
-		  count++;      
-	  }        
+    for(int j=0;jq->GetNumRows();j++){
+      state.SetElementPointer(count,bodyarray[i]->q->GetElementPointer(j));
+      statedot.SetElementPointer(count,bodyarray[i]->qdot->GetElementPointer(j));
+      statedoubledot.SetElementPointer(count,bodyarray[i]->qdotdot->GetElementPointer(j));
+      count++;
+    }
   }
 }
 
 
 void OnSolver::Solve(double time, Matrix& FF){
-	system->SetTime(time);
-	for(int i=1;iLocalKinematics();
-	
-	Vect3 Torque; Torque.Zeros();
-	Vect3 Force; Force.Zeros();
-	
-	for(int i=numbodies-1;i>0;i--){
-		Torque(1)=FF(1,i);     
-		Torque(2)=FF(2,i);
-		Torque(3)=FF(3,i);		
-		Force(1)=FF(4,i);     
-		Force(2)=FF(5,i);
-		Force(3)=FF(6,i);   
-		bodyarray[i]->LocalTriangularization(Torque,Force);
-	}
-   	
-	for(int i=1;iLocalForwardSubstitution();
-	}  
+  system->SetTime(time);
+  for(int i=1;iLocalKinematics();
+
+  Vect3 Torque; Torque.Zeros();
+  Vect3 Force; Force.Zeros();
+
+  for(int i=numbodies-1;i>0;i--){
+    Torque(1)=FF(1,i);
+    Torque(2)=FF(2,i);
+    Torque(3)=FF(3,i);
+    Force(1)=FF(4,i);
+    Force(2)=FF(5,i);
+    Force(3)=FF(6,i);
+    bodyarray[i]->LocalTriangularization(Torque,Force);
+  }
+
+  for(int i=1;iLocalForwardSubstitution();
+  }
 }
diff --git a/lib/poems/particle.cpp b/lib/poems/particle.cpp
index 3496bc1906..1993136923 100644
--- a/lib/poems/particle.cpp
+++ b/lib/poems/particle.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: particle.cpp                                            *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/particle.h b/lib/poems/particle.h
index 20aa4831ea..20fce695af 100644
--- a/lib/poems/particle.h
+++ b/lib/poems/particle.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: particle.h                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -23,7 +23,7 @@
 
 
 class Particle : public Body  {
-public: 
+public:
   Particle();
   ~Particle();
   BodyType GetType();
diff --git a/lib/poems/poemsobject.cpp b/lib/poems/poemsobject.cpp
index 7c3f1ca872..5f221f1242 100644
--- a/lib/poems/poemsobject.cpp
+++ b/lib/poems/poemsobject.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: poemsobject.cpp                                         *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 
 #include "poemsobject.h"
 #include 
diff --git a/lib/poems/poemsobject.h b/lib/poems/poemsobject.h
index 63b2915638..df92f0b51b 100644
--- a/lib/poems/poemsobject.h
+++ b/lib/poems/poemsobject.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: poemsobject.cpp                                         *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 
 #ifndef POEMSOBJECT_H
 #define POEMSOBJECT_H
@@ -23,7 +23,7 @@
 class POEMSObject {
   char* name;
   int ID;
-public: 
+public:
   POEMSObject();
   virtual ~POEMSObject();
   void ChangeName(const char* newname);
diff --git a/lib/poems/poemstreenode.cpp b/lib/poems/poemstreenode.cpp
index 0b475c0a85..d1fd965752 100644
--- a/lib/poems/poemstreenode.cpp
+++ b/lib/poems/poemstreenode.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: poemstreenode.cpp                                       *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -20,7 +20,7 @@
 // constructor; initialize the data and pointer fields
 // A null pointer value assigns a empty subtree
 TreeNode::TreeNode (const int & item, TreeNode *lptr,TreeNode *rptr,
-					int balfac):data(item), left(lptr), right(rptr), balanceFactor(balfac)
+          int balfac):data(item), left(lptr), right(rptr), balanceFactor(balfac)
 {
 }
 
@@ -29,21 +29,21 @@ TreeNode::TreeNode (const int & item, TreeNode *lptr,TreeNode *rptr,
 // return left
 TreeNode* TreeNode::Left(void)
 {
-	return left;
+  return left;
 }
 
 // return right
 TreeNode* TreeNode::Right(void)
 {
-	return right;
+  return right;
 }
 
 int TreeNode::GetBalanceFactor(void)
 {
-	return balanceFactor;
+  return balanceFactor;
 }
 
 int TreeNode::GetData(void)
 {
-	return data;
+  return data;
 }
diff --git a/lib/poems/point.cpp b/lib/poems/point.cpp
index 4383844736..66bf8d0373 100644
--- a/lib/poems/point.cpp
+++ b/lib/poems/point.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: point.cpp                                                  *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/point.h b/lib/poems/point.h
index 746a527cd7..477c7f43e8 100644
--- a/lib/poems/point.h
+++ b/lib/poems/point.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: point.h                                                  *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -29,14 +29,14 @@ enum PointType {
 };
 
 class Point : public POEMSObject {
-public: 
+public:
   Vect3 position;
 
-  Point();   
-  bool ReadIn(std::istream& in);  
+  Point();
+  bool ReadIn(std::istream& in);
   void WriteOut(std::ostream& out);
-  
-  virtual ~Point();  
+
+  virtual ~Point();
   virtual PointType GetType() = 0;
   virtual Vect3 GetPoint() = 0;
   virtual bool ReadInPointData(std::istream& in) = 0;
diff --git a/lib/poems/prismaticjoint.cpp b/lib/poems/prismaticjoint.cpp
index 7c01667a86..e0a0e7b87a 100644
--- a/lib/poems/prismaticjoint.cpp
+++ b/lib/poems/prismaticjoint.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: prismaticjoint.cpp                                      *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -41,7 +41,7 @@ bool PrismaticJoint::ReadInJointData(std::istream& in){
   // init the constant transforms
   pk_C_k = pk_C_ko;
   k_C_pk = T(pk_C_k);
-    
+
   return true;
 }
 
@@ -100,7 +100,7 @@ void PrismaticJoint::ForwardKinematics(){
 
   // compute position vector r21
   FastNegMult(k_C_pk,r12,r21);
-  
+
   // compute global location
   // body2->r = body1->r + body1->n_C_k * r12;
   FastMult(body1->n_C_k,r12,result1);
@@ -115,7 +115,7 @@ void PrismaticJoint::ForwardKinematics(){
   //body2->omega_k = T(pk_C_k) * body1->omega_k;
   FastAssign(body1->omega,body2->omega);
   FastMult(k_C_pk,body1->omega_k,body2->omega_k);
-  
+
   // compute velocities
   Vect3 pk_v_k;
   Vect3 wxgamma;
diff --git a/lib/poems/prismaticjoint.h b/lib/poems/prismaticjoint.h
index 17cf050a78..ed0bc88cc2 100644
--- a/lib/poems/prismaticjoint.h
+++ b/lib/poems/prismaticjoint.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: prismaticjoint.cpp                                       *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/revolutejoint.cpp b/lib/poems/revolutejoint.cpp
index ec5b1bec02..eef83dc978 100644
--- a/lib/poems/revolutejoint.cpp
+++ b/lib/poems/revolutejoint.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: revolutejoint.cpp                                        *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -101,7 +101,7 @@ void RevoluteJoint::ForwardKinematics(){
 
   // compute position vector r12
   //r12 = point1->position - pk_C_k * point2->position;
-  FastMult(pk_C_k,point2->position,result1); 
+  FastMult(pk_C_k,point2->position,result1);
   FastSubt(point1->position,result1,r12);// Jacks comment: needs flipping!!!
 
   // compute position vector r21
diff --git a/lib/poems/revolutejoint.h b/lib/poems/revolutejoint.h
index 478d48dbb9..fd8cdc69e2 100644
--- a/lib/poems/revolutejoint.h
+++ b/lib/poems/revolutejoint.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: revolutejoint.h                                         *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -27,7 +27,7 @@
 class RevoluteJoint : public Joint  {
   Vect3 axis_pk; // unit vector in body1 basis
   Vect3 axis_k;  // unit vector in body2 basis
-public: 
+public:
   RevoluteJoint();
   ~RevoluteJoint();
   JointType GetType();
diff --git a/lib/poems/rigidbody.cpp b/lib/poems/rigidbody.cpp
index 3ac424f9e9..92963f93da 100644
--- a/lib/poems/rigidbody.cpp
+++ b/lib/poems/rigidbody.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: rigidbody.cpp                                           *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/rigidbody.h b/lib/poems/rigidbody.h
index 0bb2a3ece2..bdadc4a50f 100644
--- a/lib/poems/rigidbody.h
+++ b/lib/poems/rigidbody.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: rigidbody.h                                             *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -21,7 +21,7 @@
 #include "body.h"
 
 class RigidBody : public Body  {
-public: 
+public:
   RigidBody();
   ~RigidBody();
   BodyType GetType();
diff --git a/lib/poems/rowmatrix.cpp b/lib/poems/rowmatrix.cpp
index feb185070e..41e24911aa 100644
--- a/lib/poems/rowmatrix.cpp
+++ b/lib/poems/rowmatrix.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: rowmatrix.cpp                                           *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/rowmatrix.h b/lib/poems/rowmatrix.h
index b04113e8ed..e64e3f09c5 100644
--- a/lib/poems/rowmatrix.h
+++ b/lib/poems/rowmatrix.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: rowmatrix.h                                             *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/solver.cpp b/lib/poems/solver.cpp
index 7b1e718b93..8380553d92 100644
--- a/lib/poems/solver.cpp
+++ b/lib/poems/solver.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: solver.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -37,16 +37,16 @@ system->ComputeForces();
 
 SolverType Solver::GetSolverType()
 {
-	return type;
+  return type;
 }
 
 Solver * Solver::GetSolver(SolverType solverToMake) //returning a pointer to a new Solver object of the appropriate type
 {
-	switch((int)solverToMake)
-	{
-		case ONSOLVER: return new OnSolver();
-		default: return nullptr;
-	}
+  switch((int)solverToMake)
+  {
+    case ONSOLVER: return new OnSolver();
+    default: return nullptr;
+  }
 }
 
 ColMatMap* Solver::GetState(){
diff --git a/lib/poems/solver.h b/lib/poems/solver.h
index 45564dd1ef..1ac219bc71 100644
--- a/lib/poems/solver.h
+++ b/lib/poems/solver.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: solver.h                                                *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:       anderk5@rpi.edu                                     *
  *_________________________________________________________________________*/
 
@@ -28,11 +28,11 @@ class Solver{
 protected:
   System* system;
 
-  
+
   double time;
   ColMatMap state;
   ColMatMap statedot;
-  ColMatMap statedoubledot;  
+  ColMatMap statedoubledot;
 
   SolverType type;
 
@@ -47,10 +47,10 @@ public:
 
   virtual void DeleteModel() = 0;
   virtual void CreateModel() = 0;
-  virtual void Solve(double time, Matrix& FF) = 0;  
-  
-    
-    
+  virtual void Solve(double time, Matrix& FF) = 0;
+
+
+
   ColMatMap* GetState();
   ColMatMap* GetStateDerivative();
   ColMatMap* GetStateDerivativeDerivative();
diff --git a/lib/poems/sphericaljoint.cpp b/lib/poems/sphericaljoint.cpp
index fb5330db17..aadd3ebd67 100644
--- a/lib/poems/sphericaljoint.cpp
+++ b/lib/poems/sphericaljoint.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: sphericaljoint.cpp                                      *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,10 +11,10 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
- 
+
 
 #include "sphericaljoint.h"
 #include "point.h"
@@ -44,24 +44,24 @@ bool SphericalJoint::ReadInJointData(std::istream& in){
 void SphericalJoint::WriteOutJointData(std::ostream& out){
 }
 
-Matrix SphericalJoint::GetForward_sP(){  
+Matrix SphericalJoint::GetForward_sP(){
   Mat3x3 sPa,sPl;
   Matrix sP(6,3);
-  sPa.Identity();    
+  sPa.Identity();
   sPl.Zeros();
-  Vect3 temp = -(point2->position);  
-  
+  Vect3 temp = -(point2->position);
+
   sPl(1,2) = temp(3);
   sPl(1,3) = -temp(2);
-  
+
   sPl(2,1) = -temp(3);
   sPl(2,3) = temp(1);
-  
-  sPl(3,1) = temp(2);  
+
+  sPl(3,1) = temp(2);
   sPl(3,2) = -temp(1);
-         
-  sP=Stack(sPa,sPl);  
-  return sP;    
+
+  sP=Stack(sPa,sPl);
+  return sP;
 }
 
 void SphericalJoint::UpdateForward_sP( Matrix& sP){
@@ -70,128 +70,128 @@ void SphericalJoint::UpdateForward_sP( Matrix& sP){
 }
 
 Matrix SphericalJoint::GetBackward_sP(){
-	cout<<" -----------"<position(1));  
-  sPl(2,3)=-(point2->position(1));   
+  sPa.Identity();
+  sPl.Zeros();
+  sPl(3,2)=(point2->position(1));
+  sPl(2,3)=-(point2->position(1));
   sP=Stack(sPa,sPl);
-  return sP;    
+  return sP;
 }
 
-void SphericalJoint::UpdateBackward_sP( Matrix& sP){  
+void SphericalJoint::UpdateBackward_sP( Matrix& sP){
   // sP is constant, do nothing.
 }
 
 void SphericalJoint::ComputeLocalTransform(){
-	Mat3x3 ko_C_k;
-	// Obtain the transformation matrix from euler parameters
-	EP_Transformation(q, ko_C_k);
-	FastMult(pk_C_ko,ko_C_k,pk_C_k);
-	}  
+  Mat3x3 ko_C_k;
+  // Obtain the transformation matrix from euler parameters
+  EP_Transformation(q, ko_C_k);
+  FastMult(pk_C_ko,ko_C_k,pk_C_k);
+  }
 
 
 void SphericalJoint::ForwardKinematics(){
   Vect3 result1,result2,result3,result4,result5;
   Vect3 pk_w_k;
-  
+
   //cout<<"Check in spherical "<position,result1); // parents basis      
-  FastAdd(result1,point1->position,r12);      
-  
-  // compute position vector r21 
-  FastNegMult(k_C_pk,r12,r21); 
+  // COMPUTE POSITION VECTOR R12 aka GAMMA
+
+  FastNegMult(pk_C_k,point2->position,result1); // parents basis
+  FastAdd(result1,point1->position,r12);
+
+  // compute position vector r21
+  FastNegMult(k_C_pk,r12,r21);
+
+
 
-  
-  
   //----------------------------------//
-  // COMPUTE GLOBAL LOCATION  
-  FastMult(body1->n_C_k,(body1->GetPoint(2))->position,result1);    
-  FastAdd(result1,body1->r,result1);  
-  FastNegMult(body2->n_C_k,(body2->GetPoint(1))->position,result2);  
-  FastAdd(result1,result2,body2->r);  
-  
-  qdot_to_u(q, u, qdot);  
-  
+  // COMPUTE GLOBAL LOCATION
+  FastMult(body1->n_C_k,(body1->GetPoint(2))->position,result1);
+  FastAdd(result1,body1->r,result1);
+  FastNegMult(body2->n_C_k,(body2->GetPoint(1))->position,result2);
+  FastAdd(result1,result2,body2->r);
+
+  qdot_to_u(q, u, qdot);
+
+
+  //-----------------------------------
+  // angular velocities
 
-  //-----------------------------------  
-  // angular velocities  
-  
   FastAssign(u,pk_w_k);
-  FastTMult(pk_C_k,body1->omega_k,result1);        
+  FastTMult(pk_C_k,body1->omega_k,result1);
   FastAdd(result1,pk_w_k,body2->omega_k);
-  FastMult(body2->n_C_k,body2->omega_k,body2->omega); 
+  FastMult(body2->n_C_k,body2->omega_k,body2->omega);
 
-  
-  
-  //-----------------------------------  
-  
-  // compute velocities  
-  FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);  
+
+
+  //-----------------------------------
+
+  // compute velocities
+  FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);
   FastAdd(body1->v_k,result1,result2);
-  FastTMult(pk_C_k,result2,result1); // In body basis  
-  
-  FastCross((body2->GetPoint(1))->position,body2->omega_k,result2);                 
-  FastAdd(result1,result2,body2->v_k);    // In body basis     
-  FastMult(body2->n_C_k,body2->v_k,body2->v); 
-  
-  
+  FastTMult(pk_C_k,result2,result1); // In body basis
+
+  FastCross((body2->GetPoint(1))->position,body2->omega_k,result2);
+  FastAdd(result1,result2,body2->v_k);    // In body basis
+  FastMult(body2->n_C_k,body2->v_k,body2->v);
+
+
   //------------------------------------------
-  //Compute the KE   
+  //Compute the KE
   Matrix tempke;
-  tempke = T(body2->v)*(body2->v);    
+  tempke = T(body2->v)*(body2->v);
   double ke = 0.0;
-  ke = body2->mass*tempke(1,1);  
+  ke = body2->mass*tempke(1,1);
   FastMult(body2->inertia,body2->omega_k,result1);
-  tempke= T(body2->omega_k)*result1;  
+  tempke= T(body2->omega_k)*result1;
   ke = 0.5*ke + 0.5*tempke(1,1);
   body2->KE=ke;
 
-  //-----------------------------------  
-  // compute state explicit angular acceleration  // Has to be in body basis    
-  FastTMult(pk_C_k,body1->alpha_t,result2);  
+  //-----------------------------------
+  // compute state explicit angular acceleration  // Has to be in body basis
+  FastTMult(pk_C_k,body1->alpha_t,result2);
   FastCross(body2->omega_k,pk_w_k,result1);
-  FastAdd(result1,result2,body2->alpha_t); 
-   
-  //-----------------------------------  
-  // compute state explicit acceleration   
-  // NEED TO DO THIS COMPLETELY IN BODY BASIS 
-  
+  FastAdd(result1,result2,body2->alpha_t);
+
+  //-----------------------------------
+  // compute state explicit acceleration
+  // NEED TO DO THIS COMPLETELY IN BODY BASIS
+
   FastCross(body1->omega_k,(body1->GetPoint(2))->position,result1);
-  FastCross(body1->omega_k,result1,result2); 
-  FastTMult(pk_C_k,result2,result1); 
-  
-  //FastCross(body2->omega_k,-(body2->GetPoint(1))->position,result3);  
-  FastCross((body2->GetPoint(1))->position,body2->omega_k,result3);  
-  FastCross(body2->omega_k,result3,result2);    
-  FastAdd(result1,result2,result3); //wxwxr in body basis  
-  
-  FastCross(body1->alpha_t,(body1->GetPoint(2))->position,result4); 
-  FastTMult(pk_C_k,result4,result5);  
+  FastCross(body1->omega_k,result1,result2);
+  FastTMult(pk_C_k,result2,result1);
+
+  //FastCross(body2->omega_k,-(body2->GetPoint(1))->position,result3);
+  FastCross((body2->GetPoint(1))->position,body2->omega_k,result3);
+  FastCross(body2->omega_k,result3,result2);
+  FastAdd(result1,result2,result3); //wxwxr in body basis
+
+  FastCross(body1->alpha_t,(body1->GetPoint(2))->position,result4);
+  FastTMult(pk_C_k,result4,result5);
   FastAssign(result5,result4);
-  
-  FastCross((body2->GetPoint(1))->position,body2->alpha_t,result2);   
-  FastAdd(result2,result4,result1); //alphaxr in body basis  
-  
+
+  FastCross((body2->GetPoint(1))->position,body2->alpha_t,result2);
+  FastAdd(result2,result4,result1); //alphaxr in body basis
+
   FastTMult(pk_C_k,body1->a_t,result2);
-  FastTripleSum(result3,result1,result2,body2->a_t);     // in body basis  
-  
-  
-  //-----------------------------------    
+  FastTripleSum(result3,result1,result2,body2->a_t);     // in body basis
+
+
+  //-----------------------------------
 }
 
 // NOTE: NOT USING BACKWARDKINEMATICS AT PRESENT
@@ -202,13 +202,13 @@ void SphericalJoint::BackwardKinematics(){
 
   // orientations
   ComputeBackwardTransforms();
-  
+
 
   // compute position vector r21
   //r21 = point2->position - k_C_pk * point1->position;
   FastMult(k_C_pk,point1->position,result1);
   FastSubt(point2->position,result1,r21);
-  
+
 
   // compute position vector r21
   FastNegMult(pk_C_k,r21,r12);
@@ -227,7 +227,7 @@ void SphericalJoint::BackwardKinematics(){
   EP_Derivatives(q,u,qdot);
 
   // angular velocities
- 
+
   FastMult(body2->n_C_k,u,result2);
   FastAdd(body2->omega,result2,body1->omega);
   FastAssign(u,k_w_pk);
@@ -247,7 +247,7 @@ void SphericalJoint::BackwardKinematics(){
   FastCross(body1->omega_k,k_w_pk,result1);
   FastMult(pk_C_k,body2->alpha_t,result2);
   FastAdd(result1,result2,body1->alpha_t);
-  
+
   // compute state explicit acceleration
   FastCross(body2->alpha_t,point2->position,result1);
   FastCross(body2->omega_k,point2->position,result2);
@@ -260,5 +260,5 @@ void SphericalJoint::BackwardKinematics(){
   FastCross(body1->omega_k,result2,result3);
 
   FastTripleSum(result5,result1,result3,body1->a_t);
-  
+
 }
diff --git a/lib/poems/sphericaljoint.h b/lib/poems/sphericaljoint.h
index ef29f8e38e..390f2fefe4 100644
--- a/lib/poems/sphericaljoint.h
+++ b/lib/poems/sphericaljoint.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: sphericaljoint.h                                        *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/system.cpp b/lib/poems/system.cpp
index 23554f4117..59107e46d7 100644
--- a/lib/poems/system.cpp
+++ b/lib/poems/system.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: system.cpp                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -23,7 +23,7 @@
 
 
 System::System(){
-	mappings = nullptr;
+  mappings = nullptr;
 }
 
 System::~System(){
@@ -42,7 +42,7 @@ int System::GetNumBodies(){
 
 int * System::GetMappings()
 {
-	return mappings;
+  return mappings;
 }
 
 void System::AddBody(Body* body){
@@ -61,16 +61,16 @@ double System::GetTime(){
   return time;
 }
 
-void System::ComputeForces(){	
-	// NOT DOING ANYTHING AT THIS TIME
-  }  
-  
+void System::ComputeForces(){
+  // NOT DOING ANYTHING AT THIS TIME
+  }
+
 bool System::ReadIn(istream& in){
   int numbodies;
   Body* body;
   int bodytype;
   char bodyname[256];
-  int index;  
+  int index;
 
   // get number of bodies
   in >> numbodies;
@@ -148,12 +148,12 @@ bool System::ReadIn(istream& in){
       delete [] bodyarray;
       return false;
     }
-    
+
     joint->SetBodies(bodyarray[body1], bodyarray[body2]);
 
     bodyarray[body1]->AddJoint(joint);
     bodyarray[body2]->AddJoint(joint);
-    
+
     in >> point1 >> point2;
 
     joint->SetPoints(bodyarray[body1]->GetPoint(point1),bodyarray[body2]->GetPoint(point2));
@@ -186,7 +186,7 @@ void System::WriteOut(ostream& out){
 
     // set the body ID for later identification
     body->SetID(i);
-    
+
     // write out the data
     body->WriteOut(out);
 
@@ -194,7 +194,7 @@ void System::WriteOut(ostream& out){
   }
 
   // number of joints
-  out << joints.GetNumElements() << endl;  
+  out << joints.GetNumElements() << endl;
 
   // joints loop
   i = 0;
@@ -209,7 +209,7 @@ void System::WriteOut(ostream& out){
 
     // write out the data
     joint->WriteOut(out);
-    
+
     i++; j_ele = j_ele->next;
   }
 }
@@ -235,68 +235,68 @@ void System::ClearJointIDs(){
 
 void System::Create_DegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space){
 
- //-------------------------------------------------------------------------//    
-  // Declaring Temporary Entities 
-  //-------------------------------------------------------------------------//   
+ //-------------------------------------------------------------------------//
+  // Declaring Temporary Entities
+  //-------------------------------------------------------------------------//
      Body* body = nullptr;
      Body* prev;
      Body* Inertial;
      Point* origin;
      Joint* joint;
-     Point* point_CM; 
-     Point* point_p;  
-     Point* point_k;  
+     Point* point_CM;
+     Point* point_p;
+     Point* point_k;
      Point* point_ch = nullptr;
-     Vect3 r1,r2,r3,v1,v2,v3; 
+     Vect3 r1,r2,r3,v1,v2,v3;
      Mat3x3 IM, N, PKCK,PKCN ;
      ColMatrix qo, uo, q, qdot,w;
-     
-	 mappings = new int[nfree];
-	 for(int i = 0; i < nfree; i++)
-	 {
-		 mappings[i] = freelist[i];		 
-	 }
+
+   mappings = new int[nfree];
+   for(int i = 0; i < nfree; i++)
+   {
+     mappings[i] = freelist[i];
+   }
      qo.Dim(4);
      uo.Dim(3);
      q.Dim(4);
-     qdot.Dim(4);     
+     qdot.Dim(4);
      PKCN.Identity();
      PKCK.Identity();
      w.Dim(3);
-	
-//-------------------------------------------------------------------------//    
-  // Setting up Inertial Frame, gravity and Origin  
-  //-------------------------------------------------------------------------//
-     Inertial= new InertialFrame;  
-     AddBody(Inertial);
-     
-     Vect3 temp1;  
-     temp1.Zeros();  
-     ((InertialFrame*) Inertial)->SetGravity(temp1);    
-     origin= new FixedPoint(temp1);
-     Inertial->AddPoint(origin);    
+
+//-------------------------------------------------------------------------//
+  // Setting up Inertial Frame, gravity and Origin
+  //-------------------------------------------------------------------------//
+     Inertial= new InertialFrame;
+     AddBody(Inertial);
+
+     Vect3 temp1;
+     temp1.Zeros();
+     ((InertialFrame*) Inertial)->SetGravity(temp1);
+     origin= new FixedPoint(temp1);
+     Inertial->AddPoint(origin);
+//-------------------------------------------------------------------------//
+  double ** xh1 = new double*[nfree];
+  double ** xh2 = new double*[nfree];
+
+  for (int i=0; imass=masstotal[mappings[i]-1];
      IM(1,1)=inertia[mappings[i]-1][0];
      IM(2,2)=inertia[mappings[i]-1][1];
@@ -307,49 +307,49 @@ void System::Create_DegenerateSystem(int& nfree, int*freelist, double *&masstota
      IM(2,1)=IM(1,2);
      IM(3,1)=IM(1,3);
      IM(3,2)=IM(2,3);
-     body->inertia = IM;   
+     body->inertia = IM;
+
+//-------------------------------------------------------//
+
+
+      for (int k=0;k<3;k++){
+          r1(k+1)=xh1[i][k]-xcm[mappings[i]-1][k];
+       r3(k+1) = xcm[mappings[i]-1][k];
+       r3(k+1)=xh2[i][k]-xcm[mappings[i]-1][k];
+      }
+
+     r2.Zeros();
+
+     for (int k=1;k<=3;k++){
+          N(k,1)=ex_space[mappings[i]-1][k-1];
+          N(k,2)=ey_space[mappings[i]-1][k-1];
+          N(k,3)=ez_space[mappings[i]-1][k-1];
+         }
 
-//-------------------------------------------------------//                  
-    
-    
-	    for (int k=0;k<3;k++){ 
-          r1(k+1)=xh1[i][k]-xcm[mappings[i]-1][k];     
-			 r3(k+1) = xcm[mappings[i]-1][k];
-			 r3(k+1)=xh2[i][k]-xcm[mappings[i]-1][k]; 	  
-	    }
-	  
-     r2.Zeros(); 
-     
-     for (int k=1;k<=3;k++){     
-          N(k,1)=ex_space[mappings[i]-1][k-1];              
-          N(k,2)=ey_space[mappings[i]-1][k-1];              
-          N(k,3)=ez_space[mappings[i]-1][k-1];              
-         }                  
-     
      PKCK=T(N);
      PKCN=T(N);
-    
-     q.Zeros();     
+
+     q.Zeros();
      EP_FromTransformation(q,N);
-                    
+
      r1=PKCN*r1;
      r3=PKCN*r3;
-     
+
      for (int k=1;k<=3;k++){
-     w(k)=omega[mappings[i]-1][k-1];                                   
-     }     
-     
+     w(k)=omega[mappings[i]-1][k-1];
+     }
+
      Vect3 cart_r, cart_v;
      for (int k=1;k<=3;k++){
-	     cart_r(k)=xcm[mappings[i]-1][k-1];	     
-	     cart_v(k)=vcm[mappings[i]-1][k-1];
-	     }
-	     	     
-	     w=PKCN*w;     
-	     EP_Derivatives(q,w,qdot);
-	     
-     
-//-------------------------------------------------------------------------//    
+       cart_r(k)=xcm[mappings[i]-1][k-1];
+       cart_v(k)=vcm[mappings[i]-1][k-1];
+       }
+
+       w=PKCN*w;
+       EP_Derivatives(q,w,qdot);
+
+
+//-------------------------------------------------------------------------//
 // Create bodies and joints with associated properties for POEMS
 //-------------------------------------------------------------------------//
 
@@ -359,12 +359,12 @@ void System::Create_DegenerateSystem(int& nfree, int*freelist, double *&masstota
      body->AddPoint(point_CM);
      body->AddPoint(point_k);
      body->AddPoint(point_ch);
-     AddBody(body);    
-   
+     AddBody(body);
+
      Mat3x3 One;
-     One.Identity();	
-	  ColMatrix qq=Stack(q,cart_r);
-          ColMatrix vv=Stack(qdot,cart_v);          
+     One.Identity();
+    ColMatrix qq=Stack(q,cart_r);
+          ColMatrix vv=Stack(qdot,cart_v);
           joint=new FreeBodyJoint;
           AddJoint(joint);
           joint->SetBodies(prev,body);
@@ -374,225 +374,225 @@ void System::Create_DegenerateSystem(int& nfree, int*freelist, double *&masstota
           joint->SetZeroOrientation(One);
           joint->DimQandU(7,6);
           joint->SetInitialState(qq,vv);
-          joint->ForwardKinematics();                             
+          joint->ForwardKinematics();
   }
   for(int i = 0; i < nfree; i++) {
-	  delete [] xh1[i];
-	  delete [] xh2[i];
+    delete [] xh1[i];
+    delete [] xh2[i];
   }
   delete [] xh1;
-  delete [] xh2;  
+  delete [] xh2;
 }
 
 
 void System::Create_System_LAMMPS(int numbodies, double *mass,double **inertia, double ** xcm, double ** xjoint,double **vcm,double **omega,double **ex_space, double **ey_space, double **ez_space, int b, int * mapping, int count){
 
-	//-------------------------------------------------------------------------//    
-  // Declaring Temporary Entities 
-	//-------------------------------------------------------------------------//   
-  	
-	Body* body = nullptr;
-	Body* prev;
-	Body* Inertial;
-	Point* origin;
-	Joint* joint;
-	Point* point_CM;   
-	Point* point_p;    
-	Point* point_k;    
-	Point* point_ch = nullptr;  
-	Vect3 r1,r2,r3,v1,v2,v3; 
-	Mat3x3 IM, N, PKCK,PKCN ;
-	ColMatrix qo, uo, q, qdot,w;
-	Vect3 cart_r, cart_v;
-	mappings = new int[b];
-	for(int i = 0; i < b; i++){
-		mappings[i] = mapping[i];		 
-	}	 
-	 
-     
-	qo.Dim(4);
-	uo.Dim(3);
-	q.Dim(4);
-	qdot.Dim(4);     
-	PKCN.Identity();
-	PKCK.Identity();
-	w.Dim(3);
-	
-	//-------------------------------------------------------------------------//    
-  // Setting up Inertial Frame, gravity and Origin  
-	//-------------------------------------------------------------------------//
-	Inertial= new InertialFrame;  
-	AddBody(Inertial);
-     
-	Vect3 temp1;  
-	temp1.Zeros();  
-	((InertialFrame*) Inertial)->SetGravity(temp1);    
-	origin= new FixedPoint(temp1);
-	Inertial->AddPoint(origin);    
-	//-------------------------------------------------------------------------//
+  //-------------------------------------------------------------------------//
+  // Declaring Temporary Entities
+  //-------------------------------------------------------------------------//
 
-	double ** xh1;
-	double ** xh2;
-		  
-	xh1 = new double*[b];		  
-	xh2 = new double*[b];
-		  
-	
-	for (int i=0; iSetGravity(temp1);
+  origin= new FixedPoint(temp1);
+  Inertial->AddPoint(origin);
+  //-------------------------------------------------------------------------//
+
+  double ** xh1;
+  double ** xh2;
+
+  xh1 = new double*[b];
+  xh2 = new double*[b];
+
+
+  for (int i=0; imass=mass[mapping[i]-1];
-		IM(1,1)=inertia[mapping[i]-1][0];
-		IM(2,2)=inertia[mapping[i]-1][1];
-		IM(3,3)=inertia[mapping[i]-1][2];
-		IM(1,2)=0.0;
-		IM(1,3)=0.0;
-		IM(2,3)=0.0;
-		IM(2,1)=IM(1,2);
-		IM(3,1)=IM(1,3);
-		IM(3,2)=IM(2,3);
-		body->inertia = IM;   
-     
-		//-------------------------------------------------------//
-             
-		for (int k=0;k<3;k++){
-			r1(k+1)=xh1[i][k]-xcm[mapping[i]-1][k]; 
-			r3(k+1)=xh2[i][k]-xcm[mapping[i]-1][k]; 
-		}
-		r2.Zeros();   
-     
-		for (int k=1;k<=3;k++){     
-			N(k,1)=ex_space[mapping[i]-1][k-1];              
-			N(k,2)=ey_space[mapping[i]-1][k-1];              
-			N(k,3)=ez_space[mapping[i]-1][k-1];              
-		}
-	 
-         
-		if (i==0){
-			PKCK=T(N);     
-			PKCN=T(N);     
-	     
-			q.Zeros();	     
-			EP_FromTransformation(q,N);
-	     
-			r1=PKCN*r1;
-			r3=PKCN*r3;
-	     
-			for (int k=1;k<=3;k++){     
-				w(k)=omega[mappings[i]-1][k-1];
-			}	     
-	     
-			for (int k=1;k<=3;k++){
-				cart_r(k)=xcm[mappings[i]-1][k-1];		     
-				cart_v(k)=vcm[mappings[i]-1][k-1];
-			}
-			w=PKCN*w;     
-			EP_Derivatives(q,w,qdot);    
-		 
-		}                 
-		else{	     
-			PKCK=PKCN*N;   
-			PKCN=T(N);     
-    
-			q.Zeros();
-			EP_FromTransformation(q,PKCK);
-               
-			r1=PKCN*r1;
-			r3=PKCN*r3;
-     
-			for (int k=1;k<=3;k++){     
-				w(k)=omega[mapping[i]-1][k-1]-omega[mapping[i-1]-1][k-1];                         
-			}
-    	
-			w=PKCN*w; 
-			EP_Derivatives(q, w, qdot);        
-		}  
-        
-	
-		//-------------------------------------------------------------------------//    
-// Create bodies and joints with associated properties for POEMS
-		//-------------------------------------------------------------------------//
+  //-------------------------------------------------------------------------//
+  for(int i=0;imass=mass[mapping[i]-1];
+    IM(1,1)=inertia[mapping[i]-1][0];
+    IM(2,2)=inertia[mapping[i]-1][1];
+    IM(3,3)=inertia[mapping[i]-1][2];
+    IM(1,2)=0.0;
+    IM(1,3)=0.0;
+    IM(2,3)=0.0;
+    IM(2,1)=IM(1,2);
+    IM(3,1)=IM(1,3);
+    IM(3,2)=IM(2,3);
+    body->inertia = IM;
+
+    //-------------------------------------------------------//
+
+    for (int k=0;k<3;k++){
+      r1(k+1)=xh1[i][k]-xcm[mapping[i]-1][k];
+      r3(k+1)=xh2[i][k]-xcm[mapping[i]-1][k];
+    }
+    r2.Zeros();
+
+    for (int k=1;k<=3;k++){
+      N(k,1)=ex_space[mapping[i]-1][k-1];
+      N(k,2)=ey_space[mapping[i]-1][k-1];
+      N(k,3)=ez_space[mapping[i]-1][k-1];
+    }
+
+
+    if (i==0){
+      PKCK=T(N);
+      PKCN=T(N);
+
+      q.Zeros();
+      EP_FromTransformation(q,N);
+
+      r1=PKCN*r1;
+      r3=PKCN*r3;
+
+      for (int k=1;k<=3;k++){
+        w(k)=omega[mappings[i]-1][k-1];
+      }
+
+      for (int k=1;k<=3;k++){
+        cart_r(k)=xcm[mappings[i]-1][k-1];
+        cart_v(k)=vcm[mappings[i]-1][k-1];
+      }
+      w=PKCN*w;
+      EP_Derivatives(q,w,qdot);
+
+    }
+    else{
+      PKCK=PKCN*N;
+      PKCN=T(N);
+
+      q.Zeros();
+      EP_FromTransformation(q,PKCK);
+
+      r1=PKCN*r1;
+      r3=PKCN*r3;
+
+      for (int k=1;k<=3;k++){
+        w(k)=omega[mapping[i]-1][k-1]-omega[mapping[i-1]-1][k-1];
+      }
+
+      w=PKCN*w;
+      EP_Derivatives(q, w, qdot);
+    }
+
+
+    //-------------------------------------------------------------------------//
+// Create bodies and joints with associated properties for POEMS
+    //-------------------------------------------------------------------------//
+
+    point_CM = new FixedPoint(r2);
+    point_k = new FixedPoint(r1);
+    point_ch = new FixedPoint(r3);
+    body->AddPoint(point_CM);
+    body->AddPoint(point_k);
+    body->AddPoint(point_ch);
+    AddBody(body);
+
+    Mat3x3 One;
+    One.Identity();
+    if (i==0){
+      ColMatrix qq=Stack(q,cart_r);
+      ColMatrix vv=Stack(qdot,cart_v);
+      joint=new FreeBodyJoint;
+      AddJoint(joint);
+      joint->SetBodies(prev,body);
+      body->AddJoint(joint);
+      prev->AddJoint(joint);
+      joint->SetPoints(point_p,point_k);
+      joint->SetZeroOrientation(One);
+      joint->DimQandU(7,6);
+      joint->SetInitialState(qq,vv);
+      joint->ForwardKinematics();
+    }
+    else{
+      joint= new SphericalJoint;
+      AddJoint(joint);
+      joint->SetBodies(prev,body);
+      body->AddJoint(joint);
+      prev->AddJoint(joint);
+      joint->SetPoints(point_p,point_k);
+      joint->SetZeroOrientation(One);
+      joint->DimQandU(4,3);
+      joint->SetInitialState(q,qdot);
+      joint->ForwardKinematics();
+    }
+  }
+  for(int i = 0; i < b; i++)
+  {
+    delete [] xh1[i];
+    delete [] xh2[i];
+  }
+  delete [] xh1;
+  delete [] xh2;
 
-		point_CM = new FixedPoint(r2);
-		point_k = new FixedPoint(r1);
-		point_ch = new FixedPoint(r3);
-		body->AddPoint(point_CM);
-		body->AddPoint(point_k);
-		body->AddPoint(point_ch);
-		AddBody(body);    
-   
-		Mat3x3 One;
-		One.Identity();	
-		if (i==0){	  
-			ColMatrix qq=Stack(q,cart_r);
-			ColMatrix vv=Stack(qdot,cart_v);          
-			joint=new FreeBodyJoint;
-			AddJoint(joint);
-			joint->SetBodies(prev,body);
-			body->AddJoint(joint);
-			prev->AddJoint(joint);
-			joint->SetPoints(point_p,point_k);
-			joint->SetZeroOrientation(One);
-			joint->DimQandU(7,6);
-			joint->SetInitialState(qq,vv);  	  
-			joint->ForwardKinematics();  
-		}    
-		else{	     
-			joint= new SphericalJoint;
-			AddJoint(joint);
-			joint->SetBodies(prev,body);
-			body->AddJoint(joint);
-			prev->AddJoint(joint);
-			joint->SetPoints(point_p,point_k);          
-			joint->SetZeroOrientation(One);
-			joint->DimQandU(4,3);
-			joint->SetInitialState(q,qdot);
-			joint->ForwardKinematics();  
-		}
-	}
-	for(int i = 0; i < b; i++)
-	{
-		delete [] xh1[i];
-		delete [] xh2[i];
-	}
-	delete [] xh1;
-	delete [] xh2;
-  
 }
diff --git a/lib/poems/vect3.cpp b/lib/poems/vect3.cpp
index 03c5d7bc00..d0cb53ff15 100644
--- a/lib/poems/vect3.cpp
+++ b/lib/poems/vect3.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect3.cpp                                               *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -48,10 +48,10 @@ Vect3::Vect3(const VirtualMatrix& A){  // copy constructor
 }
 
 double& Vect3::operator_1int (int i){ // array access
-	if(i<1 || i>3){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
+  if(i<1 || i>3){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
   return elements[i-1];
 }
 
diff --git a/lib/poems/vect3.h b/lib/poems/vect3.h
index ababe18e51..0eb4450174 100644
--- a/lib/poems/vect3.h
+++ b/lib/poems/vect3.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect3.h                                              *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -78,7 +78,7 @@ public:
   friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C);
   friend void FastAssign(ColMatrix&A, Vect3& C);
   friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C);
-  
+
 };
 
 #endif
diff --git a/lib/poems/vect4.cpp b/lib/poems/vect4.cpp
index 3b5afddc50..86b014d129 100644
--- a/lib/poems/vect4.cpp
+++ b/lib/poems/vect4.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect4.cpp                                               *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/vect4.h b/lib/poems/vect4.h
index 695f5e158a..81a3c2143c 100644
--- a/lib/poems/vect4.h
+++ b/lib/poems/vect4.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect4.h                                                 *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -39,7 +39,7 @@ public:
   void BasicSet_1int(int i, double value);
   void BasicIncrement_1int(int i, double value);
 
-  
+
   void Const(double value);
   MatrixType GetType() const;
   std::ostream& WriteData(std::ostream& c) const;
diff --git a/lib/poems/vect6.cpp b/lib/poems/vect6.cpp
index eb65d24f16..e3fe07e1ea 100644
--- a/lib/poems/vect6.cpp
+++ b/lib/poems/vect6.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect6.cpp                                               *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -51,11 +51,11 @@ Vect6::Vect6(const VirtualMatrix& A){  // copy constructor
 }
 
 double& Vect6::operator_1int (int i){ // array access
-	if(i<1 || i>6){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
-	return elements[i-1];
+  if(i<1 || i>6){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
+  return elements[i-1];
 }
 
 double Vect6::Get_1int(int i) const{
diff --git a/lib/poems/vect6.h b/lib/poems/vect6.h
index c346c852ef..1127daf80e 100644
--- a/lib/poems/vect6.h
+++ b/lib/poems/vect6.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: vect6.h                                                 *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
diff --git a/lib/poems/virtualcolmatrix.cpp b/lib/poems/virtualcolmatrix.cpp
index 3a6c6e22cd..e004458731 100644
--- a/lib/poems/virtualcolmatrix.cpp
+++ b/lib/poems/virtualcolmatrix.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: virtualcolmatrix.cpp                                    *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -29,11 +29,11 @@ VirtualColMatrix::~VirtualColMatrix(){
 }
 
 double& VirtualColMatrix::operator_2int(int i, int j){
-	if(j!=1){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
-	return (*this).operator_1int(i);
+  if(j!=1){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
+  return (*this).operator_1int(i);
 }
 
 double VirtualColMatrix::Get_2int(int i, int j) const{
diff --git a/lib/poems/virtualmatrix.cpp b/lib/poems/virtualmatrix.cpp
index 19d5946961..938c69c037 100644
--- a/lib/poems/virtualmatrix.cpp
+++ b/lib/poems/virtualmatrix.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: virtualmatrix.cpp                                       *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -38,84 +38,84 @@ int VirtualMatrix::GetNumCols() const {
 }
 
 double& VirtualMatrix::operator() (int i, int j){ // array access
-	return operator_2int(i,j);
+  return operator_2int(i,j);
 }
 
 double VirtualMatrix::Get(int i, int j) const{
-	return Get_2int(i,j);
+  return Get_2int(i,j);
 }
 
 void VirtualMatrix::Set(int i, int j, double value){
-	Set_2int(i,j,value);
+  Set_2int(i,j,value);
 }
 
 double VirtualMatrix::BasicGet(int i, int j) const{
-	return BasicGet_2int(i,j);
+  return BasicGet_2int(i,j);
 }
 
 void VirtualMatrix::BasicSet(int i, int j, double value){
-	BasicSet_2int(i,j,value);
+  BasicSet_2int(i,j,value);
 }
 
 void VirtualMatrix::BasicIncrement(int i, int j, double value){
-	BasicIncrement_2int(i,j,value);
+  BasicIncrement_2int(i,j,value);
 }
 
 double& VirtualMatrix::operator() (int i){
-	return operator_1int(i);
+  return operator_1int(i);
 }
 
 double VirtualMatrix::Get(int i) const{
-	return Get_1int(i);
+  return Get_1int(i);
 }
 
 void VirtualMatrix::Set(int i, double value){
-	Set_1int(i, value);
+  Set_1int(i, value);
 }
 
 double VirtualMatrix::BasicGet(int i) const{
-	return BasicGet_1int(i);
+  return BasicGet_1int(i);
 }
 
 void VirtualMatrix::BasicSet(int i, double value){
-	BasicSet_1int(i, value);
+  BasicSet_1int(i, value);
 }
 
 void VirtualMatrix::BasicIncrement(int i, double value){
-	BasicIncrement_1int(i, value);
+  BasicIncrement_1int(i, value);
 }
 
 double& VirtualMatrix::operator_1int (int i) {
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
-	return *(new double);
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
+  return *(new double);
 }
 
 double VirtualMatrix::Get_1int(int i) const {
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
-	return 0.0;
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
+  return 0.0;
 }
 
 void VirtualMatrix::Set_1int(int i, double value){
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
 }
 
 double VirtualMatrix::BasicGet_1int(int i) const {
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
-	return 0.0;
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
+  return 0.0;
 }
 
 void VirtualMatrix::BasicSet_1int(int i, double value) {
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
 }
 
 void VirtualMatrix::BasicIncrement_1int(int i, double value){
-	cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
-	exit(0);
+  cerr << "Error: single dimensional access is not defined for matrices of type " << GetType() << endl;
+  exit(0);
 }
 
 void VirtualMatrix::Zeros(){
@@ -132,8 +132,8 @@ ostream& VirtualMatrix::WriteData(ostream& c) const {
 }
 
 istream& VirtualMatrix::ReadData(istream& c){
-	cerr << "Error: no input definition for matrices of type " << GetType() << endl;
-	exit(0);
+  cerr << "Error: no input definition for matrices of type " << GetType() << endl;
+  exit(0);
 }
 
 //
diff --git a/lib/poems/virtualrowmatrix.cpp b/lib/poems/virtualrowmatrix.cpp
index 1a12cfbfd9..6d2976a584 100644
--- a/lib/poems/virtualrowmatrix.cpp
+++ b/lib/poems/virtualrowmatrix.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: virtualrowmatrix.cpp                                    *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -30,10 +30,10 @@ VirtualRowMatrix::~VirtualRowMatrix(){
 }
 
 double& VirtualRowMatrix::operator_2int (int i, int j){
-	if(i!=1){
-		cerr << "matrix index invalid in operator ()" << endl;
-		exit(1);
-	}
+  if(i!=1){
+    cerr << "matrix index invalid in operator ()" << endl;
+    exit(1);
+  }
   return (*this).operator_1int(j);
 }
 
diff --git a/lib/poems/virtualrowmatrix.h b/lib/poems/virtualrowmatrix.h
index 68b39f137d..9b1a3bbc44 100644
--- a/lib/poems/virtualrowmatrix.h
+++ b/lib/poems/virtualrowmatrix.h
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: virtualrowmatrix.h                                      *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -22,7 +22,7 @@
 #include "virtualmatrix.h"
 
 class VirtualRowMatrix : public VirtualMatrix  {
-public: 
+public:
   VirtualRowMatrix();
   ~VirtualRowMatrix();
   double& operator_2int (int i, int j); // array access
@@ -31,7 +31,7 @@ public:
   double BasicGet_2int(int i, int j) const;
   void BasicSet_2int(int i, int j, double value);
   void BasicIncrement_2int(int i, int j, double value);
-  
+
   virtual double& operator_1int (int i) = 0; // array access
   virtual double Get_1int(int i) const = 0;
   virtual void Set_1int(int i, double value) = 0;
diff --git a/lib/poems/workspace.cpp b/lib/poems/workspace.cpp
index 21819d4c02..655772b954 100644
--- a/lib/poems/workspace.cpp
+++ b/lib/poems/workspace.cpp
@@ -3,7 +3,7 @@
  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
  *      DESCRIPTION: SEE READ-ME                                           *
  *      FILE NAME: workspace.cpp                                           *
- *      AUTHORS: See Author List                                           * 
+ *      AUTHORS: See Author List                                           *
  *      GRANTS: See Grants List                                            *
  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
  *      LICENSE: Please see License Agreement                              *
@@ -11,7 +11,7 @@
  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
  *                     Computational Dynamics Lab                          *
  *                     Rensselaer Polytechnic Institute                    *
- *                     110 8th St. Troy NY 12180                           * 
+ *                     110 8th St. Troy NY 12180                           *
  *      CONTACT:        anderk5@rpi.edu                                    *
  *_________________________________________________________________________*/
 
@@ -32,34 +32,34 @@ void Workspace::allocateNewSystem() {
   currentIndex++;
   if(currentIndex < maxAlloc)
   {
-	  system[currentIndex].system = new System;
+    system[currentIndex].system = new System;
   }
   else
   {
-	  maxAlloc = (maxAlloc + 1) * 2; 
-									 
-	  SysData * tempPtrSys = new SysData[maxAlloc];
-	  for(int i = 0; i < currentIndex; i++)
-	  {
-		  tempPtrSys[i] = system[i];
-	  }
-	  delete [] system;				  
-	  system = tempPtrSys;
-	  system[currentIndex].system = new System; 
+    maxAlloc = (maxAlloc + 1) * 2;
+
+    SysData * tempPtrSys = new SysData[maxAlloc];
+    for(int i = 0; i < currentIndex; i++)
+    {
+      tempPtrSys[i] = system[i];
+    }
+    delete [] system;
+    system = tempPtrSys;
+    system[currentIndex].system = new System;
   }
 }
 
 Workspace::Workspace(){
-	currentIndex = -1; 
-	maxAlloc = 0;		
-	system = nullptr;		
+  currentIndex = -1;
+  maxAlloc = 0;
+  system = nullptr;
 }
 
 Workspace::~Workspace(){
   for(int i = 0; i <= currentIndex; i++){
-	  delete system[i].system;
+    delete system[i].system;
   }
-  delete [] system;						
+  delete [] system;
 }
 
 
@@ -79,111 +79,111 @@ bool Workspace::LoadFile(char* filename){
 }
 
 void Workspace::SetLammpsValues(double dtv, double dthalf, double tempcon){
-	Thalf = dthalf;
-	Tfull = dtv;
-	ConFac = tempcon;	
+  Thalf = dthalf;
+  Tfull = dtv;
+  ConFac = tempcon;
 }
 
 
 bool Workspace::MakeSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, int &njoint, int **&jointbody, double **&xjoint, int& nfree, int*freelist, double dthalf, double dtv, double tempcon, double KE){
-	
-	SetLammpsValues(dtv, dthalf, tempcon);		
-	
-if(njoint){		
-	SystemProcessor sys;	
-	sys.processArray(jointbody, njoint);  	
-	List * results = sys.getSystemData();		
 
-	int numsyschains = results->GetNumElements();	
-	int headvalue = 0;
-	List * newresults = results;	
-	ListElement * tempNode = results->GetHeadElement();			
-	int stop = 1;
-	int counter = 1;
-	for(int n = 1; n<=numsyschains; n++){						
-		while(stop){			
-			if ( (*(tempNode->value->listOfNodes.GetHeadElement()->value) == (headvalue+1) ) || (*(tempNode->value->listOfNodes.GetTailElement()->value) == (headvalue+1) ) ) {			
-			newresults->Append(tempNode->value);								
-			headvalue = headvalue + tempNode->value->listOfNodes.GetNumElements();						
-			tempNode = results->GetHeadElement();					
-			stop = 0;			
-			counter ++;						
-		}		
-		else{						
-			tempNode = tempNode->next;						
-		}				
-		}
-		stop=1;			
-	}		
-	
-	ListElement * TNode = newresults->GetHeadElement();
-	ListElement * TTNode = newresults->GetHeadElement();
-	for(int kk=1; kk<=numsyschains; kk++){		
-		if(kk!=numsyschains)
-			TTNode = TNode->next;
-		newresults->Remove(TNode);			
-		if(kk!=numsyschains)
-			TNode = TTNode;		
-	}
-	ListElement * NodeValue = newresults->GetHeadElement();
-	int count = 0; 	
-	int * array;
-	int ** arrayFromChain;
-	int numElementsInSystem;
-	int ttk = 0;
-	
-		
-	while(NodeValue != nullptr) {
-		array = new int[NodeValue->value->listOfNodes.GetNumElements()];
-		arrayFromChain = NodeValue->value->listOfNodes.CreateArray();
-		numElementsInSystem = NodeValue->value->listOfNodes.GetNumElements();								
-		for(counter = 0; counter < numElementsInSystem; counter++){
-			array[counter] = *arrayFromChain[counter];
-		}
-				
-		SetKE(1,KE);
-		allocateNewSystem();			
-		system[currentIndex].system->Create_System_LAMMPS(nbody,masstotal,inertia,xcm,xjoint,vcm,omega,ex_space,ey_space,ez_space, numElementsInSystem, array, count);					
-		
-		system[currentIndex].solver = ONSOLVER;
-		ttk = ttk + 1;		
-		count = ttk;
-		delete [] array;
-		delete [] arrayFromChain;
-		NodeValue= NodeValue->next;						
-	}
+  SetLammpsValues(dtv, dthalf, tempcon);
+
+if(njoint){
+  SystemProcessor sys;
+  sys.processArray(jointbody, njoint);
+  List * results = sys.getSystemData();
+
+  int numsyschains = results->GetNumElements();
+  int headvalue = 0;
+  List * newresults = results;
+  ListElement * tempNode = results->GetHeadElement();
+  int stop = 1;
+  int counter = 1;
+  for(int n = 1; n<=numsyschains; n++){
+    while(stop){
+      if ( (*(tempNode->value->listOfNodes.GetHeadElement()->value) == (headvalue+1) ) || (*(tempNode->value->listOfNodes.GetTailElement()->value) == (headvalue+1) ) ) {
+      newresults->Append(tempNode->value);
+      headvalue = headvalue + tempNode->value->listOfNodes.GetNumElements();
+      tempNode = results->GetHeadElement();
+      stop = 0;
+      counter ++;
+    }
+    else{
+      tempNode = tempNode->next;
+    }
+    }
+    stop=1;
+  }
+
+  ListElement * TNode = newresults->GetHeadElement();
+  ListElement * TTNode = newresults->GetHeadElement();
+  for(int kk=1; kk<=numsyschains; kk++){
+    if(kk!=numsyschains)
+      TTNode = TNode->next;
+    newresults->Remove(TNode);
+    if(kk!=numsyschains)
+      TNode = TTNode;
+  }
+  ListElement * NodeValue = newresults->GetHeadElement();
+  int count = 0;
+  int * array;
+  int ** arrayFromChain;
+  int numElementsInSystem;
+  int ttk = 0;
+
+
+  while(NodeValue != nullptr) {
+    array = new int[NodeValue->value->listOfNodes.GetNumElements()];
+    arrayFromChain = NodeValue->value->listOfNodes.CreateArray();
+    numElementsInSystem = NodeValue->value->listOfNodes.GetNumElements();
+    for(counter = 0; counter < numElementsInSystem; counter++){
+      array[counter] = *arrayFromChain[counter];
+    }
+
+    SetKE(1,KE);
+    allocateNewSystem();
+    system[currentIndex].system->Create_System_LAMMPS(nbody,masstotal,inertia,xcm,xjoint,vcm,omega,ex_space,ey_space,ez_space, numElementsInSystem, array, count);
+
+    system[currentIndex].solver = ONSOLVER;
+    ttk = ttk + 1;
+    count = ttk;
+    delete [] array;
+    delete [] arrayFromChain;
+    NodeValue= NodeValue->next;
+  }
 }
 if(nfree){
-	MakeDegenerateSystem(nfree,freelist,masstotal,inertia,xcm,vcm,omega,ex_space,ey_space,ez_space);
+  MakeDegenerateSystem(nfree,freelist,masstotal,inertia,xcm,vcm,omega,ex_space,ey_space,ez_space);
 }
-	return true;
+  return true;
 }
 
 
 bool Workspace::MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space){
-	allocateNewSystem();
-	system[currentIndex].system->Create_DegenerateSystem(nfree,freelist,masstotal,inertia,xcm,vcm,omega,ex_space,ey_space,ez_space);
-	system[currentIndex].solver = ONSOLVER;
-	return true;			
-} 
+  allocateNewSystem();
+  system[currentIndex].system->Create_DegenerateSystem(nfree,freelist,masstotal,inertia,xcm,vcm,omega,ex_space,ey_space,ez_space);
+  system[currentIndex].solver = ONSOLVER;
+  return true;
+}
 
-bool Workspace::SaveFile(char* filename, int index){ 
+bool Workspace::SaveFile(char* filename, int index){
   if(index < 0){
-	  index = currentIndex; 
+    index = currentIndex;
   }
   ofstream file;
 
   file.open(filename, ofstream::out);
-  
+
   if( !file.is_open() ){
     cerr << "File '" << filename << "' could not be opened." << endl;
     return false;
   }
   if(index >= 0 && index <= currentIndex){
-	  system[index].system->WriteOut(file);
+    system[index].system->WriteOut(file);
   }
   else {
-	  cerr << "Error, requested system index " << index << ", minimum index 0 and maximum index " << currentIndex << endl;
+    cerr << "Error, requested system index " << index << ", minimum index 0 and maximum index " << currentIndex << endl;
   }
   file.close();
   return true;
@@ -191,299 +191,299 @@ bool Workspace::SaveFile(char* filename, int index){
 
 
 System* Workspace::GetSystem(int index){
-	if(index <= currentIndex){
-		if(index >= 0){
-			return system[index].system;			
-		}
-		else{
-			return system[currentIndex].system; 
-		}
-	}
-	else{
-		return nullptr;
-	}
+  if(index <= currentIndex){
+    if(index >= 0){
+      return system[index].system;
+    }
+    else{
+      return system[currentIndex].system;
+    }
+  }
+  else{
+    return nullptr;
+  }
 }
 
 void Workspace::AddSolver(Solver* s, int index){
-	if(currentIndex >= index){
-		if(index >= 0){
-			system[index].solver = (int)s->GetSolverType();
-		}
-		else{
-			system[currentIndex].solver = (int)s->GetSolverType();
-		}
-	}
-	else{
-		cout << "Error adding solver to index " << index << endl;
-	}
+  if(currentIndex >= index){
+    if(index >= 0){
+      system[index].solver = (int)s->GetSolverType();
+    }
+    else{
+      system[currentIndex].solver = (int)s->GetSolverType();
+    }
+  }
+  else{
+    cout << "Error adding solver to index " << index << endl;
+  }
 }
 
 int Workspace::getNumberOfSystems(){
-	return currentIndex + 1;
+  return currentIndex + 1;
 }
 
 
 
-void Workspace::SetKE(int temp, double SysKE){	
+void Workspace::SetKE(int temp, double SysKE){
 KE_val = SysKE;
 FirstTime =temp;
 }
-    
+
 
 void Workspace::LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space){
-	
-	int numsys = currentIndex;
-	int numbodies;
-	double time = 0.0;
-	int * mappings;
-	double SysKE=0.0;
-		
-	for (int i = 0; i <= numsys; i++){
-		mappings = system[i].system->GetMappings();
-		numbodies = system[i].system->GetNumBodies() - 1;
-		Matrix FF(6,numbodies);
-		FF.Zeros();
-		for (int j=1; j<=numbodies; j++){
-			FF(1,j)  = torque[mappings[j - 1]-1][0]*ConFac;
-			FF(2,j)  = torque[mappings[j - 1]-1][1]*ConFac;
-			FF(3,j)  = torque[mappings[j - 1]-1][2]*ConFac;
-			
-			FF(4,j)  = fcm[mappings[j - 1]-1][0]*ConFac;
-			FF(5,j)  = fcm[mappings[j - 1]-1][1]*ConFac;
-			FF(6,j)  = fcm[mappings[j - 1]-1][2]*ConFac;
-		}
-		
-		//------------------------------------//
-		// Get a solver and solve that system.
-		Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);				
-		theSolver->SetSystem(system[i].system);	
-		theSolver->Solve(time, FF);	
-		
-		
-		theSolver->Solve(time, FF);		
-		ColMatrix tempx = *((*theSolver).GetState());
-		ColMatrix tempv = *((*theSolver).GetStateDerivative());
-		ColMatrix tempa = *((*theSolver).GetStateDerivativeDerivative());
-		
-		
-		for(int numint =0 ; numint<3; numint++){
-			theSolver->Solve(time, FF);
-			tempa = *((*theSolver).GetStateDerivativeDerivative());
-			*((*theSolver).GetStateDerivative())= tempv + Thalf*tempa;
-		}
-		
-		ColMatrix TempV= *((*theSolver).GetStateDerivative());
-		*((*theSolver).GetState())= tempx + Tfull*TempV;
-				
-		int numjoints = system[i].system->joints.GetNumElements();
-		for(int k = 0; k < numjoints; k++){
-			system[i].system->joints(k)->ForwardKinematics();
-		}		
-		
-		for(int k = 0; k < numbodies; k++){
-			Vect3 temp1 =system[i].system->bodies(k+1)->r;
-			Vect3 temp2 =system[i].system->bodies(k+1)->v;
-			Vect3 temp3 =system[i].system->bodies(k+1)->omega;
-			Mat3x3 temp4 =system[i].system->bodies(k+1)->n_C_k;			
-			for(int m = 0; m < 3; m++){
-				xcm[mappings[k]-1][m]   = temp1(m+1);
-				vcm[mappings[k]-1][m]   = temp2(m+1);
-				omega[mappings[k]-1][m] = temp3(m+1);				
-				ex_space[mappings[k]-1][m] = temp4(m+1,1);				
-				ey_space[mappings[k]-1][m] = temp4(m+1,2);
-				ez_space[mappings[k]-1][m] = temp4(m+1,3);				
-			}			
-			SysKE = SysKE + system[i].system->bodies(k+1)->KE;
-		} 		
-		delete theSolver;		      
-	}	
+
+  int numsys = currentIndex;
+  int numbodies;
+  double time = 0.0;
+  int * mappings;
+  double SysKE=0.0;
+
+  for (int i = 0; i <= numsys; i++){
+    mappings = system[i].system->GetMappings();
+    numbodies = system[i].system->GetNumBodies() - 1;
+    Matrix FF(6,numbodies);
+    FF.Zeros();
+    for (int j=1; j<=numbodies; j++){
+      FF(1,j)  = torque[mappings[j - 1]-1][0]*ConFac;
+      FF(2,j)  = torque[mappings[j - 1]-1][1]*ConFac;
+      FF(3,j)  = torque[mappings[j - 1]-1][2]*ConFac;
+
+      FF(4,j)  = fcm[mappings[j - 1]-1][0]*ConFac;
+      FF(5,j)  = fcm[mappings[j - 1]-1][1]*ConFac;
+      FF(6,j)  = fcm[mappings[j - 1]-1][2]*ConFac;
+    }
+
+    //------------------------------------//
+    // Get a solver and solve that system.
+    Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);
+    theSolver->SetSystem(system[i].system);
+    theSolver->Solve(time, FF);
+
+
+    theSolver->Solve(time, FF);
+    ColMatrix tempx = *((*theSolver).GetState());
+    ColMatrix tempv = *((*theSolver).GetStateDerivative());
+    ColMatrix tempa = *((*theSolver).GetStateDerivativeDerivative());
+
+
+    for(int numint =0 ; numint<3; numint++){
+      theSolver->Solve(time, FF);
+      tempa = *((*theSolver).GetStateDerivativeDerivative());
+      *((*theSolver).GetStateDerivative())= tempv + Thalf*tempa;
+    }
+
+    ColMatrix TempV= *((*theSolver).GetStateDerivative());
+    *((*theSolver).GetState())= tempx + Tfull*TempV;
+
+    int numjoints = system[i].system->joints.GetNumElements();
+    for(int k = 0; k < numjoints; k++){
+      system[i].system->joints(k)->ForwardKinematics();
+    }
+
+    for(int k = 0; k < numbodies; k++){
+      Vect3 temp1 =system[i].system->bodies(k+1)->r;
+      Vect3 temp2 =system[i].system->bodies(k+1)->v;
+      Vect3 temp3 =system[i].system->bodies(k+1)->omega;
+      Mat3x3 temp4 =system[i].system->bodies(k+1)->n_C_k;
+      for(int m = 0; m < 3; m++){
+        xcm[mappings[k]-1][m]   = temp1(m+1);
+        vcm[mappings[k]-1][m]   = temp2(m+1);
+        omega[mappings[k]-1][m] = temp3(m+1);
+        ex_space[mappings[k]-1][m] = temp4(m+1,1);
+        ey_space[mappings[k]-1][m] = temp4(m+1,2);
+        ez_space[mappings[k]-1][m] = temp4(m+1,3);
+      }
+      SysKE = SysKE + system[i].system->bodies(k+1)->KE;
+    }
+    delete theSolver;
+  }
 }
 
 void Workspace::LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm){
-	int numsys = currentIndex;
-	int numbodies;				
-	double time = 0.0;   
-	int * mappings;
-	double SysKE =0.0;		
-	for (int i = 0; i <= numsys; i++){
-		mappings = system[i].system->GetMappings();
-		numbodies = system[i].system->GetNumBodies() - 1;
-		Matrix FF(6,numbodies);				
-				
-		for (int j=1; j<=numbodies; j++){
-			FF(1,j)  = torque[mappings[j - 1]-1][0]*ConFac;
-			FF(2,j)  = torque[mappings[j - 1]-1][1]*ConFac;
-			FF(3,j)  = torque[mappings[j - 1]-1][2]*ConFac;
-			FF(4,j)  = fcm[mappings[j - 1]-1][0]*ConFac;
-			FF(5,j)  = fcm[mappings[j - 1]-1][1]*ConFac;
-			FF(6,j)  = fcm[mappings[j - 1]-1][2]*ConFac;
-		}			
-		
-		//------------------------------------//
-		// Get a solver and solve that system.		
-		Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);		
-		theSolver->SetSystem(system[i].system);    			
-		theSolver->Solve(time, FF);		
-		ColMatrix tempv = *((*theSolver).GetStateDerivative());
-		ColMatrix tempa = *((*theSolver).GetStateDerivativeDerivative());
-		*((*theSolver).GetStateDerivative()) = tempv + Thalf*tempa;
-		
-						
-		int numjoints = system[i].system->joints.GetNumElements();
-		for(int k = 0; k < numjoints; k++){
-			system[i].system->joints(k)->ForwardKinematics(); 
-		}				
-		    		
-		for(int k = 0; k < numbodies; k++){
-			Vect3 temp1 =system[i].system->bodies(k+1)->r;			
-			Vect3 temp2 =system[i].system->bodies(k+1)->v;	    	
-			Vect3 temp3 =system[i].system->bodies(k+1)->omega;
-			SysKE = SysKE + system[i].system->bodies(k+1)->KE;
-			for(int m = 0; m < 3; m++){
-				vcm[mappings[k]-1][m]   = temp2(m+1);
-				omega[mappings[k]-1][m] = temp3(m+1);
-			}			
-		}
-		delete theSolver;
-	}	
+  int numsys = currentIndex;
+  int numbodies;
+  double time = 0.0;
+  int * mappings;
+  double SysKE =0.0;
+  for (int i = 0; i <= numsys; i++){
+    mappings = system[i].system->GetMappings();
+    numbodies = system[i].system->GetNumBodies() - 1;
+    Matrix FF(6,numbodies);
+
+    for (int j=1; j<=numbodies; j++){
+      FF(1,j)  = torque[mappings[j - 1]-1][0]*ConFac;
+      FF(2,j)  = torque[mappings[j - 1]-1][1]*ConFac;
+      FF(3,j)  = torque[mappings[j - 1]-1][2]*ConFac;
+      FF(4,j)  = fcm[mappings[j - 1]-1][0]*ConFac;
+      FF(5,j)  = fcm[mappings[j - 1]-1][1]*ConFac;
+      FF(6,j)  = fcm[mappings[j - 1]-1][2]*ConFac;
+    }
+
+    //------------------------------------//
+    // Get a solver and solve that system.
+    Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);
+    theSolver->SetSystem(system[i].system);
+    theSolver->Solve(time, FF);
+    ColMatrix tempv = *((*theSolver).GetStateDerivative());
+    ColMatrix tempa = *((*theSolver).GetStateDerivativeDerivative());
+    *((*theSolver).GetStateDerivative()) = tempv + Thalf*tempa;
+
+
+    int numjoints = system[i].system->joints.GetNumElements();
+    for(int k = 0; k < numjoints; k++){
+      system[i].system->joints(k)->ForwardKinematics();
+    }
+
+    for(int k = 0; k < numbodies; k++){
+      Vect3 temp1 =system[i].system->bodies(k+1)->r;
+      Vect3 temp2 =system[i].system->bodies(k+1)->v;
+      Vect3 temp3 =system[i].system->bodies(k+1)->omega;
+      SysKE = SysKE + system[i].system->bodies(k+1)->KE;
+      for(int m = 0; m < 3; m++){
+        vcm[mappings[k]-1][m]   = temp2(m+1);
+        omega[mappings[k]-1][m] = temp3(m+1);
+      }
+    }
+    delete theSolver;
+  }
 }
 
-    
- 
+
+
   void Workspace::RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space){
-	
-	  double a[6];
-	  double b[6][6];
-	  double c[6];
-	  //double e[6];
-	 
-	  a[1] = 0.2;
-	  a[2] = 0.3;
-	  a[3] = 0.6;
-	  a[4] = 1.0;
-	  a[5] = 0.875;
 
-	  b[1][0] = 0.2;
-	  b[2][0] = 0.075;           b[2][1] = 0.225;
-	  b[3][0] = 0.3;             b[3][1] = -0.9;        b[3][2] = 1.2;
-	  b[4][0] = -11.0/54.0;      b[4][1] = 2.5;         b[4][2] = -70.0/27.0;    b[4][3] = 35.0/27.0;
-	  b[5][0] = 1631.0/55296.0; b[5][1] = 175.0/512.0; b[5][2] = 575.0/13824.0; b[5][3] = 44275.0/110592.0; b[5][4] = 253.0/4096.0;
+    double a[6];
+    double b[6][6];
+    double c[6];
+    //double e[6];
 
-	  c[0] = 37.0/378.0;
-	  c[1] = 0.0;
-	  c[2] = 250.0/621.0;
-	  c[3] = 125.0/594.0;
-	  c[4] = 0.0;
-	  c[5] = 512.0/1771.0;
+    a[1] = 0.2;
+    a[2] = 0.3;
+    a[3] = 0.6;
+    a[4] = 1.0;
+    a[5] = 0.875;
 
-	  int numsys = currentIndex; 
-	  int numbodies;				
-	  double time = 0.0;   
-	  int * mappings;
-	  double SysKE =0.0;
+    b[1][0] = 0.2;
+    b[2][0] = 0.075;           b[2][1] = 0.225;
+    b[3][0] = 0.3;             b[3][1] = -0.9;        b[3][2] = 1.2;
+    b[4][0] = -11.0/54.0;      b[4][1] = 2.5;         b[4][2] = -70.0/27.0;    b[4][3] = 35.0/27.0;
+    b[5][0] = 1631.0/55296.0; b[5][1] = 175.0/512.0; b[5][2] = 575.0/13824.0; b[5][3] = 44275.0/110592.0; b[5][4] = 253.0/4096.0;
 
-	  
-	  for (int i = 0; i <= numsys; i++){
-		  mappings = system[i].system->GetMappings();  
+    c[0] = 37.0/378.0;
+    c[1] = 0.0;
+    c[2] = 250.0/621.0;
+    c[3] = 125.0/594.0;
+    c[4] = 0.0;
+    c[5] = 512.0/1771.0;
 
-		  numbodies = system[i].system->GetNumBodies() - 1;
-		  Matrix FF(6,numbodies);
-		  for (int j=1; j<=numbodies; j++){
-			  FF(1,j)  = ConFac*torque[mappings[j - 1]-1][0];
-			  FF(2,j)  = ConFac*torque[mappings[j - 1]-1][1];
-			  FF(3,j)  = ConFac*torque[mappings[j - 1]-1][2];            			   
+    int numsys = currentIndex;
+    int numbodies;
+    double time = 0.0;
+    int * mappings;
+    double SysKE =0.0;
 
-			  FF(4,j)  = ConFac*fcm[mappings[j - 1]-1][0];
-			  FF(5,j)  = ConFac*fcm[mappings[j - 1]-1][1];
-			  FF(6,j)  = ConFac*fcm[mappings[j - 1]-1][2];
-		  }					  
-		
-		
-		  //------------------------------------//
-		// Get a solver and solve that system.		
-		  Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);		
-		  theSolver->SetSystem(system[i].system);    			
-		  theSolver->Solve(time, FF);	
-	
-		  ColMatrix initial_x;  
-		  ColMatrix initial_xdot;
-		  ColMatMap* x;
-		  ColMatMap* xdot;
-		  ColMatMap* xdotdot;
-	
-		  x = theSolver->GetState();  
-		  xdot = theSolver->GetStateDerivative();
-		  xdotdot=theSolver->GetStateDerivativeDerivative(); 
-	
-		  initial_x = *x;  
-		  initial_xdot = *xdot;  
-		  ColMatrix f[6];
-		  ColMatrix ff[6];
-	
-		  ff[0] = initial_xdot; 
-		  f[0] = *xdotdot; 
-	
-		  for(int ii=1;ii<6;ii++){
-			  time = a[ii] * Tfull;		
-			  (*x) = initial_x;		
-			  (*xdot) = initial_xdot;		
-			  for(int j=0;jSolve(time,FF);    
-			  f[ii] = (*xdotdot);
-			  ff[ii] = (*xdot);
-		  }  	
-  
-	
-		  (*x) = initial_x + (c[0]*Tfull)*ff[0] + (c[2]*Tfull)*ff[2] + (c[3]*Tfull)*ff[3] + (c[5]*Tfull)*ff[5];  
-	
-		  (*xdot) = initial_xdot + (c[0]*Tfull)*f[0] + (c[2]*Tfull)*f[2] + (c[3]*Tfull)*f[3] + (c[5]*Tfull)*f[5];  
-	
-	
-		  int numjoints = system[i].system->joints.GetNumElements();
-		  for(int k = 0; k < numjoints; k++){
-			  system[i].system->joints(k)->ForwardKinematics();
-		  }		      
-						      	
-		
-		  for(int k = 0; k < numbodies; k++){
-			  Vect3 temp1 =system[i].system->bodies(k+1)->r;
-			  Vect3 temp2 =system[i].system->bodies(k+1)->v;
-			  Vect3 temp3 =system[i].system->bodies(k+1)->omega;
-			  Mat3x3 temp4 =system[i].system->bodies(k+1)->n_C_k;
-			  SysKE = SysKE + system[i].system->bodies(k+1)->KE;			  
-			  for(int m = 0; m < 3; m++){
-				  xcm[mappings[k]-1][m]   = temp1(m+1);
-				  vcm[mappings[k]-1][m]   = temp2(m+1);
-				  omega[mappings[k]-1][m] = temp3(m+1);
-				
-				  ex_space[mappings[k]-1][m] = temp4(m+1,1);				
-				  ey_space[mappings[k]-1][m] = temp4(m+1,2);
-				  ez_space[mappings[k]-1][m] = temp4(m+1,3);
-			  }         
-		  } 		
-		  delete theSolver;		      
-	  }	 	
+
+    for (int i = 0; i <= numsys; i++){
+      mappings = system[i].system->GetMappings();
+
+      numbodies = system[i].system->GetNumBodies() - 1;
+      Matrix FF(6,numbodies);
+      for (int j=1; j<=numbodies; j++){
+        FF(1,j)  = ConFac*torque[mappings[j - 1]-1][0];
+        FF(2,j)  = ConFac*torque[mappings[j - 1]-1][1];
+        FF(3,j)  = ConFac*torque[mappings[j - 1]-1][2];
+
+        FF(4,j)  = ConFac*fcm[mappings[j - 1]-1][0];
+        FF(5,j)  = ConFac*fcm[mappings[j - 1]-1][1];
+        FF(6,j)  = ConFac*fcm[mappings[j - 1]-1][2];
+      }
+
+
+      //------------------------------------//
+    // Get a solver and solve that system.
+      Solver * theSolver = Solver::GetSolver((SolverType)system[i].solver);
+      theSolver->SetSystem(system[i].system);
+      theSolver->Solve(time, FF);
+
+      ColMatrix initial_x;
+      ColMatrix initial_xdot;
+      ColMatMap* x;
+      ColMatMap* xdot;
+      ColMatMap* xdotdot;
+
+      x = theSolver->GetState();
+      xdot = theSolver->GetStateDerivative();
+      xdotdot=theSolver->GetStateDerivativeDerivative();
+
+      initial_x = *x;
+      initial_xdot = *xdot;
+      ColMatrix f[6];
+      ColMatrix ff[6];
+
+      ff[0] = initial_xdot;
+      f[0] = *xdotdot;
+
+      for(int ii=1;ii<6;ii++){
+        time = a[ii] * Tfull;
+        (*x) = initial_x;
+        (*xdot) = initial_xdot;
+        for(int j=0;jSolve(time,FF);
+        f[ii] = (*xdotdot);
+        ff[ii] = (*xdot);
+      }
+
+
+      (*x) = initial_x + (c[0]*Tfull)*ff[0] + (c[2]*Tfull)*ff[2] + (c[3]*Tfull)*ff[3] + (c[5]*Tfull)*ff[5];
+
+      (*xdot) = initial_xdot + (c[0]*Tfull)*f[0] + (c[2]*Tfull)*f[2] + (c[3]*Tfull)*f[3] + (c[5]*Tfull)*f[5];
+
+
+      int numjoints = system[i].system->joints.GetNumElements();
+      for(int k = 0; k < numjoints; k++){
+        system[i].system->joints(k)->ForwardKinematics();
+      }
+
+
+      for(int k = 0; k < numbodies; k++){
+        Vect3 temp1 =system[i].system->bodies(k+1)->r;
+        Vect3 temp2 =system[i].system->bodies(k+1)->v;
+        Vect3 temp3 =system[i].system->bodies(k+1)->omega;
+        Mat3x3 temp4 =system[i].system->bodies(k+1)->n_C_k;
+        SysKE = SysKE + system[i].system->bodies(k+1)->KE;
+        for(int m = 0; m < 3; m++){
+          xcm[mappings[k]-1][m]   = temp1(m+1);
+          vcm[mappings[k]-1][m]   = temp2(m+1);
+          omega[mappings[k]-1][m] = temp3(m+1);
+
+          ex_space[mappings[k]-1][m] = temp4(m+1,1);
+          ey_space[mappings[k]-1][m] = temp4(m+1,2);
+          ez_space[mappings[k]-1][m] = temp4(m+1,3);
+        }
+      }
+      delete theSolver;
+    }
   }
 
 
 void Workspace::WriteFile(char * filename){
-	int numsys = currentIndex; 
-	int numbodies;				
-		  
-	
-	for (int i = 0; i <= numsys; i++){
-		numbodies = system[i].system->GetNumBodies() - 1;  	
-		ofstream outfile;
-		outfile.open(filename,ofstream::out | ios::app);		
-		outfile << numbodies<bodies(k+1)->r;
-			outfile<<1<<"\t"<GetNumBodies() - 1;
+    ofstream outfile;
+    outfile.open(filename,ofstream::out | ios::app);
+    outfile << numbodies<bodies(k+1)->r;
+      outfile<<1<<"\t"< for the Makefile 
+directory and now edit the Makefile. for the Makefile
 configuration used to compile LAMMPS and also update the directory
 and library settings for the Quantum ESPRESSO installation.
 
@@ -182,7 +182,7 @@ flags that will need to be used in addition to the various libraries
 from _both_ packages. Please see the provided example(s).
 
 "make -f Makefile. all" will now recurse through both the
-Quantum ESPRESSO and LAMMPS directories to compile all files that 
+Quantum ESPRESSO and LAMMPS directories to compile all files that
 require recompilation and then link the combined QM/MM executable.
 
 If you want to only update the local objects and the QM/MM executable,
@@ -190,7 +190,7 @@ you can use "make -f Makefile. pwqmmm.x"
 
 Please refer to the specific LAMMPS and Quantum ESPRESSO documentation
 for details on how to set up compilation for each package and make
-sure you have a set of settings and flags that allow you to build 
+sure you have a set of settings and flags that allow you to build
 each package successfully, so that it can run on its own.
 
 -------------------------------------------------
@@ -253,7 +253,7 @@ this is a regular input which in addition contains the line
 
 tqmmm = .true.
 
-in the &CONTROL namelist. This will make the include QE code 
+in the &CONTROL namelist. This will make the include QE code
 connect to the LAMMPS code and receive updated positions while
 it sends QM forces back to the MM code.
 
diff --git a/lib/qmmm/libqmmm.c b/lib/qmmm/libqmmm.c
index 667a44e35d..b5db2da02f 100644
--- a/lib/qmmm/libqmmm.c
+++ b/lib/qmmm/libqmmm.c
@@ -73,7 +73,7 @@ int read_qmmm_config(const char *file, qmmm_config_t *cfg)
             if ((ptr[i]=='\0') || (ptr[i]==' ') || (ptr[i]=='\t'))
                 break;
             ptr[i] = tolower(ptr[i]);
-        }   
+        }
 
         /* handle keywords */
         if (strncmp(ptr,"mode",4) == 0) {
@@ -205,7 +205,7 @@ int read_qmmm_config(const char *file, qmmm_config_t *cfg)
                     lineno, file, buf);
             return QMMM_ERROR;
         }
-        
+
         if (feof(fp)) break;
     }
 
@@ -239,7 +239,7 @@ const char *check_qmmm_config(qmmm_config_t *cfg) {
     } else if (cfg->maout == NULL) {
         msg = "MM master output file not set";
     } else if (cfg->slout == NULL) {
-        msg = "MM slave output file not set";    
+        msg = "MM slave output file not set";
     }
     return msg;
 }
diff --git a/lib/qmmm/libqmmm.h b/lib/qmmm/libqmmm.h
index 9b58867083..7264586570 100644
--- a/lib/qmmm/libqmmm.h
+++ b/lib/qmmm/libqmmm.h
@@ -52,7 +52,7 @@ typedef struct {
 
 /* declare a global variable for the QM/MM setup.
    thus there can be only one QM/MM coupling currently */
-extern qmmm_config_t qmmmcfg;    
+extern qmmm_config_t qmmmcfg;
 
 /* read and parse global QM/MM configuration file and
  * store the result in a qmmm_config_t struct */
diff --git a/lib/qmmm/pwqmmm.c b/lib/qmmm/pwqmmm.c
index 445b4ece69..99b2aed513 100644
--- a/lib/qmmm/pwqmmm.c
+++ b/lib/qmmm/pwqmmm.c
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
         const char *msg;
 
         msg = check_qmmm_config(&qmmmcfg);
-        
+
         if ((nqm < 1) || (qmmmcfg.nmm < 2)) {
             msg = "Need at least 2 MM and 1 QM processes";
         }
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
             }
         }
 
-        /* parse additional support command line flags for LAMMPS */  
+        /* parse additional support command line flags for LAMMPS */
 
         if (qmmmcfg.maarg != NULL) {
             char *ptr = strtok(qmmmcfg.maarg,delim);
@@ -308,7 +308,7 @@ int main(int argc, char **argv)
             }
         }
 
-        /* parse additional support command line flags for LAMMPS */  
+        /* parse additional support command line flags for LAMMPS */
 
         if (qmmmcfg.slarg != NULL) {
             char *ptr = strtok(qmmmcfg.maarg,delim);
diff --git a/lib/scafacos/README b/lib/scafacos/README
index c8181ac7ae..2a9e2f312a 100644
--- a/lib/scafacos/README
+++ b/lib/scafacos/README
@@ -36,7 +36,7 @@ Instructions:
     command in the scafacos base-folder.
 
 3.) If you downloaded the library as a tarball, please extract the file
-    to somewhere in your file system, or if you finished running 
+    to somewhere in your file system, or if you finished running
     './bootstrap', please run './configure' in the base folder.
     Important flags for './configure' are:
       --prefix=:       sets the directory the compiled files will