Page MenuHomec4science

chloride_ups.cpp
No OneTemporary

File Metadata

Created
Mon, Nov 25, 03:54

chloride_ups.cpp

/* =============================================================================
Copyright (c) 2014-2017 F. Georget <fabieng@princeton.edu> Princeton University
Copyright (c) 2017-2018 F. Georget <fabien.georget@epfl.ch> EPFL
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder 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 THE COPYRIGHT HOLDER 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 "reactmicp/reactmicp_chloride.hpp"
#include "specmicp_common/plugins/plugin_base.hpp"
#include "specmicp_common/plugins/plugin_interface.h"
#include <iostream>
using namespace specmicp;
using namespace specmicp::reactmicp::solver;
using namespace specmicp::reactmicp::systems::chloride;
class SPECMICP_DLL_PUBLIC UpscalingStagger:
public specmicp::reactmicp::solver::UpscalingStaggerBase
{
public:
UpscalingStagger(
SimulationData& data,
io::YAMLConfigHandle&& conf
) {}
~UpscalingStagger() {}
//! \brief Initialize the stagger at the beginning of the computation
//!
//! \param var a shared_ptr to the variables
virtual void initialize(VariablesBase * const var) override;
//! \brief Initialize the stagger at the beginning of an iteration
//!
//! This is where the predictor can be saved, the first trivial iteration done, ...
//!
//! \param dt the duration of the timestep
//! \param var a shared_ptr to the variables
virtual void initialize_timestep(
scalar_t dt,
VariablesBase * const var
) override {}
//! \param var a shared_ptr to the variables
virtual StaggerReturnCode restart_timestep(
VariablesBase * const var) override {
auto true_var = static_cast<ChlorideVariables*>(var);
AdimensionalSystemSolutionExtractor extr(true_var->adim_solution(1),
true_var->get_database(),
true_var->get_units());
return StaggerReturnCode::ResidualMinimized;
}
};
class SPECMICP_DLL_PUBLIC ChlorideUpscalingFactory: public UpscalingStaggerFactory
{
public:
static ChlorideUpscalingFactory* get() {
return new ChlorideUpscalingFactory();
}
virtual std::shared_ptr<UpscalingStaggerBase> get_upscaling_stagger(
SimulationData& data,
io::YAMLConfigHandle&& configuration
) override
{
//auto bcs = data.bcs;
//bcs->set_fixed_flux_liquid_dof(1, 0, 2.2e-8*1e4);
return std::make_shared<UpscalingStagger>(data, std::forward<io::YAMLConfigHandle>(configuration));
}
};
class SPECMICP_DLL_PUBLIC ChlorideUpscalingPlugin:
public specmicp::plugins::PluginBase
{
public:
ChlorideUpscalingPlugin():
PluginBase()
{
set_api_version(0, 1, 0);
}
bool initialize(const specmicp::plugins::PluginManagerServices& services) override
{
auto retcode = services.register_object(
"reactmicp/chloride/upscaling", "chloride_ups",
&ChlorideUpscalingFactory::get
);
if (not retcode) {
return false;
}
return true;
}
};
SPECMICP_PLUGIN(ChlorideUpscalingPlugin)
// ==============
void UpscalingStagger::initialize(VariablesBase * const var)
{
ChlorideVariables* tvars = static_cast<ChlorideVariables*>(var);
//tvars->resistance_factor().setConstant(1e-3);
//tvars->resistance_factor()(0) = 1.0;
//tvars->resistance_factor()(tvars->get_mesh()->nb_nodes()-1) = 1.0;
}

Event Timeline