Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F70282241
model.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jul 6, 02:53
Size
4 KB
Mime Type
text/x-c
Expires
Mon, Jul 8, 02:53 (2 d)
Engine
blob
Format
Raw Data
Handle
18817937
Attached To
rTAMAAS tamaas
model.cpp
View Options
/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model.hh"
#include "be_engine.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
Model::Model(const std::vector<Real>& system_size,
const std::vector<UInt>& discretization)
: system_size(system_size), discretization(discretization) {}
/* -------------------------------------------------------------------------- */
Model::~Model() = default;
/* -------------------------------------------------------------------------- */
void Model::setElasticity(Real E, Real nu) {
this->E = E;
this->nu = nu;
updateOperators();
}
/* -------------------------------------------------------------------------- */
Real Model::getHertzModulus() const { return E / (1 - nu * nu); }
/* -------------------------------------------------------------------------- */
GridBase<Real>& Model::getTraction() { return *traction; }
const GridBase<Real>& Model::getTraction() const { return *traction; }
/* -------------------------------------------------------------------------- */
GridBase<Real>& Model::getDisplacement() { return *displacement; }
const GridBase<Real>& Model::getDisplacement() const { return *displacement; }
/* -------------------------------------------------------------------------- */
const std::vector<Real>& Model::getSystemSize() const { return system_size; }
/* -------------------------------------------------------------------------- */
const std::vector<UInt>& Model::getDiscretization() const {
return discretization;
}
/* -------------------------------------------------------------------------- */
void Model::solveNeumann() {
engine->registerNeumann();
engine->solveNeumann(*traction, *displacement);
}
void Model::solveDirichlet() {
engine->registerDirichlet();
engine->solveDirichlet(*displacement, *traction);
}
/* -------------------------------------------------------------------------- */
IntegralOperator* Model::getIntegralOperator(const std::string& name) {
return operators[name].get();
}
/* -------------------------------------------------------------------------- */
void Model::updateOperators() {
for (auto& op : operators)
op.second->updateFromModel();
}
/* -------------------------------------------------------------------------- */
std::ostream& operator<<(std::ostream& o, const Model& _this) {
o << "Model<" << _this.getType() << "> (E = " << _this.getYoungModulus()
<< ", nu = " << _this.getPoissonRatio() << ")\n";
// Printing domain size
o << " - domain = [";
std::for_each(_this.getSystemSize().begin(), _this.getSystemSize().end() - 1,
[&o](const Real& x) { o << x << ", "; });
o << _this.getSystemSize().back() << "]\n";
// Printing discretization
o << " - discretization = [";
std::for_each(_this.getDiscretization().begin(),
_this.getDiscretization().end() - 1,
[&o](const UInt& x) { o << x << ", "; });
o << _this.getDiscretization().back() << "]";
return o;
}
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
Event Timeline
Log In to Comment