diff --git a/source/ConstantHeatCapacityStrategy.cc b/source/ConstantHeatCapacityStrategy.cc index d0810f87..99786c6f 100644 --- a/source/ConstantHeatCapacityStrategy.cc +++ b/source/ConstantHeatCapacityStrategy.cc @@ -8,34 +8,10 @@ // This file is part of AMPE. // For details, see https://github.com/LLNL/AMPE // Please also read AMPE/LICENSE. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// - Redistributions of source code must retain the above copyright notice, -// this list of conditions and the disclaimer below. -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the disclaimer (as noted below) in the -// documentation and/or other materials provided with the distribution. -// - Neither the name of the LLNS/LLNL nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, -// LLC, UT BATTELLE, LLC, -// THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. // #include "ConstantHeatCapacityStrategy.h" -#include "SAMRAI/pdat/CellData.h" +#include "SAMRAI/math/HierarchyCellDataOpsReal.h" ConstantHeatCapacityStrategy::ConstantHeatCapacityStrategy(const double cp, const int cp_id) @@ -46,35 +22,15 @@ ConstantHeatCapacityStrategy::ConstantHeatCapacityStrategy(const double cp, } void ConstantHeatCapacityStrategy::setCurrentValue( - std::shared_ptr patch_hierarchy) + std::shared_ptr hierarchy) { assert(d_cp_id >= 0); static bool first_time = true; if (first_time) { - int maxln = patch_hierarchy->getFinestLevelNumber(); - - for (int ln = 0; ln <= maxln; ln++) { - - std::shared_ptr level = - patch_hierarchy->getPatchLevel(ln); - - assert(level->checkAllocated(d_cp_id)); - - for (hier::PatchLevel::Iterator p(level->begin()); p != level->end(); - p++) { - - std::shared_ptr patch = *p; - - std::shared_ptr > cp_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_cp_id))); - assert(cp_data); - - cp_data->fillAll(d_cp); - } - } + math::HierarchyCellDataOpsReal mathops(hierarchy); + mathops.setToScalar(d_cp_id, d_cp); } first_time = false; diff --git a/source/PhaseFreeEnergyStrategy.cc b/source/PhaseFreeEnergyStrategy.cc index 6db5fb6b..11fdb75d 100644 --- a/source/PhaseFreeEnergyStrategy.cc +++ b/source/PhaseFreeEnergyStrategy.cc @@ -8,30 +8,6 @@ // This file is part of AMPE. // For details, see https://github.com/LLNL/AMPE // Please also read AMPE/LICENSE. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// - Redistributions of source code must retain the above copyright notice, -// this list of conditions and the disclaimer below. -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the disclaimer (as noted below) in the -// documentation and/or other materials provided with the distribution. -// - Neither the name of the LLNS/LLNL nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, -// LLC, UT BATTELLE, LLC, -// THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. // #include "PhaseFreeEnergyStrategy.h" #include "SAMRAI/pdat/CellData.h" @@ -73,31 +49,6 @@ PhaseFreeEnergyStrategy::PhaseFreeEnergyStrategy( //======================================================================= -void PhaseFreeEnergyStrategy::computeFreeEnergyLiquid( - const std::shared_ptr hierarchy, - const int temperature_id, const int fl_id, const bool gp) -{ - assert(fl_id >= 0); - (void)temperature_id; // unused - - for (int ln = 0; ln <= hierarchy->getFinestLevelNumber(); ln++) { - std::shared_ptr level = hierarchy->getPatchLevel(ln); - - for (hier::PatchLevel::Iterator ip(level->begin()); ip != level->end(); - ip++) { - std::shared_ptr patch = *ip; - - std::shared_ptr > fl( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(fl_id))); - assert(fl); - - fl->fillAll(d_f_l); - } - } -} - -//======================================================================= void PhaseFreeEnergyStrategy::computeFreeEnergyLiquid(hier::Patch& patch, const int temperature_id, const int fl_id, @@ -116,31 +67,6 @@ void PhaseFreeEnergyStrategy::computeFreeEnergyLiquid(hier::Patch& patch, //======================================================================= -void PhaseFreeEnergyStrategy::computeFreeEnergySolidA( - const std::shared_ptr hierarchy, - const int temperature_id, const int fs_id, const bool gp) -{ - assert(fs_id >= 0); - (void)temperature_id; // unused - - for (int ln = 0; ln <= hierarchy->getFinestLevelNumber(); ln++) { - std::shared_ptr level = hierarchy->getPatchLevel(ln); - - for (hier::PatchLevel::Iterator ip(level->begin()); ip != level->end(); - ip++) { - std::shared_ptr patch = *ip; - - std::shared_ptr > fs( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(fs_id))); - assert(fs); - - fs->fillAll(d_f_a); - } - } -} - -//======================================================================= void PhaseFreeEnergyStrategy::computeFreeEnergySolidA(hier::Patch& patch, const int temperature_id, const int fs_id, @@ -158,42 +84,7 @@ void PhaseFreeEnergyStrategy::computeFreeEnergySolidA(hier::Patch& patch, } //======================================================================= -// -// double PhaseFreeEnergyStrategy::computeValFreeEnergySolidB( -// const double temperature, -// const double conc, -// const bool gp ) -//{ -// return d_f_b; -//} -// -//======================================================================= - -void PhaseFreeEnergyStrategy::computeFreeEnergySolidB( - const std::shared_ptr hierarchy, - const int temperature_id, const int fs_id, const bool gp) -{ - assert(fs_id >= 0); - (void)temperature_id; // unused - - for (int ln = 0; ln <= hierarchy->getFinestLevelNumber(); ln++) { - std::shared_ptr level = hierarchy->getPatchLevel(ln); - - for (hier::PatchLevel::Iterator ip(level->begin()); ip != level->end(); - ip++) { - std::shared_ptr patch = *ip; - - std::shared_ptr > fs( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(fs_id))); - assert(fs); - fs->fillAll(d_f_b); - } - } -} - -//======================================================================= void PhaseFreeEnergyStrategy::computeFreeEnergySolidB(hier::Patch& patch, const int temperature_id, const int fs_id, diff --git a/source/PhaseFreeEnergyStrategy.h b/source/PhaseFreeEnergyStrategy.h index 5d548468..7b59ff7b 100644 --- a/source/PhaseFreeEnergyStrategy.h +++ b/source/PhaseFreeEnergyStrategy.h @@ -8,30 +8,6 @@ // This file is part of AMPE. // For details, see https://github.com/LLNL/AMPE // Please also read AMPE/LICENSE. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// - Redistributions of source code must retain the above copyright notice, -// this list of conditions and the disclaimer below. -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the disclaimer (as noted below) in the -// documentation and/or other materials provided with the distribution. -// - Neither the name of the LLNS/LLNL nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, -// LLC, UT BATTELLE, LLC, -// THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. // #ifndef included_PhaseFreeEnergyStrategy #define included_PhaseFreeEnergyStrategy @@ -56,18 +32,6 @@ class PhaseFreeEnergyStrategy : public FreeEnergyStrategy ~PhaseFreeEnergyStrategy(){}; - void computeFreeEnergyLiquid( - const std::shared_ptr hierarchy, - const int temperature_id, const int fl_id, const bool gp); - - void computeFreeEnergySolidA( - const std::shared_ptr hierarchy, - const int temperature_id, const int fs_id, const bool gp); - - void computeFreeEnergySolidB( - const std::shared_ptr hierarchy, - const int temperature_id, const int fs_id, const bool gp); - void computeFreeEnergyLiquid(hier::Patch& patch, const int temperature_id, const int fl_id, const bool gp); diff --git a/source/QuatIntegrator.cc b/source/QuatIntegrator.cc index ab629c03..70905d5f 100644 --- a/source/QuatIntegrator.cc +++ b/source/QuatIntegrator.cc @@ -2416,34 +2416,9 @@ void QuatIntegrator::setUniformDiffusionCoeffForQuat( tbox::pout << "dval=" << dval << std::endl; // set diffusion coefficients - for (int amr_level = 0; amr_level < maxl; amr_level++) { - - // tbox::pout<<"QuatSplitIntegrator, level = "< this_patch_level = - hierarchy->getPatchLevel(amr_level); - - for (hier::PatchLevel::Iterator this_p(this_patch_level->begin()); - this_p != this_patch_level->end(); ++this_p) { - std::shared_ptr this_patch = *this_p; - - std::shared_ptr > diffusion( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - this_patch->getPatchData(d_quat_diffusion_id))); - diffusion->fillAll(dval); - - std::shared_ptr > grad_side_copy_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - this_patch->getPatchData(d_quat_grad_side_copy_id))); - assert(grad_side_copy_data); - grad_side_copy_data->fillAll(alpha); - - std::shared_ptr > grad_side_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - this_patch->getPatchData(d_quat_grad_side_id))); - assert(grad_side_data); - grad_side_data->fillAll(alpha); - } - } + math::HierarchySideDataOpsReal smathops(hierarchy); + smathops.setToScalar(d_quat_diffusion_id, dval); + smathops.setToScalar(d_quat_grad_side_copy_id, alpha); } //----------------------------------------------------------------------- diff --git a/source/QuatModel.cc b/source/QuatModel.cc index 18a2d61c..8407af84 100644 --- a/source/QuatModel.cc +++ b/source/QuatModel.cc @@ -2818,30 +2818,15 @@ void QuatModel::initializeLevelData( } if (!d_model_parameters.with_concentration()) { - for (hier::PatchLevel::Iterator ip(level->begin()); ip != level->end(); - ip++) { - std::shared_ptr patch = *ip; - - if (d_model_parameters.free_energy_type()[0] == 's') { - std::shared_ptr > fl( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_f_l_id))); - assert(fl); - fl->fillAll(d_model_parameters.free_energy_liquid()); - } - std::shared_ptr > fa( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_f_a_id))); - assert(fa); - fa->fillAll(d_model_parameters.free_energy_solid_A()); + math::HierarchyCellDataOpsReal mathops(hierarchy); - if (d_model_parameters.with_three_phases()) { - std::shared_ptr > fb( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_f_b_id))); - assert(fb); - fb->fillAll(d_model_parameters.free_energy_solid_B()); - } + if (d_model_parameters.free_energy_type()[0] == 's') { + mathops.setToScalar(d_f_l_id, d_model_parameters.free_energy_liquid()); + } + mathops.setToScalar(d_f_a_id, d_model_parameters.free_energy_solid_A()); + if (d_model_parameters.with_three_phases()) { + mathops.setToScalar(d_f_b_id, + d_model_parameters.free_energy_solid_B()); } } } @@ -4700,35 +4685,11 @@ void QuatModel::computeUniformPhaseMobility( if (time == old_time && cache == CACHE) return; old_time = time; - int maxln = hierarchy->getFinestLevelNumber(); - for (int ln = 0; ln <= maxln; ln++) { - std::shared_ptr patch_level = - hierarchy->getPatchLevel(ln); - - computeUniformPhaseMobility(patch_level, phase_id, mobility_id, time); - } -} - -void QuatModel::computeUniformPhaseMobility( - const std::shared_ptr level, int& phase_id, - int& mobility_id, const double time) -{ - (void)time; - if (phase_id < 0) phase_id = d_phase_scratch_id; if (mobility_id < 0) mobility_id = d_phase_mobility_id; - for (hier::PatchLevel::Iterator p(level->begin()); p != level->end(); ++p) { - - std::shared_ptr patch = *p; - - std::shared_ptr > mobility_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(mobility_id))); - assert(mobility_data); - - mobility_data->fillAll(d_model_parameters.phase_mobility()); - } + math::HierarchyCellDataOpsReal mathops(hierarchy); + mathops.setToScalar(mobility_id, d_model_parameters.phase_mobility()); } //----------------------------------------------------------------------- diff --git a/source/QuatModel.h b/source/QuatModel.h index 79a0b1d2..e04692e9 100644 --- a/source/QuatModel.h +++ b/source/QuatModel.h @@ -209,9 +209,6 @@ class QuatModel : public PFModel void computeUniformPhaseMobility( const std::shared_ptr hierarchy, int& phase_id, int& mobility_id, const double time, const CACHE_TYPE cache = CACHE); - void computeUniformPhaseMobility( - const std::shared_ptr patch_level, int& phase_id, - int& mobility_id, const double time); void computeEtaMobility( const std::shared_ptr hierarchy, int& phase_id, diff --git a/source/ScalarTemperatureStrategy.cc b/source/ScalarTemperatureStrategy.cc index c57bb47a..ca5f7f19 100644 --- a/source/ScalarTemperatureStrategy.cc +++ b/source/ScalarTemperatureStrategy.cc @@ -8,34 +8,10 @@ // This file is part of AMPE. // For details, see https://github.com/LLNL/AMPE // Please also read AMPE/LICENSE. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// - Redistributions of source code must retain the above copyright notice, -// this list of conditions and the disclaimer below. -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the disclaimer (as noted below) in the -// documentation and/or other materials provided with the distribution. -// - Neither the name of the LLNS/LLNL nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, -// LLC, UT BATTELLE, LLC, -// THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. // #include "ScalarTemperatureStrategy.h" -#include "SAMRAI/pdat/CellData.h" +#include "SAMRAI/math/HierarchyCellDataOpsReal.h" ScalarTemperatureStrategy::ScalarTemperatureStrategy( const int temperature_id, const int temperature_scratch_id, @@ -99,7 +75,7 @@ double ScalarTemperatureStrategy::getCurrentTemperature(const double time) } void ScalarTemperatureStrategy::setCurrentTemperature( - std::shared_ptr patch_hierarchy, const double time) + std::shared_ptr hierarchy, const double time) { assert(d_temperature_id >= 0); assert(d_temperature_scratch_id >= 0); @@ -108,30 +84,8 @@ void ScalarTemperatureStrategy::setCurrentTemperature( double t = getCurrentTemperature(time); - int maxln = patch_hierarchy->getFinestLevelNumber(); - - for (int ln = 0; ln <= maxln; ln++) { - - std::shared_ptr level = - patch_hierarchy->getPatchLevel(ln); - - for (hier::PatchLevel::Iterator p(level->begin()); p != level->end(); - p++) { - - std::shared_ptr patch = *p; - - std::shared_ptr > t_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_temperature_id))); - - t_data->fillAll(t); - - std::shared_ptr > ts_data( - SAMRAI_SHARED_PTR_CAST, hier::PatchData>( - patch->getPatchData(d_temperature_scratch_id))); - - ts_data->fillAll(t); - } - } + math::HierarchyCellDataOpsReal mathops(hierarchy); + mathops.setToScalar(d_temperature_id, t); + mathops.setToScalar(d_temperature_scratch_id, t, false); } }