76 answer.
resize(ndofs, ndofs);
114 rhsMatrix.
resize(ndofs, ndofs);
121 rhsMatrix.
add(contrib);
126 rhsMatrix.
add(contrib);
132 rhsMatrix.
add(contrib);
147 for (
Dof *dof: *
this ) {
181 EngngModel :: initializeFrom(ir);
210 field = std::make_unique<DofDistributedPrimaryField>(
this, 1, FT_TransportProblemUnknowns, 2, this->
alpha);
241double DGProblem :: giveUnknownComponent(ValueModeType mode,
TimeStep *tStep,
Domain *d,
Dof *dof)
243 return this->
field->giveUnknownValue(dof, mode, tStep);
248DGProblem :: giveDeltaT(
int n)
260DGProblem :: giveDiscreteTime(
int iStep)
264 }
else if ( iStep == 0 ) {
288TimeStep* DGProblem :: giveSolutionStepWhenIcApply(
bool force)
290 if (
master && (!force)) {
291 return master->giveSolutionStepWhenIcApply();
305DGProblem :: constructBoundaryEntities () {
310 std::vector<std::set<int>> processedBoundaryEntities;
311 processedBoundaryEntities.resize(this->
giveDomain(1)->giveNumberOfElements());
314 std::vector<std::unordered_multimap<int, int>> setsBoundaryEntities;
316 std::vector<std::set<int>> boundaryNodeSets;
320 int nodeNum = nnodes;
321 int elemNum = nelems;
331 for (
int i = 1; i <= bentities.
giveSize()/2; i++) {
332 setsBoundaryEntities[iset-1].insert({bentities.
at(2*i-1), bentities.
at(2*i)});
336 std::vector<IntArray> clonedElementNodes(nelems);
338 for (
int ielem = 1; ielem<=nelems; ielem++) {
343 for (
int i = 1; i <= numNodes; i++) {
348 clonedNodes.
at(i) = nodeNum;
351 clonedElementNodes.at(ielem-1)=clonedNodes;
354 for (
int ielem = 1; ielem<=nelems; ielem++) {
357 if ( processedBoundaryEntities[e->
giveNumber()-1].find(i) != processedBoundaryEntities[e->
giveNumber()-1].end() ) {
360 IntArray bnodes, bnodesSorted, bclonednodes, neighbors;
363 for (
int j = 1; j <= bnodes.
giveSize(); j++ ) {
364 bclonednodes.
at(j) = clonedElementNodes.at(ielem-1).at(bnodes.
at(j));
367 bnodesSorted = bnodes;
372 OOFEM_ERROR(
"More than two neighbors found for boundary entity (elem %d, boundary %d)", e->
giveNumber(), i);
374 std::unique_ptr<DGBoundaryEntity> be = std::make_unique<DGBoundaryEntity>();
376 processedBoundaryEntities[e->
giveNumber()-1].insert(i);
377 IntArray bentityNodes(bclonednodes);
378 int neighborboundary=0;
384 for (
int j = 1; j <= bnodes.
giveSize(); j++)
386 auto cnode = std::make_unique<ClonedDofManager>(++nodeNum, domain, bnodes.
at(j));
395 auto range = setsBoundaryEntities[iset-1].equal_range(e->
giveNumber());
396 for (
auto it = range.first; it != range.second; ++it) {
397 if (it->second == i) {
399 for (
int k = 1; k <= bnodes.
giveSize(); k++) {
400 boundaryNodeSets.at(iset-1).insert(bentityNodes.
at(bnodes.
giveSize()+k));
407 }
else if ( neighbors.
giveSize() == 2 ) {
409 int neighborelem = neighbors.
at(1) == e->
giveNumber() ? neighbors.
at(2) : neighbors.
at(1);
412 IntArray neighborClonedBoundaryNodes;
413 for (
int j = 1; j <= this->
giveDomain(1)->giveElement(neighborelem)->giveNumberOfBoundarySides(); j++ ) {
415 neighborBoundaryNodes = this->
giveDomain(1)->giveElement(neighborelem)->giveBoundaryNodes(j);
416 int size = neighborBoundaryNodes.
giveSize();
417 neighborClonedBoundaryNodes.
resize(size);
418 for (
int k = 1; k <= size; k++ ) {
419 neighborClonedBoundaryNodes.
at(k) = clonedElementNodes.at(neighborelem-1).at(neighborBoundaryNodes.
at(k));
420 neighborBoundaryNodes.
at(k) = this->
giveDomain(1)->giveElement(neighborelem)->giveDofManager(neighborBoundaryNodes.
at(k))->giveNumber();
423 for (
int k = 1; k <= neighborBoundaryNodes.
giveSize(); k++ ) {
424 if ( !bnodesSorted.
findSorted(neighborBoundaryNodes.
at(k))) {
430 neighborboundary = j;
434 if (neighborboundary) {
435 be->addElement(neighborelem, neighborboundary);
436 processedBoundaryEntities[neighborelem-1].insert(neighborboundary);
438 for (
int j = 1; j <= bnodes.
giveSize(); j++)
443 OOFEM_ERROR(
"Boundary entity not found in neighbor element");
452 belem->setCrossSection(1);
453 belem->setMaterial(1);
454 domain->
setElement(elemNum, std::move(belem));
460 for (
int ielem = 1; ielem<=nelems; ielem++) {
466 IntArray nodes(boundaryNodeSets.at(iset-1).size());
468 for (
auto bnode: boundaryNodeSets.at(iset-1)) {
469 nodes.
at(counter++)=bnode;
477 for (
int i = 1; i <= nodeNum; i++) {
486 for (
int i = 1; i <= elemNum; i++) {
494 OOFEM_LOG_INFO(
"fem2DG: FE (%d nodes, %d elements) -> DG (%d nodes, %d elements)\n", nnodes, nelems, nodeNum, elemNum);
499std::unique_ptr< Element>
502 std::unique_ptr<Element> belem;
505 belem =
classFactory.createElement(
"sadgbline1", elemNum, domain);
508 belem =
classFactory.createElement(
"sadgbquad1", elemNum, domain);
511 OOFEM_ERROR(
"Unknown boundary element geometry type");
513 belem->setDofManagers(bentityNodes);
518DGProblem :: postInitialize()
523 istep = metaStep.setStepBounds(istep);
532 domain->postInitialize();
538 for (
auto &dman: this->
giveDomain(1)->dofManagerList ) {
540 Node *ndman =
dynamic_cast<Node*
>(dman.get());
549 printf(
"%10s %4d master %4d coords %6f %6f %6f dofs", name.c_str(), dman->giveNumber(),
master, dman->giveCoordinate(1), dman->giveCoordinate(2), dman->giveCoordinate(3));
550 for (
Dof *dof: *dman ) {
551 printf(
" %d", dof->giveDofID());
555 for (
auto &elem: this->
giveDomain(1)->elementList) {
567 for (
int i = 1; i <= (set->
giveNodeList()).giveSize(); i++) {
605 field->advanceSolution(tStep);
628 this->
field->applyBoundaryCondition(tStep);
650DGProblem :: applyIC()
655 this->
field->applyDefaultInitialCondition();
668DGProblem :: requiresEquationRenumbering(
TimeStep *tStep)
676 for (
auto &gbc : d->
giveBcs() ) {
691DGProblem :: forceEquationNumbering()
695 return EngngModel :: forceEquationNumbering();
700DGProblem :: printOutputAt(FILE *file,
TimeStep *tStep)
702 if ( !this->
giveDomain(1)->giveOutputManager()->testTimeStepOutput(tStep) ) {
706 EngngModel :: printOutputAt(file, tStep);
713 EngngModel :: updateYourself(tStep);
719 EngngModel :: saveContext(stream, mode);
720 field->saveContext(stream);
727 EngngModel :: restoreContext(stream, mode);
728 field->restoreContext(stream);
733DGProblem :: giveUnknownDictHashIndx(ValueModeType mode,
TimeStep *tStep)
740DGProblem :: requiresUnknownsDictionaryUpdate()
746DGProblem :: checkConsistency()
748 return EngngModel :: checkConsistency();
753DGProblem :: updateDomainLinks()
755 EngngModel :: updateDomainLinks();
767 OOFEM_ERROR(
"Unable to return field representation for non-current time step");
769 if ( key == FT_Velocity ) {
771 }
else if ( key == FT_Pressure ) {
772 return std::make_shared<MaskedPrimaryField>( key, this->
field.get(),
IntArray{P_f} );
773 }
else if ( key == FT_Temperature ) {
774 return std::make_shared<MaskedPrimaryField>( key, this->
field.get(),
IntArray{T_f} );
797 for (
int ielem = 1; ielem <= nelem; ielem++ ) {
#define REGISTER_EngngModel(class)
virtual bool requiresActiveDofs()
const char * giveClassName() const override
void printOutputAt(FILE *file, TimeStep *tStep) override
void giveElementsWithNodes(IntArray &answer, const IntArray &nodes)
double initT
Initial time from which the computation runs. Default is zero.
FloatArray prescribedTimes
Specified times where the problem is solved.
int dtFunction
Associated time function for time step increment.
TimeStep * giveSolutionStepWhenIcApply(bool force=false) override
SparseMtrxType sparseMtrxType
LinSystSolverType solverType
FieldPtr giveField(FieldType key, TimeStep *tStep) override
std ::unique_ptr< SparseLinearSystemNM > nMethod
Numerical method used to solve the problem.
std ::unique_ptr< DofDistributedPrimaryField > field
std::unique_ptr< Element > CreateBoundaryElement(Element_Geometry_Type egt, int elemNum, Domain *domain, IntArray &bentityNodes) const
bool preprocessFEM2DG
flag indicating whether the FEM input should be preprocessed to DG problem input (boundary entity gen...
int targetAllNodeSet
int target sets for all nodes and all elements
IntArray sets2preprocess
array of sets to process to generate boundary node sets
std ::vector< std::unique_ptr< DGBoundaryEntity > > boundaryEntities
NumericalMethod * giveNumericalMethod(MetaStep *mStep) override
Returns reference to receiver's numerical method.
double deltaT
Length of time step.
Variable::VariableQuantity unknownQuantity
std ::unique_ptr< SparseMtrx > lhsMatrix
void updateSolution(FloatArray &solutionVector, TimeStep *tStep, Domain *d) override
double giveDiscreteTime(int iStep)
void constructBoundaryEntities()
IntArray targetBoundaryNodeSets
array of target sets (same size as sets2preprocess) to store the generated boundary node sets
std::string problemType
identifies what problem to solve (UP, UPV, etc)
std ::unique_ptr< SparseMtrx > rhsMatrix
void assembleDirichletBcRhsVector(FloatArray &answer, TimeStep *tStep, ValueModeType mode, const UnknownNumberingScheme &ns, Domain *d) const
const FloatArray & giveCoordinates() const
void resizeDofManagers(int _newSize)
Resizes the internal data structure to accommodate space for _newSize dofManagers.
void resizeElements(int _newSize)
Resizes the internal data structure to accommodate space for _newSize elements.
void setElement(int i, std::unique_ptr< Element > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
int giveNumberOfElements() const
Returns number of elements in domain.
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
std ::vector< std ::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
DofManager * giveDofManager(int n)
Element * giveElement(int n)
EngngModel * giveEngngModel()
std ::vector< std ::unique_ptr< Element > > & giveElements()
void setDofManager(int i, std::unique_ptr< DofManager > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
virtual void giveElementDofIDMask(IntArray &answer) const
virtual void giveCharacteristicMatrix(FloatMatrix &answer, CharType type, TimeStep *tStep)
virtual int giveNumberOfDofs()
virtual FEInterpolation * giveInterpolation() const
virtual int giveNumberOfBoundarySides()
Returns number of boundaries (entities of element_dimension-1: points, edges, surfaces).
virtual void updateYourself(TimeStep *tStep)
void computeVectorOfPrescribed(ValueModeType u, TimeStep *tStep, FloatArray &answer)
void setDofManagers(const IntArray &dmans)
void giveLocationArray(IntArray &locationArray, const UnknownNumberingScheme &s, IntArray *dofIds=NULL) const
virtual IntArray giveBoundaryNodes(int boundary) const
void computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
const char * giveClassName() const override
virtual int giveNumberOfDofManagers() const
DofManager * giveDofManager(int i) const
virtual void updateInternalState(TimeStep *tStep)
int giveDofManagerNumber(int i) const
FieldManager * giveFieldManager()
int giveNumberOfTimeStepWhenIcApply()
Returns the time step number, when initial conditions should apply.
std ::vector< std ::unique_ptr< Domain > > domainList
List of problem domains.
virtual TimeStep * giveCurrentStep(bool force=false)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
virtual void printDofOutputAt(FILE *stream, Dof *iDof, TimeStep *tStep)
EngngModelContext * giveContext()
Context requesting service.
EngngModel(int i, EngngModel *_master=NULL)
std ::unique_ptr< TimeStep > previousStep
Previous time step.
MetaStep * giveCurrentMetaStep()
Returns current meta step.
int ndomains
Number of receiver domains.
Domain * giveDomain(int n)
std ::unique_ptr< TimeStep > currentStep
Current time step.
EngngModelTimer timer
E-model timer.
std ::vector< MetaStep > metaStepList
List of problem metasteps.
EngngModel * master
Master e-model; if defined receiver is in maintained (slave) mode.
virtual int giveNumberOfFirstStep(bool force=false)
bool isParallel() const
Returns true if receiver in parallel mode.
std ::unique_ptr< TimeStep > stepWhenIcApply
Solution step when IC (initial conditions) apply.
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
virtual const Element_Geometry_Type giveBoundaryGeometryType(int boundary) const =0
Domain * giveDomain() const
void registerField(FieldPtr eField, FieldType key)
FieldPtr giveField(FieldType key)
bool containsOnlyZeroes() const
void assemble(const FloatArray &fe, const IntArray &loc)
void zero()
Zeroes all coefficients of receiver.
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
void add(const FloatMatrix &a)
void resize(Index rows, Index cols)
void zero()
Zeroes all coefficient of receiver.
bool isNotEmpty() const
Tests for empty matrix.
void assemble(const FloatMatrix &src, const IntArray &loc)
virtual int giveNumberOfInternalDofManagers()
Gives the number of internal dof managers.
void followedBy(const IntArray &b, int allocChunk=0)
int findSorted(int value) const
int findFirstIndexOf(int value) const
Base class for elements based on mp (multi-physics) concept.
virtual void getLocalCodeNumbers(IntArray &answer, const Variable::VariableQuantity q) const
Variable::VariableQuantity q
Variable::VariableQuantity q
void setNodeList(IntArray newNodes)
const IntArray & giveBoundaryList()
void setElementList(IntArray newElements)
const IntArray & giveNodeList()
ConvergedReason convergedReason
Status of solution step (Converged,.
double giveTimeIncrement()
Returns solution step associated time increment.
double giveTargetTime()
Returns target time.
int giveNumber()
Returns receiver's number.
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
oofem::VariableQuantity VariableQuantity
#define _IFT_DGProblem_initt
#define _IFT_DGProblem_prescribedtimes
#define _IFT_DGProblem_targetAllNodeSet
target sets to map allnodes and allelements
#define _IFT_DGProblem_exportFields
Fields to export for staggered problems.
#define _IFT_DGProblem_deltatfunction
#define _IFT_DGProblem_targetBoundaryNodeSets
#define _IFT_DGProblem_alpha
#define _IFT_DGProblem_problemType
#define _IFT_DGProblem_keepTangent
Fixes the tangent to be reused on each step.
#define _IFT_DGProblem_preprocessFEM2DG
#define _IFT_DGProblem_targetAllElementSet
Target sets to store all elements.
#define _IFT_DGProblem_deltat
#define _IFT_DGProblem_sets2preprocess
Sets to preprocess from FEM to DG problem.
#define _IFT_EngngModel_smtype
#define OOFEM_LOG_INFO(...)
#define OOFEM_LOG_RELEVANT(...)
FieldType
Physical type of field.
FloatArrayF< N > assemble(const FloatArrayF< M > &x, int const (&c)[M])
Assemble components into zero matrix.
@ SMT_Skyline
Symmetric skyline.
ClassFactory & classFactory
std::shared_ptr< Field > FieldPtr