| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Rapid Optimization Library (ROL) Package |
| 4 |
// |
| 5 |
// Copyright 2014 NTESS and the ROL contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
/*! \file pde_elasticity.hpp |
| 11 |
\brief Implements the local PDE interface for the structural topology |
| 12 |
optimization problem. |
| 13 |
*/ |
| 14 |
|
| 15 |
#ifndef PDE_TOPO_OPT_MULTIMAT_HPP |
| 16 |
#define PDE_TOPO_OPT_MULTIMAT_HPP |
| 17 |
|
| 18 |
#include "../../../TOOLS/pde.hpp" |
| 19 |
#include "../../../TOOLS/fe.hpp" |
| 20 |
#include "../../../TOOLS/fieldhelper.hpp" |
| 21 |
#include "../../../TOOLS/Intrepid_HGRAD_C0_FEM.hpp" |
| 22 |
|
| 23 |
#include "dirichlet.hpp" |
| 24 |
#include "traction.hpp" |
| 25 |
#include "load.hpp" |
| 26 |
#include "materialtensor.hpp" |
| 27 |
|
| 28 |
#include "Intrepid_HGRAD_QUAD_C1_FEM.hpp" |
| 29 |
#include "Intrepid_HGRAD_QUAD_C2_FEM.hpp" |
| 30 |
#include "Intrepid_HGRAD_HEX_C1_FEM.hpp" |
| 31 |
#include "Intrepid_HGRAD_HEX_C2_FEM.hpp" |
| 32 |
#include "Intrepid_DefaultCubatureFactory.hpp" |
| 33 |
#include "Intrepid_FunctionSpaceTools.hpp" |
| 34 |
#include "Intrepid_CellTools.hpp" |
| 35 |
|
| 36 |
#include "ROL_Ptr.hpp" |
| 37 |
|
| 38 |
template <class Real> |
| 39 |
class PDE_MultiMat_Elasticity : public PDE<Real> { |
| 40 |
private: |
| 41 |
// Finite element basis information |
| 42 |
ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>> basisPtr_; |
| 43 |
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> basisPtrs_; |
| 44 |
ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>> basisPtrDens_; |
| 45 |
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> basisPtrsDens_; |
| 46 |
// Cell cubature information |
| 47 |
ROL::Ptr<Intrepid::Cubature<Real>> cellCub_; |
| 48 |
ROL::Ptr<Intrepid::Cubature<Real>> bdryCub_; |
| 49 |
// Cell node information |
| 50 |
ROL::Ptr<Intrepid::FieldContainer<Real>> volCellNodes_; |
| 51 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> bdryCellNodes_; |
| 52 |
std::vector<std::vector<std::vector<int>>> bdryCellLocIds_; |
| 53 |
// Finite element definition |
| 54 |
ROL::Ptr<FE<Real>> fe_, feDens_; |
| 55 |
std::vector<std::vector<ROL::Ptr<FE<Real>>>> feBdry_; |
| 56 |
// Local degrees of freedom on boundary, for each side of the reference cell (first index). |
| 57 |
std::vector<std::vector<int>> fidx_; |
| 58 |
// Coordinates of degrees freedom on boundary cells. |
| 59 |
// Indexing: [sideset number][local side id](cell number, value at dof) |
| 60 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> bdryCellDofValues_; |
| 61 |
// Field pattern, offsets, etc. |
| 62 |
std::vector<std::vector<int>> fieldPattern_; // local Field/DOF pattern; set from DOF manager |
| 63 |
int numFields_; // number of fields (equations in the PDE) |
| 64 |
int numDofs_; // total number of degrees of freedom for all (local) fields |
| 65 |
std::vector<int> offset_; // for each field, a counting offset |
| 66 |
std::vector<int> numFieldDofs_; // for each field, number of degrees of freedom |
| 67 |
std::vector<std::vector<int>> fieldPatternDens_; // local Field/DOF pattern; set from DOF manager |
| 68 |
int numFieldsDens_; // number of fields (equations in the PDE) |
| 69 |
int numDofsDens_; // total number of degrees of freedom for all (local) fields |
| 70 |
std::vector<int> offsetDens_; // for each field, a counting offset |
| 71 |
std::vector<int> numFieldDofsDens_; // for each field, number of degrees of freedom |
| 72 |
|
| 73 |
ROL::Ptr<MultiMat_Load<Real>> load_; |
| 74 |
std::vector<ROL::Ptr<MultiMat_MaterialTensor<Real>>> matTensor_; |
| 75 |
ROL::Ptr<MultiMat_Dirichlet<Real>> dirichlet_; |
| 76 |
ROL::Ptr<MultiMat_Traction<Real>> traction_; |
| 77 |
ROL::Ptr<FieldUtils::FieldInfo> fieldInfo_, fieldInfoDens_; |
| 78 |
|
| 79 |
bool getFields2called_; |
| 80 |
|
| 81 |
public: |
| 82 |
PDE_MultiMat_Elasticity(Teuchos::ParameterList &parlist) : getFields2called_(false) { |
| 83 |
// Material properties |
| 84 |
ROL::ParameterList list; |
| 85 |
list.set("Use Plain Stress", parlist.sublist("Problem").get("Use Plain Stress", true)); |
| 86 |
list.set("SIMP Power", parlist.sublist("Problem").get("SIMP Power", 1.0)); |
| 87 |
std::vector<Real> ym = ROL::getArrayFromStringParameter<Real>(parlist.sublist("Problem"), "Young's Modulus"); |
| 88 |
std::vector<Real> pr = ROL::getArrayFromStringParameter<Real>(parlist.sublist("Problem"), "Poisson Ratio"); |
| 89 |
int T = ym.size(); |
| 90 |
matTensor_.resize(T); |
| 91 |
for (int t=0; t<T; ++t) { |
| 92 |
list.set("Young's Modulus",ym[t]); |
| 93 |
list.set("Poisson Ratio",pr[t]); |
| 94 |
matTensor_[t] = ROL::makePtr<MultiMat_MaterialTensor<Real>>(list); |
| 95 |
} |
| 96 |
std::string example = parlist.sublist("Problem").get("Example","Default"); |
| 97 |
load_ = ROL::makePtr<MultiMat_Load<Real>>(parlist.sublist("Problem"),example); |
| 98 |
traction_ = ROL::makePtr<MultiMat_Traction<Real>>(parlist.sublist("Problem"),example); |
| 99 |
dirichlet_ = ROL::makePtr<MultiMat_Dirichlet<Real>>(parlist.sublist("Problem"),example); |
| 100 |
|
| 101 |
// Finite element fields. |
| 102 |
int basisOrder = parlist.sublist("Problem").get("Basis Order",1); |
| 103 |
int basisOrderDens = parlist.sublist("Problem").get("Density Basis Order",0); |
| 104 |
int cubDegree = parlist.sublist("Problem").get("Cubature Degree",4); |
| 105 |
int bdryCubDegree = parlist.sublist("Problem").get("Boundary Cubature Degree",2); |
| 106 |
int probDim = parlist.sublist("Problem").get("Problem Dimension",2); |
| 107 |
if (probDim> 3 || probDim < 2) { |
| 108 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, |
| 109 |
">>> PDE-OPT/binary/elasticity/pde_elasticity.hpp: Problem dimension is not 2 or 3!"); |
| 110 |
} |
| 111 |
if (basisOrder> 2 || basisOrder < 1) { |
| 112 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, |
| 113 |
">>> PDE-OPT/binary/elasticity/pde_elasticity.hpp: Basis order is not 1 or 2!"); |
| 114 |
} |
| 115 |
if (basisOrderDens > 1 || basisOrderDens < 0) { |
| 116 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, |
| 117 |
">>> PDE-OPT/binary/elasticity/pde_elasticity.hpp: Density basis order is not 0 1!"); |
| 118 |
} |
| 119 |
if (probDim == 2) { |
| 120 |
if (basisOrder == 1) { |
| 121 |
basisPtr_ = ROL::makePtr<Intrepid::Basis_HGRAD_QUAD_C1_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 122 |
} |
| 123 |
else if (basisOrder == 2) { |
| 124 |
basisPtr_ = ROL::makePtr<Intrepid::Basis_HGRAD_QUAD_C2_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 125 |
} |
| 126 |
if (basisOrderDens == 0) { |
| 127 |
basisPtrDens_ = ROL::makePtr<Intrepid::Basis_HGRAD_C0_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 128 |
} |
| 129 |
else if (basisOrderDens == 1) { |
| 130 |
basisPtrDens_ = ROL::makePtr<Intrepid::Basis_HGRAD_QUAD_C1_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 131 |
} |
| 132 |
} |
| 133 |
else if (probDim == 3) { |
| 134 |
if (basisOrder == 1) { |
| 135 |
basisPtr_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C1_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 136 |
} |
| 137 |
else if (basisOrder == 2) { |
| 138 |
basisPtr_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C2_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 139 |
} |
| 140 |
if (basisOrderDens == 0) { |
| 141 |
// This does not work in 3D |
| 142 |
basisPtrDens_ = ROL::makePtr<Intrepid::Basis_HGRAD_C0_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 143 |
} |
| 144 |
else if (basisOrderDens == 1) { |
| 145 |
basisPtrDens_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C1_FEM<Real, Intrepid::FieldContainer<Real>>>(); |
| 146 |
} |
| 147 |
} |
| 148 |
basisPtrs_.clear(); basisPtrsDens_.clear(); |
| 149 |
for (int i=0; i<probDim; ++i) { |
| 150 |
basisPtrs_.push_back(basisPtr_); // Displacement component |
| 151 |
} |
| 152 |
for (int i=0; i<T; ++i) { |
| 153 |
basisPtrsDens_.push_back(basisPtrDens_); // Density components |
| 154 |
} |
| 155 |
|
| 156 |
// Quadrature rules. |
| 157 |
shards::CellTopology cellType = basisPtr_->getBaseCellTopology(); // get cell type from basis |
| 158 |
Intrepid::DefaultCubatureFactory<Real> cubFactory; // create cubature factory |
| 159 |
cellCub_ = cubFactory.create(cellType, cubDegree); // create default cubature |
| 160 |
|
| 161 |
shards::CellTopology bdryCellType = cellType.getCellTopologyData(probDim-1, 0); |
| 162 |
bdryCub_ = cubFactory.create(bdryCellType, bdryCubDegree); |
| 163 |
|
| 164 |
numDofs_ = 0; |
| 165 |
numFields_ = basisPtrs_.size(); |
| 166 |
offset_.resize(numFields_); |
| 167 |
numFieldDofs_.resize(numFields_); |
| 168 |
for (int i=0; i<numFields_; ++i) { |
| 169 |
if (i==0) { |
| 170 |
offset_[i] = 0; |
| 171 |
} |
| 172 |
else { |
| 173 |
offset_[i] = offset_[i-1] + basisPtrs_[i-1]->getCardinality(); |
| 174 |
} |
| 175 |
numFieldDofs_[i] = basisPtrs_[i]->getCardinality(); |
| 176 |
numDofs_ += numFieldDofs_[i]; |
| 177 |
} |
| 178 |
|
| 179 |
numDofsDens_ = 0; |
| 180 |
numFieldsDens_ = basisPtrsDens_.size(); |
| 181 |
offsetDens_.resize(numFieldsDens_); |
| 182 |
numFieldDofsDens_.resize(numFieldsDens_); |
| 183 |
for (int i=0; i<numFieldsDens_; ++i) { |
| 184 |
if (i==0) { |
| 185 |
offsetDens_[i] = 0; |
| 186 |
} |
| 187 |
else { |
| 188 |
offsetDens_[i] = offsetDens_[i-1] + basisPtrsDens_[i-1]->getCardinality(); |
| 189 |
} |
| 190 |
numFieldDofsDens_[i] = basisPtrsDens_[i]->getCardinality(); |
| 191 |
numDofsDens_ += numFieldDofsDens_[i]; |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
void residual(ROL::Ptr<Intrepid::FieldContainer<Real>> & res, |
| 196 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 197 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 198 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 199 |
// Retrieve dimensions. |
| 200 |
int c = fe_->gradN()->dimension(0); |
| 201 |
int f = fe_->gradN()->dimension(1); |
| 202 |
int p = fe_->gradN()->dimension(2); |
| 203 |
int d = fe_->gradN()->dimension(3); |
| 204 |
int matd = matTensor_[0]->getMatrixDim(); |
| 205 |
int T = matTensor_.size(); |
| 206 |
|
| 207 |
// Initialize residuals. |
| 208 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> R(d); |
| 209 |
for (int i=0; i<d; ++i) { |
| 210 |
R[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f); |
| 211 |
} |
| 212 |
|
| 213 |
// Split u_coeff into components. |
| 214 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U, Z; |
| 215 |
FieldUtils::splitFieldCoeff<Real>(U, u_coeff, fieldInfo_); |
| 216 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 217 |
|
| 218 |
// Evaluate/interpolate finite element fields on cells. |
| 219 |
ROL::Ptr<Intrepid::FieldContainer<Real>> UMat, rho, valZ_eval, rhoUMat; |
| 220 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradDisp_eval(d); |
| 221 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 222 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 223 |
rhoUMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 224 |
for (int i=0; i<d; ++i) { |
| 225 |
gradDisp_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 226 |
fe_->evaluateGradient(gradDisp_eval[i], U[i]); |
| 227 |
} |
| 228 |
matTensor_[0]->computeUmat(UMat, gradDisp_eval); |
| 229 |
for (int t=0; t<T; ++t) { |
| 230 |
valZ_eval->initialize(); rho->initialize(); rhoUMat->initialize(); |
| 231 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 232 |
matTensor_[t]->computeDensity(rho, valZ_eval); |
| 233 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*rhoUMat, *rho, *UMat); |
| 234 |
for (int i=0; i<d; ++i) { |
| 235 |
Intrepid::FunctionSpaceTools::integrate<Real>(*R[i], |
| 236 |
*rhoUMat, // C B U |
| 237 |
*matTensor_[t]->CBdetJ(i), // B' |
| 238 |
Intrepid::COMP_CPP, |
| 239 |
true); |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
// EVALUATE LOAD |
| 244 |
if (!load_->isNull()) { |
| 245 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> load(d); |
| 246 |
for (int i=0; i<d; ++i) { |
| 247 |
load[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 248 |
} |
| 249 |
load_->compute(load, fe_, PDE<Real>::getParameter(), static_cast<Real>(-1)); |
| 250 |
for (int i=0; i<d; ++i) { |
| 251 |
Intrepid::FunctionSpaceTools::integrate<Real>(*R[i], |
| 252 |
*load[i], // F |
| 253 |
*fe_->NdetJ(), // N |
| 254 |
Intrepid::COMP_CPP, |
| 255 |
true); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
// APPLY TRACTION CONDITIONS |
| 260 |
if (!traction_->isNull()) { |
| 261 |
traction_->apply(R, feBdry_, PDE<Real>::getParameter(), static_cast<Real>(-1)); |
| 262 |
} |
| 263 |
|
| 264 |
// APPLY DIRICHLET CONDITIONS |
| 265 |
dirichlet_->applyResidual(R, U); |
| 266 |
|
| 267 |
// Combine the residuals. |
| 268 |
FieldUtils::combineFieldCoeff<Real>(res, R, fieldInfo_); |
| 269 |
} |
| 270 |
|
| 271 |
void Jacobian_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & jac, |
| 272 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 273 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 274 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 275 |
// Retrieve dimensions. |
| 276 |
int c = fe_->gradN()->dimension(0); |
| 277 |
int f = fe_->gradN()->dimension(1); |
| 278 |
int p = fe_->gradN()->dimension(2); |
| 279 |
int d = fe_->gradN()->dimension(3); |
| 280 |
int matd = matTensor_[0]->getMatrixDim(); |
| 281 |
int T = matTensor_.size(); |
| 282 |
|
| 283 |
// Initialize Jacobians. |
| 284 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> J(d); |
| 285 |
for (int i=0; i<d; ++i) { |
| 286 |
for (int j=0; j<d; ++j) { |
| 287 |
J[i].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f,f)); |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
// Split z_coeff into components. |
| 292 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> Z; |
| 293 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 294 |
|
| 295 |
// Evaluate/interpolate finite element fields on cells. |
| 296 |
ROL::Ptr<Intrepid::FieldContainer<Real>> rho, valZ_eval, rhoBMat; |
| 297 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 298 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 299 |
rhoBMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p, matd); |
| 300 |
for (int t=0; t<T; ++t) { |
| 301 |
valZ_eval->initialize(); rho->initialize(); |
| 302 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 303 |
matTensor_[t]->computeDensity(rho, valZ_eval); |
| 304 |
|
| 305 |
/*** Evaluate weak form of the Jacobian. ***/ |
| 306 |
for (int i=0; i<d; ++i) { |
| 307 |
rhoBMat->initialize(); |
| 308 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataField<Real>(*rhoBMat, *rho, *matTensor_[t]->B(i)); |
| 309 |
for (int j=0; j<d; ++j) { |
| 310 |
Intrepid::FunctionSpaceTools::integrate<Real>(*J[i][j], |
| 311 |
*rhoBMat, // rho B |
| 312 |
*matTensor_[t]->CBdetJ(j), // B' C |
| 313 |
Intrepid::COMP_CPP, |
| 314 |
true); |
| 315 |
} |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
// APPLY DIRICHLET CONDITIONS |
| 320 |
dirichlet_->applyJacobian1(J); |
| 321 |
|
| 322 |
// Combine the jacobians. |
| 323 |
FieldUtils::combineFieldCoeff<Real>(jac, J, fieldInfo_, fieldInfo_); |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
void Jacobian_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & jac, |
| 328 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 329 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 330 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 331 |
// Retrieve dimensions. |
| 332 |
int c = fe_->gradN()->dimension(0); |
| 333 |
int f = fe_->gradN()->dimension(1); |
| 334 |
int fd = feDens_->gradN()->dimension(1); |
| 335 |
int p = fe_->gradN()->dimension(2); |
| 336 |
int d = fe_->gradN()->dimension(3); |
| 337 |
int matd = matTensor_[0]->getMatrixDim(); |
| 338 |
int T = matTensor_.size(); |
| 339 |
|
| 340 |
// Initialize Jacobians. |
| 341 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> J(d); |
| 342 |
for (int i=0; i<d; ++i) { |
| 343 |
for (int j=0; j<T; ++j) { |
| 344 |
J[i].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f,fd)); |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
// Split u_coeff into components. |
| 349 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U, Z; |
| 350 |
FieldUtils::splitFieldCoeff<Real>(U, u_coeff, fieldInfo_); |
| 351 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 352 |
|
| 353 |
// Evaluate/interpolate finite element fields on cells. |
| 354 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradDisp_eval(d); |
| 355 |
ROL::Ptr<Intrepid::FieldContainer<Real>> rho, valZ_eval, UMat, rhoUMat, CBrhoUMat; |
| 356 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 357 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 358 |
rhoUMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 359 |
CBrhoUMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p); |
| 360 |
for (int i=0; i<d; ++i) { |
| 361 |
gradDisp_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 362 |
fe_->evaluateGradient(gradDisp_eval[i], U[i]); |
| 363 |
} |
| 364 |
matTensor_[0]->computeUmat(UMat, gradDisp_eval); |
| 365 |
for (int t=0; t<T; ++t) { |
| 366 |
valZ_eval->initialize(); rho->initialize(); rhoUMat->initialize(); |
| 367 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 368 |
matTensor_[t]->computeDensity(rho, valZ_eval, 1); // first derivative |
| 369 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*rhoUMat, *rho, *UMat); |
| 370 |
|
| 371 |
for (int i=0; i<d; ++i) { |
| 372 |
CBrhoUMat->initialize(); |
| 373 |
Intrepid::FunctionSpaceTools::dotMultiplyDataField<Real>(*CBrhoUMat, *rhoUMat, *matTensor_[t]->CBdetJ(i)); |
| 374 |
/*** Evaluate weak form of the residual. ***/ |
| 375 |
Intrepid::FunctionSpaceTools::integrate<Real>(*J[i][t], |
| 376 |
*CBrhoUMat, // B' C drho B U |
| 377 |
*feDens_->N(), // N |
| 378 |
Intrepid::COMP_CPP, |
| 379 |
false); |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
// APPLY DIRICHLET CONDITIONS |
| 384 |
dirichlet_->applyJacobian2(J); |
| 385 |
|
| 386 |
// Combine the jacobians. |
| 387 |
FieldUtils::combineFieldCoeff<Real>(jac, J, fieldInfo_, fieldInfoDens_); |
| 388 |
} |
| 389 |
|
| 390 |
void Hessian_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 391 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff, |
| 392 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 393 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 394 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 395 |
throw Exception::Zero(">>> (PDE_TopoOpt::Hessian_11): Hessian is zero."); |
| 396 |
} |
| 397 |
|
| 398 |
void Hessian_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 399 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff, |
| 400 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 401 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 402 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 403 |
// Retrieve dimensions. |
| 404 |
int c = fe_->gradN()->dimension(0); |
| 405 |
int f = fe_->gradN()->dimension(1); |
| 406 |
int fd = feDens_->gradN()->dimension(1); |
| 407 |
int p = fe_->gradN()->dimension(2); |
| 408 |
int d = fe_->gradN()->dimension(3); |
| 409 |
int matd = matTensor_[0]->getMatrixDim(); |
| 410 |
int T = matTensor_.size(); |
| 411 |
|
| 412 |
// Initialize Hessians. |
| 413 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> J(T); |
| 414 |
for (int t=0; t<T; ++t) { |
| 415 |
for (int i=0; i<d; ++i) { |
| 416 |
J[t].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,fd,f)); |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
// Split u_coeff into components. |
| 421 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> L, Z; |
| 422 |
FieldUtils::splitFieldCoeff<Real>(L, l_coeff, fieldInfo_); |
| 423 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 424 |
|
| 425 |
// Apply Dirichlet conditions to the multipliers. |
| 426 |
dirichlet_->applyMultiplier(L); |
| 427 |
|
| 428 |
// Evaluate/interpolate finite element fields on cells. |
| 429 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradDisp_eval(d); |
| 430 |
ROL::Ptr<Intrepid::FieldContainer<Real>> rho, valZ_eval, LMat, rhoLMat, CBrhoLMat; |
| 431 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 432 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 433 |
rhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 434 |
CBrhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p); |
| 435 |
for (int i=0; i<d; ++i) { |
| 436 |
gradDisp_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 437 |
fe_->evaluateGradient(gradDisp_eval[i], L[i]); |
| 438 |
} |
| 439 |
matTensor_[0]->computeUmat(LMat, gradDisp_eval); |
| 440 |
for (int t=0; t<T; ++t) { |
| 441 |
valZ_eval->initialize(); rho->initialize(); rhoLMat->initialize(); |
| 442 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 443 |
matTensor_[t]->computeDensity(rho, valZ_eval, 1); // first derivative |
| 444 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*rhoLMat, *rho, *LMat); |
| 445 |
|
| 446 |
for (int i=0; i<d; ++i) { |
| 447 |
CBrhoLMat->initialize(); |
| 448 |
Intrepid::FunctionSpaceTools::dotMultiplyDataField<Real>(*CBrhoLMat, *rhoLMat, *matTensor_[t]->CBdetJ(i)); |
| 449 |
/*** Evaluate weak form of the residual. ***/ |
| 450 |
Intrepid::FunctionSpaceTools::integrate<Real>(*J[t][i], |
| 451 |
*feDens_->N(), // N |
| 452 |
*CBrhoLMat, // B' C drho B U |
| 453 |
Intrepid::COMP_CPP, |
| 454 |
false); |
| 455 |
} |
| 456 |
} |
| 457 |
|
| 458 |
// Combine the Hessians. |
| 459 |
FieldUtils::combineFieldCoeff<Real>(hess, J, fieldInfoDens_, fieldInfo_); |
| 460 |
} |
| 461 |
|
| 462 |
void Hessian_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 463 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff, |
| 464 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 465 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 466 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 467 |
// Retrieve dimensions. |
| 468 |
int c = fe_->gradN()->dimension(0); |
| 469 |
int f = fe_->gradN()->dimension(1); |
| 470 |
int fd = feDens_->gradN()->dimension(1); |
| 471 |
int p = fe_->gradN()->dimension(2); |
| 472 |
int d = fe_->gradN()->dimension(3); |
| 473 |
int matd = matTensor_[0]->getMatrixDim(); |
| 474 |
int T = matTensor_.size(); |
| 475 |
|
| 476 |
// Initialize Hessians. |
| 477 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> J(d); |
| 478 |
for (int i=0; i<d; ++i) { |
| 479 |
for (int t=0; t<T; ++t) { |
| 480 |
J[i].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f,fd)); |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
// Split u_coeff into components. |
| 485 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> L, Z; |
| 486 |
FieldUtils::splitFieldCoeff<Real>(L, l_coeff, fieldInfo_); |
| 487 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 488 |
|
| 489 |
// Apply Dirichlet conditions to the multipliers. |
| 490 |
dirichlet_->applyMultiplier(L); |
| 491 |
|
| 492 |
// Evaluate/interpolate finite element fields on cells. |
| 493 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradDisp_eval(d); |
| 494 |
ROL::Ptr<Intrepid::FieldContainer<Real>> rho, valZ_eval, LMat, rhoLMat, CBrhoLMat; |
| 495 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 496 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 497 |
rhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 498 |
CBrhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p); |
| 499 |
for (int i=0; i<d; ++i) { |
| 500 |
gradDisp_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 501 |
fe_->evaluateGradient(gradDisp_eval[i], L[i]); |
| 502 |
} |
| 503 |
matTensor_[0]->computeUmat(LMat, gradDisp_eval); |
| 504 |
for (int t=0; t<T; ++t) { |
| 505 |
valZ_eval->initialize(); rho->initialize(); rhoLMat->initialize(); |
| 506 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 507 |
matTensor_[t]->computeDensity(rho, valZ_eval, 1); // first derivative |
| 508 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*rhoLMat, *rho, *LMat); |
| 509 |
|
| 510 |
for (int i=0; i<d; ++i) { |
| 511 |
CBrhoLMat->initialize(); |
| 512 |
Intrepid::FunctionSpaceTools::dotMultiplyDataField<Real>(*CBrhoLMat, *rhoLMat, *matTensor_[t]->CBdetJ(i)); |
| 513 |
/*** Evaluate weak form of the residual. ***/ |
| 514 |
Intrepid::FunctionSpaceTools::integrate<Real>(*J[i][t], |
| 515 |
*CBrhoLMat, // B' C drho B U |
| 516 |
*feDens_->N(), // N |
| 517 |
Intrepid::COMP_CPP, |
| 518 |
false); |
| 519 |
} |
| 520 |
} |
| 521 |
|
| 522 |
// Combine the Hessians. |
| 523 |
FieldUtils::combineFieldCoeff(hess, J, fieldInfo_, fieldInfoDens_); |
| 524 |
} |
| 525 |
|
| 526 |
void Hessian_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 527 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff, |
| 528 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 529 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 530 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 531 |
// Retrieve dimensions. |
| 532 |
int c = fe_->gradN()->dimension(0); |
| 533 |
int fd = feDens_->gradN()->dimension(1); |
| 534 |
int p = fe_->gradN()->dimension(2); |
| 535 |
int d = fe_->gradN()->dimension(3); |
| 536 |
int matd = matTensor_[0]->getMatrixDim(); |
| 537 |
int T = matTensor_.size(); |
| 538 |
|
| 539 |
// Initialize Hessians. |
| 540 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> J(T); |
| 541 |
for (int t=0; t<T; ++t) { |
| 542 |
for (int s=0; s<T; ++s) { |
| 543 |
J[t].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,fd,fd)); |
| 544 |
} |
| 545 |
} |
| 546 |
|
| 547 |
// Split u_coeff into components. |
| 548 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U, L, Z; |
| 549 |
FieldUtils::splitFieldCoeff<Real>(U, u_coeff, fieldInfo_); |
| 550 |
FieldUtils::splitFieldCoeff<Real>(L, l_coeff, fieldInfo_); |
| 551 |
FieldUtils::splitFieldCoeff<Real>(Z, z_coeff, fieldInfoDens_); |
| 552 |
|
| 553 |
// Apply Dirichlet conditions to the multipliers. |
| 554 |
dirichlet_->applyMultiplier(L); |
| 555 |
|
| 556 |
// Evaluate/interpolate finite element fields on cells. |
| 557 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradDispU_eval(d), gradDispL_eval(d); |
| 558 |
ROL::Ptr<Intrepid::FieldContainer<Real>> rho, valZ_eval, UMat, LMat, rhoLMat, CUMat, CUrhoLMat, NCUrhoLMat; |
| 559 |
rho = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 560 |
valZ_eval = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 561 |
rhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 562 |
CUMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, matd); |
| 563 |
CUrhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 564 |
NCUrhoLMat = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fd, p); |
| 565 |
for (int i=0; i<d; ++i) { |
| 566 |
gradDispU_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 567 |
fe_->evaluateGradient(gradDispU_eval[i], U[i]); |
| 568 |
gradDispL_eval[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 569 |
fe_->evaluateGradient(gradDispL_eval[i], L[i]); |
| 570 |
} |
| 571 |
matTensor_[0]->computeUmat(UMat, gradDispU_eval); |
| 572 |
matTensor_[0]->computeUmat(LMat, gradDispL_eval); |
| 573 |
for (int t=0; t<T; ++t) { |
| 574 |
valZ_eval->initialize(); rho->initialize(); rhoLMat->initialize(); |
| 575 |
CUMat->initialize(); CUrhoLMat->initialize(); NCUrhoLMat->initialize(); |
| 576 |
feDens_->evaluateValue(valZ_eval, Z[t]); |
| 577 |
matTensor_[t]->computeDensity(rho, valZ_eval, 2); // second derivative |
| 578 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*rhoLMat, *rho, *LMat); |
| 579 |
matTensor_[t]->applyTensor(CUMat, UMat); |
| 580 |
|
| 581 |
Intrepid::FunctionSpaceTools::dotMultiplyDataData<Real>(*CUrhoLMat, *rhoLMat, *CUMat); |
| 582 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataField<Real>(*NCUrhoLMat, *CUrhoLMat, *feDens_->N()); |
| 583 |
|
| 584 |
/*** Evaluate weak form of the residual. ***/ |
| 585 |
Intrepid::FunctionSpaceTools::integrate<Real>(*J[t][t], |
| 586 |
*NCUrhoLMat, // N L' B' C ddrho B U |
| 587 |
*feDens_->NdetJ(), // N |
| 588 |
Intrepid::COMP_CPP, |
| 589 |
false); |
| 590 |
} |
| 591 |
|
| 592 |
// Combine the Hessians. |
| 593 |
FieldUtils::combineFieldCoeff(hess, J, fieldInfoDens_, fieldInfoDens_); |
| 594 |
} |
| 595 |
|
| 596 |
void RieszMap_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & riesz) { |
| 597 |
//throw Exception::NotImplemented(">>> (PDE_TopoOpt::RieszMap_1): Not implemented."); |
| 598 |
|
| 599 |
// Retrieve dimensions. |
| 600 |
int c = fe_->gradN()->dimension(0); |
| 601 |
int f = fe_->gradN()->dimension(1); |
| 602 |
int d = fe_->gradN()->dimension(3); |
| 603 |
|
| 604 |
// Initialize Riesz maps. |
| 605 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> R(d); |
| 606 |
for (int i=0; i<d; ++i) { |
| 607 |
for (int j=0; j<d; ++j) { |
| 608 |
R[i].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f,f)); |
| 609 |
} |
| 610 |
} |
| 611 |
|
| 612 |
for (int i=0; i<d; ++i) { |
| 613 |
*(R[i][i]) = *(fe_->stiffMat()); |
| 614 |
Intrepid::RealSpaceTools<Real>::add(*(R[i][i]),*(fe_->massMat())); |
| 615 |
} |
| 616 |
|
| 617 |
// Combine the Riesz maps. |
| 618 |
FieldUtils::combineFieldCoeff<Real>(riesz, R, fieldInfo_, fieldInfo_); |
| 619 |
} |
| 620 |
|
| 621 |
void RieszMap_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & riesz) { |
| 622 |
//throw Exception::NotImplemented(">>> (PDE_TopoOpt::RieszMap_2): Not implemented."); |
| 623 |
|
| 624 |
// Retrieve dimensions. |
| 625 |
int c = feDens_->gradN()->dimension(0); |
| 626 |
int f = feDens_->gradN()->dimension(1); |
| 627 |
int T = matTensor_.size(); |
| 628 |
|
| 629 |
// Initialize Riesz maps. |
| 630 |
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> R(numFieldsDens_); |
| 631 |
for (int i=0; i<T; ++i) { |
| 632 |
for (int j=0; j<T; ++j) { |
| 633 |
R[i].push_back(ROL::makePtr<Intrepid::FieldContainer<Real>>(c,f,f)); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
for (int i=0; i<T; ++i) { |
| 638 |
*(R[i][i]) = *(fe_->massMat()); |
| 639 |
} |
| 640 |
|
| 641 |
// Combine the Riesz maps. |
| 642 |
FieldUtils::combineFieldCoeff<Real>(riesz, R, fieldInfoDens_, fieldInfoDens_); |
| 643 |
} |
| 644 |
|
| 645 |
// This must be called before getFields2 |
| 646 |
void setDensityFields(const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs) { |
| 647 |
if (getFields2called_) { |
| 648 |
TEUCHOS_TEST_FOR_EXCEPTION(getFields2called_, std::invalid_argument, |
| 649 |
">>> PDE-OPT/topo-opt/elasticity/src/pde_elasticity.hpp: Must call before getFields2!"); |
| 650 |
} |
| 651 |
else { |
| 652 |
basisPtrDens_ = basisPtrs[0]; |
| 653 |
basisPtrsDens_ = basisPtrs; |
| 654 |
|
| 655 |
numDofsDens_ = 0; |
| 656 |
numFieldsDens_ = basisPtrsDens_.size(); |
| 657 |
offsetDens_.resize(numFieldsDens_); |
| 658 |
numFieldDofsDens_.resize(numFieldsDens_); |
| 659 |
for (int i=0; i<numFieldsDens_; ++i) { |
| 660 |
if (i==0) { |
| 661 |
offsetDens_[i] = 0; |
| 662 |
} |
| 663 |
else { |
| 664 |
offsetDens_[i] = offsetDens_[i-1] + basisPtrsDens_[i-1]->getCardinality(); |
| 665 |
} |
| 666 |
numFieldDofsDens_[i] = basisPtrsDens_[i]->getCardinality(); |
| 667 |
numDofsDens_ += numFieldDofsDens_[i]; |
| 668 |
} |
| 669 |
} |
| 670 |
} |
| 671 |
|
| 672 |
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> getFields() { |
| 673 |
return basisPtrs_; |
| 674 |
} |
| 675 |
|
| 676 |
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> getFields2() { |
| 677 |
getFields2called_ = true; |
| 678 |
return basisPtrsDens_; |
| 679 |
} |
| 680 |
|
| 681 |
void setCellNodes(const ROL::Ptr<Intrepid::FieldContainer<Real>> &volCellNodes, |
| 682 |
const std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> &bdryCellNodes, |
| 683 |
const std::vector<std::vector<std::vector<int>>> &bdryCellLocIds) { |
| 684 |
volCellNodes_ = volCellNodes; |
| 685 |
bdryCellNodes_ = bdryCellNodes; |
| 686 |
bdryCellLocIds_ = bdryCellLocIds; |
| 687 |
// Finite element definition. |
| 688 |
fe_ = ROL::makePtr<FE<Real>>(volCellNodes_,basisPtr_,cellCub_); |
| 689 |
feDens_ = ROL::makePtr<FE<Real>>(volCellNodes_,basisPtrDens_,cellCub_,false); |
| 690 |
fidx_ = fe_->getBoundaryDofs(); |
| 691 |
if (!traction_->isNull()) { |
| 692 |
traction_->setCellNodes(bdryCellNodes_,bdryCellLocIds_); |
| 693 |
} |
| 694 |
dirichlet_->setCellNodes(bdryCellNodes_,bdryCellLocIds_,fidx_); |
| 695 |
int T = matTensor_.size(); |
| 696 |
for (int t=0; t<T; ++t) { |
| 697 |
matTensor_[t]->setFE(fe_); |
| 698 |
} |
| 699 |
// Construct boundary FE |
| 700 |
int numSideSets = bdryCellLocIds_.size(); |
| 701 |
if (numSideSets> 0) { |
| 702 |
feBdry_.resize(numSideSets); |
| 703 |
for (int i = 0; i < numSideSets; ++i) { |
| 704 |
int numLocSides = bdryCellNodes[i].size(); |
| 705 |
feBdry_[i].resize(numLocSides); |
| 706 |
for (int j = 0; j < numLocSides; ++j) { |
| 707 |
if (bdryCellNodes[i][j] != ROL::nullPtr) { |
| 708 |
feBdry_[i][j] = ROL::makePtr<FE<Real>>(bdryCellNodes[i][j],basisPtr_,bdryCub_,j); |
| 709 |
} |
| 710 |
} |
| 711 |
} |
| 712 |
} |
| 713 |
} |
| 714 |
|
| 715 |
void setFieldPattern(const std::vector<std::vector<int>> &fieldPattern, |
| 716 |
const std::vector<std::vector<int>> &fieldPattern2) { |
| 717 |
fieldPattern_ = fieldPattern; |
| 718 |
fieldPatternDens_ = fieldPattern2; |
| 719 |
fieldInfo_ = ROL::makePtr<FieldUtils::FieldInfo>(numFields_, numDofs_, numFieldDofs_, fieldPattern_); |
| 720 |
fieldInfoDens_ = ROL::makePtr<FieldUtils::FieldInfo>(numFieldsDens_, numDofsDens_, numFieldDofsDens_, fieldPatternDens_); |
| 721 |
} |
| 722 |
|
| 723 |
const ROL::Ptr<FE<Real>> getFE(void) const { |
| 724 |
return fe_; |
| 725 |
} |
| 726 |
|
| 727 |
const ROL::Ptr<FE<Real>> getDensityFE(void) const { |
| 728 |
return feDens_; |
| 729 |
} |
| 730 |
|
| 731 |
const std::vector<std::vector<ROL::Ptr<FE<Real>>>> getBdryFE(void) const { |
| 732 |
return feBdry_; |
| 733 |
} |
| 734 |
|
| 735 |
const std::vector<std::vector<std::vector<int>>> getBdryCellLocIds(void) const { |
| 736 |
return bdryCellLocIds_; |
| 737 |
} |
| 738 |
|
| 739 |
const ROL::Ptr<FieldUtils::FieldInfo> getFieldInfo(void) const { |
| 740 |
return fieldInfo_; |
| 741 |
} |
| 742 |
|
| 743 |
const ROL::Ptr<FieldUtils::FieldInfo> getDensityFieldInfo(void) const { |
| 744 |
return fieldInfoDens_; |
| 745 |
} |
| 746 |
|
| 747 |
const ROL::Ptr<MultiMat_Load<Real>> getLoad(void) const { |
| 748 |
return load_; |
| 749 |
} |
| 750 |
|
| 751 |
const ROL::Ptr<MultiMat_Traction<Real>> getTraction(void) const { |
| 752 |
return traction_; |
| 753 |
} |
| 754 |
|
| 755 |
const std::vector<ROL::Ptr<MultiMat_MaterialTensor<Real>>> getMaterialTensor(void) const { |
| 756 |
return matTensor_; |
| 757 |
} |
| 758 |
|
| 759 |
}; // PDE_TopoOpt |
| 760 |
|
| 761 |
#endif |